return ret;
}
-..entity weaponentity_fld;
.float m_alpha;
.string w_weaponname;
.int w_dmg;
else this.alpha = 1;
Weapon wep = this.owner.(weaponentity).m_weapon;
- if (wep) this.glowmod = weaponentity_glowmod(wep, this.owner, this.owner.clientcolors);
+ if (wep) this.glowmod = weaponentity_glowmod(wep, this.owner, this.owner.clientcolors, this.owner.(weaponentity));
this.colormap = this.owner.colormap;
CSQCMODEL_AUTOUPDATE(this);
{
if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
bool ammo = false;
- if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
- else ammo = thiswep.wr_checkammo1(thiswep, actor);
+ if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
+ else ammo = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
if (thiswep == WEP_MINE_LAYER)
// check if the other firing mode has enough ammo
bool ammo_other = false;
- if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
- else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
+ if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor, weaponentity);
+ else ammo_other = thiswep.wr_checkammo2(thiswep, actor, weaponentity);
if (ammo_other)
{
if (time - actor.prevwarntime > 1)
{
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;
+ this.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)
{
}
// switch away if the amount of ammo is not enough to keep using this weapon
Weapon w = actor.(weaponentity).m_weapon;
- if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
+ if (!(w.wr_checkammo1(w, actor, weaponentity) + w.wr_checkammo2(w, actor, weaponentity)))
{
actor.clip_load = -1; // reload later
W_SwitchToOtherWeapon(actor, weaponentity);
actor.clip_load = actor.(weapon_load[actor.(weaponentity).m_weapon.m_id]) = -1;
}
-void W_DropEvent(.void(Weapon, entity actor) event, entity player, float weapon_type, entity weapon_item)
+void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
{
Weapon w = Weapons_from(weapon_type);
weapon_dropevent_item = weapon_item;
- w.event(w, player);
+ w.event(w, player, weaponentity);
}