}
..entity weaponentity_fld;
+.float m_alpha;
void CL_Weaponentity_Think()
{
CL_WeaponEntity_SetModel(this, this.owner.weaponname);
}
- this.effects = EF_NODRAW; // TODO: don't render this entity at all
+ this.alpha = -1; // TODO: don't render this entity at all
- if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha;
- else if (this.owner.alpha != 0) this.alpha = this.owner.alpha;
- else this.alpha = 1;
+ if (this.owner.alpha == default_player_alpha) this.m_alpha = default_weapon_alpha;
+ else if (this.owner.alpha != 0) this.m_alpha = this.owner.alpha;
+ else this.m_alpha = 1;
- if (this.weaponchild) this.weaponchild.effects = this.effects;
+ if (this.weaponchild)
+ {
+ this.weaponchild.alpha = this.alpha;
+ this.weaponchild.effects = this.effects;
+ }
}
void CL_ExteriorWeaponentity_Think()
if (thiswep == WEP_SHOTGUN)
if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
- if (thiswep == Weapons_from(actor.switchweapon) && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
+ if (thiswep == PS(actor).m_switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
{
sound(actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
actor.prevdryfire = time;
return false;
// do not even think about shooting if switching
- if (actor.switchweapon != actor.weapon) return false;
+ if (PS(actor).m_switchweapon.m_id != actor.weapon) return false;
if (attacktime >= 0)
{
vector or = v_right;
vector ou = v_up;
+ vector a = '0 0 0';
if (this)
{
this.wframe = fr;
- vector a = '0 0 0';
if (fr == WFRAME_IDLE) a = this.anim_idle;
else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
else // if (fr == WFRAME_RELOAD)
a = this.anim_reload;
a.z *= g_weaponratefactor;
- entity e;
- FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim);
}
v_forward = of;
// dprint("reset weapon animation timer at ", ftos(time), "\n");
}
this.weapon_nextthink += t;
- if (weaponentity == weaponentities[0]) actor.weapon_nextthink = this.weapon_nextthink;
+ if (weaponentity == weaponentities[0]) STAT(WEAPON_NEXTTHINK, actor) = this.weapon_nextthink;
this.weapon_think = func;
// dprint("next ", ftos(this.weapon_nextthink), "\n");
+ if (this)
+ {
+ entity e;
+ FOR_EACH_CLIENT(e) if (e == actor || (IS_SPEC(e) && e.enemy == actor)) wframe_send(e, this, a, restartanim);
+ }
+
if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
{
- if ((actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id)
- && fr == WFRAME_FIRE2) animdecide_setaction(actor, ANIMACTION_MELEE, restartanim);
- else animdecide_setaction(actor, ANIMACTION_SHOOT, restartanim);
+ int act = (fr == WFRAME_FIRE2 && (actor.weapon == WEP_SHOCKWAVE.m_id || actor.weapon == WEP_SHOTGUN.m_id))
+ ? ANIMACTION_MELEE
+ : ANIMACTION_SHOOT
+ ;
+ animdecide_setaction(actor, act, restartanim);
}
- else
+ else if (actor.anim_upper_action == ANIMACTION_SHOOT || actor.anim_upper_action == ANIMACTION_MELEE)
{
- if (actor.anim_upper_action == ANIMACTION_SHOOT
- || actor.anim_upper_action == ANIMACTION_MELEE) actor.anim_upper_action = 0;
+ actor.anim_upper_action = 0;
}
}
}
}
- if (actor.switchweapon == 0)
+ if (PS(actor).m_switchweapon.m_id == 0)
{
actor.weapon = 0;
actor.switchingweapon = 0;
vector up = v_up;
// Change weapon
- if (actor.weapon != actor.switchweapon)
+ if (actor.weapon != PS(actor).m_switchweapon.m_id)
{
switch (this.state)
{
case WS_CLEAR:
{
// end switching!
- actor.switchingweapon = actor.switchweapon;
- entity newwep = Weapons_from(actor.switchweapon);
+ Weapon newwep = PS(actor).m_switchweapon;
+ actor.switchingweapon = newwep.m_id;
// the two weapon entities will notice this has changed and update their models
- actor.weapon = actor.switchweapon;
+ actor.weapon = newwep.m_id;
actor.weaponname = newwep.mdl;
actor.bulletcounter = 0;
actor.ammo_field = newwep.ammo_field;
// set our clip load to the load of the weapon we switched to, if it's reloadable
if ((newwep.spawnflags & WEP_FLAG_RELOADABLE) && newwep.reloading_ammo) // prevent accessing undefined cvars
{
- actor.clip_load = actor.(weapon_load[actor.switchweapon]);
+ actor.clip_load = actor.(weapon_load[PS(actor).m_switchweapon.m_id]);
actor.clip_size = newwep.reloading_ammo;
}
else
case WS_DROP:
{
// in dropping phase we can switch at any time
- actor.switchingweapon = actor.switchweapon;
+ actor.switchingweapon = PS(actor).m_switchweapon.m_id;
break;
}
case WS_READY:
{
// start switching!
- actor.switchingweapon = actor.switchweapon;
+ actor.switchingweapon = PS(actor).m_switchweapon.m_id;
entity oldwep = Weapons_from(actor.weapon);
// set up weapon switch think in the future, and start drop anim
- if (
-#if INDEPENDENT_ATTACK_FINISHED
- true
-#else
- ATTACK_FINISHED(actor, slot) <= time + actor.weapon_frametime * 0.5
-#endif
- )
+ if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + actor.weapon_frametime * 0.5)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
this.state = WS_DROP;
// server framerate is very low and the weapon fire rate very high
for (int c = 0; c < W_TICSPERFRAME; ++c)
{
- if (w && !(actor.weapons & WepSet_FromWeapon(w)))
+ if (w && !(actor.weapons & WepSet_FromWeapon(Weapons_from(w))))
{
- if (actor.weapon == actor.switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
+ if (actor.weapon == PS(actor).m_switchweapon.m_id) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
w = 0;
}
}
else
{
- if (key_pressed && actor.switchweapon != WEP_HOOK.m_id && !actor.hook_switchweapon) W_SwitchWeapon(
- WEP_HOOK.m_id);
+ if (key_pressed && PS(actor).m_switchweapon != WEP_HOOK && !actor.hook_switchweapon)
+ W_SwitchWeapon(WEP_HOOK);
actor.hook_switchweapon = key_pressed;
Weapon h = WEP_HOOK;
block_weapon = (actor.weapon == h.m_id && (actor.BUTTON_ATCK || key_pressed));