trigger timer and truck health

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Waylander76
Sergeant Major
Posts: 122
Joined: Wed Jun 01, 2005 10:03 am

trigger timer and truck health

Post by Waylander76 »

Hi All

I've been converting the Enemy Territory map to Spearhead and it's almost done...apart
form one or two little bits of scripting.

I have a working script but just need to add two things but I don't know
how to...so any help greatfully recieved.

Firstly the allies have to repair a tank.
I have a trigger use around the tank and when the allies use it
off the tank goes as it should.
I would like the player to have to hold the use key for 10 seconds with
a stopwatch counting down,with a 'reparing tank' message and then
a 'tank repaired' message before the tank moves...like when planting
a bomb in OBJ.

I've looked at how it's done in the dm_obj.scr and I just don't get how to
fit that into my script.

Secondly is the putting the crate on the truck.
When the ally player steals the crate I want only that player to be able
to put the crate on the truck.
If he dies the crate resets so it can be collecetd again.

I've modifed the undervocer script and it works but I just can't get it
to recognise the player with the crate.

Thirdly destroying the getaway truck.
I've given it a health value so when it gets shot it disappears.
how do I add an explsion to this, bearing in mind that the origin
of the truck is changing as it is in motion?

I've posted my complete script below so any help would be appreciated.

Code: Select all



main:

exec global/ai.scr
exec global/friendly.scr

	setcvar "g_obj_alliedtext1" "Repair The Tank"
	setcvar "g_obj_alliedtext2" "Steal The Crate"
	setcvar "g_obj_alliedtext3" "Steal The Truck"
	setcvar "g_obj_axistext1" "Stop The Aliies"
	setcvar "g_obj_axistext2" "Stealing The Crate"
	setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" "obj_goldrush"


level waittill prespawn

 
exec global/ambient.scr 
thread global/exploder.scr::main 
level.script = "maps/obj/obj_sh_goldrush.scr"
level.targets_to_destroy = 1
level.music = mohdm7
level.allieshascrate = 0


level waittill spawn

level.defusing_team = "axis" 
level.planting_team = "allies"
level.bomb_damage = 200 
level.bomb_explosion_radius = 1024
level.clockside = axis 

$tank_speaker loopsound king_snd_idle
$truck_speaker loopsound opeltruck_snd_idle
$truck vehicleanim idlenolights
$truck health 1000
$tank nodamage
$tank speed 128
$crate_on_truck hide
$truck_clip bind $truck
$truck_speaker bind truck
$tank_speaker bind $tank
$bankdoor_destroyed hide
$bankwall_destroyed hide


level waittill roundstart


thread axis_win_timer
thread allies_get_crate
thread tank
thread truck
thread tank_bridge
thread tank_courtyard
thread escape

end

/////////////////////////////
// Steal the crate        //
///////////////////////////

allies_get_crate:


$crate_trigger waittill trigger

local.player = parm.other
if (local.player.dmteam == "axis")
{
local.player iprint "You cannot use this!"
goto allies_get_crate
}

if ((local.player.dmteam == "allies") && (level.allieshascrate == 0))
    $crate hide
    $crate_trigger hide
iprintlnbold_noloc "The Allies have stolen the crate!"
local.thief = parm.other
{
    local.thief iprint "Take the crate to the truck!"
    level.allieshascrate++
    
while(level.allieshascrate>0)

{
        if ((!isAlive local.thief)||(local.thief.dmteam !=allies))
        {
          level.allieshascrate--
          println "[player local.thief died] level.allieshascrate = :" level.allieshascrate
    $crate show
    $crate_trigger show
    thread allies_get_crate
          break
        }
        wait 1
      }
  }
goto allies_get_crate
end

/////////////////////////////////////
//  Put crate on the truck    //////
///////////////////////////////////

truck:

$truck_trigger waittill trigger

local.player = parm.other
if (local.player.dmteam == "axis")
{
local.player iprint "You cannot use this!"
goto truck
}
if ((local.player.dmteam == "allies") && (level.allieshascrate == 1))
{
$truck_speaker stop loopsound
wait .1
$truck_speaker playsound opeltruck_snd_on
$crate_on_truck show
$crate_on_truck bind $truck
level.targets_destroyed++

iprintlnbold_noloc "The Truck is escaping!"
iprintlnbold_noloc "Stop the truck!!"
$truck vehicleanim idlelights

//wait 1
$truck_speaker loopsound opeltruck_snd_run
$truck drive $truckwap1 
$truck waittill drive
wait 25
$truck stop  
$truck_speaker stop loopsound  
end
}
end


