From 6b618b2c1bfb41424e900ad42ac65d4e223f025e Mon Sep 17 00:00:00 2001 From: seienabunae Date: Sun, 9 Jan 2005 22:02:27 +0000 Subject: [PATCH] Some changes to the grenade launcher and shotgun that weren't my changes SUB_Null changed to nullfunction More deathtypes added for falling, falling down endless pits, drowning, and trigger_hurt trigger_hurts can have custom death messages (set .message field to something like "was in the wrong place." Make sure there is no space at the beginning and it ends with a punctuation character.) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@251 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- qcsrc/gamec/cl_client.c | 9 ++--- qcsrc/gamec/constants.h | 11 ++--- qcsrc/gamec/g_casings.c | 2 +- qcsrc/gamec/g_damage.c | 71 +++++++++++++++++++++++---------- qcsrc/gamec/g_subs.c | 16 +------- qcsrc/gamec/g_triggers.c | 14 +++---- qcsrc/gamec/g_violence.c | 2 +- qcsrc/gamec/t_jumppads.c | 2 +- qcsrc/gamec/t_plats.c | 6 +-- qcsrc/gamec/w_crylink.c | 2 +- qcsrc/gamec/w_electro.c | 6 +-- qcsrc/gamec/w_grenadelauncher.c | 35 ++++++---------- qcsrc/gamec/w_hagar.c | 2 +- qcsrc/gamec/w_laser.c | 2 +- qcsrc/gamec/w_rocketlauncher.c | 2 +- 15 files changed, 94 insertions(+), 88 deletions(-) diff --git a/qcsrc/gamec/cl_client.c b/qcsrc/gamec/cl_client.c index 02e39ec50..f1f7b430e 100644 --- a/qcsrc/gamec/cl_client.c +++ b/qcsrc/gamec/cl_client.c @@ -92,8 +92,8 @@ void PutClientInServer (void) self.speed_finished = 0; self.slowmo_finished = 0; // players have no think function - self.think = SUB_Null; - self.nextthink = 0; + self.think = nullfunction; + self.nextthink = -1; self.deadflag = DEAD_NO; @@ -103,7 +103,6 @@ void PutClientInServer (void) self.viewzoom = 0.6; setmodel (self, self.playermodel); - setsize (self, PL_MIN, PL_MAX); setorigin (self, spot.origin + '0 0 1' * (1 - self.mins_z - 24)); // don't reset back to last position, even if new position is stuck in solid @@ -440,7 +439,7 @@ void PlayerPostThink (void) { local float dm; dm = bound(0, 0.1*(fabs(self.jump_flag) - 600), 20); - Damage (self, world, world, dm, 1, '0 0 0', '0 0 0'); + Damage (self, world, world, dm, DEATH_FALL, '0 0 0', '0 0 0'); } self.jump_flag = 0; } @@ -467,7 +466,7 @@ void PlayerPostThink (void) if (time < self.lip) {// prevent all inventory drop self.weapon = 0; - Damage (self, world, world, 40000, 1, '0 0 0', '0 0 0'); + Damage (self, world, world, 40000, DEATH_BIGFALL, '0 0 0', '0 0 0'); } } } diff --git a/qcsrc/gamec/constants.h b/qcsrc/gamec/constants.h index a38f44553..913c3e296 100644 --- a/qcsrc/gamec/constants.h +++ b/qcsrc/gamec/constants.h @@ -129,6 +129,12 @@ float MSG_ONE = 1; float MSG_ALL = 2; float MSG_INIT = 3; +// Deathtypes (weapon deathtypes are the IT_* constants below) +float DEATH_FALL = 10000; +float DEATH_BIGFALL = 10001; +float DEATH_DROWN = 10002; +float DEATH_HURTTRIGGER = 10003; + float IT_LASER = 4096; float IT_SHOTGUN = 1; float IT_UZI = 2; @@ -153,11 +159,6 @@ vector PL_VIEW_OFS = '0 0 35'; vector PL_MIN = '-16 -16 -24'; vector PL_MAX = '16 16 45'; -//vector PL_VIEW_OFS = '0 0 32'; -//vector PL_MIN = '-16 -16 -48'; -//vector PL_MAX = '16 16 48'; - - // Sajt - added these, just as constants. Not sure how you want them actually put in the game, but I just // did this so at least they worked // NOTE: instagib IS NOT compatible with rocket-arena, so make sure to prevent selecting both in a menu diff --git a/qcsrc/gamec/g_casings.c b/qcsrc/gamec/g_casings.c index 34266d89c..93ebb713f 100644 --- a/qcsrc/gamec/g_casings.c +++ b/qcsrc/gamec/g_casings.c @@ -5,7 +5,7 @@ void() casingtouch = if (time >= self.attack_finished) sound (self, CHAN_WEAPON, "weapons/tink1.wav", 0.5, ATTN_NORM); self.attack_finished = time + 0.2; - //self.touch = SUB_Null; // one tink is enough + //self.touch = nullfunction; // one tink is enough //self.dest = self.origin - self.groundentity.origin; }; diff --git a/qcsrc/gamec/g_damage.c b/qcsrc/gamec/g_damage.c index 5063c50c6..7f6c0c72f 100644 --- a/qcsrc/gamec/g_damage.c +++ b/qcsrc/gamec/g_damage.c @@ -1,40 +1,69 @@ void Obituary (entity attacker, entity targ, float deathtype) { - local string s; + string s; + if (targ.classname == "player" || targ.classname == "corpse") { - s = targ.netname; if (targ.classname == "corpse") s = "A corpse"; + else + s = targ.netname; + + // Suicides if (targ == attacker) { - if (deathtype == IT_LASER) {bprint(s);bprint(" was unable to resist the urge to self-immolate\n");} - else if (deathtype == IT_GRENADE_LAUNCHER) {bprint(s);bprint(" detonated\n");} - else if (deathtype == IT_ELECTRO) {bprint(s);bprint(" played with plasma\n");} - else if (deathtype == IT_HAGAR) {bprint(s);bprint(" should have used a different weapon\n");} - else if (deathtype == IT_ROCKET_LAUNCHER) {bprint(s);bprint(" exploded\n");} - else {bprint(s);bprint(" competes for the darwin awards\n");} + if (deathtype == IT_LASER) + bprint (s, " was unable to resist the urge to self-immolate\n"); + else if (deathtype == IT_GRENADE_LAUNCHER) + bprint (s, " detonated\n"); + else if (deathtype == IT_ELECTRO) + bprint (s, " played with plasma\n"); + else if (deathtype == IT_HAGAR) + bprint (s, " should have used a different weapon\n"); + else if (deathtype == IT_ROCKET_LAUNCHER) + bprint (s, " exploded\n"); + else + bprint (s, " competes for the Darwin awards\n"); + self.frags = self.frags - 1; } + // Kills else if (attacker.classname == "player") { - if (deathtype == IT_LASER) {bprint(s);bprint(" was a victim of laser surgeon ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_UZI) {bprint(s);bprint(" was gunned down by ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_SHOTGUN) {bprint(s);bprint(" was gunned down by ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_GRENADE_LAUNCHER) {bprint(s);bprint(" was blasted by ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_ELECTRO) {bprint(s);bprint(" bathed in plasma from ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_CRYLINK) {bprint(s);bprint(" was zapped by ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_NEX) {bprint(s);bprint(" sports a new hole from ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_HAGAR) {bprint(s);bprint(" was pummeled by ");bprint(attacker.netname);bprint("\n");} - else if (deathtype == IT_ROCKET_LAUNCHER) {bprint(s);bprint(" was given a lesson in rocketry by ");bprint(attacker.netname);bprint("\n");} - else {bprint(s);bprint(" was killed by ");bprint(attacker.netname);bprint("\n");} + if (deathtype == IT_LASER) + bprint (s, " was a victim of laser surgeon ", attacker.netname, "\n"); + else if (deathtype == IT_UZI) + bprint (s, " was riddled full of holes by ", attacker.netname, "\n"); + else if (deathtype == IT_SHOTGUN) + bprint (s, " was gunned by ", attacker.netname, "\n"); + else if (deathtype == IT_GRENADE_LAUNCHER) + bprint (s, " was blasted by ", attacker.netname, "\n"); + else if (deathtype == IT_ELECTRO) + bprint (s, " bathed in ", attacker.netname, "'s plasma\n"); + else if (deathtype == IT_CRYLINK) + bprint (s, " was zapped by ", attacker.netname, "\n"); + else if (deathtype == IT_NEX) + bprint (s, " sports a new hole from ", attacker.netname, "\n"); + else if (deathtype == IT_HAGAR) + bprint (s, " was pummeled by ", attacker.netname, "\n"); + else if (deathtype == IT_ROCKET_LAUNCHER) + bprint (s, " was given a lesson in rocketry by ", attacker.netname, "\n"); + else + bprint (s, " was killed by ", attacker.netname, "\n"); + attacker.frags = attacker.frags + 1; } + else if (deathtype == DEATH_HURTTRIGGER) + bprint (s, " ", attacker.message, "\n"); + else if (deathtype == DEATH_FALL) + bprint (s, " hit the ground with a crunch\n"); + else if (deathtype == DEATH_BIGFALL) + bprint (s, " fell into oblivion\n"); + else if (deathtype == DEATH_DROWN) + bprint (s, " wished he had gills\n"); else - { - {bprint(s);bprint(" died\n");} - } + bprint (s, " died\n"); } } diff --git a/qcsrc/gamec/g_subs.c b/qcsrc/gamec/g_subs.c index 935d7f8ea..625d09ea5 100644 --- a/qcsrc/gamec/g_subs.c +++ b/qcsrc/gamec/g_subs.c @@ -1,25 +1,13 @@ +nosave var void nullfunction (void); + void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove; void() SUB_CalcMoveDone; void() SUB_CalcAngleMoveDone; -void() SUB_Null; //void() SUB_UseTargets; void() SUB_Remove; void info_null (void) { - -} - -/* -================== -SUB_Null - -Do nothing -================== -*/ -void SUB_Null (void) -{ - } /* diff --git a/qcsrc/gamec/g_triggers.c b/qcsrc/gamec/g_triggers.c index 0d9ad1c60..14283501c 100644 --- a/qcsrc/gamec/g_triggers.c +++ b/qcsrc/gamec/g_triggers.c @@ -92,11 +92,8 @@ void() SUB_UseTargets = otemp = other; self = t; other = stemp; - if (self.use != SUB_Null) - { - if (self.use) - self.use (); - } + if (self.use) + self.use (); self = stemp; other = otemp; activator = act; @@ -167,7 +164,8 @@ void() multi_trigger = else { // we can't just remove (self) here, because this is a touch function // called wheil C code is looping through area links... - self.touch = SUB_Null; + self.touch = nullfunction; + self.nextthink = time + 0.1; self.think = SUB_Remove; } @@ -357,7 +355,7 @@ void() hurt_touch = if (other.takedamage) { self.solid = SOLID_NOT; - Damage (other, self, self, self.dmg, 1, '0 0 0', '0 0 0'); + Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, '0 0 0', '0 0 0'); self.think = hurt_on; self.nextthink = time + 1; } @@ -376,6 +374,8 @@ void() trigger_hurt = self.touch = hurt_touch; if (!self.dmg) self.dmg = 5; + if (!self.message) + self.message = "was in the wrong place."; }; //void() target_speaker_use = {sound(self, CHAN_VOICE, self.noise, 1, 1);} diff --git a/qcsrc/gamec/g_violence.c b/qcsrc/gamec/g_violence.c index 8cf036d83..daabeb3d6 100644 --- a/qcsrc/gamec/g_violence.c +++ b/qcsrc/gamec/g_violence.c @@ -5,7 +5,7 @@ void GibDamage (entity inflictor, entity attacker, float damage, float deathtype self.health = self.health - damage; if (self.health <= -300) { - self.event_damage = SUB_Null; + self.event_damage = nullfunction; SUB_VanishOrRemove (self); } } diff --git a/qcsrc/gamec/t_jumppads.c b/qcsrc/gamec/t_jumppads.c index b71234956..6b1356c10 100644 --- a/qcsrc/gamec/t_jumppads.c +++ b/qcsrc/gamec/t_jumppads.c @@ -36,7 +36,7 @@ void() trigger_push_touch = if (self.spawnflags & PUSH_ONCE) { - self.touch = SUB_Null; + self.touch = nullfunction; self.think = SUB_Remove; self.nextthink = time; } diff --git a/qcsrc/gamec/t_plats.c b/qcsrc/gamec/t_plats.c index 3ea01f251..6c55256d9 100644 --- a/qcsrc/gamec/t_plats.c +++ b/qcsrc/gamec/t_plats.c @@ -113,7 +113,7 @@ void() plat_crush = void() plat_use = { - self.use = SUB_Null; + self.use = nullfunction; if (self.state != 4) objerror ("plat_use: not in up state"); plat_go_down(); @@ -381,7 +381,7 @@ void() func_rotating = // wait for targets to spawn self.nextthink = self.ltime + 999999999; - self.think = SUB_Null; + self.think = nullfunction; }; .float height; @@ -442,5 +442,5 @@ void() func_bobbing = controller.nextthink = time + 1; controller.think = func_bobbing_controller_think; self.nextthink = self.ltime + 999999999; - self.think = SUB_Null; + self.think = nullfunction; }; diff --git a/qcsrc/gamec/w_crylink.c b/qcsrc/gamec/w_crylink.c index 4070d825e..59418eb3d 100644 --- a/qcsrc/gamec/w_crylink.c +++ b/qcsrc/gamec/w_crylink.c @@ -34,7 +34,7 @@ void(float req) w_crylink = void W_Crylink_Touch (void) { - self.event_damage = SUB_Null; + self.event_damage = nullfunction; te_smallflash(self.origin); RadiusDamage (self, self.owner, 45, 0, 3, world, 55, IT_CRYLINK); remove (self); diff --git a/qcsrc/gamec/w_electro.c b/qcsrc/gamec/w_electro.c index 1f7723600..5f25617ff 100644 --- a/qcsrc/gamec/w_electro.c +++ b/qcsrc/gamec/w_electro.c @@ -43,7 +43,7 @@ void W_Electro_Touch (void) WriteCoord (MSG_BROADCAST, 0); // Sajt: Yeah.. I agree with him WriteCoord (MSG_BROADCAST, 0); WriteByte (MSG_BROADCAST, 155); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 50, 10, 70, world, 50, IT_ELECTRO); sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM); remove (self); @@ -107,7 +107,7 @@ void W_Plasma_Explode (entity ignore) te_customflash (self.origin, 5000, 10, '0 0 1'); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 100, 50, 100, world, 50, IT_ELECTRO); sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM); @@ -128,7 +128,7 @@ void W_Plasma_Explode2 (entity ignore) te_customflash (self.origin, 5000, 10, '0 0 1'); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 150, 50, 150, world, 150, IT_ELECTRO); sound (self, CHAN_IMPACT, "weapons/plasmahit.wav", 1, ATTN_NORM); diff --git a/qcsrc/gamec/w_grenadelauncher.c b/qcsrc/gamec/w_grenadelauncher.c index bc94465ee..b60e8bdd7 100644 --- a/qcsrc/gamec/w_grenadelauncher.c +++ b/qcsrc/gamec/w_grenadelauncher.c @@ -31,35 +31,29 @@ void(float req) w_glauncher = weapon_hasammo = glauncher_check(); }; -void W_Grenade_Explode (entity ignore) +void W_Grenade_Explode (void) { ImpactEffect (self, IT_GRENADE_LAUNCHER); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 65, 35, 140, world, 400, IT_GRENADE_LAUNCHER); remove (self); } -void W_Grenade_FuseExplode (void) -{ - W_Grenade_Explode (world); -} - - void W_Grenade_Touch (void) { if (other.classname == "player" || other.classname == "corpse") - W_Grenade_Explode (other); + W_Grenade_Explode (); else sound (self, CHAN_BODY, "weapons/grenade_bounce.wav", 1, ATTN_NORM); } -void W_Grenade_Damage (vector hitloc, float damage, entity inflictor, entity attacker, float deathtype) +void W_Grenade_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) { self.health = self.health - damage; if (self.health <= 0) - W_Grenade_FuseExplode(); + W_Grenade_Explode(); } void W_Grenade_Attack (void) @@ -76,22 +70,17 @@ void W_Grenade_Attack (void) gren.movetype = MOVETYPE_BOUNCE; gren.solid = SOLID_BBOX; setmodel(gren, "models/grenademodel.md3"); - setsize(gren, '-12 -12 -4', '12 12 4'); - setorigin(gren, (self.origin + self.view_ofs)); + setsize(gren, '-6 -6 -3', '6 6 3'); + setorigin(gren, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -12); gren.health = 1; gren.takedamage = DAMAGE_YES; - if (self.v_angle_x) - gren.velocity = v_forward * (1200 + 1 * 800) + (v_up * 200) + (crandom () * v_right * 10) + (crandom () * v_up * 10); - else - { - gren.velocity = aim (self, 10000) * (1200 + 1 * 800); - gren.velocity_z = 200; - } + gren.velocity = v_forward * 2000 + v_up * 200; gren.avelocity_x = random () * -500 - 500; + setsize (gren, gren.mins, gren.maxs); gren.angles = vectoangles (gren.velocity); gren.touch = W_Grenade_Explode; gren.think = W_Grenade_Explode; - gren.nextthink = time + 3; + gren.nextthink = time + 30; self.ammo_rockets = self.ammo_rockets - 1; @@ -122,7 +111,7 @@ void W_Grenade_Attack2 (void) setmodel (gren, "models/grenademodel.md3"); setsize (gren, '-6 -6 -3', '6 6 3'); - setorigin (gren, self.origin + self.view_ofs + v_forward * 18 + v_right * 5 + v_up * -12); + setorigin (gren, self.origin + self.view_ofs + v_forward * 15 + v_right * 5 + v_up * -12); gren.velocity = v_forward * 900 + v_up * 200; gren.angles = vectoangles (gren.velocity); @@ -150,4 +139,4 @@ void() glauncher_fire2_01 = { weapon_doattack(glauncher_check, glauncher_check, W_Grenade_Attack2); weapon_thinkf(WFRAME_FIRE2, 0.8, glauncher_ready_01); -}; +}; \ No newline at end of file diff --git a/qcsrc/gamec/w_hagar.c b/qcsrc/gamec/w_hagar.c index c08a256c8..79204a325 100644 --- a/qcsrc/gamec/w_hagar.c +++ b/qcsrc/gamec/w_hagar.c @@ -35,7 +35,7 @@ void W_Hagar_Explode (void) { ImpactEffect (self, IT_HAGAR); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 40, 15, 70, world, 100, IT_HAGAR); remove (self); diff --git a/qcsrc/gamec/w_laser.c b/qcsrc/gamec/w_laser.c index e808d80b5..681983778 100644 --- a/qcsrc/gamec/w_laser.c +++ b/qcsrc/gamec/w_laser.c @@ -53,7 +53,7 @@ void W_Laser_Touch (void) - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 15, 20, 50, world, 200, IT_LASER); sound (self, CHAN_IMPACT, "weapons/laserimpact.wav", 1, ATTN_NORM); diff --git a/qcsrc/gamec/w_rocketlauncher.c b/qcsrc/gamec/w_rocketlauncher.c index b296d91e5..d447a0a77 100644 --- a/qcsrc/gamec/w_rocketlauncher.c +++ b/qcsrc/gamec/w_rocketlauncher.c @@ -40,7 +40,7 @@ void W_Rocket_Explode (entity ignore) { ImpactEffect (self, IT_ROCKET_LAUNCHER); - self.event_damage = SUB_Null; + self.event_damage = nullfunction; RadiusDamage (self, self.owner, 130, 50, 170, ignore, 600, IT_ROCKET_LAUNCHER); remove (self); -- 2.39.2