Jump to content
Mr. Green Gaming

Creating an Explosion?


Recommended Posts

Posted

Hey

Does anyone of you know if it's possible to create an explosion at a certain point in the map? I want it to be at the race start, like 3 ... 2... 1... BOOM! (it needs to be pretty accurate aswell)

Why? Well I want to implement something like this in a map: http://www.youtube.com/watch?v=6S1hidemGwU

I know that it's not always 100% accurate but it works fine most of the time. :) So maybe theres a script for explosion or something? Could be a barrel or an exploding car or anything...

Posted (edited)

Thanks a lot Bin :) I'll try and see how it turns out.

Oh and I think I also need a script to make the player invulnerable?

EDIT: Nvm, I read up. I suppose I can just use the damaging = false in that line then. :)

Edited by KillaMarci
Posted (edited)

Nop, you can't use that line..

because the script I gave you is server-side

you'd need a client-side one for that argument to work..

so do you actually die/explode when this script runs?

Edited by BinSlayer
Posted (edited)

Nop, you can't use that line..

because the script I gave you is server-side

you'd need a client-side one for that argument to work..

so do you actually die/explode when this script runs?

Alright. Well then I will need an additional script for invulnerable players -.

I just tried it out and yes it works exactly as it should :D I only tested the grenade explosion so far and it's not powerfull enough right now (not getting satisfying height) I will test the other forms of explosion aswell and hope for the best now :) Otherwise I might just try to use multiple explosion for one catapult. I don't know if I will make multiple catapults or if I just do one for all players so we will see

EDIT: Yay guys I got it!! :D It works and it's so fun, here's a demo.

http://www.youtube.com/watch?v=W4NHPrfdZR0

I haven't actually experimented with anything else yet, only added more grenade explosions. I uploaded my testmap and script so you guys can experiment with different explosion types, different vehicles (how about a bus? LOL) and so on. :)

Best of all is that the landing place is always verrry accurate, I land on exactly the same spot all the time.

Now I just have to find a good way to implement this into a good map, oh and btw. I won't need a invulnerable script of anything, it actually works fine with the MTB. You may need it for other vehicles. (someone try it with a sweeper pls lol)

cata.rar

Edited by KillaMarci
Posted

Nah I now decided not to do that. Would be too much work to sync all the cars so the players all fly to the same destination from different places. Would be too much of a hassle IMO. One spawnpoint for everyone is fine right? Might cause more lag for some people but I dunno...

Posted (edited)

try this:

addEvent('onRaceStateChanging', true)
addEventHandler('onRaceStateChanging', getRootElement(),
function(newstate, oldstate)
if newstate == 'Running' then
for i,j in ipairs(getElementsByType('player')) do
x,y,z = getElementLocation(j)
createExplosion( x, y, z, 0)
end
end
end
)

DO NOT change x,y,z this time :) Just use this script exactly as it is.. And note something: Make 40 spawnpoints! otherwise there will be 2 or more explosions created in the same place and this could be big enough to kill the players

What this should do is create an explosion for each player :)

I think the explosion is now created exactly in the vehicle.. so i'm not sure how that will work out. If you don't like it, change a bit the 'y' and make it y+1 or something like that

Edited by BinSlayer
Posted

try this:

addEvent('onRaceStateChanging', true)
addEventHandler('onRaceStateChanging', getRootElement(),
function(newstate, oldstate)
if newstate == 'Running' then
for i,j in ipairs(getElementsByType('player')) do
x,y,z = getElementLocation(j)
createExplosion( x, y, z, 0)
end
end
end
)

DO NOT change x,y,z this time :) Just use this script exactly as it is.. And note something: Make 40 spawnpoints! otherwise there will be 2 or more explosions created in the same place and this could be big enough to kill the players

What this should do is create an explosion for each player :)

I think the explosion is now created exactly in the vehicle.. so i'm not sure how that will work out. If you don't like it, change a bit the 'y' and make it y+1 or something like that

Yup sounds plausible. Is there a way to copy whole parts of a map? Like the MTB spawnpoint standing on the wrecked car? Because it's pretty hard to set that up to work fine, especially if I have to do it 40 times! :P

I doubt the explosion is going to be hard enough to kill the player actually. Right now I use 10 helicopter explosions which are at exactly the same location for each catapult.

Will theese explosions be for each player individually then? Like 20 player = 20*10explosions = 200explosions at one place. Is that what you meant? :P

Posted (edited)

Yeah that's what I meant..

If you want to copy the wrecked car for all players use this:

(dont use the other scripts, delete them and use this one!)

