X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fnades%2Fnades.qc;h=23ee565b221bc5be7443dd5134d16640af45ed71;hb=2416db2a50e9696003244ab4c6565c5e021c0d6d;hp=1d5a8c37b38b2bf9f167bf041830a957dabb5bbd;hpb=8ba1f6c672361186033b8bebc3be677ac94bd4da;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 1d5a8c37b..23ee565b2 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1,7 +1,5 @@ #include "nades.qh" -#ifdef IMPLEMENTATION - #ifdef SVQC bool autocvar_g_nades_nade_small; float autocvar_g_nades_spread = 0.04; @@ -9,7 +7,7 @@ float autocvar_g_nades_spread = 0.04; REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small) -#ifndef MENUQC +#ifdef GAMEQC entity Nade_TrailEffect(int proj, int nade_team) { switch (proj) @@ -18,7 +16,7 @@ entity Nade_TrailEffect(int proj, int nade_team) case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team); } - FOREACH(Nades, true, LAMBDA( + FOREACH(Nades, true, { for (int j = 0; j < 2; j++) { if (it.m_projectile[j] == proj) @@ -28,7 +26,7 @@ entity Nade_TrailEffect(int proj, int nade_team) break; } } - )); + }); return EFFECT_Null; } @@ -76,7 +74,7 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile) if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN) { - loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM); + loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM); proj.mins = '-16 -16 -16'; proj.maxs = '16 16 16'; } @@ -94,7 +92,7 @@ MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile) proj.maxs = '16 16 16'; } proj.colormod = nade_type.m_color; - proj.move_movetype = MOVETYPE_BOUNCE; + set_movetype(proj, MOVETYPE_BOUNCE); settouch(proj, func_null); proj.scale = 1.5; proj.avelocity = randomvec() * 720; @@ -135,7 +133,7 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor); if(autocvar_hud_panel_ammo_text) - drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); if(draw_expanding) drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time); @@ -147,23 +145,25 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan #ifdef SVQC -#include -#include +#include +#include #include #include REGISTER_MUTATOR(nades, cvar("g_nades")); .float nade_time_primed; +.float nade_lifetime; .entity nade_spawnloc; + void nade_timer_think(entity this) { - this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10); + this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10); this.nextthink = time; if(!this.owner || wasfreed(this.owner)) - remove(this); + delete(this); } void nade_burn_spawn(entity _nade) @@ -213,14 +213,14 @@ void napalm_damage(entity this, float dist, float damage, float edgedamage, floa if(d < dist) { e.fireball_impactvec = p; - RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e)); + RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e)); } } if(RandomSelection_chosen_ent) { d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec); d = damage + (edgedamage - damage) * (d / dist); - Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE); + Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype); //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec); Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1); } @@ -232,13 +232,13 @@ void napalm_ball_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } if(time > this.pushltime) { - remove(this); + delete(this); return; } @@ -265,7 +265,7 @@ void nade_napalm_ball(entity this) entity proj; vector kick; - spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM); + spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM); proj = new(grenade); proj.owner = this.owner; @@ -273,7 +273,7 @@ void nade_napalm_ball(entity this) proj.team = this.owner.team; proj.bot_dodge = true; proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage; - proj.movetype = MOVETYPE_BOUNCE; + set_movetype(proj, MOVETYPE_BOUNCE); proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id; PROJECTILE_MAKETRIGGER(proj); setmodel(proj, MDL_Null); @@ -294,6 +294,8 @@ void nade_napalm_ball(entity this) proj.angles = vectoangles(proj.velocity); proj.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, proj); + IL_PUSH(g_bot_dodge, proj); proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC; //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true); @@ -306,13 +308,13 @@ void napalm_fountain_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } if(time >= this.ltime) { - remove(this); + delete(this); return; } @@ -350,13 +352,16 @@ void nade_napalm_boom(entity this) fountain.owner = this.owner; fountain.realowner = this.realowner; fountain.origin = this.origin; + fountain.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, fountain); + IL_PUSH(g_bot_dodge, fountain); setorigin(fountain, fountain.origin); setthink(fountain, napalm_fountain_think); fountain.nextthink = time; fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime; fountain.pushltime = fountain.ltime; fountain.team = this.team; - fountain.movetype = MOVETYPE_TOSS; + set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id; fountain.bot_dodge = true; fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage; @@ -379,7 +384,7 @@ void nade_ice_think(entity this) if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(this); + delete(this); return; } @@ -396,7 +401,7 @@ void nade_ice_think(entity this) Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this); } - remove(this); + delete(this); return; } @@ -426,16 +431,13 @@ void nade_ice_think(entity this) float current_freeze_time = this.ltime - time - 0.1; - entity e; - for(e = findradius(this.origin, autocvar_g_nades_nade_radius); e; e = e.chain) - if(e != this) - if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, this.realowner) || e == this.realowner)) - if(e.takedamage && !IS_DEAD(e)) - if(e.health > 0) - if(!e.revival_time || ((time - e.revival_time) >= 1.5)) - if(!STAT(FROZEN, e)) - if(current_freeze_time > 0) - nade_ice_freeze(this, e, current_freeze_time); + FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0, + { + if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner)) + if(!it.revival_time || ((time - it.revival_time) >= 1.5)) + if(!STAT(FROZEN, it)) + nade_ice_freeze(this, it, current_freeze_time); + }); } void nade_ice_boom(entity this) @@ -451,7 +453,7 @@ void nade_ice_boom(entity this) fountain.ltime = time + autocvar_g_nades_ice_freeze_time; fountain.pushltime = fountain.wait = fountain.ltime; fountain.team = this.team; - fountain.movetype = MOVETYPE_TOSS; + set_movetype(fountain, MOVETYPE_TOSS); fountain.projectiledeathtype = DEATH_NADE_ICE.m_id; fountain.bot_dodge = false; setsize(fountain, '-16 -16 -16', '16 16 16'); @@ -497,7 +499,7 @@ void nade_spawn_boom(entity this) entity spawnloc = spawn(); setorigin(spawnloc, this.origin); setsize(spawnloc, this.realowner.mins, this.realowner.maxs); - spawnloc.movetype = MOVETYPE_NONE; + set_movetype(spawnloc, MOVETYPE_NONE); spawnloc.solid = SOLID_NOT; spawnloc.drawonlytoclient = this.realowner; spawnloc.effects = EF_STARDUST; @@ -505,7 +507,7 @@ void nade_spawn_boom(entity this) if(this.realowner.nade_spawnloc) { - remove(this.realowner.nade_spawnloc); + delete(this.realowner.nade_spawnloc); this.realowner.nade_spawnloc = NULL; } @@ -516,7 +518,7 @@ void nades_orb_think(entity this) { if(time >= this.ltime) { - remove(this); + delete(this); return; } @@ -562,35 +564,33 @@ entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, return orb; } -void nade_entrap_touch(entity this) +void nade_entrap_touch(entity this, entity toucher) { - if(DIFF_TEAM(other, this.realowner)) // TODO: what if realowner changes team or disconnects? + if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects? { - if (!isPushable(other)) + if (!isPushable(toucher)) return; - float pushdeltatime = time - other.lastpushtime; + float pushdeltatime = time - toucher.lastpushtime; if (pushdeltatime > 0.15) pushdeltatime = 0; - other.lastpushtime = time; + toucher.lastpushtime = time; if(!pushdeltatime) return; // div0: ticrate independent, 1 = identity (not 20) -#ifdef SVQC - other.velocity = other.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime); + toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime); - UpdateCSQCProjectile(other); -#elif defined(CSQC) - other.move_velocity = other.move_velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime); -#endif + #ifdef SVQC + UpdateCSQCProjectile(toucher); + #endif } - if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) || IS_MONSTER(other) ) + if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) ) { - entity show_tint = (IS_VEHICLE(other)) ? other.owner : other; + entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher; STAT(ENTRAP_ORB, show_tint) = time + 0.1; float tint_alpha = 0.75; - if(SAME_TEAM(other, this.realowner)) + if(SAME_TEAM(toucher, this.realowner)) tint_alpha = 0.45; STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime; } @@ -604,43 +604,43 @@ void nade_entrap_boom(entity this) orb.colormod = NADE_TYPE_ENTRAP.m_color; } -void nade_heal_touch(entity this) +void nade_heal_touch(entity this, entity toucher) { float maxhealth; float health_factor; - if(IS_PLAYER(other) || IS_MONSTER(other)) - if(!IS_DEAD(other)) - if(!STAT(FROZEN, other)) + if(IS_PLAYER(toucher) || IS_MONSTER(toucher)) + if(!IS_DEAD(toucher)) + if(!STAT(FROZEN, toucher)) { health_factor = autocvar_g_nades_heal_rate*frametime/2; - if ( other != this.realowner ) + if ( toucher != this.realowner ) { - if ( SAME_TEAM(other,this) ) + if ( SAME_TEAM(toucher,this) ) health_factor *= autocvar_g_nades_heal_friend; else health_factor *= autocvar_g_nades_heal_foe; } if ( health_factor > 0 ) { - maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max; - if ( other.health < maxhealth ) + maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max; + if ( toucher.health < maxhealth ) { if ( this.nade_show_particles ) - Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1); - other.health = min(other.health+health_factor, maxhealth); + Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1); + toucher.health = min(toucher.health+health_factor, maxhealth); } - other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); + toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot); } else if ( health_factor < 0 ) { - Damage(other,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0'); + Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,toucher.origin,'0 0 0'); } } - if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) ) + if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) ) { - entity show_red = (IS_VEHICLE(other)) ? other.owner : other; + entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher; show_red.stat_healing_orb = time+0.1; show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.orb_lifetime; } @@ -656,7 +656,7 @@ void nade_heal_boom(entity this) void nade_monster_boom(entity this) { - entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1); + entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1); if(autocvar_g_nades_pokenade_monster_lifetime > 0) e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime; @@ -736,13 +736,12 @@ void nade_boom(entity this) case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break; } - FOREACH_ENTITY_ENT(aiment, this, + IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, { - if(it.classname == "grapplinghook") - RemoveGrapplingHook(it.realowner); + RemoveHook(it); }); - remove(this); + delete(this); } void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype); @@ -759,24 +758,23 @@ void nade_pickup(entity this, entity thenade) } bool CanThrowNade(entity this); -void nade_touch(entity this) +void nade_touch(entity this, entity toucher) { - if(other) + if(toucher) UpdateCSQCProjectile(this); - if(other == this.realowner) + if(toucher == this.realowner) return; // no this impacts if(autocvar_g_nades_pickup) if(time >= this.spawnshieldtime) - if(!other.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much - if(!other.frozen) - if(CanThrowNade(other)) // prevent some obvious things, like dead players - if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here + if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much + if(CanThrowNade(toucher)) // prevent some obvious things, like dead players + if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here { - nade_pickup(other, this); + nade_pickup(toucher, this); sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); - remove(this); + delete(this); return; } /*float is_weapclip = 0; @@ -786,26 +784,25 @@ void nade_touch(entity this) is_weapclip = 1;*/ if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip) { - FOREACH_ENTITY_ENT(aiment, this, + IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, { - if(it.classname == "grapplinghook") - RemoveGrapplingHook(it.realowner); + RemoveHook(it); }); - remove(this); + delete(this); return; } - PROJECTILE_TOUCH(this); + PROJECTILE_TOUCH(this, toucher); //setsize(this, '-2 -2 -2', '2 2 2'); //UpdateCSQCProjectile(this); if(this.health == this.max_health) { - spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM); + spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM); return; } - this.enemy = other; + this.enemy = toucher; nade_boom(this); } @@ -866,7 +863,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i if(this.health == this.max_health) { sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); - this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time); + this.nextthink = max(time + this.nade_lifetime, time); setthink(this, nade_beep); } @@ -889,22 +886,21 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) entity _nade = e.nade; e.nade = NULL; - remove(e.fake_nade); + delete(e.fake_nade); e.fake_nade = NULL; - makevectors(e.v_angle); + Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES); - W_SetupShot(e, false, false, SND_Null, CH_WEAPON_A, 0); + makevectors(e.v_angle); - Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES); + // NOTE: always throw from first weapon entity? + W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0); 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'; + + (v_right * autocvar_g_nades_throw_offset.y) + + (v_up * autocvar_g_nades_throw_offset.z); - setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1); + setorigin(_nade, w_shotorg + offset); //setmodel(_nade, MDL_PROJECTILE_NADE); //setattachment(_nade, NULL, ""); PROJECTILE_MAKETRIGGER(_nade); @@ -912,9 +908,9 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) setsize(_nade, '-8 -8 -8', '8 8 8'); else setsize(_nade, '-16 -16 -16', '16 16 16'); - _nade.movetype = MOVETYPE_BOUNCE; + set_movetype(_nade, MOVETYPE_BOUNCE); - tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade); + tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade); if (trace_startsolid) setorigin(_nade, e.origin); @@ -944,8 +940,11 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) _nade.gravity = 1; _nade.missile_flags = MIF_SPLASH | MIF_ARC; _nade.damagedbycontents = true; + IL_PUSH(g_damagedbycontents, _nade); _nade.angles = vectoangles(_nade.velocity); _nade.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, _nade); + IL_PUSH(g_bot_dodge, _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); @@ -1002,10 +1001,10 @@ MUTATOR_HOOKFUNCTION(nades, PutClientInServer) nades_RemoveBonus(player); } -float nade_customize(entity this) +bool nade_customize(entity this, entity client) { - //if(IS_SPEC(other)) { return false; } - if(other == this.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == this.exteriormodeltoclient)) + //if(IS_SPEC(client)) { return false; } + if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient)) { // somewhat hide the model, but keep the glow //this.effects = 0; @@ -1034,6 +1033,8 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin if(Nades_from(n.nade_type) == NADE_TYPE_Null) n.nade_type = NADE_TYPE_NORMAL.m_id; + .entity weaponentity = weaponentities[0]; // TODO: unhardcode + setmodel(n, MDL_PROJECTILE_NADE); //setattachment(n, player, "bip01 l hand"); n.exteriormodeltoclient = player; @@ -1048,9 +1049,10 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin setthink(n, nade_beep); n.nextthink = max(n.wait - 3, time); n.projectiledeathtype = DEATH_NADE.m_id; + n.weaponentity_fld = weaponentity; + n.nade_lifetime = ntime; setmodel(fn, MDL_NADE_VIEW); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode setattachment(fn, player.(weaponentity), ""); fn.realowner = fn.owner = player; fn.colormod = Nades_from(n.nade_type).m_color; @@ -1058,6 +1060,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin fn.glowmod = player.glowmod; setthink(fn, SUB_Remove); fn.nextthink = n.wait; + fn.weaponentity_fld = weaponentity; player.nade = n; player.fake_nade = fn; @@ -1070,10 +1073,10 @@ void nade_prime(entity this) return; // only allow bonus nades if(this.nade) - remove(this.nade); + delete(this.nade); if(this.fake_nade) - remove(this.fake_nade); + delete(this.fake_nade); int ntype; string pntype = this.pokenade_type; @@ -1100,9 +1103,6 @@ bool CanThrowNade(entity this) if(this.vehicle) return false; - if(gameover) - return false; - if(IS_DEAD(this)) return false; @@ -1154,9 +1154,9 @@ void nades_CheckThrow(entity this) void nades_Clear(entity player) { if(player.nade) - remove(player.nade); + delete(player.nade); if(player.fake_nade) - remove(player.fake_nade); + delete(player.fake_nade); player.nade = player.fake_nade = NULL; player.nade_timer = 0; @@ -1174,18 +1174,6 @@ CLASS(NadeOffhand, OffhandWeapon) METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed)) { entity held_nade = player.nade; - if (held_nade) - { - 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, false, '0 0 0', time + 0.05); - } if (!CanThrowNade(player)) return; if (!(time > player.nade_refire)) return; @@ -1227,6 +1215,20 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton); + entity held_nade = player.nade; + if (held_nade) + { + player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1); + // LOG_TRACEF("%d %d", 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, false, '0 0 0', time + 0.05); + } + if(IS_PLAYER(player)) { if ( autocvar_g_nades_bonus && autocvar_g_nades ) @@ -1274,7 +1276,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) { vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; n = 0; - FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it != player, { if(!IS_DEAD(it)) if(STAT(FROZEN, it) == 0) if(SAME_TEAM(it, player)) @@ -1286,7 +1288,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) it.reviving = true; ++n; } - )); + }); } if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us @@ -1302,10 +1304,10 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); } - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { it.revive_progress = player.revive_progress; it.reviving = false; - )); + }); } } @@ -1354,7 +1356,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) if(player.nade_spawnloc.cnt <= 0) { - remove(player.nade_spawnloc); + delete(player.nade_spawnloc); player.nade_spawnloc = NULL; } } @@ -1369,19 +1371,19 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade) toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05)); - float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor); - if(IS_PLAYER(frag_attacker)) { + float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor); + if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target) nades_RemoveBonus(frag_attacker); else if(frag_target.flagcarried) nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium); - else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1) + else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1) { #define SPREE_ITEM(counta,countb,center,normal,gentle) \ case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; } - switch(frag_attacker.killcount) + switch(CS(frag_attacker).killcount) { KILL_SPREE_LIST default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break; @@ -1395,7 +1397,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) nades_RemoveBonus(frag_target); } -MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(nades, Damage_Calculate) { entity frag_inflictor = M_ARGV(0, entity); entity frag_attacker = M_ARGV(1, entity); @@ -1432,7 +1434,7 @@ MUTATOR_HOOKFUNCTION(nades, MonsterDies) MUTATOR_HOOKFUNCTION(nades, DropSpecialItems) { entity frag_target = M_ARGV(0, entity); - + if(frag_target.nade) toss_nade(frag_target, true, '0 0 0', time + 0.05); } @@ -1488,4 +1490,3 @@ MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString) } #endif -#endif