main local.pathname local.origin local.angles local.offtime local.bombsoff local.bulletstokill local.killtime: local.radio = spawn script_model local.radio model "animate/military_radio.tik" local.radio.origin = local.origin local.radio.angles = local.angles local.radio notsolid local.switchtrig = spawn trigger_use local.switchtrig.origin = local.radio.origin local.switchtrig setsize ( -10 -10 -10 ) ( 10 10 10 ) // when using setthread instead of thread, variables can be carried over when attached to the setthread's "self" object (local.switchtrig.variablename). local.switchtrig setthread notready local.switchtrig.istriggered = 0 // make loopsound commands trigger only once, when in while loops (0 or 1). local.switchtrig.state = 0 // holds the radio's current state (none, notready, ready, holding USE, successful: 0,1,2,3,4). local.switchtrig.team = 0 // holds player's team (none, allies, axis: 0,1,2). local.switchtrig.inc = 0 // rotates sounds played if radio is triggered while not yet ready (sound off, static1, static2: 0,1,2). local.t = 0 while(local.t < local.offtime) { if(local.switchtrig.istriggered == 1) { local.radio stoploopsound } if(local.switchtrig.inc == 1 && local.switchtrig.istriggered == 1) { local.radio loopsound radiostatic3 } if(local.switchtrig.inc == 2 && local.switchtrig.istriggered == 1) { local.radio loopsound radiostatic2 } local.switchtrig.istriggered = 0 local.t = local.t + 0.1 wait 0.1 } local.radio.model = "animate/pulse_military_radio.tik" local.switchtrig setthread ready local.random = randomint(2) while(local.switchtrig.state < 4) { if(local.switchtrig.state < 3) { local.radio stoploopsound } if(local.switchtrig.state == 3) { if(local.random == 0) { local.radio loopsound radiomorsecode1 } if(local.random == 1) { local.radio loopsound radiomorsecode2 } } wait 0.05 } local.radio stoploopsound local.radio playsound sendtransmission local.random2 = randomint(3) if(local.switchtrig.team == 3) { local.switchtrig.team = randomint(2) + 1 } if(local.switchtrig.team == 1) { if(local.random2 == 0) { local.radio playsound allied_airstrike1 } if(local.random2 == 1) { local.radio playsound allied_airstrike2 } if(local.random2 == 2) { local.radio playsound allied_airstrike3 } } if(local.switchtrig.team == 2) { if(local.random2 == 0) { local.radio playsound axis_airstrike1 } if(local.random2 == 1) { local.radio playsound axis_airstrike2 } if(local.random2 == 2) { local.radio playsound axis_airstrike3 } } /////////////////////////////////////////////*** add code here ***////// exec maps/training_mapscripts/airstrikebombs.scr::splinepath_change local.pathname waitframe // keep offtime = 0 or NIL since offtime is already inside "airstrike_radiotrig.scr". exec maps/training_mapscripts/airstrikebombs.scr local.pathname first local.bombsoff 0 local.bulletstokill local.killtime // if offtime > 0, then airstrikes will continuously occur after each "offtime" exec maps/training_mapscripts/airstrikebombs.scr local.pathname second local.bombsoff 0 local.bulletstokill local.killtime // duration has passed (ideally exec'd in map's main script). //////////////////////////////////////////////////////////////////////// local.radio remove local.switchtrig remove thread main local.pathname local.origin local.angles local.offtime local.bombsoff local.bulletstokill local.killtime end //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// notready: local.player = parm.other local.player iprint ("Airstrikes are not available yet.") self.inc++ if(self.inc >= 3) { self.inc = 0 } self.team = 0 self.state = 1 self.istriggered = 1 end //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// ready: local.player = parm.other local.team = local.player.dmteam // dmteam checks probably not needed, but helps prevent triggering if player changes team or goes to spectator. if(level.airspace_toobusy == 1) { local.player iprint ("The airspace is too crowded! Please wait a few seconds, then try again.") end } local.calltimer = 0 while(local.player.useheld == 1 && level.airspace_toobusy != 1 && local.player.dmteam == local.team && isalive local.player) { if(local.calltimer == 0) { self.state = 3 local.player stopwatch 4 // begin counting when USE key is held. } if(local.calltimer >= 80) // 20 loops/sec * 4 seconds = 80. { self.state = 4 local.player stopwatch 0 if(local.team == allies) { self.team = 1 } if(local.team == axis) { self.team = 2 } if(local.team == freeforall) { self.team = 3 } local.player iprint ("AIRSTRIKE CALLED!") end } local.calltimer++ local.team = local.player.dmteam // if player is still alive, then make player's dmteam = local.team. wait 0.05 // 20 while-loop increments per second. } local.player iprint ("Hold USE for 4 seconds near the radio to call for an airstrike.") local.player stopwatch 0 self.team = 0 self.state = 2 // did not hold USE for 4 seconds. released USE key too early. end