![]() |
Need help: Scripting planes in Flughafen
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 //Turn off the lights! thread init_runway_lights ////////////////////////// level waittill prespawn ////////////////////////// ////////////////////////// level waittill spawn ////////////////////////// //init aagun params $aagun.collisionent = $aagun_collision $aagun_turret0.collisionent = $aagun_turret_collision $aagun thread global/stationaryweapons.scr::MountedStationaryWeaponWith Collision "models/statweapons/p_aagun_d.tik" $aagun_destroyed_collision //init granatwefer 1 params $granat_1.collisionent = $granatwerfer_collision $granat_1_turret0.collisionent = $granatwerfer_turret_collision $granat_1 thread global/stationaryweapons.scr::MountedStationaryWeaponWith Collision "models/statweapons/p_granatwerfer_d.tik" $granatwerfer_destroyed_collision $granat_1_turret0 maxyawoffset "40" //init granatwefer 2 params $granat_2.collisionent = $granatwerfer_collision $granat_2_turret0.collisionent = $granatwerfer_turret_collision $granat_2 thread global/stationaryweapons.scr::MountedStationaryWeaponWith Collision "models/statweapons/p_granatwerfer_d.tik" $granatwerfer_destroyed_collision $granat_2_turret0 maxyawoffset "40" // 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: if( level.bRoundStarted == 1 ) { if( parm.other.dmteam == axis ) { if( $obj_hangar_doors_2.ControlledBy != 0 ) { //flip the switch thread toggle_hangar_2_doors_switch //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: //First lets do the allies if( $obj_hangar_doors_1.ControlledBy == 0 ) { $obj_hangar_doors_1 SetCurrent 1 } else if( $Obj_airstrike.ControlledBy == 0 ) //start FLOT mod { $Obj_airstrike SetCurrent 1 } //end FLOT mod else if( $obj_runway_lights.ControlledBy == 0 ) { $obj_runway_lights SetCurrent 1 } else if( $obj_hangar_doors_2.ControlledBy == 0 ) { $obj_hangar_doors_2 SetCurrent 1 } else if( $obj_axis_spawner.ControlledBy == 0 ) { $obj_axis_spawner SetCurrent 1 } //Now the Axis if( $obj_hangar_doors_2.ControlledBy == 1 ) { $obj_hangar_doors_2 SetCurrent 0 } else if( $obj_runway_lights.ControlledBy == 1 ) { $obj_runway_lights SetCurrent 0 } else if( $obj_hangar_doors_1.ControlledBy == 1 ) { $obj_hangar_doors_1 SetCurrent 0 } else if( $obj_allied_spawner.ControlledBy == 1 ) { $obj_allied_spawner SetCurrent 0 } else if( $Obj_airstrike.ControlledBy == 1 ) //Start FLOT mod { $Obj_airstrike SetCurrent 0 } //End FLOT mod end //-------------------------------------------------------------- //Turns On/Off Airstike bombs //-------------------------------------------------------------- airstrike_switch: if( level.bAirStrikeSwitchUp == 1 ) { $airstrike_origin speed 1.0 $airstrike_origin rotatexdownto 180 $airstrike_origin waitmove $airstrike_origin playsound switchbox level.bAirStrikeSwitchUp = 0 } else { $airstrike_origin rotatexupto 0 $airstrike_origin waitmove level.bAirStrikeSwitchUp = 1 } end //---------------------------------------------------------- //init the spawner bombs //---------------------------------------------------------- init_spawner_bombs: //Allied spawner bomb $gmc_bomb thread global/tow_dm.scr::bomb_thinker "axis" maps/obj/MP_Flughafen_TOW.scr::destroy_allied_spawner $opel_bomb thread global/tow_dm.scr::bomb_thinker "allies" maps/obj/MP_Flughafen_TOW.scr::destroy_axis_spawner end //---------------------------------------------------------- //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 $hangar_doors_2_switch notsolid $hangar_doors_2_switch_origin notsolid $runway_switch notsolid $runway_switch_origin notsolid end //-------------------------------------------------------------- //Open hangar 1 doors //-------------------------------------------------------------- toggle_hangar_1_doors_switch: if( level.hangar1_switch_up == 1 ) { $hangar_doors_1_switch_origin speed 1.0 $hangar_doors_1_switch_origin rotatezdownto 180 $hangar_doors_1_switch_origin waitmove $hangar_doors_1_switch_origin playsound switchbox level.hangar1_switch_up = 0 } else { $hangar_doors_1_switch_origin speed 1.0 $hangar_doors_1_switch_origin rotatezupto 0 $hangar_doors_1_switch_origin waitmove $hangar_doors_1_switch_origin playsound switchbox level.hangar1_swith_up = 1 } end //-------------------------------------------------------------- //Open hangar 2 doors //-------------------------------------------------------------- toggle_hangar_2_doors_switch: if( level.hangar2_switch_up == 1 ) { $hangar_doors_2_switch_origin speed 1.0 $hangar_doors_2_switch_origin rotatezdownto 180 $hangar_doors_2_switch_origin waitmove $hangar_doors_2_switch_origin playsound switchbox level.hangar2_switch_up = 0 } else { $hangar_doors_2_switch_origin speed 1.0 $hangar_doors_2_switch_origin rotatezupto 0 $hangar_doors_2_switch_origin waitmove $hangar_doors_2_switch_origin playsound switchbox level.hangar2_switch_up = 1 } end //----------------------------------------------- // Call in the allied air strike //----------------------------------------------- call_air_strike: if( self.fire_attack_thread != NIL && self.fire_attack_thread != NULL ) { //switching targets self.fire_attack_thread delete wait 2 } self.fire_attach_thread = local 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: if( level.runway_switch_up == 1 ) { $runway_switch_origin speed 1.0 $runway_switch_origin rotatezdownto 180 $runway_switch_origin waitmove $runway_switch_origin playsound switchbox level.runway_switch_up = 0 level.bAirStrikeSwitchUp = 0 //FLOT mod } else { $runway_switch_origin speed 1.0 $runway_switch_origin rotatezupto 0 $runway_switch_origin waitmove $runway_switch_origin playsound switchbox level.runway_switch_up = 1 level.bAirStrikeSwitchUp = 1 //FLOT mod } end //----------------------------------------------- // Turn off the runway lights //----------------------------------------------- turn_on_runway_lights: //Turn on the lights $run_lights_01 show $run_lights_01 playsound runway_lights_on wait .2 $run_lights_02 show $run_lights_02 playsound runway_lights_on wait .2 $run_lights_03 show $run_lights_03 playsound runway_lights_on wait .2 $run_lights_04 show $run_lights_04 playsound runway_lights_on wait .2 $run_lights_05 show $run_lights_05 playsound runway_lights_on wait .2 $run_lights_06 show $run_lights_06 playsound runway_lights_on wait .2 $run_lights_07 show $run_lights_07 playsound runway_lights_on wait .2 $run_lights_08 show $run_lights_08 playsound runway_lights_on wait .2 $run_lights_09 show $run_lights_09 playsound runway_lights_on wait .2 $run_lights_10 show $run_lights_10 playsound runway_lights_on wait .2 $run_lights_11 show $run_lights_11 playsound runway_lights_on wait .2 $run_lights_12 show $run_lights_12 playsound runway_lights_on end //----------------------------------------------- // Turn off the runway lights //----------------------------------------------- turn_off_runway_lights: //Turn off the lights $run_lights_01 hide $run_lights_01 playsound runway_lights_off wait .2 $run_lights_02 hide $run_lights_02 playsound runway_lights_off wait .2 $run_lights_03 hide $run_lights_03 playsound runway_lights_off wait .2 $run_lights_04 hide $run_lights_04 playsound runway_lights_off wait .2 $run_lights_05 hide $run_lights_05 playsound runway_lights_off wait .2 $run_lights_06 hide $run_lights_06 playsound runway_lights_off wait .2 $run_lights_07 hide $run_lights_07 playsound runway_lights_off wait .2 $run_lights_08 hide $run_lights_08 playsound runway_lights_off wait .2 $run_lights_09 hide $run_lights_09 playsound runway_lights_off wait .2 $run_lights_10 hide $run_lights_10 playsound runway_lights_off wait .2 $run_lights_11 hide $run_lights_11 playsound runway_lights_off wait .2 $run_lights_12 hide $run_lights_12 playsound runway_lights_off end //----------------------------------------------- // Check for end match condition //----------------------------------------------- Check_End_Match: local.nAxis = 0 //Allied Spawner if( $obj_allied_spawner.ControlledBy == 0 ) { local.nAxis++ } //Axis Spawner if( $obj_axis_spawner.ControlledBy == 0 ) { local.nAxis++ } //Hangar Doors 1 if( $obj_hangar_doors_1.ControlledBy == 0 ) { local.nAxis++ } //Hangar Doors 2 if( $obj_hangar_doors_2.ControlledBy == 0 ) { local.nAxis++ } //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 forcemusic aux2 aux2 local.plane = spawn script_model model vehicles/ho-ix.tik origin $p00.origin angles $p00.angles local.plane notsolid local.plane thread TakeOff $p00 thread DoAlliedCamera local.plane local.plane2 = spawn script_model model vehicles/ho-ix.tik origin $p_00.origin angles $p_00.angles local.plane2 waitthread TakeOff $p_00 forcemusic aux3 aux3 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 forcemusic aux4 aux4 local.camera = spawn func_camera origin $axiswincam.origin angles $axiswincam.angles local.camera cut cuecamera local.camera waitthread global/ai.scr::spawnset 30 set30 waitthread global/ai.scr::spawnset 40 set40 for (local.i=1;local.i<=$set30.size;local.i++) { $set30[local.i] thread RunAway } wait 0.75 for (local.i=1;local.i<=$set40.size;local.i++) { $set40[local.i] thread Chase } wait 7 $cine_hangar_doors close $cine_hangar_doors_entity wait 8 forcemusic aux5 aux5 teamwin axis wait 5 end //------------------------------------------------------------- //RunAway dudes running away //------------------------------------------------------------- RunAway: self exec global/disable_ai.scr self nodamage self runto self.target end //------------------------------------------------------------- // Chase dudes chasing the dudes running away.. //------------------------------------------------------------- Chase local.target: self exec global/disable_ai.scr self nodamage self runto self.target self thread FireShots $set30[1] end //------------------------------------------------------------- // Fire! //------------------------------------------------------------- FireShots local.target: self aimat local.target while ( isAlive self ) { local.rand = randomfloat 0.75 local.rand += 0.2 wait local.rand self fire } end |
Needs more cowbell. happy:
Seriously, I'd try the scripting section of TMT forums. |
Quote:
|
You need to script pathnodes where you want the planes to go the exec them in the script
|
[quote="Scorpion -]M15F1T[-":c60e4]You need to script pathnodes where you want the planes to go the exec them in the script[/quote:c60e4]
I'm using Berlin as a model. It doesn't script pathnodes. It creates a random path for the planes. |
No there are path nodes in brlin look at the.map in the SDK .
also in the script there are 4 flight paths the random is just which one it picks. |
scorp seems to be the expert scripter here at gf1 :)
|
Nah just picked up a lot of bits and pieces over my time between here and TMT
|
All times are GMT -6. The time now is 09:52 AM. |
Powered by vBulletin® Version 3.8.12 by ScriptzBin
Copyright ©2000 - 2025, vBulletin Solutions Inc.
© 1998 - 2007 by Rudedog Productions | All trademarks used are properties of their respective owners. All rights reserved.