makevectors(e.v_angle);
// NOTE: always throw from first weapon entity?
- W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
+ W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0);
Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
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;
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;
var = strzone(x); \
MACRO_END
-#ifdef SVQC
- .int w_sv_entnum;
- .Weapon w_m_switchweapon;
- .Weapon w_m_switchingweapon;
- .Weapon w_m_weapon;
- //.float w_weapon_nextthink;
- .float w_m_alpha;
- .float w_vortex_charge;
- .int w_m_gunalign;
- .bool w_porto_v_angle_held;
- .int w_tuba_instrument;
-#endif
-
// #define PROP(public, fld, set, sv, cl)
#define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
WriteHeader(chan, ENT_CLIENT_WEPENT);
else
WriteHeader(chan, CLIENT_WEPENT);
- .entity weaponentity = this.weaponentity_fld;
+ .entity weaponentity = this.owner.weaponentity_fld;
WriteByte(chan, weaponslot(weaponentity));
WriteShort(chan, sf);
int i = 0;
return _wepent_send(this, to, sf, MSG_ENTITY);
}
- void wepent_update(entity this)
+ void wepent_think(entity this)
{
+ if(wasfreed(this.owner) || !this.owner)
+ {
+ delete(this);
+ return;
+ }
+
+ this.nextthink = time;
+
+ entity o = this.owner;
+
int i = 0;
#define X(public, fld, set, sv, cl) { \
- if (this.w_##fld != this.fld) { \
- set(this.w_##fld, this.fld); \
+ if (this.fld != o.fld) { \
+ set(this.fld, o.fld); \
this.SendFlags |= BIT(i); \
} \
i += 1; \
void wepent_link(entity wep)
{
- Net_LinkEntity(wep, false, 0, wepent_send);
+ entity e = new(wepent_sender);
+ e.owner = wep;
+ setthink(e, wepent_think);
+ e.nextthink = time;
+ Net_LinkEntity(e, false, 0, wepent_send);
}
#endif
bool ReadWepent(entity this)
{
- this.m_wepent_slot = ReadByte();
+ int slot = ReadByte();
+ this.m_wepent_slot = slot;
+ viewmodels[slot].m_wepent_slot = slot;
int sf = ReadShort();
int i = 0;
#define X(public, fld, set, sv, cl) { \
bool wepent_send(entity this, entity to, int sf);
- void wepent_update(entity this);
-
void wepent_link(entity wep);
.int m_forceupdate;
Weapon wep = this.(weaponentity).m_weapon;
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- .entity wepent = weaponentities[slot];
- wep.wr_playerdeath(wep, this, wepent);
+ .entity went = weaponentities[slot];
+ wep.wr_playerdeath(wep, this, went);
}
RemoveGrapplingHooks(this);
// throw a weapon
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- .entity wepent = weaponentities[slot];
- SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, this.(wepent).m_switchweapon.m_id, wepent);
+ .entity went = weaponentities[slot];
+ SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, this.(went).m_switchweapon.m_id, went);
}
// become fully visible
this.weaponchild.alpha = this.alpha;
this.weaponchild.effects = this.effects;
}
-
- wepent_update(this);
}
void CL_ExteriorWeaponentity_Think(entity this)
{
this.nextthink = time;
.entity weaponentity = this.weaponentity_fld;
- entity wepent = this.owner.(weaponentity);
+ entity w_ent = this.owner.(weaponentity);
if (this.owner.exteriorweaponentity != this)
{
delete(this);
this.model = "";
return;
}
- if (this.weaponname != wepent.weaponname || this.dmg != wepent.modelindex
- || this.deadflag != wepent.deadflag)
+ if (this.weaponname != w_ent.weaponname || this.dmg != w_ent.modelindex
+ || this.deadflag != w_ent.deadflag)
{
- this.weaponname = wepent.weaponname;
- this.dmg = wepent.modelindex;
- this.deadflag = wepent.deadflag;
- if (wepent.weaponname != "")
+ this.weaponname = w_ent.weaponname;
+ this.dmg = w_ent.modelindex;
+ this.deadflag = w_ent.deadflag;
+ if (w_ent.weaponname != "")
{
- _setmodel(this, W_Model(strcat("v_", wepent.weaponname, ".md3")));
+ _setmodel(this, W_Model(strcat("v_", w_ent.weaponname, ".md3")));
setsize(this, '0 0 0', '0 0 0');
}
else this.model = "";