// CQ void DetpackExplode(); void JPFlameTouch() { if(other == self.owner) return; if(other.classname != "player" && other.classname != "bot" && other.classname != "detonator") return; if(other.classname == "detonator") { other.think = DetpackExplode; other.nextthink = time; } if(other.health) { other.deathtype = "flame"; T_Damage(other, self.owner, self.owner, 50); other.fire = time + 0.5; } } // CQ //void() SUB_regen; //void() StartItem; // CQ // void() BecomeExplosion; // CQ //for use with old code, I think void() s_explode1 = [0, s_explode2] {}; void() s_explode2 = [1, s_explode3] {}; void() s_explode3 = [2, s_explode4] {}; void() s_explode4 = [3, s_explode5] {}; void() s_explode5 = [4, s_explode6] {}; void() s_explode6 = [5, SUB_Remove] {}; void() BecomeExplosion = { self.movetype = MOVETYPE_NONE; self.velocity = '0 0 0'; self.touch = JPFlameTouch; setmodel (self, "progs/s_explod.spr"); // setsize(self, '-32 -32 -48', '32 32 16'); self.solid = SOLID_TRIGGER; s_explode1 (); }; //#Harlequin# This is what happens when a player grabs a jetpack /*void() jetpack_touch = { //#Harlequin# Don't give to dead players or non-players if (other.classname != "player") return; if (other.health <= 0) return; //#Harlequin# Tell them about it if (other.JETPACK_FUEL) sprint (other, "You got some jetpack fuel\n"); else { sprint (other, "You got the "); sprint (other, self.netname); //#Harlequin# self.netname = "Jetpack" sprint (other,"\n"); } //#Harlequin# Prepare to respawn in 1 minute if deathmatch if (deathmatch) { self.mdl = self.model; self.nextthink = time + 60; self.think = SUB_regen; } //#Harlequin# Play sound & make screen flash sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM); stuffcmd (other, "bf\n"); //#Harlequin# Become invisible and noclip self.solid = SOLID_NOT; self.model = string_null; //#Harlequin# Give the player some fuel other.JETPACK_FUEL = other.JETPACK_FUEL + 400; //#Harlequin# Activate any targets associated with the jetpack activator = other; SUB_UseTargets(); }; //#Harlequin# The spawn function for jetpacks void() item_jetpack = { self.touch = jetpack_touch; self.noise = "weapons/lock4.wav"; setmodel (self, "progs/backpack.mdl"); self.netname = "Jetpack"; setsize (self, '-16 -16 -24', '16 16 32'); StartItem (); };*/ //#Harlequin# Spawn flames from player when flying void() SpawnJetpackFlame = { local entity jetpackflame; local vector flamepos; jetpackflame = spawn(); jetpackflame.owner = self; setmodel(jetpackflame, "progs/s_explod.spr"); // setsize(jetpackflame, '-32 -32 -48', '32 32 16'); jetpackflame.solid = SOLID_TRIGGER; jetpackflame.movetype = MOVETYPE_NONE; jetpackflame.velocity = '0 0 0'; jetpackflame.touch = JPFlameTouch; //#Harlequin# If player is looking down, move flame back so it doesn't //get in the way of vision if (self.v_angle_x > 0) { makevectors(self.v_angle); flamepos = aim(self, 1000); flamepos = flamepos * self.v_angle_x * (-0.9); jetpackflame.origin = self.origin + flamepos; } else jetpackflame.origin = self.origin; //#Harlequin# Move it up to about chest height jetpackflame.origin_z = self.origin_z + 16; //#Harlequin# Animate it jetpackflame.think = BecomeExplosion; jetpackflame.nextthink = time; }; //#Harlequin# This is the routine called when the player is flying void() JetpackFly = { local float gravcorrection; //#Harlequin# gravcorrection is the upward velocity that (nearly) exactly counteracts gravity, giving a z velocity of 0 gravcorrection = ceil(cvar("sv_gravity") / 15); //#Harlequin# Jetpack sound, which coincidentally actually sounds like a jetpack. I was happy :-) // CQ if(time >= self.Turbine) { sound(self, CHAN_AUTO, "jetpack/jpturbine.wav", 1, ATTN_NORM); self.Turbine = time + 0.7; self.JETPACK_FUEL = self.JETPACK_FUEL - 1; if(self.JETPACK_FUEL <= 10) { safe_soundtoclient(self, self, CHAN_AUTO, "d5k/outside-fov.wav", 1, ATTN_NORM); if (self.JETPACK_FUEL == 10) { stuffcmd(self, "bf\n"); sprint(self, PRINT_HIGH, "WARNING -- LOW FUEL\n"); } } } // CQ //#Harlequin# Push the player in the proper direction self.velocity = aim(self, 1000); self.velocity = self.velocity * 500; //#Harlequin# Correct for gravity during flight, else it "feels" funny (though perhaps more realistic) self.velocity_z = self.velocity_z + gravcorrection; //#Harlequin# Hover mode -- don't let player sink while flying if (self.velocity_z < gravcorrection) self.velocity_z = gravcorrection; //#Harlequin# Sets frame to make them just stand there, rather than running in midair which looks stupid self.walkframe = 1; //#Harlequin# Fuel stuff: //#Harlequin# Decrements fuel // self.JETPACK_FUEL = self.JETPACK_FUEL - 1; //#Harlequin# If less than 3 seconds of fuel, warn them (once only) // CQ // moved this routine into the turbine sound routine above // to fix an Audio quake issue with the message repeating /* if (self.JETPACK_FUEL == 10) { stuffcmd(self, "bf\n"); sprint(self, PRINT_HIGH, "WARNING -- LOW FUEL"); } */ // CQ //#Harlequin# Spawn flames SpawnJetpackFlame(); }; //#Harlequin# JetpackThink starts the jetpack if the player presses jump //while in the air. Called by client.qc. void() JetpackThink = { // CQ if(self.JETPACK_FUEL < 1) { if(self.JetPackFlying) { sound(self, CHAN_ITEM, "jetpack/jplanding.wav", 1, ATTN_NORM); self.JetPackLand = 0; self.JetPackFlying = 0; self.JPChargeTime = time + 1; } else return; } if(time < self.emp) { if(self.JetPackFlying > 0) { sound(self, CHAN_ITEM, "jetpack/jplanding.wav", 1, ATTN_NORM); self.JetPackLand = 0; self.JetPackFlying = -1; self.JPChargeTime = time + 1; return; } else { if(self.button2) { if(rint(random()) < 0.5) sound(self, CHAN_AUTO, "emp/empdmg.wav", 1, ATTN_NORM); else sound(self, CHAN_AUTO, "emp/empdmg2.wav", 1, ATTN_NORM); } return; } } //#Harlequin# Don't activate if player is on the ground, not pressing //jump, in water, or hasn't yet released the button after jumping if (self.flags & FL_ONGROUND) { if(self.JetPackFlying > 0) { sound(self, CHAN_ITEM, "jetpack/jplanding.wav", 1, ATTN_NORM); self.JetPackLand = 1; self.JetPackFlying = 0; self.JPChargeTime = time + 1; return; } else return; } if(self.waterlevel > 1) { if(self.JetPackFlying) { sound(self, CHAN_ITEM, "jetpack/jplanding.wav", 1, ATTN_NORM); self.JetPackLand = 1; self.JetPackFlying = 0; self.JPChargeTime = time + 1; } else { return; } } if (!(self.flags & FL_JUMPRELEASED)) return; if(!(self.button2)) self.JetPackIgnition = 0; if(!(self.JetPackIgnition)) { if(self.button2) { self.JetPackIgnition = 1; if(self.JetPackFlying == 0) { self.JetPackFlying = 1; sound(self, CHAN_ITEM, "jetpack/jptakeoff.wav", 1, ATTN_NORM); self.Turbine = time + 0.5; self.ForceJump = 0; if(self.hooking && infokey(self, "VampHook") != "0") BreakHook(); } else { sound(self, CHAN_ITEM, "jetpack/jplanding.wav", 1, ATTN_NORM); self.JetPackLand = 1; self.JetPackFlying = 0; self.JPChargeTime = time + 1; } } } if(self.JetPackFlying == 0) return; // CQ //#Harlequin# Do the Peter Pan thing JetpackFly(); };