This is an intermediate tutorial, and I assume you
can make a basic room and light.
In this tutorial, I will show you how to plant explosives
on tanks. Let's begin!
You must make a room with lights and an info_player_start.
Start by adding a script object with keys and values:
model:
vehicles/tigertank.tik
$destroyed_model:
vehicles/tigertank_d.tik
targetname:
tank
You should see a tiger tank. I used a tiger tank. You
can use any model, Sherman, Panzer or King tiger. Make
a script model and add these keys and values:
model:
items/pulse_explosive.tik
$trigger_name:
tank_trigger
$explosion_fx:
emitters/explosion_tank.tik
$explosion_sound:
explode_aagun
targetname:
bomb
target:
tank
spawnflags:
1 (or check "not solid")
You should have seen an arrow connecting the explosive
to the tank. Place the explosive anywhere. (I placed
it at the back.)
Add a trigger_use over the pulse explosive. Give it
a targetname of "tank_trigger".
Ok, now add a script_origin with targetname "obj1"
over the tank.
That was easy, now for the scripting part, much harder!
$player item
weapons/thompsonsmg.tik //gives
you a gun $player ammo
smg 300 $player useweaponclass
smg fadein 2 0 0
0 1 wait 2 thread maingame
end
maingame:
waitthread global/items.scr::add_item
"explosive" //gives player
explosives
waitthread global/objectives.scr::add_objectives
1 2 "Bomb the tiger tank." $obj1.origin //compass
will point to the tank waitthread global/objectives.scr::current_objectives
1
level.bombedtanks
= 0 //number of bombed tanks level.tank_bombplanted
= 0 //tanks with bombs planted level.bombsleft
= 3 //bombs left
thread tank_bombed
end
//***********************
//bomb the tank
//**********************
tank_bombed: $tank_trigger
waittill trigger //the trigger
used in above $bomb model "animate/explosive.tik"
//the animation used for
exploding $bomb playsound
explosive // the sound level.tank_bombplanted
= 1 // will be 1 tank with
bomb planted level.bombsleft--
//bombs left after planting,
which is original bombs minus 1 thread explode
end
//***********
//Explode
//***********
explode: $player loopsound
bombtick //tick tock tick
tock $player stopwatch
8 //number of seconds wait 8 $player stoploopsound
bombtick //stop the tick
tock sound $bomb playsound
explode_tank //explosion
sound $bomb remove
//removes the bomb $tank thread
global/vehicles_thinkers.scr::tank_killed //"kills"
the tank level.bomb_damage
= 100 //damage caused level.bomb_explosion_radius
= 512 //radius of effect thread levelend
end
Compile, sit back, and watch the tank explode! Try
getting close to the tank, you'll get hurt.
*Note, when you
use the script object, you MAY see that your tank appears
to be moving. To prevent this, just add the tank by
right clicking in the 2D view and selecting the tank.