Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include maps\mp\_utility;
- #include maps\mp\gametypes\_hud_util;
- #include common_scripts\utility;
- init()
- {
- self thread onPlayerConnect();
- }
- onPlayerConnect()
- {
- for(;;)
- {
- level waittill("connected", player);
- player thread givehelionfrag();
- }
- }
- givehelionfrag()
- {
- while(1)
- {
- wait 0.05;
- if( self fragbuttonpressed() )
- {
- destination = 0;
- random_path = randomint( level.heli_paths[destination].size );
- startnode = level.heli_paths[destination][random_path];
- self thread heli_think( self, startnode, self.pers["team"] );
- break;
- }
- }
- }
- heli_think( owner, startnode, heli_team, requiredDeathCount )
- {
- heliAngles = owner.angles;
- heliOrigin = owner.origin + (0,0,2000);
- if( heli_team == "allies" )
- {
- chopper = spawnHelicopter( owner, heliOrigin, heliAngles, "cobra_mp", "vehicle_mi24p_hind_mp");
- }
- else
- {
- chopper = spawnHelicopter( owner, heliOrigin, heliAngles, "cobra_mp", "vehicle_mi24p_hind_mp");
- }
- chopper.requiredDeathCount = owner.deathCount;
- chopper.team = heli_team;
- chopper.pers["team"] = heli_team;
- chopper.owner = owner;
- owner.choppa = chopper;
- owner.choppa = chopper;
- chopper thread heli_existance();
- //chopper thread heli_trig_interval( level.heli_trigger, level.heli_hardpoint_timer );
- if( isDefined( level.firstchopper ) )
- level.secondchopper = chopper;
- else
- level.firstchopper = chopper;
- if( isDefined( level.firstchopper ) && isDefined( level.secondchopper ) )
- level.chopper = chopper;
- // TO DO: convert all helicopter attributes into dvars
- chopper.reached_dest = false; // has helicopter reached destination
- chopper.maxhealth = level.heli_maxhealth; // max health
- chopper.waittime = level.heli_dest_wait; // the time helicopter will stay stationary at destination
- chopper.loopcount = 0; // how many times helicopter circled the map
- chopper.evasive = false; // evasive manuvering
- chopper.health_bulletdamageble = level.heli_armor; // when damage taken is above this value, helicopter can be damage by bullets to its full amount
- chopper.health_evasive = level.heli_armor; // when damage taken is above this value, helicopter performs evasive manuvering
- chopper.health_low = level.heli_maxhealth*0.8; // when damage taken is above this value, helicopter catchs on fire
- chopper.targeting_delay = level.heli_targeting_delay; // delay between per targeting scan - in seconds
- chopper.primaryTarget = undefined; // primary target ( player )
- chopper.secondaryTarget = undefined; // secondary target ( player )
- chopper.attacker = undefined; // last player that shot the helicopter
- chopper.missile_ammo = level.heli_missile_max; // initial missile ammo
- chopper.currentstate = "ok"; // health state
- chopper.lastRocketFireTime = -1;
- chopper.angles = owner.angles;
- chopper.origin = owner.origin + (0,0,1000);
- owner hide();
- if( owner.pers["team"] == "allies" )
- {
- heli_centroid = chopper.origin + ( 0, 0, -145 );
- heli_forward_norm = anglestoforward( chopper.angles );
- heli_turret_point = heli_centroid + 110*heli_forward_norm;
- }
- else
- {
- heli_centroid = chopper.origin + ( 0, 0, -100 );
- heli_forward_norm = anglestoforward( chopper.angles );
- heli_turret_point = heli_centroid + 120*heli_forward_norm;
- }
- owner setorigin( heli_turret_point );
- owner.flyingheli = true;
- self.zething = spawn("script_origin", owner.origin);
- self.zething EnableLinkTo();
- owner PlayerLinkTo( self.zething );
- self.zething LinkTo( chopper );
- chopper thread heli_fly( owner ); // fly heli to given node and continue on its path
- //chopper thread heli_damage_monitor(); // monitors damage
- //chopper thread heli_health(); // display helicopter's health through smoke/fire
- }
- heli_existance()
- {
- self waittill_any( "death", "crashing", "leaving" );
- level notify( "helicopter gone" );
- }
- heli_fly( owner )
- {
- self endon( "death" );
- self notify( "flying");
- self endon( "flying" );
- self endon( "abandoned" );
- owner takeallweapons();
- self.reached_dest = false;
- owner.choppa SetTurningAbility(1);
- owner.isturretsafe = true;
- owner.islinked = true;
- self.ispitchedown = false;
- pos = self.origin;
- owner setclientdvar( "cg_thirdperson", "1" );
- owner setclientdvar( "cg_thirdpersonrange", "1500" );
- wait( 2 );
- while( isAlive( owner ) )
- {
- angle = owner getPlayerAngles();
- if( owner meleebuttonpressed() )
- owner thread moveonangle( angle );
- else
- {
- distance = self thread vector_scal123(anglesToForward(self getPlayerAngles()),1000000);
- if( self.ispitchedown )
- {
- self setVehGoalPos( self.origin + distance, 1 );
- self helirotateto( (self.angles[0], self.angles[1], self.angles[2] ), "up" );
- self.ispitchedown = false;
- }
- self.angles = owner.angles;
- }
- if( owner attackbuttonpressed() && owner.isturretsafe )
- {
- owner.isturretsafe = false;
- //owner thread maketurretsafe();
- //owner thread firemissile( angle );
- }
- if( owner fragbuttonpressed() )
- {
- owner heli_vertical( "down" );
- }
- if( owner SecondaryOffhandButtonPressed() )
- {
- owner heli_vertical( "up" );
- }
- self.angles = angle;
- wait 0.05;
- }
- }
- helirotateto( vec, dif )
- {
- if( dif == "up" )
- {
- for( i = 0; i < 10; i++ )
- {
- self.angles = self.angles + ( 1.5,0,0 );
- wait 0.05;
- }
- }
- else
- {
- for( i = 0; i < 10; i++ )
- {
- self.angles = self.angles - ( 1.5,0,0 );
- wait 0.05;
- }
- }
- }
- heli_vertical( dir )
- {
- if( dir == "up" )
- {
- if( bullettracepassed( self.choppa.origin, self.choppa.origin + (0,0,25), false, self.choppa ) )
- {
- self.choppa Vehicle_SetSpeed( 100, 100 );
- self.choppa setVehGoalPos( self.choppa.origin + (0,0,50), 1 );
- }
- else
- {
- self iprintlnbold("You Crashed your helicopter, try to");
- self iprintlnbold("keep a little bit higher next time.");
- //self.choppa thread heli_explode();
- }
- }
- else
- {
- if( bullettracepassed( self.choppa.origin, self.choppa.origin - (0,0,25), false, self.choppa ) )
- {
- self.choppa Vehicle_SetSpeed( 100, 100 );
- self.choppa setVehGoalPos( self.choppa.origin - (0,0,50), 1 );
- }
- else
- {
- self iprintlnbold("You Crashed your helicopter, try to");
- self iprintlnbold("keep a little bit higher next time.");
- //self.choppa thread heli_explode();
- }
- }
- }
- moveonangle( angle )
- {
- distance = self thread vector_scal123(anglesToForward(self getPlayerAngles()),1000000);
- if( bullettracepassed( self.origin, self.origin + distance, false, self.choppa ) )
- {
- if( !isDefined( self.choppa ) )
- return;
- if( !self.choppa.ispitchedown )
- {
- self helirotateto( (0,0,0), "down" );
- self.choppa.ispitchedown = true;
- }
- self.choppa Vehicle_SetSpeed( 50, 50 );
- self.choppa SetTargetYaw( angle[1] );
- self.choppa SetYawSpeed( 180, 60, 60, 0 );
- self.choppa setVehGoalPos( self.choppa.origin + distance, 0 );
- }
- else
- {
- self iprintlnbold("You Crashed your helicopter, try to");
- self iprintlnbold("keep a little bit higher next time.");
- //self.choppa thread heli_explode();
- }
- }
- vector_scal123(vec,scale)
- {
- vec=(vec[0]*scale,vec[1]*scale,vec[2]*scale);
- return vec;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement