if(drawlocal) { sf &= ~ARC_SF_LOCALMASK; }
WriteByte(MSG_ENTITY, sf);
+ WriteByte(MSG_ENTITY, weaponslot(this.weaponentity_fld));
if(sf & ARC_SF_SETTINGS) // settings information
{
this.beam_type = new_beam_type;
}
- this.owner.beam_prev = time;
+ this.owner.(weaponentity).beam_prev = time;
this.nextthink = time;
}
{
// only play fire sound if 1 sec has passed since player let go the fire button
- if(time - actor.beam_prev > 1)
+ if(time - actor.(weaponentity).beam_prev > 1)
sound(actor, CH_WEAPON_A, SND_ARC_FIRE, VOL_BASE, ATTN_NORM);
entity beam = actor.(weaponentity).arc_beam = new(W_Arc_Beam);
NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
{
int sf = ReadByte();
+ int slot = ReadByte();
entity flash;
if(isnew)
{
int gunalign = W_GunAlign(NULL, STAT(GUNALIGN));
- this.beam_shotorigin = arc_shotorigin[gunalign];
+ this.beam_shotorigin = arc_shotorigin[gunalign]; // quick
+ for(int j = 1; j < 5; ++j)
+ {
+ if(gunaligns[j] == viewmodels[slot])
+ {
+ this.beam_shotorigin = arc_shotorigin[j - 1]; // accurate
+ break;
+ }
+ }
// set other main attributes of the beam
this.draw = Draw_ArcBeam;
.Weapon w_m_switchingweapon;
.Weapon w_m_weapon;
//.float w_weapon_nextthink;
+.float w_m_alpha;
// #define PROP(public, fld, set, sv, cl)
#define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
PROP(false, m_weapon, WEPENT_SET_NORMAL, \
{ WriteByte(chan, this.m_weapon.m_id); }, \
{ (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
+ \
+ PROP(false, m_alpha, WEPENT_SET_NORMAL, \
+ { WriteByte(chan, this.m_alpha * 16); }, \
+ { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
\
/**/
{
int slot = weaponslot(weaponentity);
// don't fire if previous attack is not finished
- if (ATTACK_FINISHED(actor, slot) > time + actor.weapon_frametime * 0.5) return false;
+ if (ATTACK_FINISHED(actor, slot) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
entity this = actor.(weaponentity);
// don't fire while changing weapon
if (this.state != WS_READY) return false;
if (attacktime >= 0)
{
int slot = weaponslot(weaponentity);
- if (ATTACK_FINISHED(actor, slot) < time - actor.weapon_frametime * 1.5)
+ if (ATTACK_FINISHED(actor, slot) < time - this.weapon_frametime * 1.5)
{
ATTACK_FINISHED(actor, slot) = time;
// dprint("resetting attack finished to ", ftos(time), "\n");
}
ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor);
}
- actor.bulletcounter += 1;
+ actor.(weaponentity).bulletcounter += 1;
// dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
}
this.weapon_nextthink = time;
// dprint("started firing at ", ftos(time), "\n");
}
- if (this.weapon_nextthink < time - actor.weapon_frametime * 1.5
- || this.weapon_nextthink > time + actor.weapon_frametime * 1.5)
+ if (this.weapon_nextthink < time - this.weapon_frametime * 1.5
+ || this.weapon_nextthink > time + this.weapon_frametime * 1.5)
{
this.weapon_nextthink = time;
// dprint("reset weapon animation timer at ", ftos(time), "\n");
if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
{
- bool primary_melee = boolean(fr == WFRAME_FIRE1 && (actor.(weaponentity).m_weapon.spawnflags & WEP_TYPE_MELEE_PRI));
- bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (actor.(weaponentity).m_weapon.spawnflags & WEP_TYPE_MELEE_SEC));
+ bool primary_melee = boolean(fr == WFRAME_FIRE1 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_PRI));
+ bool secondary_melee = boolean(fr == WFRAME_FIRE2 && (this.m_weapon.spawnflags & WEP_TYPE_MELEE_SEC));
int act = (primary_melee || secondary_melee)
? ANIMACTION_MELEE
: ANIMACTION_SHOOT
TC(Player, actor);
TC(PlayerState, PS(actor));
entity this = actor.(weaponentity);
- if (frametime) actor.weapon_frametime = frametime;
+ if (frametime) this.weapon_frametime = frametime;
if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands
if (forbidWeaponUse(actor))
{
- if (actor.(weaponentity).state != WS_CLEAR)
+ if (this.state != WS_CLEAR)
{
Weapon wpn = this.m_weapon;
w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
// the two weapon entities will notice this has changed and update their models
this.m_weapon = newwep;
this.weaponname = newwep.mdl;
- actor.bulletcounter = 0;
+ this.bulletcounter = 0;
actor.ammo_field = newwep.ammo_field;
newwep.wr_setup(newwep, actor);
this.state = WS_RAISE;
entity oldwep = this.m_weapon;
// set up weapon switch think in the future, and start drop anim
- if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + actor.weapon_frametime * 0.5)
+ if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + this.weapon_frametime * 0.5)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
this.state = WS_DROP;
}
}
- if (time + actor.weapon_frametime * 0.5 >= this.weapon_nextthink)
+ if (time + this.weapon_frametime * 0.5 >= this.weapon_nextthink)
{
if (this.weapon_think)
{