Need help: Scripting planes in Flughafen -
02-09-2005, 10:02 PM
Here's what I'm trying to do... using the Berlin script as an example, I have tried to set it up so that in TDM mode, allied players can turn on the runway lights. In turn, this is supposed to initiate airstrikes, just like in Berlin, TOW mode. I've gotten it so I can turn on the lights and it says the bombing will start, but nothing happens other than the runway lights coming on. Below is my script. Perhaps you experts out there can look it over and see what I've done wrong.
// MP_Flughafen_TOW
// Note: For objective function calls TakeOver and SetCurrent the
// teams are as such:
// 0 = Axis
// 1 = Allies
// 2 = Neutral
//----------------------------------------------------------
// Main
//----------------------------------------------------------
main:
exec global/ai.scr
exec global/friendly.scr
level.script="maps/obj/MP_Flughafen_TOW.scr"
level.music="MP_Flughafen_TOW"
setcvar "g_scoreboardpic" "mp_flughafen_tow"
exec global/tow_dm.scr
exec global/ambient.scr
exec global/door_locked.scr
level.gametype = int( getcvar( g_gametype ) )
//gametype 5 = Tug of War
if( level.gametype == 5 )
{
setcvar "g_obj_alliedtext1" "Protect Allied Transport"
setcvar "g_obj_alliedtext2" "Open 1st Hangar Doors"
setcvar "g_obj_alliedtext3" "Turn On the Runway Lights"
setcvar "g_obj_alliedtext4" "Open the 2nd Hangar Doors"
setcvar "g_obj_alliedtext5" "Detonate Axis Motorpool"
setcvar "g_obj_axistext1" "Protect Axis Motorpool"
setcvar "g_obj_axistext2" "Close the 2nd Hangar Doors"
setcvar "g_obj_axistext3" "Turn Off the Runway Lights"
setcvar "g_obj_axistext4" "Close the 1st Hangar Doors"
setcvar "g_obj_axistext5" "Destroy Allied Transport"
}
else
{
$gmc_bomb remove
$opel_bomb remove
// set scoreboard messages
setcvar "g_obj_alliedtext1" "Flughafen"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""
}
//set our farplane and culling parameters
$world farplane 3000
$world farplane_color ".03 .05 .09" //this matches eben's new sky
$world farplane_cull 2
//Open the hangar 1 doors
$hangar_doors_1 open $hangar_doors_1_entity
// open these doors at the start...
$cine_hangar_doors open $cine_hangar_doors_entity
// set the parameters for this round based match
level.bRoundStarted = 0
level.dmrespawning = 1 // 1 or 0
level.clockside = axis // set to axis, allies, kills, or draw
level.dmroundlimit = 15 // round time limit in minutes
level.numObjectives = 5 // Number of objectives needed to win
level.bAirStrikeSwitchUp = 1
level.hangar1_switch_up = 1
level.hangar2_switch_up = 1
level.runway_switch_up = 1
//////////////////////////
//level waittill roundstart
//////////////////////////
//If we are in TOW mode setup the TOW stuff...
if( level.gametype == 5 )
{
thread init_switches
thread init_spawner_bombs
//Flip the hangar switch
thread toggle_hangar_1_doors_switch
//Setup the starting team objectives
thread set_objectives
level.bRoundStarted = 1
}
else //start FLOT Mod
{
if( level.gametype == 2 )
thread init_switches
//Setup the starting team objectives
thread set_objectives
level.bRoundStarted = 1
} //end FLOT mod
end
//----------------------------------------------------------
//Destroy the Allied spawner here
//----------------------------------------------------------
destroy_allied_spawner:
iprintln "The Allied transport has been destroyed!"
//Take over the objective
$obj_allied_spawner TakeOver 0
iprintln "The Allied Team can no longer respawn!"
thread Check_End_Match
end
//----------------------------------------------------------
//Destroy the Axis spawner here
//----------------------------------------------------------
destroy_axis_spawner:
iprintln "The Axis Motorpool has been destroyed!"
//Take over the objective
$obj_axis_spawner TakeOver 1
iprintln "The Axis Team can no longer respawn!"
thread Check_End_Match
end
//----------------------------------------------------------
//Open/close the 1st Hangar Doors here
//----------------------------------------------------------
toggle_hangar_doors_1:
if( level.bRoundStarted == 1 )
{
if( parm.other.dmteam == axis )
{
if( $obj_hangar_doors_1.ControlledBy != 0 )
{
//flip the switch
thread toggle_hangar_1_doors_switch
//Close the hangar doors
$hangar_doors_1 close $hangar_doors_1_entity
$hangar_doors_1 playsound hanger_closed
$obj_hangar_doors_1 TakeOver 0
iprintln "The Axis have closed the 1st Hangar Doors!"
}
}
else if( parm.other.dmteam == allies )
{
if( $obj_hangar_doors_1.ControlledBy != 1 )
{
//flip the switch
thread toggle_hangar_1_doors_switch
//Open the pen doors
$hangar_doors_1 open $hangar_doors_1_entity
$hangar_doors_1 playsound hanger_open
$obj_hangar_doors_1 TakeOver 1
iprintln "The Allies have opened the 1st Hangar Doors!"
}
}
//Did anyone win?
thread Check_End_Match
//Update team current objectives
thread set_objectives
}
end
//----------------------------------------------------------
//Open/close the 2st Hangar Doors here
//----------------------------------------------------------
toggle_hangar_doors_2:
//Close the hangar doors
$hangar_doors_2 close $hangar_doors_2_entity
$hangar_doors_2 playsound hanger_closed
$obj_hangar_doors_2 TakeOver 0
iprintln "The Axis have closed the 2nd Hangar Doors!"
}
}
else if( parm.other.dmteam == allies )
{
if( $obj_hangar_doors_2.ControlledBy != 1 )
{
//flip the switch
thread toggle_hangar_2_doors_switch
//Open the hangar doors
$hangar_doors_2 open $hangar_doors_2_entity
$hangar_doors_2 playsound hanger_open
$obj_hangar_doors_2 TakeOver 1
iprintln "The Allies have opened the 2nd Hangar Doors!"
}
}
//Did anyone win?
thread Check_End_Match
//Update team current objectives
thread set_objectives
}
end
//----------------------------------------------------------
//Turn on/Shut down the runway lights
//----------------------------------------------------------
toggle_runway_lights:
if( level.bRoundStarted == 1 )
{
if( parm.other.dmteam == allies )
{
if( $obj_runway_lights.ControlledBy != 1 )
{
//flip the switch
thread toggle_runway_switch
waitthread turn_on_runway_lights
//Take the objective
$obj_runway_lights TakeOver 1
//iprintln "The Allies have turned on the Runway Lights!"
if( $Obj_airstrike.ControlledBy != 1 ) //start FLOT mod
{
//Flip the switch
//thread airstrike_switch
$airstrike_radio_speaker playsound radio_on
$Obj_airstrike TakeOver 1
//$tower_lights_01 hide
thread call_air_strike
iprintln "The Allies have turned on the runway lights! Allied planes are on their way to attack the airfield!"
} //end FLOT mod
}
}
else if( parm.other.dmteam == axis )
{
if( $obj_runway_lights.ControlledBy != 0 )
{
//flip the switch
thread toggle_runway_switch
waitthread turn_off_runway_lights
//Take the objective
$obj_runway_lights TakeOver 0
//iprintln "The Axis have turned off the Runway Lights!"
if( $Obj_airstrike.ControlledBy != 0 )
{
//Flip the switch
//thread airstrike_switch
$airstrike_radio_speaker playsound radio_off
$Obj_airstrike TakeOver 0
//$tower_lights_01 hide
iprintln "The Axis have turned off the runway lights. The Allied planes can't find the runway!"
}
}
}
//Did anyone win?
thread Check_End_Match
//Update team current objectives
thread set_objectives
}
end
//----------------------------------------------------------
//Initialize the runway lights
//----------------------------------------------------------
init_runway_lights:
$run_lights_01 hide
$run_lights_02 hide
$run_lights_03 hide
$run_lights_04 hide
$run_lights_05 hide
$run_lights_06 hide
$run_lights_07 hide
$run_lights_08 hide
$run_lights_09 hide
$run_lights_10 hide
$run_lights_11 hide
$run_lights_12 hide
end
//----------------------------------------------------------
//Set the teams current objectives
//----------------------------------------------------------
set_objectives:
//----------------------------------------------------------
//init the trigger switches
//----------------------------------------------------------
init_switches:
$hangar_doors_1_switch bind $hangar_doors_1_switch_origin
$hangar_doors_2_switch bind $hangar_doors_2_switch_origin
$runway_switch bind $runway_switch_origin
//make all the switches non solid so as not to injure the player when triggered.
$hangar_doors_1_switch notsolid
$hangar_doors_1_switch_origin notsolid
while( $Obj_airstrike.ControlledBy == 1 )
{
//Plane 1 flypath
local.rand = randomint 3
switch( local.rand )
{
//local.flypath is the path the plane will follow
//local.wait is the delay before it drops it's bombs
case 0:
local.flypath = $plane_path1
local.wait = randomfloat 1.0
local.wait += 2
wait local.wait
break;
case 1:
local.flypath = $plane_path2
local.wait = randomfloat 1.0
local.wait += 2
wait local.wait
break;
case 2:
local.flypath = $plane_path3
local.wait = randomfloat 1.0
local.wait += 2
wait local.wait
break;
case 3:
local.flypath = $plane_path4
local.wait = randomfloat 1.0
local.wait += 2
wait local.wait
break;
}
//Plane 2 flypath
local.rand2 = randomint 3
//Make sure we get a different path.
while( local.rand2 == local.rand )
{
local.rand2 = randomint 3
}
switch( local.rand2 )
{
//local.flypath2 is the path the plane will follow
//local.wait2 is the delay before it drops it's bombs
case 0:
local.flypath2 = $plane_path1
local.wait2 = randomfloat 1.0
local.wait2 += 2
wait local.wait2
break;
case 1:
local.flypath2 = $plane_path2
local.wait2 = randomfloat 1.0
local.wait2 += 2
wait local.wait2
break;
case 2:
local.flypath2 = $plane_path3
local.wait2 = randomfloat 1.0
local.wait2 += 2
wait local.wait2
break;
case 3:
local.flypath2 = $plane_path4
local.wait2 = randomfloat 1.0
local.wait2 += 2
wait local.wait2
break;
}
thread spawn_plane "Plane1" "Plane1_bomb" "Plane1_bomb2" local.flypath local.wait
// if( $Obj_radarcontrol.ControlledBy == 1 )
// {
// wait 1
// thread spawn_plane "Plane2" "Plane2_bomb" "Plane2_bomb2" local.flypath2 local.wait2
// }
//
//How long between plane runs
wait 15
}
end
//-----------------------------------------------
// Spawn in a plane
//-----------------------------------------------
spawn_plane local.planeName local.bombName local.bombName2 local.flypath local.wait:
//spawn the plane in and start flying over the target
spawn script_model model models/vehicles/yak_7b.tik "$targetname" local.planeName origin local.flypath.origin
local.planeName followpath local.flypath 2500 2000 256
local.planeName playsound plane
local.planeName move
local.planeName notsolid
wait local.wait
spawn models/projectiles/Berlin_Bombs.tik "$targetname" local.bombName origin local.flypath.origin
local.bombName becomebomb local.planeName
local.bombName model "ammo/us_bomb.tik"
local.bombName show
//Delay slightly before dropping the second bomb
wait 0.2
spawn models/projectiles/Berlin_Bombs.tik "$targetname" local.bombName2 origin local.flypath.origin
local.bombName2 becomebomb local.planeName
local.bombName2 model "ammo/us_bomb.tik"
local.bombName2 show
local.planeName waitmove
local.planeName remove
end
//--------------------------------------------------------------
//Turn on Runway Lights
//--------------------------------------------------------------
toggle_runway_switch:
//Runway lights
if( $obj_runway_lights.ControlledBy == 0 )
{
local.nAxis++
}
//Allies first
if( $obj_runway_lights.ControlledBy == 1 && $obj_hangar_doors_1.ControlledBy == 1 && $obj_hangar_doors_2.ControlledBy == 1 )
{
//ignore the clock
level ignoreclock 1
//if there is a bomb ticking stop it.
waitthread global/tow_dm.scr::StopBomb
//Allies win do the movie then end the map
thread AlliesWon
}
else if( local.nAxis == level.numObjectives )
{
//ignore the clock
level ignoreclock 1
//if there is a bomb ticking stop it.
waitthread global/tow_dm.scr::StopBomb
//Axis win do their movie and end the map
thread AxisWon
}
end
//-------------------------------------------------------------
// Do the Allied camera stuff
//-------------------------------------------------------------
DoAlliedCamera local.ent:
local.camera = spawn func_camera origin $cam01.origin angles $cam01.angles
local.camera fov 100
local.camera watch local.ent
local.camera cut
cuecamera local.camera
end
//-------------------------------------------------------------
// when allies win, we watch the two planes take off and do a
// fly-by passed each other....
//-------------------------------------------------------------
AlliesWon:
$player nodamage
$player hide
freezeplayer
level ignoreclock 1
teamwin allies
wait 5
end
//-------------------------------------------------------------
// have the plane take off
//-------------------------------------------------------------
TakeOff local.path:
self notsolid
self playsound plane // todo: more appropriate sound maybe?
thread RaiseLandingGear
self followpath local.path
self waitmove
self delete
end
//--------------------------------------------------------------
// Raise the landing gear
//--------------------------------------------------------------
RaiseLandingGear:
wait 2
self anim takeoff
end
//-------------------------------------------------------------
// Watch the allies run by while the germans shoot at them...
// much like berlin's ending....
// open hanger door?
//-------------------------------------------------------------
AxisWon:
$player nodamage
$player hide
freezeplayer