PDA

View Full Version : [Tutorial] Making a TimeBomb with Trigger



pollo
19th February 2013, 18:47
Hey :D

I'm going to show (for those who don't know) how to make a bomb, so when you press F it appears and after a few seconds it explodes. The tutorial is step-by-step, so don't worry, you will understand it easily.

First, open Radiant and make a wall, like this:

157

After doing that, make a copy of that wall and select one of them, do right click on the 2d view and select script->brushmodel. Give the wall these values:

158

Move the wall you asigned these values out of the other one, so you won't confuse, and after that, select the other wall and "destroy" it:

159

(Note: to make decals, make a brush, give the texture nodraw_decal, inside Tools, select one face of the brush and give it a decal).


Once done that, select all of the destroyed wall, including the decals and details you put, and give them these values:

160

Ok you made it, now put the first wall (before) exactly over the one you've done now. We're gonna put the bomb. Do right click on the 2d view, script->model. Search for the bomb model (military_tntbomb). If you don't know how to put models, there's a topic inside this forum). Put the bomb wherever you want, press N and give it these values:

161


Now make a trig_use_touch over the bomb and give it these values:

162

Make a script_origin in the bomb, like this, and give the following values (this will set the origin of the explosion and the sound):

163

And the mapping part is done!

Now let's script. You will need to script a gsc.

For the gsc:


main()
{
//mapstuff.....

//functions
thread precachefx();
thread bomb();
}

precachefx()

{
//loads the given effect so you
//can use this effect anywhere in you script
//without needing to be loaded again
level._effect["explosion"] = loadfx("fx/props/barrelexp.efx");
}

bomb()
{
//first we define the variables

before = getent("wallbefore","targetname");
after = getent("wallafter","targetname");
bomb = getent("bomb","targetname");
trig_bomb = getent("trig_bomb","targetname");
origin = getent("origin_bomb","targetname");

while(1)
{

//hide the bomb and the wall at first

bomb hide();
after hide();
after notsolid();

//someone puts the bomb

trig_bomb waittill("trigger",user);
playfx(level._effect["explosion"],origin.origin);
bomb show();
user iprintlnbold("Bomb Planted");
user iprintlnbold("Will explode in a few seconds");
origin playsound("MP_bomb_plant");
origin playloopsound("bomb_tick");

//the bomb is shown and starts
//to play a tictac

wait(5);

//wait 5 seconds until the bomb
//explodes

origin stoploopsound();
earthquake( 0.5, 3, origin.origin, 900 );
radiusDamage(origin.origin, 250, 300, 20);
playfx(level._effect["explosion"],origin.origin);
origin playsound("mortar_explosion3");

//do an earthquake, radius damage
//and plays the sound and the effect
//for more info about radiusdmg
//and the earthquake
//see the docs section

before delete();
trig_bomb delete();
bomb delete();
after show();
after solid();

//the old wall, the trig
//and the bomb delete
//and the destroyed wall
//is shown

break;

//so the loop wont repeat again
//if you want another bomb in the
//same place, just put a wait
//command
}
}


And the bomb is done! You could do it other ways, but this one is more easy. For more info about radiusdamage and earthquake, go to CoD2/Docs/Script Functions and look for it

Maybe I've comit mistakes, because I made this tutorial very fast, 1 hour lol, and not in my computer (still in the cyber) so if there is, I hope you understand it ;)

Pollo

kung foo man
20th February 2013, 02:26
Hey, nice tutorial :)

I've replaced [code] with [php], so the script is colored now.

Also replaced the external images, since they are important and shouldnt be deleted for whatever-reason. Please use next time the attachment-system directly :)