http://pastebin.com/raw.php?i=Tj0dWa8s

change the explosion type to whatever you want. (the '0' you know)

and when you see this line: obj[k]=createObject(10831,xx,yy,zz-1)

change 10831 to the ID of the wrecked car (i dont know it)

'zz-1' is the position height of the wrecked car.. so change it like zz+1 or zz or anything like that if u wanna change a bit the height where the wrecked car spawns

Edited by BinSlayer
Posted

Wow that's a little much for now :P Still pretty new to this but I guess I will actually figure it out when I test it.

Another question: How do I test different spawnpoints? When I "test" the race it always gives me the same spawnpoint...

Posted (edited)

Wow that's a little much for now :P Still pretty new to this but I guess I will actually figure it out when I test it.

Another question: How do I test different spawnpoints? When I "test" the race it always gives me the same spawnpoint...

You dont

btw all you have to do is copy-paste the script and change what you like that is explosion type and id of wrecked car

Any questions? Just ask

Edited by BinSlayer
Posted (edited)

Well I feel like understanding the code is a better way of learning what is going on so:


addEvent('onRaceStateChanging', true)
addEventHandler('onRaceStateChanging', getRootElement(),
function(newstate, oldstate)
if newstate == 'Running' then
for i,j in ipairs(getElementsByType('player')) do
x,y,z = getElementPosition(j)
createExplosion( x, y, z, 0)
end
end
end
)

--I think I do understand this part.You get the players position and create an explosion exactly where he stands...right? (I'll have to edit the value's slightly in order to get the explosion infront of the car then)


obj = { }
k = 1
addEventHandler('onResourceStart', getResourceRootElement(getThisResource()),
function()
for i,j in ipairs(getElementsByType('spawnpoint')) do
xx,yy,zz = getElementPosition(j)
obj[k]=createObject(10831,xx,yy,zz-1)
k = k + 1
end
end

--Here you get the players spawnpoint and create the wrecked car under it (UNDER because of the zz(-1) I suppose?)


addEventHandler('onResourceStop', getResourceRootElement(getThisResource()),
function()
number = #obj
for i=1,number do
destroyElement(obj[i])
end
end
)

-- I don't really get this part, but I suppose this is nothing I actually need to understand.

Did I get everything right? So I should basically just add a spawnpoint, and it should automatically add the wrecked car under it and create the explosion at the players position right? :)

Thx for you help!

EDIT: The problem with the spawnpoints is also something I will have to overcome, because I need to see where the player goes because I want them all to go to one definite place. I think I will just add a spawnpoint, test it, and if it works I'll save the coordinates and go on to the next one. Long long process but I have no better option right now.

Edited by KillaMarci
Posted (edited)

Put the spawnpoints in a nice order on the map.. and just test for 1 spawn because the explosion must throw everybody in a certain area as wide as the spawn area actually

The part you said you dont understand, objects created via scripts stay forever in the server (even if map restarts or changes) so destroyElement would destroy the object when the map has ended.

You will NOT see the wrecked car in the map editor overview. You will only see it if you 'test' the map

and if zz-1 is too much in the ground.. you can try zz-0.5 or any other float number

to get the explosion in front of the car you need to alter "y" like y+1 or so

Edited by BinSlayer
Posted

Yea I get what you mean with the spawnpoints, I first wanted to place some all around the map but now I realize that its too much of a hassle.

I'll start with the map in a second, anyone got any ideas how to continue the map? I guess it shouldnt be that long, since the catapult is the main attraction of the map. I guess I'll just make it something 40-50second-ish

Posted

What about that first part plus a slide?

Check it out:

Map starts, you get launched to a CP that changes you into a harvester and you land on the slide fences thing :D

Im suggesting this because you said the landing position seems to be very accurate.

The map should be around 1m maybe and be all about crazy stuff like that and prolly something else if you can come up with it lol.

Posted

Uh yeh it's accurate but no THAT accurate really :P Landing space is always about +/-10ft. And if the player comes sideways the slide doesn't work and so on. In my slide map I tried to make the entering space real small so they had do slide down no matter what. What you suggested would probably be better for the SGA Skillserver xD

Posted

btw.. my script doesn't cover late joiners :/

So if you join after the race has started, you won't get an explosion

is this a problem for your map?

if it is, I may try to find a better way or to fix it somehow, but maybe you don't need, so thats why i am asking

Posted

Well yea it sucks but I guess since the map is going to be pretty short it's not going to be a big problem. Would still be cool if you could solve it somehow (if it's not too much of a hassle, otherwise don't)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...