X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator_nades.qc;h=292bba261aad86083993bc4b699209d9e7f04db5;hb=refs%2Fmerge-requests%2F234%2Fhead;hp=70c4578bd02baea2c19b7185add6ddaade69913b;hpb=b2a0a591474681192b67caeb100f65ced41708b7;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator_nades.qc b/qcsrc/server/mutators/mutator_nades.qc index 70c4578bd..40e07b1ea 100644 --- a/qcsrc/server/mutators/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator_nades.qc @@ -1,7 +1,21 @@ +#include "mutator_nades.qh" + +#include "mutator.qh" + +#include "gamemode_keyhunt.qh" +#include "gamemode_freezetag.qh" +#include "../../common/nades/all.qh" +#include "../../common/gamemodes/all.qh" +#include "../../common/monsters/spawn.qh" +#include "../../common/monsters/sv_monsters.qh" +#include "../g_subs.qh" + +.float nade_time_primed; + .entity nade_spawnloc; void nade_timer_think() -{ +{SELFPARAM(); self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10); self.nextthink = time; if(!self.owner || wasfreed(self.owner)) @@ -10,13 +24,13 @@ void nade_timer_think() void nade_burn_spawn(entity _nade) { - CSQCProjectile(_nade, TRUE, Nade_ProjectileFromID(_nade.nade_type, TRUE), TRUE); + CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true); } void nade_spawn(entity _nade) { entity timer = spawn(); - setmodel(timer, "models/ok_nade_counter/ok_nade_counter.md3"); + setmodel(timer, MDL_NADE_TIMER); setattachment(timer, _nade, ""); timer.classname = "nade_timer"; timer.colormap = _nade.colormap; @@ -29,11 +43,11 @@ void nade_spawn(entity _nade) _nade.effects |= EF_LOWPRECISION; - CSQCProjectile(_nade, TRUE, Nade_ProjectileFromID(_nade.nade_type, FALSE), TRUE); + CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true); } void napalm_damage(float dist, float damage, float edgedamage, float burntime) -{ +{SELFPARAM(); entity e; float d; vector p; @@ -42,16 +56,16 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime) return; RandomSelection_Init(); - for(e = WarpZone_FindRadius(self.origin, dist, TRUE); e; e = e.chain) + for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain) if(e.takedamage == DAMAGE_AIM) if(self.realowner != e || autocvar_g_nades_napalm_selfdamage) if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self)) if(!e.frozen) { p = e.origin; - p_x += e.mins_x + random() * (e.maxs_x - e.mins_x); - p_y += e.mins_y + random() * (e.maxs_y - e.mins_y); - p_z += e.mins_z + random() * (e.maxs_z - e.mins_z); + p.x += e.mins.x + random() * (e.maxs.x - e.mins.x); + p.y += e.mins.y + random() * (e.maxs.y - e.mins.y); + p.z += e.mins.z + random() * (e.maxs.z - e.mins.z); d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p); if(d < dist) { @@ -64,14 +78,14 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime) d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec); d = damage + (edgedamage - damage) * (d / dist); Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE); - //trailparticles(self, particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec); - pointparticles(particleeffectnum("fireball_laser"), self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1); + //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec); + Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1); } } void napalm_ball_think() -{ +{SELFPARAM(); if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { @@ -104,23 +118,23 @@ void napalm_ball_think() void nade_napalm_ball() -{ +{SELFPARAM(); entity proj; vector kick; - spamsound(self, CH_SHOTS, "weapons/fireball_fire.wav", VOL_BASE, ATTEN_NORM); + spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM); proj = spawn (); proj.owner = self.owner; proj.realowner = self.realowner; proj.team = self.owner.team; proj.classname = "grenade"; - proj.bot_dodge = TRUE; + proj.bot_dodge = true; proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage; proj.movetype = MOVETYPE_BOUNCE; - proj.projectiledeathtype = DEATH_NADE_NAPALM; + proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id; PROJECTILE_MAKETRIGGER(proj); - setmodel(proj, "null"); + setmodel(proj, MDL_Null); proj.scale = 1;//0.5; setsize(proj, '-4 -4 -4', '4 4 4'); setorigin(proj, self.origin); @@ -129,9 +143,9 @@ void nade_napalm_ball() proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale; proj.effects = EF_LOWPRECISION | EF_FLAME; - kick_x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread; - kick_y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread; - kick_z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread; + kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread; + kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread; + kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread; proj.velocity = kick; proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime; @@ -140,12 +154,12 @@ void nade_napalm_ball() proj.flags = FL_PROJECTILE; proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC; - //CSQCProjectile(proj, TRUE, PROJECTILE_NAPALM_FIRE, TRUE); + //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true); } void napalm_fountain_think() -{ +{SELFPARAM(); if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) @@ -183,10 +197,10 @@ void napalm_fountain_think() } void nade_napalm_boom() -{ +{SELFPARAM(); entity fountain; - local float c; - for (c = 0; c < autocvar_g_nades_napalm_ball_count; c ++) + int c; + for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++) nade_napalm_ball(); @@ -201,30 +215,30 @@ void nade_napalm_boom() fountain.pushltime = fountain.ltime; fountain.team = self.team; fountain.movetype = MOVETYPE_TOSS; - fountain.projectiledeathtype = DEATH_NADE_NAPALM; - fountain.bot_dodge = TRUE; + fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id; + fountain.bot_dodge = true; fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage; fountain.nade_special_time = time; setsize(fountain, '-16 -16 -16', '16 16 16'); - CSQCProjectile(fountain, TRUE, PROJECTILE_NAPALM_FOUNTAIN, TRUE); + CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true); } void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time) { frost_target.frozen_by = freezefield.realowner; - pointparticles(particleeffectnum("electro_impact"), frost_target.origin, '0 0 0', 1); - Freeze(frost_target, 1/freeze_time, 3, FALSE); + Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1); + Freeze(frost_target, 1/freeze_time, 3, false); if(frost_target.ballcarried) if(g_keepaway) { ka_DropEvent(frost_target); } else { DropBall(frost_target.ballcarried, frost_target.origin, frost_target.velocity);} if(frost_target.flagcarried) { ctf_Handle_Throw(frost_target, world, DROP_THROW); } if(frost_target.nade) { toss_nade(frost_target, '0 0 0', time + 0.05); } - - kh_Key_DropAll(frost_target, FALSE); + + kh_Key_DropAll(frost_target, false); } void nade_ice_think() -{ +{SELFPARAM(); if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) @@ -237,17 +251,9 @@ void nade_ice_think() { if ( autocvar_g_nades_ice_explode ) { - string expef; - switch(self.realowner.team) - { - case NUM_TEAM_1: expef = "nade_red_explode"; break; - case NUM_TEAM_2: expef = "nade_blue_explode"; break; - case NUM_TEAM_3: expef = "nade_yellow_explode"; break; - case NUM_TEAM_4: expef = "nade_pink_explode"; break; - default: expef = "nade_neutral_explode"; break; - } - pointparticles(particleeffectnum(expef), self.origin + '0 0 1', '0 0 0', 1); - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); + entity expef = EFFECT_NADE_EXPLODE(self.realowner.team); + Send_Effect(expef, self.origin + '0 0 1', '0 0 0', 1); + sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy); @@ -268,18 +274,17 @@ void nade_ice_think() float randomw; randomw = random()*M_PI*2; vector randomp; - randomp_x = randomr*cos(randomw); - randomp_y = randomr*sin(randomw); - randomp_z = 1; - pointparticles(particleeffectnum("electro_muzzleflash"), self.origin + randomp, '0 0 0', 1); + randomp.x = randomr*cos(randomw); + randomp.y = randomr*sin(randomw); + randomp.z = 1; + Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, self.origin + randomp, '0 0 0', 1); if(time >= self.nade_special_time) { self.nade_special_time = time+0.7; - - pointparticles(particleeffectnum("electro_impact"), self.origin, '0 0 0', 1); - pointparticles(particleeffectnum("icefield"), self.origin, '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1); + Send_Effect(EFFECT_ICEFIELD, self.origin, '0 0 0', 1); } @@ -298,7 +303,7 @@ void nade_ice_think() } void nade_ice_boom() -{ +{SELFPARAM(); entity fountain; fountain = spawn(); fountain.owner = self.owner; @@ -311,17 +316,17 @@ void nade_ice_boom() fountain.pushltime = fountain.wait = fountain.ltime; fountain.team = self.team; fountain.movetype = MOVETYPE_TOSS; - fountain.projectiledeathtype = DEATH_NADE_ICE; - fountain.bot_dodge = FALSE; + fountain.projectiledeathtype = DEATH_NADE_ICE.m_id; + fountain.bot_dodge = false; setsize(fountain, '-16 -16 -16', '16 16 16'); fountain.nade_special_time = time+0.3; fountain.angles = self.angles; if ( autocvar_g_nades_ice_explode ) { - setmodel(fountain, "models/grenademodel.md3"); + setmodel(fountain, MDL_PROJECTILE_GRENADE); entity timer = spawn(); - setmodel(timer, "models/ok_nade_counter/ok_nade_counter.md3"); + setmodel(timer, MDL_NADE_TIMER); setattachment(timer, fountain, ""); timer.classname = "nade_timer"; timer.colormap = self.colormap; @@ -333,31 +338,27 @@ void nade_ice_boom() timer.skin = 10; } else - setmodel(fountain, "null"); + setmodel(fountain, MDL_Null); } void nade_translocate_boom() -{ +{SELFPARAM(); if(self.realowner.vehicle) return; - vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins_z - 24); + vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24); tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner); locout = trace_endpos; makevectors(self.realowner.angles); - entity oldself = self; - self = self.realowner; - MUTATOR_CALLHOOK(PortalTeleport); - self.realowner = self; - self = oldself; + MUTATOR_CALLHOOK(PortalTeleport, self.realowner); - TeleportPlayer(self, self.realowner, locout, self.realowner.mangle, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); + TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER); } void nade_spawn_boom() -{ +{SELFPARAM(); entity spawnloc = spawn(); setorigin(spawnloc, self.origin); setsize(spawnloc, self.realowner.mins, self.realowner.maxs); @@ -377,15 +378,15 @@ void nade_spawn_boom() } void nade_heal_think() -{ +{SELFPARAM(); if(time >= self.ltime) { remove(self); return; } - + self.nextthink = time; - + if(time >= self.nade_special_time) { self.nade_special_time = time+0.25; @@ -396,10 +397,10 @@ void nade_heal_think() } void nade_heal_touch() -{ +{SELFPARAM(); float maxhealth; float health_factor; - if(IS_PLAYER(other) || (other.flags & FL_MONSTER)) + if(IS_PLAYER(other) || IS_MONSTER(other)) if(other.deadflag == DEAD_NO) if(!other.frozen) { @@ -413,32 +414,32 @@ void nade_heal_touch() } if ( health_factor > 0 ) { - maxhealth = (other.flags & FL_MONSTER) ? other.max_health : g_pickup_healthmega_max; + maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max; if ( other.health < maxhealth ) { if ( self.nade_show_particles ) - pointparticles(particleeffectnum("healing_fx"), other.origin, '0 0 0', 1); + Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1); other.health = min(other.health+health_factor, maxhealth); } - other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); + other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); } else if ( health_factor < 0 ) { - Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL,other.origin,'0 0 0'); + Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0'); } - + } - - if ( IS_REAL_CLIENT(other) || (other.vehicle_flags & VHF_ISVEHICLE) ) + + if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) ) { - entity show_red = (other.vehicle_flags & VHF_ISVEHICLE) ? other.owner : other; + entity show_red = (IS_VEHICLE(other)) ? other.owner : other; show_red.stat_healing_orb = time+0.1; show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime; } } void nade_heal_boom() -{ +{SELFPARAM(); entity healer; healer = spawn(); healer.owner = self.owner; @@ -447,83 +448,79 @@ void nade_heal_boom() healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar healer.ltime = time + healer.healer_lifetime; healer.team = self.realowner.team; - healer.bot_dodge = FALSE; + healer.bot_dodge = false; healer.solid = SOLID_TRIGGER; healer.touch = nade_heal_touch; - setmodel(healer, "models/ctf/shield.md3"); + setmodel(healer, MDL_NADE_HEAL); healer.healer_radius = autocvar_g_nades_nade_radius; vector size = '1 1 1' * healer.healer_radius / 2; setsize(healer,-size,size); - - Net_LinkEntity(healer, TRUE, 0, healer_send); - + + Net_LinkEntity(healer, true, 0, healer_send); + healer.think = nade_heal_think; healer.nextthink = time; healer.SendFlags |= 1; } void nade_monster_boom() -{ - entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, FALSE, FALSE, 1); - +{SELFPARAM(); + entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1); + if(autocvar_g_nades_pokenade_monster_lifetime > 0) e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime; e.monster_skill = MONSTER_SKILL_INSANE; } void nade_boom() -{ - string expef; - float nade_blast = 1; +{SELFPARAM(); + entity expef = NULL; + bool nade_blast = true; - switch ( self.nade_type ) + switch ( Nades[self.nade_type] ) { case NADE_TYPE_NAPALM: nade_blast = autocvar_g_nades_napalm_blast; - expef = "explosion_medium"; + expef = EFFECT_EXPLOSION_MEDIUM; break; case NADE_TYPE_ICE: - nade_blast = 0; - expef = "electro_combo"; // hookbomb_explode electro_combo bigplasma_impact + nade_blast = false; + expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact break; case NADE_TYPE_TRANSLOCATE: - nade_blast = 0; - expef = ""; + nade_blast = false; break; case NADE_TYPE_MONSTER: case NADE_TYPE_SPAWN: - nade_blast = 0; + nade_blast = false; switch(self.realowner.team) { - case NUM_TEAM_1: expef = "spawn_event_red"; break; - case NUM_TEAM_2: expef = "spawn_event_blue"; break; - case NUM_TEAM_3: expef = "spawn_event_yellow"; break; - case NUM_TEAM_4: expef = "spawn_event_pink"; break; - default: expef = "spawn_event_neutral"; break; + case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break; + case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break; + case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break; + case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break; + default: expef = EFFECT_SPAWN_NEUTRAL; break; } break; case NADE_TYPE_HEAL: - nade_blast = 0; - expef = "spawn_event_red"; + nade_blast = false; + expef = EFFECT_SPAWN_RED; break; default: case NADE_TYPE_NORMAL: - switch(self.realowner.team) - { - case NUM_TEAM_1: expef = "nade_red_explode"; break; - case NUM_TEAM_2: expef = "nade_blue_explode"; break; - case NUM_TEAM_3: expef = "nade_yellow_explode"; break; - case NUM_TEAM_4: expef = "nade_pink_explode"; break; - default: expef = "nade_neutral_explode"; break; - } + expef = EFFECT_NADE_EXPLODE(self.realowner.team); + break; } - pointparticles(particleeffectnum(expef), self.origin + '0 0 1', '0 0 0', 1); + if(expef) + Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1); - sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM); - sound(self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM); + sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); + sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); + + self.event_damage = func_null; // prevent somehow calling damage in the next call if(nade_blast) { @@ -532,7 +529,8 @@ void nade_boom() Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self); } - switch ( self.nade_type ) + if(self.takedamage) + switch ( Nades[self.nade_type] ) { case NADE_TYPE_NAPALM: nade_napalm_boom(); break; case NADE_TYPE_ICE: nade_ice_boom(); break; @@ -542,18 +540,38 @@ void nade_boom() case NADE_TYPE_MONSTER: nade_monster_boom(); break; } + entity head; + for(head = world; (head = find(head, classname, "grapplinghook")); ) + if(head.aiment == self) + RemoveGrapplingHook(head.realowner); + remove(self); } void nade_touch() -{ - if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; } +{SELFPARAM(); + /*float is_weapclip = 0; + if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW) + if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID)) + if (!(trace_dphitcontents & DPCONTENTS_OPAQUE)) + is_weapclip = 1;*/ + if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip) + { + entity head; + for(head = world; (head = find(head, classname, "grapplinghook")); ) + if(head.aiment == self) + RemoveGrapplingHook(head.realowner); + remove(self); + return; + } + PROJECTILE_TOUCH; + //setsize(self, '-2 -2 -2', '2 2 2'); //UpdateCSQCProjectile(self); if(self.health == self.max_health) { - spamsound(self, CH_SHOTS, strcat("weapons/grenade_bounce", ftos(1 + rint(random() * 5)), ".wav"), VOL_BASE, ATTEN_NORM); + spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM); return; } @@ -562,52 +580,70 @@ void nade_touch() } void nade_beep() -{ - sound(self, CH_SHOTS_SINGLE, "overkill/grenadebip.ogg", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); +{SELFPARAM(); + sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); self.think = nade_boom; self.nextthink = max(self.wait, time); } -void nade_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) -{ - if(self.nade_type == NADE_TYPE_TRANSLOCATE || self.nade_type == NADE_TYPE_SPAWN) +void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{SELFPARAM(); + if(ITEM_DAMAGE_NEEDKILL(deathtype)) + { + self.takedamage = DAMAGE_NO; + nade_boom(); return; + } - if(DEATH_ISWEAPON(deathtype, WEP_BLASTER)) + if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id) return; + if(DEATH_ISWEAPON(deathtype, WEP_BLASTER)) + { + force *= 1.5; + damage = 0; + } + + if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY)) + { + force *= 0.5; // too much + frag_damage = 0; + } + if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) { force *= 6; damage = self.max_health * 0.55; } - if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN)) + if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_HMG)) damage = self.max_health * 0.1; - if((DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) && (deathtype & HITTYPE_SECONDARY)) // WEAPONTODO + if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO + if(deathtype & HITTYPE_SECONDARY) { damage = self.max_health * 0.1; force *= 10; } else - damage = self.max_health * 1.1; + damage = self.max_health * 1.15; self.velocity += force; + UpdateCSQCProjectile(self); - if(!damage || (self.flags & FL_ONGROUND && IS_PLAYER(attacker))) + if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker))) return; if(self.health == self.max_health) { - sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); + sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time); self.think = nade_beep; } - self.health -= damage; - - if ( self.nade_type != NADE_TYPE_HEAL || IS_PLAYER(attacker) ) + self.health -= damage; + + if ( self.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) ) self.realowner = attacker; if(self.health <= 0) @@ -617,7 +653,7 @@ void nade_damage(entity inflictor, entity attacker, float damage, float deathtyp } void toss_nade(entity e, vector _velocity, float _time) -{ +{SELFPARAM(); if(e.nade == world) return; @@ -629,29 +665,35 @@ void toss_nade(entity e, vector _velocity, float _time) makevectors(e.v_angle); - W_SetupShot(e, FALSE, FALSE, "", CH_WEAPON_A, 0); + W_SetupShot(e, false, false, "", CH_WEAPON_A, 0); Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES); - setorigin(_nade, w_shotorg + (v_right * 25) * -1); - //setmodel(_nade, "models/weapons/v_ok_grenade.md3"); + vector offset = (v_forward * autocvar_g_nades_throw_offset.x) + + (v_right * autocvar_g_nades_throw_offset.y) + + (v_up * autocvar_g_nades_throw_offset.z); + if(autocvar_g_nades_throw_offset == '0 0 0') + offset = '0 0 0'; + + setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1); + //setmodel(_nade, MDL_PROJECTILE_NADE); //setattachment(_nade, world, ""); PROJECTILE_MAKETRIGGER(_nade); setsize(_nade, '-16 -16 -16', '16 16 16'); _nade.movetype = MOVETYPE_BOUNCE; - tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, FALSE, _nade); + tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade); if (trace_startsolid) setorigin(_nade, e.origin); - if(self.v_angle_x >= 70 && self.v_angle_x <= 110) + if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH) _nade.velocity = '0 0 100'; else if(autocvar_g_nades_nade_newton_style == 1) _nade.velocity = e.velocity + _velocity; else if(autocvar_g_nades_nade_newton_style == 2) _nade.velocity = _velocity; else - _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, TRUE); + _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true); _nade.touch = nade_touch; _nade.health = autocvar_g_nades_nade_health; @@ -660,19 +702,23 @@ void toss_nade(entity e, vector _velocity, float _time) _nade.event_damage = nade_damage; _nade.customizeentityforclient = func_null; _nade.exteriormodeltoclient = world; - _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; _nade.traileffectnum = 0; - _nade.teleportable = TRUE; - _nade.pushable = TRUE; + _nade.teleportable = true; + _nade.pushable = true; _nade.gravity = 1; _nade.missile_flags = MIF_SPLASH | MIF_ARC; - _nade.damagedbycontents = TRUE; + _nade.damagedbycontents = true; _nade.angles = vectoangles(_nade.velocity); _nade.flags = FL_PROJECTILE; - _nade.projectiledeathtype = DEATH_NADE; + _nade.projectiledeathtype = DEATH_NADE.m_id; _nade.toss_time = time; _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX); + if(_nade.nade_type == NADE_TYPE_TRANSLOCATE.m_id || _nade.nade_type == NADE_TYPE_SPAWN.m_id) + _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; + else + _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY; + nade_spawn(_nade); if(_time) @@ -700,7 +746,7 @@ void nades_GiveBonus(entity player, float score) if ( player.bonus_nade_score >= 1 ) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS); - play2(player,"kh/alarm.wav"); + play2(player, SND(KH_ALARM)); player.bonus_nades++; player.bonus_nade_score -= 1; } @@ -713,8 +759,8 @@ void nades_RemoveBonus(entity player) } float nade_customize() -{ - //if(IS_SPEC(other)) { return FALSE; } +{SELFPARAM(); + //if(IS_SPEC(other)) { return false; } if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner)) { // somewhat hide the model, but keep the glow @@ -727,15 +773,19 @@ float nade_customize() { //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; if(!self.traileffectnum) - self.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(self.nade_type, FALSE), self.team)); + self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name); self.alpha = 1; } - - return TRUE; + + return true; } void nade_prime() -{ +{SELFPARAM(); + if(autocvar_g_nades_bonus_only) + if(!self.bonus_nades) + return; // only allow bonus nades + if(self.nade) remove(self.nade); @@ -747,7 +797,7 @@ void nade_prime() n.classname = "nade"; fn.classname = "fake_nade"; - if(self.items & IT_STRENGTH && autocvar_g_nades_bonus_onstrength) + if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength) n.nade_type = self.nade_type; else if (self.bonus_nades >= 1) { @@ -760,28 +810,28 @@ void nade_prime() n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type); n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); } - - n.nade_type = bound(1, n.nade_type, NADE_TYPE_LAST); - setmodel(n, "models/weapons/v_ok_grenade.md3"); + n.nade_type = bound(1, n.nade_type, Nades_COUNT); + + setmodel(n, MDL_PROJECTILE_NADE); //setattachment(n, self, "bip01 l hand"); n.exteriormodeltoclient = self; n.customizeentityforclient = nade_customize; - n.traileffectnum = particleeffectnum(Nade_TrailEffect(Nade_ProjectileFromID(n.nade_type, FALSE), self.team)); - n.colormod = Nade_Color(n.nade_type); + n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name); + n.colormod = Nades[n.nade_type].m_color; n.realowner = self; n.colormap = self.colormap; n.glowmod = self.glowmod; n.wait = time + autocvar_g_nades_nade_lifetime; - n.lifetime = time; + n.nade_time_primed = time; n.think = nade_beep; n.nextthink = max(n.wait - 3, time); - n.projectiledeathtype = DEATH_NADE; + n.projectiledeathtype = DEATH_NADE.m_id; - setmodel(fn, "models/weapons/h_ok_grenade.iqm"); + setmodel(fn, MDL_NADE_VIEW); setattachment(fn, self.weaponentity, ""); fn.realowner = fn.owner = self; - fn.colormod = Nade_Color(n.nade_type); + fn.colormod = Nades[n.nade_type].m_color; fn.colormap = self.colormap; fn.glowmod = self.glowmod; fn.think = SUB_Remove; @@ -792,36 +842,40 @@ void nade_prime() } float CanThrowNade() -{ +{SELFPARAM(); if(self.vehicle) - return FALSE; + return false; if(gameover) - return FALSE; + return false; if(self.deadflag != DEAD_NO) - return FALSE; + return false; if (!autocvar_g_nades) - return FALSE; // allow turning them off mid match + return false; // allow turning them off mid match - if(forbidWeaponUse()) - return FALSE; + if(forbidWeaponUse(self)) + return false; if (!IS_PLAYER(self)) - return FALSE; + return false; - return TRUE; + return true; } +.bool nade_altbutton; + void nades_CheckThrow() -{ +{SELFPARAM(); if(!CanThrowNade()) return; - if(!self.nade) + entity held_nade = self.nade; + if (!held_nade) { - if(self.nade_refire < time) + self.nade_altbutton = true; + if(time > self.nade_refire) { Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW); nade_prime(); @@ -830,10 +884,10 @@ void nades_CheckThrow() } else { - if(time - self.nade.lifetime >= 1) - { + self.nade_altbutton = false; + if (time >= held_nade.nade_time_primed + 1) { makevectors(self.v_angle); - float _force = time - self.nade.lifetime; + float _force = time - held_nade.nade_time_primed; _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0); @@ -852,65 +906,65 @@ void nades_Clear(entity player) player.nade_timer = 0; } -MUTATOR_HOOKFUNCTION(nades_CheckThrow) -{ - if(MUTATOR_RETURNVALUE) { nades_CheckThrow(); } - return FALSE; -} - MUTATOR_HOOKFUNCTION(nades_VehicleEnter) { if(vh_player.nade) toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05)); - return FALSE; + return false; } -MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) -{ - if(!IS_PLAYER(self)) { return FALSE; } - - float key_pressed = self.BUTTON_HOOK; - float time_score; - - if(g_grappling_hook || client_hasweapon(self, WEP_HOOK, FALSE, FALSE) || (weaponsInMap & WEPSET_HOOK) || g_jetpack || self.items & IT_JETPACK) - key_pressed = self.button16; // if hook/jetpack is enabled, use an alternate key - - if(self.nade) - { - self.nade_timer = bound(0, (time - self.nade.lifetime) / autocvar_g_nades_nade_lifetime, 1); - //print(sprintf("%d %d\n", self.nade_timer, time - self.nade.lifetime)); - makevectors(self.angles); - self.nade.velocity = self.velocity; - - setorigin(self.nade, self.origin + self.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0); - self.nade.angles_y = self.angles_y; - } - - if(self.nade) - if(self.nade.wait - 0.1 <= time) - toss_nade(self, '0 0 0', time + 0.05); - - if(CanThrowNade()) - if(self.nade_refire < time) - { - if(key_pressed) +CLASS(NadeOffhand, OffhandWeapon) + METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed)) + { + entity held_nade = player.nade; + if (held_nade) { - if(!self.nade) - nade_prime(); + player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1); + // LOG_TRACEF("%d %d\n", player.nade_timer, time - held_nade.nade_time_primed); + makevectors(player.angles); + held_nade.velocity = player.velocity; + setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0); + held_nade.angles_y = player.angles.y; + + if (time + 0.1 >= held_nade.wait) + toss_nade(player, '0 0 0', time + 0.05); } - else if(time - self.nade.lifetime >= 1) - { - if(self.nade) - { - makevectors(self.v_angle); - float _force = time - self.nade.lifetime; + + if (!CanThrowNade()) return; + if (!(time > player.nade_refire)) return; + if (key_pressed) { + if (!held_nade) { + nade_prime(); + held_nade = player.nade; + } + } else if (time >= held_nade.nade_time_primed + 1) { + if (held_nade) { + makevectors(player.v_angle); + float _force = time - held_nade.nade_time_primed; _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); - toss_nade(self, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0); + toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0); } } + } +ENDCLASS(NadeOffhand) +NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); } + +MUTATOR_HOOKFUNCTION(nades_CheckThrow) +{ + if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) { + nades_CheckThrow(); + return true; } + return false; +} + +MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) +{SELFPARAM(); + if (!IS_PLAYER(self)) { return false; } + + if (self.nade && self.offhand != OFFHAND_NADE) OFFHAND_NADE.offhand_think(OFFHAND_NADE, self, self.nade_altbutton); if(IS_PLAYER(self)) { @@ -920,11 +974,12 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) float key_count = 0; FOR_EACH_KH_KEY(key) if(key.owner == self) { ++key_count; } + float time_score; if(self.flagcarried || self.ballcarried) // this player is important time_score = autocvar_g_nades_bonus_score_time_flagcarrier; else time_score = autocvar_g_nades_bonus_score_time; - + if(key_count) time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding @@ -938,8 +993,8 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) self.nade_type = autocvar_g_nades_bonus_type; self.pokenade_type = autocvar_g_nades_pokenade_monster_type; } - - self.nade_type = bound(1, self.nade_type, NADE_TYPE_LAST); + + self.nade_type = bound(1, self.nade_type, Nades_COUNT); if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max) nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max); @@ -968,7 +1023,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) if(!o) o = other; if(self.frozen == 1) - other.reviving = TRUE; + other.reviving = true; ++n; } } @@ -990,15 +1045,15 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink) FOR_EACH_PLAYER(other) if(other.reviving) { other.revive_progress = self.revive_progress; - other.reviving = FALSE; + other.reviving = false; } } - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_PlayerSpawn) -{ +{SELFPARAM(); if(autocvar_g_nades_spawn) self.nade_refire = time + autocvar_g_spawnshieldtime; else @@ -1009,11 +1064,13 @@ MUTATOR_HOOKFUNCTION(nades_PlayerSpawn) self.nade_timer = 0; + if (!self.offhand) self.offhand = OFFHAND_NADE; + if(self.nade_spawnloc) { setorigin(self, self.nade_spawnloc.origin); self.nade_spawnloc.cnt -= 1; - + if(self.nade_spawnloc.cnt <= 0) { remove(self.nade_spawnloc); @@ -1021,7 +1078,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerSpawn) } } - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_PlayerDies) @@ -1055,7 +1112,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDies) nades_RemoveBonus(frag_target); - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_PlayerDamage) @@ -1063,40 +1120,40 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDamage) if(frag_target.frozen) if(autocvar_g_freezetag_revive_nade) if(frag_attacker == frag_target) - if(frag_deathtype == DEATH_NADE) + if(frag_deathtype == DEATH_NADE.m_id) if(time - frag_inflictor.toss_time <= 0.1) { Unfreeze(frag_target); frag_target.health = autocvar_g_freezetag_revive_nade_health; - pointparticles(particleeffectnum("iceorglass"), frag_target.origin, '0 0 0', 3); + Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3); frag_damage = 0; frag_force = '0 0 0'; Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname); Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF); } - - return FALSE; + + return false; } MUTATOR_HOOKFUNCTION(nades_MonsterDies) -{ +{SELFPARAM(); if(IS_PLAYER(frag_attacker)) if(DIFF_TEAM(frag_attacker, self)) if(!(self.spawnflags & MONSTERFLAG_SPAWNED)) nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_RemovePlayer) -{ +{SELFPARAM(); nades_Clear(self); nades_RemoveBonus(self); - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_SpectateCopy) -{ +{SELFPARAM(); self.nade_timer = other.nade_timer; self.nade_type = other.nade_type; self.pokenade_type = other.pokenade_type; @@ -1104,7 +1161,7 @@ MUTATOR_HOOKFUNCTION(nades_SpectateCopy) self.bonus_nade_score = other.bonus_nade_score; self.stat_healing_orb = other.stat_healing_orb; self.stat_healing_orb_alpha = other.stat_healing_orb_alpha; - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_GetCvars) @@ -1112,19 +1169,19 @@ MUTATOR_HOOKFUNCTION(nades_GetCvars) GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type"); GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type"); - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_BuildMutatorsString) { ret_string = strcat(ret_string, ":Nades"); - return FALSE; + return false; } MUTATOR_HOOKFUNCTION(nades_BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", Nades"); - return FALSE; + return false; } void nades_Initialize() @@ -1135,20 +1192,6 @@ void nades_Initialize() addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score); addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb); addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha); - - precache_model("models/ok_nade_counter/ok_nade_counter.md3"); - precache_model("models/weapons/h_ok_grenade.iqm"); - precache_model("models/weapons/v_ok_grenade.md3"); - precache_model("models/ctf/shield.md3"); - - precache_sound("weapons/rocket_impact.wav"); - precache_sound("weapons/grenade_bounce1.wav"); - precache_sound("weapons/grenade_bounce2.wav"); - precache_sound("weapons/grenade_bounce3.wav"); - precache_sound("weapons/grenade_bounce4.wav"); - precache_sound("weapons/grenade_bounce5.wav"); - precache_sound("weapons/grenade_bounce6.wav"); - precache_sound("overkill/grenadebip.ogg"); } MUTATOR_DEFINITION(mutator_nades) @@ -1173,5 +1216,5 @@ MUTATOR_DEFINITION(mutator_nades) nades_Initialize(); } - return FALSE; + return false; }