//////////////////////
// TANK Thread     //
////////////////////

tank:

$tank_trigger waittill trigger
local.player = parm.other
if (local.player.dmteam == "axis")
{
local.player iprint "You must stop the Allies stealing this!"
goto tank
}
if (local.player.dmteam == "allies")
{
$tank setcollisionentity self.target // Set the tank collision mask
$tank stop loopsound
wait .1
$tank loopsound tank_snd_on
//wait 10
iprintlnbold_noloc "The Tank has been stolen!"
$tank drive $wap1 
$tank waittill drive
$tank stop
$tank stop loopsound
wait 2
$tank.gun = $tank QueryTurretSlotEntity 0
$tank.gun setAimTarget $tank_target
$tank.gun waittill ontarget
wait 2
$tank.gun startFiring
wait .1
local.Exp1 = spawn "animate/fx_explosion_tank.tik" 
local.Exp1.origin = $exp_origin
local.Exp1 playsound explode_tank
local.Exp1 anim start 
$tank.gun stopFiring

$bankdoor_destroyed show
$bankwall_destroyed show
wait 1
local.Exp2 = spawn "animate/fx_explosion_flak88.tik" 
local.Exp2.origin = $tank_target2 
local.Exp2 playsound explode_tank
local.Exp2 anim start 
$bankdoor remove
$bankwall remove
local.Exp1 anim stop
local.Exp1 remove
local.Exp2 anim stop
local.Exp2 remove
end
}
end

/////////////////////////
// Axis victory test  //
///////////////////////

axis_win_timer:
level waittill axiswin 
end 

/////////////////////////////
// Vehicle marker threads //
///////////////////////////
 
escape:
$truck_escape_trigger waittill trigger
teamwin allies
end

tank_bridge:
$tank_bridge_trigger waittill trigger
iprintlnbold_noloc "The Tank is on the bridge!"
end

tank_courtyard:
$tank_courtyard_trigger waittill trigger
iprintlnbold_noloc "The Tank is approaching the courtyard!"
end

Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Heh, all of this won't be that easy to do in MoHAA, unfortunately. ;) You'll need some pretty complicated scripting.

I once made an ET-style tank thinker script (it followed a path if the proper team was somewhere around the tank, it could be destroyed and repaired), can dig it up for you. As for the gold crate stealing, it's pretty easy to do.

BTW, did you rescale the map? I once attempted converting Goldrush to MoHAA, but gave up on it, mainly because of VIS (geez, didn't have the patience to turn every god damn relevant brush detail) and scale issues (player sizes differ in ET and MoHAA).

Add me on MSN, I could give you a hand. :)

Oh, one more thing, are you the Waylander from SD forums?
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Waylander76
Sergeant Major
Posts: 122
Joined: Wed Jun 01, 2005 10:03 am

Post by Waylander76 »

hi Rookie

I know the actual Goldrush gameplay won't be that easy to do...so I didn't go that way..I simplified it for MoH OBJ ;)

What happens is the Allies have to reapir the tank once.
The tank (which cannot be destroyed) moves on it's path to the courtyard and blows the bank doors off.

The allies steal one crate and drop it off into the truck
once the truck is moving it can be destroyed by the axis and not repaired

All the above works with the above script apart from the things mentioned.
however I have made progress :)

I'm now just down to two things...determining the allied player with the crate and getting rid of the stopwatch whislt repairing the tank if the
use key is let go.

I'm not the waylander from the SD forums :)

The map isn't rescaled and the vis took 12 hours

this is the tank repair thread...this works but the stopwatch doesn't
disappear if the use key isn't held

Code: Select all

tank:

$tank_trigger waittill trigger
local.player = parm.other
if (local.player.dmteam == "axis")
{
local.player iprint "You must stop the Allies stealing this!"
goto tank
}
if (local.player.dmteam == "allies")

      local.counter = 0
while (local.player.useheld == 1) 
      {
       local.counter++
$tank playsound plantbomb
        wait 0.1
local.player stopwatch (level.tankrepairtime - local.counter)
if(local.counter == 10)
break
wait 1
}
if(local.counter == 10)
{
iprintlnbold_noloc "The Allies have repaired the Tank!"
wait 2
thread tankdrive
}

goto tank
end
Post Reply