#include "electro.qh"
#ifdef SVQC
-spawnfunc(weapon_electro) { weapon_defaultspawnfunc(this, WEP_ELECTRO); }
void W_Electro_TriggerCombo(vector org, float rad, entity own)
{
NULL,
WEP_CVAR(electro, combo_force),
WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
+ this.weaponentity_fld,
NULL
);
NULL,
WEP_CVAR_SEC(electro, force),
this.projectiledeathtype,
+ this.weaponentity_fld,
directhitentity
);
}
NULL,
WEP_CVAR_PRI(electro, force),
this.projectiledeathtype,
+ this.weaponentity_fld,
directhitentity
);
}
2,
SND_ELECTRO_FIRE,
CH_WEAPON_A,
- WEP_CVAR_PRI(electro, damage)
+ WEP_CVAR_PRI(electro, damage),
+ thiswep.m_id
);
Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
proj.nextthink = time;
proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
PROJECTILE_MAKETRIGGER(proj);
- proj.projectiledeathtype = WEP_ELECTRO.m_id;
+ proj.projectiledeathtype = thiswep.m_id;
+ proj.weaponentity_fld = weaponentity;
setorigin(proj, w_shotorg);
// if (IS_CSQC)
newproj.takedamage = this.takedamage;
newproj.damageforcescale = this.damageforcescale;
- newproj.health = this.health;
+ SetResource(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
newproj.event_damage = this.event_damage;
newproj.spawnshieldtime = this.spawnshieldtime;
newproj.damagedbycontents = true;
set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
newproj.projectiledeathtype = this.projectiledeathtype;
+ newproj.weaponentity_fld = this.weaponentity_fld;
settouch(newproj, func_null);
setthink(newproj, getthink(this));
delete(this);
if(to)
- SetMovetypeFollow(this, to);
+ SetMovetypeFollow(newproj, to);
}
void W_Electro_Orb_Touch(entity this, entity toucher)
{
PROJECTILE_TOUCH(this, toucher);
- if(toucher.takedamage == DAMAGE_AIM)
- { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this, toucher); } }
- else
+ if(toucher.takedamage == DAMAGE_AIM && WEP_CVAR_SEC(electro, touchexplode))
+ { W_Electro_Explode(this, toucher); }
+ else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles!
{
//UpdateCSQCProjectile(this);
spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
}
}
-void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
{
- if(this.health <= 0)
+ if(GetResource(this, RES_HEALTH) <= 0)
return;
// note: combos are usually triggered by W_Electro_TriggerCombo, not damage
if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
return; // g_projectiles_damage says to halt
- this.health = this.health - damage;
- if(this.health <= 0)
+ TakeResource(this, RES_HEALTH, damage);
+ if(GetResource(this, RES_HEALTH) <= 0)
{
this.takedamage = DAMAGE_NO;
this.nextthink = time;
2,
SND_ELECTRO_FIRE2,
CH_WEAPON_A,
- WEP_CVAR_SEC(electro, damage)
+ WEP_CVAR_SEC(electro, damage),
+ thiswep.m_id | HITTYPE_SECONDARY
);
w_shotdir = v_forward; // no TrueAim for grenades please
proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
PROJECTILE_MAKETRIGGER(proj);
- proj.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SECONDARY;
+ proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
+ proj.weaponentity_fld = weaponentity;
setorigin(proj, w_shotorg);
//proj.glow_size = 50;
setsize(proj, '-4 -4 -4', '4 4 4');
proj.takedamage = DAMAGE_YES;
proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
- proj.health = WEP_CVAR_SEC(electro, health);
+ SetResource(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
proj.event_damage = W_Electro_Orb_Damage;
proj.flags = FL_PROJECTILE;
IL_PUSH(g_projectiles, proj);
proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
proj.missile_flags = MIF_SPLASH | MIF_ARC;
-#if 0
- entity p2;
- p2 = spawn();
- copyentity(proj, p2);
- setmodel(p2, MDL_PROJECTILE_ELECTRO);
- setsize(p2, proj.mins, proj.maxs);
-#endif
-
CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
MUTATOR_CALLHOOK(EditProjectile, actor, proj);
if(PHYS_INPUT_BUTTON_ATCK2(actor))
if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
{
- W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity);
+ W_Electro_Attack_Orb(thiswep, actor, weaponentity);
actor.(weaponentity).electro_count -= 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
return;
}
METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo);
return ammo_amount;
}
METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
float ammo_amount;
if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
}
else
{
- ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo);
}
return ammo_amount;
}