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)
break;
}
}
- ));
+ });
return EFFECT_Null;
}
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';
}
entity nade_type = Nade_FromProjectile(proj.cnt);
if (nade_type == NADE_TYPE_Null) return;
- if(STAT(NADES_SMALL, NULL))
+ if(STAT(NADES_SMALL))
{
proj.mins = '-8 -8 -8';
proj.maxs = '8 8 8';
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);
#include <common/monsters/sv_monsters.qh>
#include <server/g_subs.qh>
-REGISTER_MUTATOR(nades, cvar("g_nades"));
+REGISTER_MUTATOR(nades, autocvar_g_nades);
.float nade_time_primed;
.float nade_lifetime;
{
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);
}
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;
CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
}
-void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
+void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
{
frost_target.frozen_by = freezefield.realowner;
Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
- Freeze(frost_target, 1/freeze_time, 3, false);
+ Freeze(frost_target, 1 / freezetime, 3, false);
Drop_Special_Items(frost_target);
}
float current_freeze_time = this.ltime - time - 0.1;
- FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0,
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResourceAmount(it, RESOURCE_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(!pushdeltatime) return;
// div0: ticrate independent, 1 = identity (not 20)
- toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime);
+ toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
#ifdef SVQC
UpdateCSQCProjectile(toucher);
if ( health_factor > 0 )
{
maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
- if ( toucher.health < maxhealth )
+ float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
+ if (hp < maxhealth)
{
- if ( this.nade_show_particles )
+ if (this.nade_show_particles)
+ {
Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
- toucher.health = min(toucher.health+health_factor, maxhealth);
+ }
+ GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
}
- toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
}
else if ( health_factor < 0 )
{
IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
{
- RemoveGrapplingHook(it.realowner);
+ RemoveHook(it);
});
delete(this);
if(autocvar_g_nades_pickup)
if(time >= this.spawnshieldtime)
- if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much
- if(!STAT(FROZEN, toucher))
+ if(!toucher.nade && GetResourceAmount(this, RESOURCE_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
{
{
IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
{
- RemoveGrapplingHook(it.realowner);
+ RemoveHook(it);
});
delete(this);
return;
//setsize(this, '-2 -2 -2', '2 2 2');
//UpdateCSQCProjectile(this);
- if(this.health == this.max_health)
+ if(GetResourceAmount(this, RESOURCE_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;
}
if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
return;
- if(this.health == this.max_health)
+ float hp = GetResourceAmount(this, RESOURCE_HEALTH);
+ if(hp == this.max_health)
{
sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
this.nextthink = max(time + this.nade_lifetime, time);
setthink(this, nade_beep);
}
- this.health -= damage;
+ hp -= damage;
+ SetResourceAmount(this, RESOURCE_HEALTH, hp);
+
if ( this.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
this.realowner = attacker;
- if(this.health <= 0)
+ if(hp <= 0)
W_PrepareExplosionByDamage(this, attacker, nade_boom);
else
nade_burn_spawn(this);
delete(e.fake_nade);
e.fake_nade = NULL;
+ Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
+
makevectors(e.v_angle);
// NOTE: always throw from first weapon entity?
- W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
-
- Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
+ 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);
settouch(_nade, nade_touch);
_nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
- _nade.health = autocvar_g_nades_nade_health;
+ SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
_nade.max_health = _nade.health;
_nade.takedamage = DAMAGE_AIM;
_nade.event_damage = nade_damage;
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;
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;
fn.glowmod = player.glowmod;
setthink(fn, SUB_Remove);
fn.nextthink = n.wait;
+ fn.weaponentity_fld = weaponentity;
player.nade = n;
player.fake_nade = fn;
}
else
{
- ntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_nade_type : autocvar_g_nades_nade_type);
- pntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
+ ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
+ pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
}
spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
if(this.vehicle)
return false;
- if(gameover)
- return false;
-
if(IS_DEAD(this))
return false;
FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
float time_score;
- if(player.flagcarried || player.ballcarried) // this player is important
+ if(GameRules_scoring_is_vip(player))
time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
else
time_score = autocvar_g_nades_bonus_score_time;
if(autocvar_g_nades_bonus_client_select)
{
- player.nade_type = player.cvar_cl_nade_type;
- player.pokenade_type = player.cvar_cl_pokenade_type;
+ player.nade_type = CS(player).cvar_cl_nade_type;
+ player.pokenade_type = CS(player).cvar_cl_pokenade_type;
}
else
{
}
}
- float n = 0;
+ int n = 0;
entity o = NULL;
if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
n = -1;
- else
+ else if(STAT(FROZEN, player) == 3)
{
vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
n = 0;
- FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
- if(!IS_DEAD(it))
- if(STAT(FROZEN, it) == 0)
- if(SAME_TEAM(it, player))
+ FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
+ if(!IS_DEAD(it) && STAT(FROZEN, it) == 0 && SAME_TEAM(it, player))
if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
{
if(!o)
o = it;
- if(STAT(FROZEN, player) == 1)
- it.reviving = true;
+ it.reviving = true;
++n;
}
- ));
+ });
}
- if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
+ if(n > 0 && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
{
player.revive_progress = bound(0, player.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
- player.health = max(1, player.revive_progress * start_health);
+ SetResourceAmount(player, RESOURCE_HEALTH, max(1, player.revive_progress * start_health));
if(player.revive_progress >= 1)
{
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;
- ));
+ });
}
}
player.nade_refire = time + autocvar_g_nades_nade_refire;
if(autocvar_g_nades_bonus_client_select)
- player.nade_type = player.cvar_cl_nade_type;
+ player.nade_type = CS(player).cvar_cl_nade_type;
player.nade_timer = 0;
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)
+ else if(GameRules_scoring_is_vip(frag_target))
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;
if(time - frag_inflictor.toss_time <= 0.1)
{
Unfreeze(frag_target);
- frag_target.health = autocvar_g_freezetag_revive_nade_health;
+ SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
M_ARGV(4, float) = 0;
M_ARGV(6, vector) = '0 0 0';
M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
}
-MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
-{
- M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Nades");
-}
-
MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
{
M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");