From: TimePath Date: Thu, 1 Oct 2015 23:57:06 +0000 (+1000) Subject: Weapons: remove many direct references to `self` X-Git-Tag: xonotic-v0.8.2~1874^2~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2db2e01c23ba8f4db932a3336abb14edc759d062;p=xonotic%2Fxonotic-data.pk3dir.git Weapons: remove many direct references to `self` --- diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index f7ec01408..0ae830c1e 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -40,21 +40,20 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike)); void M_Mage_Attack_Spike(vector dir); void M_Mage_Attack_Push(); -METHOD(MageSpike, wr_think, void(MageSpike thiswep, bool fire1, bool fire2)) { - SELFPARAM(); +METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bool fire2)) { if (fire1) - if (!IS_PLAYER(self) || weapon_prepareattack(false, 0.2)) { - if (!self.target_range) self.target_range = autocvar_g_monsters_target_range; - self.enemy = Monster_FindTarget(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - if (!IS_PLAYER(self)) w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin); + if (!IS_PLAYER(actor) || weapon_prepareattack(actor, false, 0.2)) { + if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range; + actor.enemy = Monster_FindTarget(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + if (!IS_PLAYER(actor)) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Mage_Attack_Spike(w_shotdir); - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); } if (fire2) - if (!IS_PLAYER(self) || weapon_prepareattack(true, 0.5)) { + if (!IS_PLAYER(actor) || weapon_prepareattack(actor, true, 0.5)) { M_Mage_Attack_Push(); - weapon_thinkf(WFRAME_FIRE2, 0, w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready); } } @@ -361,7 +360,7 @@ float M_Mage_Attack(float attack_type, entity targ) if(random() <= 0.7) { Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, false, true); + wep.wr_think(wep, self, false, true); return true; } @@ -383,7 +382,7 @@ float M_Mage_Attack(float attack_type, entity targ) self.attack_finished_single = time + (autocvar_g_monster_mage_attack_spike_delay); self.anim_finished = time + 1; Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, true, false); + wep.wr_think(wep, self, true, false); return true; } } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index c305ec668..b3ebeeac6 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -50,32 +50,31 @@ float autocvar_g_monster_spider_attack_bite_delay; void M_Spider_Attack_Web(); -METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if ((!isPlayer && time >= self.spider_web_delay) || weapon_prepareattack(false, autocvar_g_monster_spider_attack_web_delay)) { + if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(actor, false, autocvar_g_monster_spider_attack_web_delay)) { if (!isPlayer) { - self.spider_web_delay = time + 3; - setanim(self, self.anim_shoot, true, true, true); - self.attack_finished_single = time + (autocvar_g_monster_spider_attack_web_delay); - self.anim_finished = time + 1; + actor.spider_web_delay = time + 3; + setanim(actor, actor.anim_shoot, true, true, true); + actor.attack_finished_single = time + (autocvar_g_monster_spider_attack_web_delay); + actor.anim_finished = time + 1; } - if (isPlayer) self.enemy = Monster_FindTarget(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - if (!isPlayer) w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin); + if (isPlayer) actor.enemy = Monster_FindTarget(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + if (!isPlayer) w_shotdir = normalize((actor.enemy.origin + '0 0 10') - actor.origin); M_Spider_Attack_Web(); - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); return; } if (fire2) - if (!isPlayer || weapon_prepareattack(true, 0.5)) { + if (!isPlayer || weapon_prepareattack(actor, true, 0.5)) { if (isPlayer) { - self.enemy = Monster_FindTarget(self); - self.attack_range = 60; + actor.enemy = Monster_FindTarget(actor); + actor.attack_range = 60; } - Monster_Attack_Melee(self.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER, true); - weapon_thinkf(WFRAME_FIRE2, 0, w_ready); + Monster_Attack_Melee(actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER, true); + weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready); } } @@ -159,12 +158,12 @@ bool M_Spider_Attack(int attack_type, entity targ) Weapon wep = WEP_SPIDER_ATTACK; case MONSTER_ATTACK_MELEE: { - wep.wr_think(wep, false, true); + wep.wr_think(wep, self, false, true); return true; } case MONSTER_ATTACK_RANGED: { - wep.wr_think(wep, true, false); + wep.wr_think(wep, self, true, false); return true; } } diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index c74067a4e..74449c715 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -48,25 +48,23 @@ float autocvar_g_monster_wyvern_attack_fireball_speed; void M_Wyvern_Attack_Fireball_Explode(); void M_Wyvern_Attack_Fireball_Touch(); -METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - +METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) { if (fire1) - if (time > self.attack_finished_single || weapon_prepareattack(false, 1.2)) { - if (IS_PLAYER(self)) W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - if (IS_MONSTER(self)) { - self.attack_finished_single = time + 1.2; - self.anim_finished = time + 1.2; - monster_makevectors(self.enemy); + if (time > actor.attack_finished_single || weapon_prepareattack(actor, false, 1.2)) { + if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + if (IS_MONSTER(actor)) { + actor.attack_finished_single = time + 1.2; + actor.anim_finished = time + 1.2; + monster_makevectors(actor.enemy); } entity missile = spawn(); - missile.owner = missile.realowner = self; + missile.owner = missile.realowner = actor; missile.solid = SOLID_TRIGGER; missile.movetype = MOVETYPE_FLYMISSILE; missile.projectiledeathtype = DEATH_MONSTER_WYVERN; setsize(missile, '-6 -6 -6', '6 6 6'); - setorigin(missile, self.origin + self.view_ofs + v_forward * 14); + setorigin(missile, actor.origin + actor.view_ofs + v_forward * 14); missile.flags = FL_PROJECTILE; missile.velocity = w_shotdir * (autocvar_g_monster_wyvern_attack_fireball_speed); missile.avelocity = '300 300 300'; @@ -75,7 +73,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, bool fire1, bool fire2 missile.touch = M_Wyvern_Attack_Fireball_Touch; CSQCProjectile(missile, true, PROJECTILE_FIREMINE, true); - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); } } @@ -130,7 +128,7 @@ float M_Wyvern_Attack(float attack_type, entity targ) { w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin); Weapon wep = WEP_WYVERN_ATTACK; - wep.wr_think(wep, true, false); + wep.wr_think(wep, self, true, false); return true; } } diff --git a/qcsrc/common/turrets/turret.qh b/qcsrc/common/turrets/turret.qh index edf1d5b57..8862f47d7 100644 --- a/qcsrc/common/turrets/turret.qh +++ b/qcsrc/common/turrets/turret.qh @@ -46,7 +46,7 @@ CLASS(Turret, Object) /** (SERVER) called when turret attacks */ METHOD(Turret, tr_attack, void(Turret this)) { Weapon w = this.m_weapon; - w.wr_think(w, true, false); + w.wr_think(w, self, true, false); } /** (ALL) */ METHOD(Turret, tr_config, void(Turret this)) { diff --git a/qcsrc/common/turrets/turret/ewheel_weapon.qc b/qcsrc/common/turrets/turret/ewheel_weapon.qc index 377c8a4f4..13ca1e11a 100644 --- a/qcsrc/common/turrets/turret/ewheel_weapon.qc +++ b/qcsrc/common/turrets/turret/ewheel_weapon.qc @@ -16,32 +16,31 @@ REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack)); #ifdef SVQC void turret_initparams(entity); -METHOD(EWheelAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - turret_do_updates(self); + turret_do_updates(actor); entity missile = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, true, true); missile.missile_flags = MIF_SPLASH; - Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1); + Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); if (!isPlayer) { - self.tur_head.frame += 2; + actor.tur_head.frame += 2; - if (self.tur_head.frame > 3) - self.tur_head.frame = 0; + if (actor.tur_head.frame > 3) + actor.tur_head.frame = 0; } } } diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index 277df6e45..fd59b8d0c 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -16,19 +16,18 @@ REGISTER_WEAPON(FLAC, NEW(FlacAttack)); #ifdef SVQC void turret_flac_projectile_think_explode(); -METHOD(FlacAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - self.tur_impacttime = 10; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + actor.tur_impacttime = 10; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } turret_tag_fire_update(); @@ -36,13 +35,13 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { entity proj = turret_projectile(SND(HAGAR_FIRE), 5, 0, DEATH_TURRET_FLAC, PROJECTILE_HAGAR, true, true); proj.missile_flags = MIF_SPLASH | MIF_PROXY; proj.think = turret_flac_projectile_think_explode; - proj.nextthink = time + self.tur_impacttime + (random() * 0.01 - random() * 0.01); - Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1); + proj.nextthink = time + actor.tur_impacttime + (random() * 0.01 - random() * 0.01); + Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); if (!isPlayer) { - self.tur_head.frame = self.tur_head.frame + 1; - if (self.tur_head.frame >= 4) - self.tur_head.frame = 0; + actor.tur_head.frame = actor.tur_head.frame + 1; + if (actor.tur_head.frame >= 4) + actor.tur_head.frame = 0; } } } diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 0556c6600..6e76f27fe 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -19,25 +19,24 @@ float autocvar_g_turrets_unit_hellion_shot_speed_gain; float autocvar_g_turrets_unit_hellion_shot_speed_max; void turret_hellion_missile_think(); -METHOD(HellionAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - self.shot_radius = 500; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + actor.shot_radius = 500; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } if (!isPlayer) { - if (self.tur_head.frame != 0) - self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire")); + if (actor.tur_head.frame != 0) + actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire")); else - self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire2")); + actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2")); } entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HELLION, PROJECTILE_ROCKET, FALSE, FALSE); @@ -48,7 +47,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { missile.max_health = time + 9; missile.tur_aimpos = randomvec() * 128; missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_HEAT; - if (!isPlayer) self.tur_head.frame += 1; + if (!isPlayer) actor.tur_head.frame += 1; } } diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index 3678c9628..313b0f193 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -23,19 +23,18 @@ float autocvar_g_turrets_unit_hk_shot_speed_max; float autocvar_g_turrets_unit_hk_shot_speed_turnrate; void turret_hk_missile_think(); -METHOD(HunterKillerAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) +METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_HK, PROJECTILE_ROCKET, FALSE, FALSE); te_explosion (missile.origin); @@ -43,15 +42,15 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, bool fire1, bool fire2 missile.think = turret_hk_missile_think; missile.nextthink = time + 0.25; missile.movetype = MOVETYPE_BOUNCEMISSILE; - missile.velocity = self.tur_shotdir_updated * (self.shot_speed * 0.75); + missile.velocity = actor.tur_shotdir_updated * (actor.shot_speed * 0.75); missile.angles = vectoangles(missile.velocity); missile.cnt = time + 30; missile.ticrate = max(autocvar_sys_ticrate, 0.05); missile.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_GUIDED_AI; if (!isPlayer) - if (self.tur_head.frame == 0) - self.tur_head.frame = self.tur_head.frame + 1; + if (actor.tur_head.frame == 0) + actor.tur_head.frame = actor.tur_head.frame + 1; } } diff --git a/qcsrc/common/turrets/turret/machinegun_weapon.qc b/qcsrc/common/turrets/turret/machinegun_weapon.qc index b467187ba..d8993a3ed 100644 --- a/qcsrc/common/turrets/turret/machinegun_weapon.qc +++ b/qcsrc/common/turrets/turret/machinegun_weapon.qc @@ -17,23 +17,22 @@ REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack)); void W_MachineGun_MuzzleFlash(); -METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) +METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR(machinegun, sustained_refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); } - fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0); + fireBullet (actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN, 0); W_MachineGun_MuzzleFlash(); - setattachment(self.muzzle_flash, self.tur_head, "tag_fire"); + setattachment(actor.muzzle_flash, actor.tur_head, "tag_fire"); } } diff --git a/qcsrc/common/turrets/turret/mlrs_weapon.qc b/qcsrc/common/turrets/turret/mlrs_weapon.qc index 4e17d7531..bc9a94e91 100644 --- a/qcsrc/common/turrets/turret/mlrs_weapon.qc +++ b/qcsrc/common/turrets/turret/mlrs_weapon.qc @@ -15,24 +15,23 @@ REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack)); #ifdef SVQC -METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) +METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR(machinegun, sustained_refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - self.shot_radius = 500; - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + actor.shot_radius = 500; + weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); } turret_tag_fire_update(); entity missile = turret_projectile(SND(ROCKET_FIRE), 6, 10, DEATH_TURRET_MLRS, PROJECTILE_ROCKET, TRUE, TRUE); - missile.nextthink = time + max(self.tur_impacttime,(self.shot_radius * 2) / self.shot_speed); + missile.nextthink = time + max(actor.tur_impacttime,(actor.shot_radius * 2) / actor.shot_speed); missile.missile_flags = MIF_SPLASH; te_explosion (missile.origin); } diff --git a/qcsrc/common/turrets/turret/phaser_weapon.qc b/qcsrc/common/turrets/turret/phaser_weapon.qc index 5db0bbb27..e8e4f1428 100644 --- a/qcsrc/common/turrets/turret/phaser_weapon.qc +++ b/qcsrc/common/turrets/turret/phaser_weapon.qc @@ -18,20 +18,19 @@ void beam_think(); .int fireflag; -METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) +METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - self.shot_speed = 1; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + actor.shot_speed = 1; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } entity beam = spawn(); beam.ticrate = 0.1; //autocvar_sys_ticrate; @@ -39,28 +38,28 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2 beam.effects = EF_LOWPRECISION; beam.solid = SOLID_NOT; beam.think = beam_think; - beam.cnt = time + self.shot_speed; + beam.cnt = time + actor.shot_speed; beam.shot_spread = time + 2; beam.nextthink = time; - beam.owner = self; - beam.shot_dmg = self.shot_dmg / (self.shot_speed / beam.ticrate); - beam.scale = self.target_range / 256; + beam.owner = actor; + beam.shot_dmg = actor.shot_dmg / (actor.shot_speed / beam.ticrate); + beam.scale = actor.target_range / 256; beam.movetype = MOVETYPE_NONE; - beam.enemy = self.enemy; + beam.enemy = actor.enemy; beam.bot_dodge = true; beam.bot_dodgerating = beam.shot_dmg; sound (beam, CH_SHOTS_SINGLE, SND_TUR_PHASER, VOL_BASE, ATTEN_NORM); - self.fireflag = 1; + actor.fireflag = 1; - beam.attack_finished_single = self.attack_finished_single; - self.attack_finished_single = time; // + autocvar_sys_ticrate; + beam.attack_finished_single = actor.attack_finished_single; + actor.attack_finished_single = time; // + autocvar_sys_ticrate; - setattachment(beam,self.tur_head, "tag_fire"); + setattachment(beam,actor.tur_head, "tag_fire"); - soundat (self, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM); + soundat (actor, trace_endpos, CH_SHOTS, SND(NEXIMPACT), VOL_BASE, ATTEN_NORM); if (!isPlayer) - if (self.tur_head.frame == 0) - self.tur_head.frame = 1; + if (actor.tur_head.frame == 0) + actor.tur_head.frame = 1; } } diff --git a/qcsrc/common/turrets/turret/plasma_weapon.qc b/qcsrc/common/turrets/turret/plasma_weapon.qc index a7a23f452..cc58d6059 100644 --- a/qcsrc/common/turrets/turret/plasma_weapon.qc +++ b/qcsrc/common/turrets/turret/plasma_weapon.qc @@ -15,22 +15,21 @@ REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack)); #ifdef SVQC -METHOD(PlasmaAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } entity missile = turret_projectile(SND(HAGAR_FIRE), 1, 0, DEATH_TURRET_PLASMA, PROJECTILE_ELECTRO_BEAM, true, true); missile.missile_flags = MIF_SPLASH; - Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1); + Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); } } diff --git a/qcsrc/common/turrets/turret/tesla_weapon.qc b/qcsrc/common/turrets/turret/tesla_weapon.qc index 130bac0f3..c8e61f748 100644 --- a/qcsrc/common/turrets/turret/tesla_weapon.qc +++ b/qcsrc/common/turrets/turret/tesla_weapon.qc @@ -16,35 +16,34 @@ REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack)); #ifdef SVQC entity toast(entity from, float range, float damage); -METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - float d = self.shot_dmg; - float r = self.target_range; + float d = actor.shot_dmg; + float r = actor.target_range; entity e = spawn(); - setorigin(e,self.tur_shotorg); + setorigin(e,actor.tur_shotorg); - self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK; + actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK; entity t = toast(e,r,d); remove(e); if (t == NULL) return; - self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK; + actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK; - self.attack_finished_single = time + self.shot_refire; + actor.attack_finished_single = time + actor.shot_refire; for (int i = 0; i < 10; ++i) { d *= 0.75; r *= 0.85; diff --git a/qcsrc/common/turrets/turret/walker_weapon.qc b/qcsrc/common/turrets/turret/walker_weapon.qc index a557d7ff0..0a2039ba1 100644 --- a/qcsrc/common/turrets/turret/walker_weapon.qc +++ b/qcsrc/common/turrets/turret/walker_weapon.qc @@ -15,22 +15,21 @@ REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack)); #ifdef SVQC -METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); +METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); if (fire1) - if (!isPlayer || weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) { + if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { - turret_initparams(self); - W_SetupShot_Dir(self, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); - self.tur_shotdir_updated = w_shotdir; - self.tur_shotorg = w_shotorg; - self.tur_head = self; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + turret_initparams(actor); + W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0); + actor.tur_shotdir_updated = w_shotdir; + actor.tur_shotorg = w_shotorg; + actor.tur_head = actor; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - sound (self, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM); - fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0); - Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1); + sound (actor, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM); + fireBullet (actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_WALK_GUN, 0); + Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); } } diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 13891c5fc..e9211d545 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -322,7 +322,7 @@ float racer_frame() // Fix z-aim (for chase mode) crosshair_trace(player); w_shotdir.z = normalize(trace_endpos - org).z * 0.5; - wep1.wr_think(wep1, true, false); + wep1.wr_think(wep1, self, true, false); } if(autocvar_g_vehicle_racer_rocket_locktarget) diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index e201260f0..388564c98 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -42,15 +42,13 @@ float autocvar_g_vehicle_racer_rocket_climbspeed; float autocvar_g_vehicle_racer_rocket_locked_maxangle; void racer_fire_rocket(vector org, vector dir, entity trg); -METHOD(RacerAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) +METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - entity player = isPlayer ? self : self.owner; + bool isPlayer = IS_PLAYER(actor); + entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - setself(player); if (fire1) - if (weapon_prepareattack(false, autocvar_g_vehicle_racer_cannon_refire)) { + if (weapon_prepareattack(player, false, autocvar_g_vehicle_racer_cannon_refire)) { if (veh) { veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost; veh.wait = time; @@ -63,15 +61,14 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, bool fire1, bool fire2)) autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force, 0, DEATH_VH_WAKI_GUN, PROJECTILE_WAKICANNON, 0, true, true, player); bolt.velocity = normalize(dir) * autocvar_g_vehicle_racer_cannon_speed; - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready); } if (fire2) - if (!isPlayer || weapon_prepareattack(false, 0.2)) { - if (isPlayer) W_SetupShot_Dir(self, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0); + if (!isPlayer || weapon_prepareattack(actor, false, 0.2)) { + if (isPlayer) W_SetupShot_Dir(actor, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0); racer_fire_rocket(w_shotorg, w_shotdir, NULL); - weapon_thinkf(WFRAME_FIRE2, 0, w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready); } - setself(this); } METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep)) diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 5dcef76ad..cff7fe9cb 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -392,7 +392,7 @@ float raptor_frame() if(player.BUTTON_ATCK) if (wep1.wr_checkammo1(wep1)) { - wep1.wr_think(wep1, true, false); + wep1.wr_think(wep1, self, true, false); } if(self.vehicle_flags & VHF_SHIELDREGEN) @@ -411,7 +411,7 @@ float raptor_frame() if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire) if(player.BUTTON_ATCK2) { - wep2a.wr_think(wep2a, false, true); + wep2a.wr_think(wep2a, self, false, true); raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire; raptor.lip = time; } @@ -422,7 +422,7 @@ float raptor_frame() if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire) if(player.BUTTON_ATCK2) { - wep2b.wr_think(wep2b, false, true); + wep2b.wr_think(wep2b, self, false, true); raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire; raptor.lip = time; } diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 47c480c46..6e8748877 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -51,16 +51,14 @@ float autocvar_g_vehicle_raptor_bomblet_radius; float autocvar_g_vehicle_raptor_bomblet_force; float autocvar_g_vehicle_raptor_bomblet_explode_delay; -METHOD(RaptorCannon, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - entity player = isPlayer ? self : self.owner; +METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); + entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - setself(player); // 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait] float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4); if (fire1) - if (weapon_prepareattack(false, t)) { + if (weapon_prepareattack(player, false, t)) { if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0); vector org = w_shotorg; vector dir = w_shotdir; @@ -70,15 +68,14 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, bool fire1, bool fire2)) { : (((veh.misc_bulletcounter == 4) ? veh.misc_bulletcounter = 0 : 0), gettaginfo(veh.gun2, gettagindex(veh.gun2, "fire1"))); dir = v_forward; veh.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost; - self.cnt = time; + actor.cnt = time; } vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND(LASERGUN_FIRE), org, normalize(dir + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed, autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force, 0, DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, true, true, veh ? veh : player); - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready); } - setself(this); } METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) { SELFPARAM(); @@ -91,19 +88,16 @@ METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) { float autocvar_g_vehicle_raptor_bombs_refire; void raptor_bombdrop(); -METHOD(RaptorBomb, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - entity player = isPlayer ? self : self.owner; +METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); + entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - setself(player); if (fire2) - if (weapon_prepareattack(false, autocvar_g_vehicle_raptor_bombs_refire)) { + if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_bombs_refire)) { if (veh) setself(veh); raptor_bombdrop(); - weapon_thinkf(WFRAME_FIRE1, 0, w_ready); + weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready); } - setself(this); } float autocvar_g_vehicle_raptor_flare_refire; @@ -115,23 +109,21 @@ void raptor_flare_think(); void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); void raptor_flare_touch(); -METHOD(RaptorFlare, wr_think, void(entity thiswep, bool fire1, bool fire2)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - entity player = isPlayer ? self : self.owner; +METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { + bool isPlayer = IS_PLAYER(actor); + entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - setself(player); if (fire2) - if (weapon_prepareattack(true, autocvar_g_vehicle_raptor_flare_refire)) { + if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_flare_refire)) { for(int i = 0; i < 3; ++i) { entity _flare = spawn(); setmodel(_flare, MDL_VEH_RAPTOR_FLARE); _flare.effects = EF_LOWPRECISION | EF_FLAME; _flare.scale = 0.5; - setorigin(_flare, self.origin - '0 0 16'); + setorigin(_flare, actor.origin - '0 0 16'); _flare.movetype = MOVETYPE_TOSS; _flare.gravity = 0.15; - _flare.velocity = 0.25 * self.velocity + (v_forward + randomvec() * 0.25)* -500; + _flare.velocity = 0.25 * actor.velocity + (v_forward + randomvec() * 0.25)* -500; _flare.think = raptor_flare_think; _flare.nextthink = time; _flare.owner = veh ? veh : player; @@ -142,9 +134,8 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, bool fire1, bool fire2)) { _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime; _flare.touch = raptor_flare_touch; } - weapon_thinkf(WFRAME_FIRE2, 0, w_ready); + weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready); } - setself(this); } diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 718272adf..bba894cb6 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -49,7 +49,7 @@ CLASS(Weapon, Object) /** (SERVER) setup weapon data */ METHOD(Weapon, wr_setup, void(Weapon this)) {} /** (SERVER) logic to run every frame */ - METHOD(Weapon, wr_think, void(Weapon this, bool fire1, bool fire2)) {} + METHOD(Weapon, wr_think, void(Weapon this, entity actor, bool fire1, bool fire2)) {} /** (SERVER) checks ammo for weapon primary */ METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;} /** (SERVER) checks ammo for weapon second */ diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 36ba74e2c..b3fe1b1ef 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -656,36 +656,35 @@ void Arc_Smoke() ); } } - METHOD(Arc, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Arc, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - Arc_Player_SetHeat(self); + Arc_Player_SetHeat(actor); Arc_Smoke(); - if (time >= self.arc_overheat) - if (fire1 || fire2 || self.arc_beam.beam_bursting) + if (time >= actor.arc_overheat) + if (fire1 || fire2 || actor.arc_beam.beam_bursting) { - if(self.arc_BUTTON_ATCK_prev) + if(actor.arc_BUTTON_ATCK_prev) { #if 0 - if(self.animstate_startframe == self.anim_shoot.x && self.animstate_numframes == self.anim_shoot.y) - weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready); + if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y) + weapon_thinkf(actor, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready); else #endif - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); } - if((!self.arc_beam) || wasfreed(self.arc_beam)) + if((!actor.arc_beam) || wasfreed(actor.arc_beam)) { - if(weapon_prepareattack(fire2, 0)) + if(weapon_prepareattack(actor, fire2, 0)) { W_Arc_Beam(fire2); - if(!self.arc_BUTTON_ATCK_prev) + if(!actor.arc_BUTTON_ATCK_prev) { - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - self.arc_BUTTON_ATCK_prev = true; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); + actor.arc_BUTTON_ATCK_prev = true; } } } @@ -693,22 +692,22 @@ void Arc_Smoke() return; } - if(self.arc_BUTTON_ATCK_prev) + if(actor.arc_BUTTON_ATCK_prev) { - sound(self, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(); + sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); + ATTACK_FINISHED(actor) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(); } - self.arc_BUTTON_ATCK_prev = false; + actor.arc_BUTTON_ATCK_prev = false; #if 0 if(fire2) - if(weapon_prepareattack(true, autocvar_g_balance_arc_secondary_refire)) + if(weapon_prepareattack(actor, true, autocvar_g_balance_arc_secondary_refire)) { W_Arc_Attack2(); - self.arc_count = autocvar_g_balance_arc_secondary_count; - weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack); - self.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(); + actor.arc_count = autocvar_g_balance_arc_secondary_count; + weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack); + actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(); } #endif } diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 699f8f1d9..32310d033 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -84,6 +84,7 @@ void W_Blaster_Think(void) } void W_Blaster_Attack( + entity actor, float atk_deathtype, float atk_shotangle, float atk_damage, @@ -97,11 +98,11 @@ void W_Blaster_Attack( {SELFPARAM(); vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD); - W_SetupShot_Dir(self, s_forward, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, atk_damage); + W_SetupShot_Dir(actor, s_forward, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, atk_damage); Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); entity missile = spawn(); - missile.owner = missile.realowner = self; + missile.owner = missile.realowner = actor; missile.classname = "blasterbolt"; missile.bot_dodge = true; missile.bot_dodgerating = atk_damage; @@ -139,9 +140,9 @@ void W_Blaster_Attack( missile.think = W_Blaster_Think; missile.nextthink = time + atk_delay; - MUTATOR_CALLHOOK(EditProjectile, self, missile); + MUTATOR_CALLHOOK(EditProjectile, actor, missile); - if(time >= missile.nextthink) + if (time >= missile.nextthink) { WITH(entity, self, missile, missile.think()); } @@ -160,13 +161,14 @@ void W_Blaster_Attack( { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } } - METHOD(Blaster, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, bool fire1, bool fire2)) { if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(blaster, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(blaster, refire))) { W_Blaster_Attack( + actor, WEP_BLASTER.m_id, WEP_CVAR_PRI(blaster, shotangle), WEP_CVAR_PRI(blaster, damage), @@ -178,7 +180,7 @@ void W_Blaster_Attack( WEP_CVAR_PRI(blaster, delay), WEP_CVAR_PRI(blaster, lifetime) ); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready); } } else if(fire2) @@ -187,16 +189,17 @@ void W_Blaster_Attack( { case 0: // switch to last used weapon { - if(self.switchweapon == WEP_BLASTER.m_id) // don't do this if already switching + if(actor.switchweapon == WEP_BLASTER.m_id) // don't do this if already switching W_LastWeapon(); break; } case 1: // normal projectile secondary { - if(weapon_prepareattack(true, WEP_CVAR_SEC(blaster, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(blaster, refire))) { W_Blaster_Attack( + actor, WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(blaster, shotangle), WEP_CVAR_SEC(blaster, damage), @@ -208,7 +211,7 @@ void W_Blaster_Attack( WEP_CVAR_SEC(blaster, delay), WEP_CVAR_SEC(blaster, lifetime) ); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(blaster, animtime), w_ready); } break; diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 229580562..0ed21c80f 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -349,7 +349,7 @@ void W_Crylink_Attack(Weapon thiswep) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(crylink, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(crylink, ammo)); maxdmg = WEP_CVAR_PRI(crylink, damage) * WEP_CVAR_PRI(crylink, shots); maxdmg *= 1 + WEP_CVAR_PRI(crylink, bouncedamagefactor) * WEP_CVAR_PRI(crylink, bounces); @@ -458,7 +458,7 @@ void W_Crylink_Attack2(Weapon thiswep) vector forward, right, up; float maxdmg; - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(crylink, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(crylink, ammo)); maxdmg = WEP_CVAR_SEC(crylink, damage) * WEP_CVAR_SEC(crylink, shots); maxdmg *= 1 + WEP_CVAR_SEC(crylink, bouncedamagefactor) * WEP_CVAR_SEC(crylink, bounces); @@ -574,61 +574,60 @@ void W_Crylink_Attack2(Weapon thiswep) else self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); } - METHOD(Crylink, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Crylink, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); - if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } if(fire1) { - if(self.crylink_waitrelease != 1) - if(weapon_prepareattack(false, WEP_CVAR_PRI(crylink, refire))) + if(actor.crylink_waitrelease != 1) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(crylink, refire))) { W_Crylink_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready); } } if(fire2 && autocvar_g_balance_crylink_secondary) { - if(self.crylink_waitrelease != 2) - if(weapon_prepareattack(true, WEP_CVAR_SEC(crylink, refire))) + if(actor.crylink_waitrelease != 2) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(crylink, refire))) { W_Crylink_Attack2(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready); } } - if((self.crylink_waitrelease == 1 && !fire1) || (self.crylink_waitrelease == 2 && !fire2)) + if((actor.crylink_waitrelease == 1 && !fire1) || (actor.crylink_waitrelease == 2 && !fire2)) { - if(!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time) + if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time) { // fired and released now! - if(self.crylink_lastgroup) + if(actor.crylink_lastgroup) { vector pos; entity linkjoineffect; - float isprimary = (self.crylink_waitrelease == 1); + float isprimary = (actor.crylink_waitrelease == 1); - pos = W_Crylink_LinkJoin(self.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed)); + pos = W_Crylink_LinkJoin(actor.crylink_lastgroup, WEP_CVAR_BOTH(crylink, isprimary, joinspread) * WEP_CVAR_BOTH(crylink, isprimary, speed)); linkjoineffect = spawn(); linkjoineffect.think = W_Crylink_LinkJoinEffect_Think; linkjoineffect.classname = "linkjoineffect"; linkjoineffect.nextthink = time + w_crylink_linkjoin_time; - linkjoineffect.owner = self; + linkjoineffect.owner = actor; setorigin(linkjoineffect, pos); } - self.crylink_waitrelease = 0; + actor.crylink_waitrelease = 0; if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { // ran out of ammo! - self.cnt = WEP_CRYLINK.m_id; - self.switchweapon = w_getbestweapon(self); + actor.cnt = WEP_CRYLINK.m_id; + actor.switchweapon = w_getbestweapon(actor); } } } @@ -665,7 +664,7 @@ void W_Crylink_Attack2(Weapon thiswep) } METHOD(Crylink, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND(RELOAD)); } METHOD(Crylink, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 130eb88b0..3e142d5ec 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -342,7 +342,7 @@ void W_Devastator_Attack(Weapon thiswep) entity missile; entity flash; - W_DecreaseAmmo(thiswep, WEP_CVAR(devastator, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(devastator, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 5, SND(ROCKET_FIRE), CH_WEAPON_A, WEP_CVAR(devastator, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -388,7 +388,7 @@ void W_Devastator_Attack(Weapon thiswep) setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below SUB_SetFade(flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(flash, '5 0 0'); + W_AttachToShotorg(self, flash, '5 0 0'); // common properties MUTATOR_CALLHOOK(EditProjectile, self, missile); @@ -518,32 +518,31 @@ void W_Devastator_Attack(Weapon thiswep) } } #endif - METHOD(Devastator, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Devastator, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(devastator, reload_ammo) && self.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else - { + } else { if(fire1) { - if(self.rl_release || WEP_CVAR(devastator, guidestop)) - if(weapon_prepareattack(false, WEP_CVAR(devastator, refire))) + if(actor.rl_release || WEP_CVAR(devastator, guidestop)) + if(weapon_prepareattack(actor, false, WEP_CVAR(devastator, refire))) { W_Devastator_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); - self.rl_release = 0; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); + actor.rl_release = 0; } } else - self.rl_release = 1; + actor.rl_release = 1; if(fire2) - if(self.switchweapon == WEP_DEVASTATOR.m_id) + if(actor.switchweapon == WEP_DEVASTATOR.m_id) { entity rock; bool rockfound = false; - for(rock = world; (rock = find(rock, classname, "rocket")); ) if(rock.realowner == self) + for(rock = world; (rock = find(rock, classname, "rocket")); ) if(rock.realowner == actor) { if(!rock.rl_detonate_later) { @@ -552,7 +551,7 @@ void W_Devastator_Attack(Weapon thiswep) } } if(rockfound) - sound(self, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); + sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); } } } @@ -614,7 +613,7 @@ void W_Devastator_Attack(Weapon thiswep) } METHOD(Devastator, wr_reload, void(entity thiswep)) { - W_Reload(WEP_CVAR(devastator, ammo), SND(RELOAD)); + W_Reload(self, WEP_CVAR(devastator, ammo), SND(RELOAD)); } METHOD(Devastator, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 14f24e876..b15563225 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -249,7 +249,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep) {SELFPARAM(); entity proj; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(electro, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -347,7 +347,7 @@ void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int d void W_Electro_Attack_Orb(Weapon thiswep) {SELFPARAM(); - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(electro, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(electro, ammo)); W_SetupShot_ProjectileSize( self, @@ -406,19 +406,19 @@ void W_Electro_Attack_Orb(Weapon thiswep) MUTATOR_CALLHOOK(EditProjectile, self, proj); } -void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2) +void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) {SELFPARAM(); if(self.electro_count > 1) if(self.BUTTON_ATCK2) - if(weapon_prepareattack(true, -1)) + if(weapon_prepareattack(actor, true, -1)) { W_Electro_Attack_Orb(WEP_ELECTRO); self.electro_count -= 1; - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); return; } // WEAPONTODO: when the player releases the button, cut down the length of refire2? - w_ready(thiswep, fire1, fire2); + w_ready(thiswep, actor, fire1, fire2); } .float bot_secondary_electromooth; @@ -451,19 +451,19 @@ void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2) } } } - METHOD(Electro, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Electro, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO { float ammo_amount = 0; - if(self.clip_load >= WEP_CVAR_PRI(electro, ammo)) + if(actor.clip_load >= WEP_CVAR_PRI(electro, ammo)) ammo_amount = 1; - if(self.clip_load >= WEP_CVAR_SEC(electro, ammo)) + if(actor.clip_load >= WEP_CVAR_SEC(electro, ammo)) ammo_amount += 1; if(!ammo_amount) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); return; } @@ -471,21 +471,21 @@ void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2) if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(electro, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) { W_Electro_Attack_Bolt(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } } else if(fire2) { - if(time >= self.electro_secondarytime) - if(weapon_prepareattack(true, WEP_CVAR_SEC(electro, refire))) + if(time >= actor.electro_secondarytime) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(electro, refire))) { W_Electro_Attack_Orb(thiswep); - self.electro_count = WEP_CVAR_SEC(electro, count); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); - self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); + actor.electro_count = WEP_CVAR_SEC(electro, count); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); + actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); } } } @@ -524,7 +524,7 @@ void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2) } METHOD(Electro, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD)); } METHOD(Electro, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 9a292c5dd..fd10eb2e1 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -226,35 +226,35 @@ void W_Fireball_AttackEffect(float i, vector f_diff) Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); } -void W_Fireball_Attack1_Frame4(Weapon thiswep, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, bool fire1, bool fire2) { W_Fireball_Attack1(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready); } -void W_Fireball_Attack1_Frame3(Weapon thiswep, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, bool fire1, bool fire2) { W_Fireball_AttackEffect(0, '+1.25 +3.75 0'); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4); } -void W_Fireball_Attack1_Frame2(Weapon thiswep, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2) { W_Fireball_AttackEffect(0, '-1.25 +3.75 0'); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3); } -void W_Fireball_Attack1_Frame1(Weapon thiswep, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2) { W_Fireball_AttackEffect(1, '+1.25 -3.75 0'); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2); } -void W_Fireball_Attack1_Frame0(Weapon thiswep, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, bool fire1, bool fire2) {SELFPARAM(); W_Fireball_AttackEffect(0, '-1.25 -3.75 0'); sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1); } void W_Fireball_Firemine_Think(void) @@ -371,23 +371,23 @@ void W_Fireball_Attack2(void) } } } - METHOD(Fireball, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Fireball, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { if(fire1) { - if(time >= self.fireball_primarytime) - if(weapon_prepareattack(false, WEP_CVAR_PRI(fireball, refire))) + if(time >= actor.fireball_primarytime) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(fireball, refire))) { - W_Fireball_Attack1_Frame0(thiswep, fire1, fire2); - self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(); + W_Fireball_Attack1_Frame0(thiswep, actor, fire1, fire2); + actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(); } } else if(fire2) { - if(weapon_prepareattack(true, WEP_CVAR_SEC(fireball, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(fireball, refire))) { W_Fireball_Attack2(); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready); } } } diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 3feeb0b32..af62d534d 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -127,7 +127,7 @@ void W_Hagar_Attack(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hagar, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(hagar, ammo)); W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage)); @@ -170,7 +170,7 @@ void W_Hagar_Attack2(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo)); W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); @@ -223,7 +223,7 @@ void W_Hagar_Attack2_Load_Release(void) if(!self.hagar_load) return; - weapon_prepareattack_do(true, WEP_CVAR_SEC(hagar, refire)); + weapon_prepareattack_do(self, true, WEP_CVAR_SEC(hagar, refire)); W_SetupShot(self, false, 2, SND(HAGAR_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage)); Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -286,7 +286,7 @@ void W_Hagar_Attack2_Load_Release(void) MUTATOR_CALLHOOK(EditProjectile, self, missile); } - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready); + weapon_thinkf(self, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready); self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(); self.hagar_load = 0; } @@ -319,7 +319,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) { // if we pressed primary fire while loading, unload all rockets and abort self.weaponentity.state = WS_READY; - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo self.hagar_load = 0; sound(self, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM); @@ -337,7 +337,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) { if(!self.hagar_loadblock && self.hagar_loadstep < time) { - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo)); self.weaponentity.state = WS_INUSE; self.hagar_load += 1; sound(self, CH_WEAPON_B, SND_HAGAR_LOAD, VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most @@ -407,30 +407,30 @@ void W_Hagar_Attack2_Load(Weapon thiswep) else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); } - METHOD(Hagar, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Hagar, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { float loadable_secondary; loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary)); if(loadable_secondary) W_Hagar_Attack2_Load(thiswep); // must always run each frame - if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(fire1 && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset + } else if(fire1 && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset { - if(weapon_prepareattack(false, WEP_CVAR_PRI(hagar, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hagar, refire))) { W_Hagar_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready); } } else if(fire2 && !loadable_secondary && WEP_CVAR(hagar, secondary)) { - if(weapon_prepareattack(true, WEP_CVAR_SEC(hagar, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hagar, refire))) { W_Hagar_Attack2(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready); } } } @@ -453,7 +453,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) if(self.hagar_load) { - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary self.hagar_load = 0; } } @@ -486,7 +486,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) METHOD(Hagar, wr_reload, void(entity thiswep)) { if(!self.hagar_load) // require releasing loaded rockets first - W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND(RELOAD)); } METHOD(Hagar, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index fe1a04f26..5b61dddf9 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -72,7 +72,7 @@ void W_HLAC_Attack(Weapon thiswep) entity missile; float spread; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hlac, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(hlac, ammo)); spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter); spread = min(spread,WEP_CVAR_PRI(hlac, spread_max)); @@ -161,33 +161,33 @@ void W_HLAC_Attack2(void) } // weapon frames -void W_HLAC_Attack_Frame(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - if(self.weapon != self.switchweapon) // abort immediately if switching +void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + if(actor.weapon != actor.switchweapon) // abort immediately if switching { - w_ready(thiswep, fire1, fire2); + w_ready(thiswep, actor, fire1, fire2); return; } - if(self.BUTTON_ATCK) + if(actor.BUTTON_ATCK) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if(!w.wr_checkammo1(w)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(); W_HLAC_Attack(WEP_HLAC); - self.misc_bulletcounter = self.misc_bulletcounter + 1; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); + actor.misc_bulletcounter = actor.misc_bulletcounter + 1; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } else { - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, animtime), w_ready); } } @@ -195,7 +195,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) {SELFPARAM(); float i; - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hlac, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hlac, ammo)); for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i) W_HLAC_Attack2(); @@ -211,27 +211,27 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false); } - METHOD(HLAC, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(HLAC, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(hlac, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hlac, refire))) { - self.misc_bulletcounter = 0; + actor.misc_bulletcounter = 0; W_HLAC_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } } else if(fire2 && WEP_CVAR(hlac, secondary)) { - if(weapon_prepareattack(true, WEP_CVAR_SEC(hlac, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hlac, refire))) { W_HLAC_Attack2_Frame(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready); } } } @@ -257,7 +257,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) } METHOD(HLAC, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), SND(RELOAD)); } METHOD(HLAC, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index 1ed33f8b1..e9ddfb4f7 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -45,48 +45,48 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); } -void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - if (!self.BUTTON_ATCK) +void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + if (!actor.BUTTON_ATCK) { - w_ready(thiswep, fire1, fire2); + w_ready(thiswep, actor, fire1, fire2); return; } - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if(!w.wr_checkammo1(w)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - W_DecreaseAmmo(WEP_HMG, WEP_CVAR(hmg, ammo)); + W_DecreaseAmmo(WEP_HMG, self, WEP_CVAR(hmg, ammo)); - W_SetupShot (self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(hmg, damage)); + W_SetupShot (actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(hmg, damage)); if(!autocvar_g_norecoil) { - self.punchangle_x = random () - 0.5; - self.punchangle_y = random () - 0.5; + actor.punchangle_x = random () - 0.5; + actor.punchangle_y = random () - 0.5; } - float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * self.misc_bulletcounter), WEP_CVAR(hmg, spread_max)); + float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * actor.misc_bulletcounter), WEP_CVAR(hmg, spread_max)); fireBullet(w_shotorg, w_shotdir, hmg_spread, WEP_CVAR(hmg, solidpenetration), WEP_CVAR(hmg, damage), WEP_CVAR(hmg, force), WEP_HMG.m_id, 0); - self.misc_bulletcounter = self.misc_bulletcounter + 1; + actor.misc_bulletcounter = actor.misc_bulletcounter + 1; Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); W_MachineGun_MuzzleFlash(); - W_AttachToShotorg(self.muzzle_flash, '5 0 0'); + W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); if (autocvar_g_casings >= 2) // casing code - SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self); + SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); - ATTACK_FINISHED(self) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto); + ATTACK_FINISHED(actor) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto); } METHOD(HeavyMachineGun, wr_aim, void(entity thiswep)) @@ -96,18 +96,18 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) else self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); } - METHOD(HeavyMachineGun, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(hmg, reload_ammo) && self.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { if (fire1) - if (weapon_prepareattack(false, 0)) + if (weapon_prepareattack(actor, false, 0)) { - self.misc_bulletcounter = 0; - W_HeavyMachineGun_Attack_Auto(thiswep, fire1, fire2); + actor.misc_bulletcounter = 0; + W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2); } } } @@ -139,7 +139,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) } METHOD(HeavyMachineGun, wr_reload, void(entity thiswep)) { - W_Reload(WEP_CVAR(hmg, ammo), SND(RELOAD)); + W_Reload(self, WEP_CVAR(hmg, ammo), SND(RELOAD)); } METHOD(HeavyMachineGun, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index fdb98a0cc..ffee55dd2 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -21,7 +21,7 @@ CLASS(OffhandHook, OffhandWeapon) METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity player, bool key_pressed)) { Weapon wep = WEP_HOOK; - WITH(entity, self, player, wep.wr_think(wep, key_pressed, false)); + WITH(entity, self, player, wep.wr_think(wep, self, key_pressed, false)); } ENDCLASS(OffhandHook) OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); } @@ -135,7 +135,7 @@ void W_Hook_Attack2(Weapon thiswep) {SELFPARAM(); entity gren; - //W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) + //W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb) W_SetupShot(self, false, 4, SND(HOOKBOMB_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); gren = spawn(); @@ -176,68 +176,68 @@ void W_Hook_Attack2(Weapon thiswep) MUTATOR_CALLHOOK(EditProjectile, self, gren); } - METHOD(Hook, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(fire1 || self.BUTTON_HOOK) + if(fire1 || actor.BUTTON_HOOK) { - if(!self.hook) - if(!(self.hook_state & HOOK_WAITING_FOR_RELEASE)) - if(!(self.hook_state & HOOK_FIRING)) - if(time > self.hook_refire) - if(weapon_prepareattack(false, -1)) + if(!actor.hook) + if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE)) + if(!(actor.hook_state & HOOK_FIRING)) + if(time > actor.hook_refire) + if(weapon_prepareattack(actor, false, -1)) { - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(hook, ammo)); - self.hook_state |= HOOK_FIRING; - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hook, ammo)); + actor.hook_state |= HOOK_FIRING; + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready); } } if(fire2) { - if(weapon_prepareattack(true, WEP_CVAR_SEC(hook, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hook, refire))) { W_Hook_Attack2(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready); } } - if(self.hook) + if(actor.hook) { // if hooked, no bombs, and increase the timer - self.hook_refire = max(self.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor()); + actor.hook_refire = max(actor.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor()); // hook also inhibits health regeneration, but only for 1 second - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) - self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen); + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) + actor.pauseregen_finished = max(actor.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen); } - if(self.hook && self.hook.state == 1) + if(actor.hook && actor.hook.state == 1) { float hooked_time_max = WEP_CVAR_PRI(hook, hooked_time_max); if(hooked_time_max > 0) { - if( time > self.hook_time_hooked + hooked_time_max ) - self.hook_state |= HOOK_REMOVING; + if( time > actor.hook_time_hooked + hooked_time_max ) + actor.hook_state |= HOOK_REMOVING; } float hooked_fuel = WEP_CVAR_PRI(hook, hooked_ammo); if(hooked_fuel > 0) { - if( time > self.hook_time_fueldecrease ) + if( time > actor.hook_time_fueldecrease ) { - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - if( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel ) + if( actor.ammo_fuel >= (time - actor.hook_time_fueldecrease) * hooked_fuel ) { - W_DecreaseAmmo(thiswep, (time - self.hook_time_fueldecrease) * hooked_fuel); - self.hook_time_fueldecrease = time; + W_DecreaseAmmo(thiswep, actor, (time - actor.hook_time_fueldecrease) * hooked_fuel); + actor.hook_time_fueldecrease = time; // decrease next frame again } else { - self.ammo_fuel = 0; - self.hook_state |= HOOK_REMOVING; - W_SwitchWeapon_Force(self, w_getbestweapon(self)); + actor.ammo_fuel = 0; + actor.hook_state |= HOOK_REMOVING; + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); } } } @@ -245,33 +245,33 @@ void W_Hook_Attack2(Weapon thiswep) } else { - self.hook_time_hooked = time; - self.hook_time_fueldecrease = time + WEP_CVAR_PRI(hook, hooked_time_free); + actor.hook_time_hooked = time; + actor.hook_time_fueldecrease = time + WEP_CVAR_PRI(hook, hooked_time_free); } - if(self.BUTTON_CROUCH) + if(actor.BUTTON_CROUCH) { - self.hook_state &= ~HOOK_PULLING; - if(fire1 || self.BUTTON_HOOK) - self.hook_state &= ~HOOK_RELEASING; + actor.hook_state &= ~HOOK_PULLING; + if(fire1 || actor.BUTTON_HOOK) + actor.hook_state &= ~HOOK_RELEASING; else - self.hook_state |= HOOK_RELEASING; + actor.hook_state |= HOOK_RELEASING; } else { - self.hook_state |= HOOK_PULLING; - self.hook_state &= ~HOOK_RELEASING; + actor.hook_state |= HOOK_PULLING; + actor.hook_state &= ~HOOK_RELEASING; - if(fire1 || self.BUTTON_HOOK) + if(fire1 || actor.BUTTON_HOOK) { // already fired - if(self.hook) - self.hook_state |= HOOK_WAITING_FOR_RELEASE; + if(actor.hook) + actor.hook_state |= HOOK_WAITING_FOR_RELEASE; } else { - self.hook_state |= HOOK_REMOVING; - self.hook_state &= ~HOOK_WAITING_FOR_RELEASE; + actor.hook_state |= HOOK_REMOVING; + actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE; } } diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 59c0f15b0..9c2259196 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -124,97 +124,97 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype) Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); W_MachineGun_MuzzleFlash(); - W_AttachToShotorg(self.muzzle_flash, '5 0 0'); + W_AttachToShotorg(self, self.muzzle_flash, '5 0 0'); // casing code if(autocvar_g_casings >= 2) SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self); if(self.misc_bulletcounter == 1) - W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, first_ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(machinegun, first_ammo)); else - W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, sustained_ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(machinegun, sustained_ammo)); } // weapon frames -void W_MachineGun_Attack_Frame(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - if(self.weapon != self.switchweapon) // abort immediately if switching +void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + if(actor.weapon != actor.switchweapon) // abort immediately if switching { - w_ready(thiswep, fire1, fire2); + w_ready(thiswep, actor, fire1, fire2); return; } - if(self.BUTTON_ATCK) + if(actor.BUTTON_ATCK) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if(!w.wr_checkammo2(w)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - self.misc_bulletcounter = self.misc_bulletcounter + 1; + actor.misc_bulletcounter = actor.misc_bulletcounter + 1; W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); } else - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), w_ready); } -void W_MachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); +void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ float machinegun_spread; if(!fire1) { - w_ready(thiswep, fire1, fire2); + w_ready(thiswep, actor, fire1, fire2); return; } - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if(!w.wr_checkammo1(w)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - W_DecreaseAmmo(WEP_MACHINEGUN, WEP_CVAR(machinegun, sustained_ammo)); + W_DecreaseAmmo(WEP_MACHINEGUN, actor, WEP_CVAR(machinegun, sustained_ammo)); - W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); + W_SetupShot(actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) { - self.punchangle_x = random() - 0.5; - self.punchangle_y = random() - 0.5; + actor.punchangle_x = random() - 0.5; + actor.punchangle_y = random() - 0.5; } - machinegun_spread = bound(WEP_CVAR(machinegun, spread_min), WEP_CVAR(machinegun, spread_min) + (WEP_CVAR(machinegun, spread_add) * self.misc_bulletcounter), WEP_CVAR(machinegun, spread_max)); + machinegun_spread = bound(WEP_CVAR(machinegun, spread_min), WEP_CVAR(machinegun, spread_min) + (WEP_CVAR(machinegun, spread_add) * actor.misc_bulletcounter), WEP_CVAR(machinegun, spread_max)); fireBullet(w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), WEP_MACHINEGUN.m_id, 0); - self.misc_bulletcounter = self.misc_bulletcounter + 1; + actor.misc_bulletcounter = actor.misc_bulletcounter + 1; Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); W_MachineGun_MuzzleFlash(); - W_AttachToShotorg(self.muzzle_flash, '5 0 0'); + W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); if(autocvar_g_casings >= 2) // casing code - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); - ATTACK_FINISHED(self) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); + ATTACK_FINISHED(actor) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); } -void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); +void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + W_SetupShot(actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) { - self.punchangle_x = random() - 0.5; - self.punchangle_y = random() - 0.5; + actor.punchangle_x = random() - 0.5; + actor.punchangle_y = random() - 0.5; } fireBullet(w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_speed), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), WEP_MACHINEGUN.m_id, 0); @@ -222,20 +222,20 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2) Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); W_MachineGun_MuzzleFlash(); - W_AttachToShotorg(self.muzzle_flash, '5 0 0'); + W_AttachToShotorg(actor, actor.muzzle_flash, '5 0 0'); if(autocvar_g_casings >= 2) // casing code - SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self); + SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); - self.misc_bulletcounter = self.misc_bulletcounter + 1; - if(self.misc_bulletcounter == 0) + actor.misc_bulletcounter = actor.misc_bulletcounter + 1; + if(actor.misc_bulletcounter == 0) { - ATTACK_FINISHED(self) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready); + ATTACK_FINISHED(actor) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready); } else { - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_refire), W_MachineGun_Attack_Burst); } } @@ -247,56 +247,56 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2) else self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); } - METHOD(MachineGun, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(machinegun, reload_ammo) && self.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else if(WEP_CVAR(machinegun, mode) == 1) { if(fire1) - if(weapon_prepareattack(false, 0)) + if(weapon_prepareattack(actor, false, 0)) { - self.misc_bulletcounter = 0; - W_MachineGun_Attack_Auto(thiswep, fire1, fire2); + actor.misc_bulletcounter = 0; + W_MachineGun_Attack_Auto(thiswep, actor, fire1, fire2); } if(fire2) - if(weapon_prepareattack(true, 0)) + if(weapon_prepareattack(actor, true, 0)) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if(!w.wr_checkammo2(w)) - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, burst_ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo)); - self.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; - W_MachineGun_Attack_Burst(thiswep, fire1, fire2); + actor.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; + W_MachineGun_Attack_Burst(thiswep, actor, fire1, fire2); } } else { if(fire1) - if(weapon_prepareattack(false, 0)) + if(weapon_prepareattack(actor, false, 0)) { - self.misc_bulletcounter = 1; + actor.misc_bulletcounter = 1; W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); // sets attack_finished - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); } if(fire2 && WEP_CVAR(machinegun, first)) - if(weapon_prepareattack(true, 0)) + if(weapon_prepareattack(actor, true, 0)) { - self.misc_bulletcounter = 1; + actor.misc_bulletcounter = 1; W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready); } } } @@ -344,7 +344,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2) } METHOD(MachineGun, wr_reload, void(entity thiswep)) { - W_Reload(min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND(RELOAD)); + W_Reload(self, min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo)), SND(RELOAD)); } METHOD(MachineGun, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 0ca67ab9a..be07f516f 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -325,7 +325,7 @@ void W_MineLayer_Attack(Weapon thiswep) } } - W_DecreaseAmmo(thiswep, WEP_CVAR(minelayer, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(minelayer, ammo)); W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', false, 5, SND(MINE_FIRE), CH_WEAPON_A, WEP_CVAR(minelayer, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -371,7 +371,7 @@ void W_MineLayer_Attack(Weapon thiswep) setmodel(flash, MDL_MINELAYER_MUZZLEFLASH); // precision set below SUB_SetFade(flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(flash, '5 0 0'); + W_AttachToShotorg(self, flash, '5 0 0'); // common properties @@ -499,29 +499,29 @@ float W_MineLayer_PlacedMines(float detonate) if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false; } } - METHOD(MineLayer, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload + if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload { // not if we're holding the minelayer without enough ammo, but can detonate existing mines - if(!(W_MineLayer_PlacedMines(false) && self.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) { - Weapon w = get_weaponinfo(self.weapon); + if(!(W_MineLayer_PlacedMines(false) && actor.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) { + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } } else if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR(minelayer, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(minelayer, refire))) { W_MineLayer_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready); } } if(fire2) { if(W_MineLayer_PlacedMines(true)) - sound(self, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM); + sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM); } } METHOD(MineLayer, wr_init, void(entity thiswep)) @@ -556,7 +556,7 @@ float W_MineLayer_PlacedMines(float detonate) } METHOD(MineLayer, wr_reload, void(entity thiswep)) { - W_Reload(WEP_CVAR(minelayer, ammo), SND(RELOAD)); + W_Reload(self, WEP_CVAR(minelayer, ammo), SND(RELOAD)); } METHOD(MineLayer, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index e4fef1b27..5a7bf93a0 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -202,7 +202,7 @@ void W_Mortar_Attack(Weapon thiswep) {SELFPARAM(); entity gren; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(mortar, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(mortar, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please @@ -251,7 +251,7 @@ void W_Mortar_Attack2(Weapon thiswep) {SELFPARAM(); entity gren; - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(mortar, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(mortar, ammo)); W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, SND(GRENADE_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage)); w_shotdir = v_forward; // no TrueAim for grenades please @@ -334,17 +334,17 @@ void W_Mortar_Attack2(Weapon thiswep) wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)))); wepinfo_ter_dps = 0; */ - METHOD(Mortar, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Mortar, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(autocvar_g_balance_mortar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(mortar, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(mortar, refire))) { W_Mortar_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); } } else if(fire2) @@ -353,7 +353,7 @@ void W_Mortar_Attack2(Weapon thiswep) { bool nadefound = false; entity nade; - for(nade = world; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == self) + for(nade = world; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == actor) { if(!nade.gl_detonate_later) { @@ -362,12 +362,12 @@ void W_Mortar_Attack2(Weapon thiswep) } } if(nadefound) - sound(self, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); + sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM); } - else if(weapon_prepareattack(true, WEP_CVAR_SEC(mortar, refire))) + else if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(mortar, refire))) { W_Mortar_Attack2(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready); } } } @@ -393,7 +393,7 @@ void W_Mortar_Attack2(Weapon thiswep) } METHOD(Mortar, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND(RELOAD)); // WEAPONTODO + W_Reload(self, min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), SND(RELOAD)); // WEAPONTODO } METHOD(Mortar, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index cfc146944..0e00121c2 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -298,60 +298,59 @@ void W_Porto_Attack(float type) { PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); } - METHOD(PortoLaunch, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - SELFPARAM(); if(WEP_CVAR(porto, secondary)) { if(fire1) - if(!self.porto_current) - if(!self.porto_forbidden) - if(weapon_prepareattack(false, WEP_CVAR_PRI(porto, refire))) + if(!actor.porto_current) + if(!actor.porto_forbidden) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire))) { W_Porto_Attack(0); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } if(fire2) - if(!self.porto_current) - if(!self.porto_forbidden) - if(weapon_prepareattack(true, WEP_CVAR_SEC(porto, refire))) + if(!actor.porto_current) + if(!actor.porto_forbidden) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(porto, refire))) { W_Porto_Attack(1); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready); } } else { - if(self.porto_v_angle_held) + if(actor.porto_v_angle_held) { if(!fire2) { - self.porto_v_angle_held = 0; + actor.porto_v_angle_held = 0; - ClientData_Touch(self); + ClientData_Touch(actor); } } else { if(fire2) { - self.porto_v_angle = self.v_angle; - self.porto_v_angle_held = 1; + actor.porto_v_angle = actor.v_angle; + actor.porto_v_angle_held = 1; - ClientData_Touch(self); + ClientData_Touch(actor); } } - if(self.porto_v_angle_held) - makevectors(self.porto_v_angle); // override the previously set angles + if(actor.porto_v_angle_held) + makevectors(actor.porto_v_angle); // override the previously set angles if(fire1) - if(!self.porto_current) - if(!self.porto_forbidden) - if(weapon_prepareattack(false, WEP_CVAR_PRI(porto, refire))) + if(!actor.porto_current) + if(!actor.porto_forbidden) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire))) { W_Porto_Attack(-1); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } } } diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 8d57cd339..d994f0151 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -57,7 +57,7 @@ void W_Rifle_FireBullet(Weapon thiswep, float pSpread, float pDamage, float pFor {SELFPARAM(); float i; - W_DecreaseAmmo(thiswep, pAmmo); + W_DecreaseAmmo(thiswep, self, pAmmo); W_SetupShot(self, true, 2, pSound, CH_WEAPON_A, pDamage * pShots); @@ -90,28 +90,28 @@ void W_Rifle_Attack2(void) .float rifle_bullethail_frame; .float rifle_bullethail_animtime; .float rifle_bullethail_refire; -void W_Rifle_BulletHail_Continue(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); +void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ float r, sw, af; - sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing - af = ATTACK_FINISHED(self); - self.switchweapon = self.weapon; - ATTACK_FINISHED(self) = time; - LOG_INFO(ftos(self.WEP_AMMO(RIFLE)), "\n"); - r = weapon_prepareattack(self.rifle_bullethail_frame == WFRAME_FIRE2, self.rifle_bullethail_refire); - if(self.switchweapon == self.weapon) - self.switchweapon = sw; + sw = actor.switchweapon; // make it not detect weapon changes as reason to abort firing + af = ATTACK_FINISHED(actor); + actor.switchweapon = actor.weapon; + ATTACK_FINISHED(actor) = time; + LOG_INFO(ftos(actor.WEP_AMMO(RIFLE)), "\n"); + r = weapon_prepareattack(actor, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire); + if(actor.switchweapon == actor.weapon) + actor.switchweapon = sw; if(r) { - self.rifle_bullethail_attackfunc(); - weapon_thinkf(self.rifle_bullethail_frame, self.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue); + actor.rifle_bullethail_attackfunc(); + weapon_thinkf(actor, actor.rifle_bullethail_frame, actor.rifle_bullethail_animtime, W_Rifle_BulletHail_Continue); LOG_INFO("thinkf set\n"); } else { - ATTACK_FINISHED(self) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time - LOG_INFO("out of ammo... ", ftos(self.weaponentity.state), "\n"); + ATTACK_FINISHED(actor) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time + LOG_INFO("out of ammo... ", ftos(actor.weaponentity.state), "\n"); } } @@ -126,12 +126,12 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt self.rifle_bullethail_frame = fr; self.rifle_bullethail_animtime = animtime; self.rifle_bullethail_refire = refire; - weapon_thinkf(fr, animtime, W_Rifle_BulletHail_Continue); + weapon_thinkf(self, fr, animtime, W_Rifle_BulletHail_Continue); } else { // just one shot - weapon_thinkf(fr, animtime, w_ready); + weapon_thinkf(self, fr, animtime, w_ready); } } @@ -160,37 +160,37 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt } } } - METHOD(Rifle, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Rifle, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(autocvar_g_balance_rifle_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { - self.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), self.rifle_accumulator, time); + actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time); if(fire1) - if(weapon_prepareattack_check(false, WEP_CVAR_PRI(rifle, refire))) - if(time >= self.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost)) + if(weapon_prepareattack_check(actor, false, WEP_CVAR_PRI(rifle, refire))) + if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost)) { - weapon_prepareattack_do(false, WEP_CVAR_PRI(rifle, refire)); + weapon_prepareattack_do(actor, false, WEP_CVAR_PRI(rifle, refire)); W_Rifle_BulletHail(WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire)); - self.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost); + actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost); } if(fire2) { if(WEP_CVAR(rifle, secondary)) { if(WEP_CVAR_SEC(rifle, reload)) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { - if(weapon_prepareattack_check(true, WEP_CVAR_SEC(rifle, refire))) - if(time >= self.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost)) + if(weapon_prepareattack_check(actor, true, WEP_CVAR_SEC(rifle, refire))) + if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost)) { - weapon_prepareattack_do(true, WEP_CVAR_SEC(rifle, refire)); + weapon_prepareattack_do(actor, true, WEP_CVAR_SEC(rifle, refire)); W_Rifle_BulletHail(WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire)); - self.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost); + actor.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost); } } } @@ -223,7 +223,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt } METHOD(Rifle, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), SND(RELOAD)); } METHOD(Rifle, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/weapons/weapon/rpc.qc index cce7cebaa..0c75cceb3 100644 --- a/qcsrc/common/weapons/weapon/rpc.qc +++ b/qcsrc/common/weapons/weapon/rpc.qc @@ -109,7 +109,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(self); entity flash = spawn (); - W_DecreaseAmmo(thiswep, WEP_CVAR(rpc, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(rpc, ammo)); W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', false, 5, SND(ROCKET_FIRE), CH_WEAPON_A, WEP_CVAR(rpc, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); PROJECTILE_MAKETRIGGER(missile); @@ -143,7 +143,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below SUB_SetFade (flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(flash, '5 0 0'); + W_AttachToShotorg(self, flash, '5 0 0'); missile.pos1 = missile.velocity; MUTATOR_CALLHOOK(EditProjectile, self, missile); @@ -153,19 +153,19 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) { self.BUTTON_ATCK = bot_aim(WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false); } - METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(rpc, reload_ammo) && self.clip_load < WEP_CVAR(rpc, ammo)) { - Weapon w = get_weaponinfo(self.weapon); + if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) { + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { if (fire1) { - if(weapon_prepareattack(false, WEP_CVAR(rpc, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(rpc, refire))) { W_RocketPropelledChainsaw_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready); } } @@ -195,7 +195,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) } METHOD(RocketPropelledChainsaw, wr_reload, void(entity thiswep)) { - W_Reload(WEP_CVAR(rpc, ammo), SND(RELOAD)); + W_Reload(self, WEP_CVAR(rpc, ammo), SND(RELOAD)); } METHOD(RocketPropelledChainsaw, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 24cb325d6..64cb9ee17 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -249,7 +249,7 @@ void W_Seeker_Fire_Missile(Weapon thiswep, vector f_diff, entity m_target) {SELFPARAM(); entity missile; - W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, missile_ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, missile_ammo)); makevectors(self.v_angle); W_SetupShot_ProjectileSize(self, '-2 -2 -2', '2 2 2', false, 2, SND(SEEKER_FIRE), CH_WEAPON_A, 0); @@ -324,7 +324,7 @@ void W_Seeker_Fire_Flac(Weapon thiswep) vector f_diff; float c; - W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, flac_ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, flac_ammo)); c = self.bulletcounter % 4; switch(c) @@ -559,7 +559,7 @@ void W_Seeker_Tag_Touch(void) void W_Seeker_Fire_Tag(Weapon thiswep) {SELFPARAM(); entity missile; - W_DecreaseAmmo(thiswep, WEP_CVAR(seeker, tag_ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR(seeker, tag_ammo)); W_SetupShot_ProjectileSize(self, '-2 -2 -2', '2 2 2', false, 2, SND(TAG_FIRE), CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count)); @@ -608,27 +608,27 @@ void W_Seeker_Fire_Tag(Weapon thiswep) else self.BUTTON_ATCK = bot_aim(WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); } - METHOD(Seeker, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Seeker, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(autocvar_g_balance_seeker_reload_ammo && self.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else if(fire1) { if(WEP_CVAR(seeker, type) == 1) { - if(weapon_prepareattack(false, WEP_CVAR(seeker, missile_refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, missile_refire))) { W_Seeker_Attack(); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready); } } else { - if(weapon_prepareattack(false, WEP_CVAR(seeker, tag_refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire))) { W_Seeker_Fire_Tag(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } } @@ -637,18 +637,18 @@ void W_Seeker_Fire_Tag(Weapon thiswep) { if(WEP_CVAR(seeker, type) == 1) { - if(weapon_prepareattack(false, WEP_CVAR(seeker, tag_refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire))) { W_Seeker_Fire_Tag(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready); } } else { - if(weapon_prepareattack(false, WEP_CVAR(seeker, flac_refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, flac_refire))) { W_Seeker_Fire_Flac(thiswep); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready); } } } @@ -693,7 +693,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) } METHOD(Seeker, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo)), SND(RELOAD)); } METHOD(Seeker, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 0755adcf6..a9c758212 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -229,17 +229,17 @@ void W_Shockwave_Melee_Think(void) } } -void W_Shockwave_Melee(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready); +void W_Shockwave_Melee(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready); entity meleetemp; meleetemp = spawn(); - meleetemp.owner = meleetemp.realowner = self; + meleetemp.owner = meleetemp.realowner = actor; meleetemp.think = W_Shockwave_Melee_Think; meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(); - W_SetupShot_Range(self, true, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); + W_SetupShot_Range(actor, true, 0, "", 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); } // SHOCKWAVE ATTACK MODE @@ -675,28 +675,28 @@ void W_Shockwave_Attack(void) else { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); } } - METHOD(Shockwave, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { if(fire1) { - if(time >= self.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary + if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary { - if(weapon_prepareattack(false, WEP_CVAR(shockwave, blast_animtime))) + if(weapon_prepareattack(actor, false, WEP_CVAR(shockwave, blast_animtime))) { W_Shockwave_Attack(); - self.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready); + actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready); } } } else if(fire2) { - //if(self.clip_load >= 0) // we are not currently reloading - if(!self.crouch) // no crouchmelee please - if(weapon_prepareattack(true, WEP_CVAR(shockwave, melee_refire))) + //if(actor.clip_load >= 0) // we are not currently reloading + if(!actor.crouch) // no crouchmelee please + if(weapon_prepareattack(actor, true, WEP_CVAR(shockwave, melee_refire))) { // attempt forcing playback of the anim by switching to another anim (that we never play) here... - weapon_thinkf(WFRAME_FIRE1, 0, W_Shockwave_Melee); + weapon_thinkf(actor, WFRAME_FIRE1, 0, W_Shockwave_Melee); } } } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 7f5ef5728..09bdf2107 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -61,7 +61,7 @@ void W_Shotgun_Attack(Weapon thiswep, float isprimary) float sc; entity flash; - W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(shotgun, ammo)); + W_DecreaseAmmo(thiswep, self, WEP_CVAR_PRI(shotgun, ammo)); W_SetupShot(self, true, 5, SND(SHOTGUN_FIRE), ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), WEP_CVAR_PRI(shotgun, damage) * WEP_CVAR_PRI(shotgun, bullets)); for(sc = 0;sc < WEP_CVAR_PRI(shotgun, bullets);sc = sc + 1) @@ -80,7 +80,7 @@ void W_Shotgun_Attack(Weapon thiswep, float isprimary) flash.think = SUB_Remove; flash.nextthink = time + 0.06; flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(flash, '5 0 0'); + W_AttachToShotorg(self, flash, '5 0 0'); } .float swing_prev; @@ -181,48 +181,48 @@ void W_Shotgun_Melee_Think(void) } } -void W_Shotgun_Attack2(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM); - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready); +void W_Shotgun_Attack2(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready); entity meleetemp; meleetemp = spawn(); - meleetemp.realowner = self; + meleetemp.realowner = actor; meleetemp.think = W_Shotgun_Melee_Think; meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor(); - W_SetupShot_Range(self, true, 0, "", 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); + W_SetupShot_Range(actor, true, 0, "", 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); } // alternate secondary weapon frames -void W_Shotgun_Attack3_Frame2(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - Weapon w = get_weaponinfo(self.weapon); +void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + Weapon w = get_weaponinfo(actor.weapon); if (!w.wr_checkammo2(w)) - if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } - sound(self, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound + sound(actor, CH_WEAPON_SINGLE, SND_Null, VOL_BASE, ATTN_NORM); // kill previous sound W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); } -void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - Weapon w = get_weaponinfo(self.weapon); +void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + Weapon w = get_weaponinfo(actor.weapon); if (!w.wr_checkammo2(w)) - if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(thiswep, fire1, fire2); + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); + w_ready(thiswep, actor, fire1, fire2); return; } W_Shotgun_Attack(WEP_SHOTGUN, false); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2); } .float shotgun_primarytime; @@ -234,13 +234,13 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2) else self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); } - METHOD(Shotgun, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(shotgun, reload_ammo) && self.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload + if(WEP_CVAR(shotgun, reload_ammo) && actor.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload { // don't force reload an empty shotgun if its melee attack is active if(WEP_CVAR(shotgun, secondary) < 2) { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } } @@ -248,37 +248,37 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2) { if(fire1) { - if(time >= self.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary + if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { - if(weapon_prepareattack(false, WEP_CVAR_PRI(shotgun, animtime))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(shotgun, animtime))) { W_Shotgun_Attack(thiswep, true); - self.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); + actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); } } } else if(fire2 && WEP_CVAR(shotgun, secondary) == 2) { - if(time >= self.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary + if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { - if(weapon_prepareattack(false, WEP_CVAR_SEC(shotgun, alt_animtime))) + if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(shotgun, alt_animtime))) { W_Shotgun_Attack(thiswep, false); - self.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); + actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); } } } } - if(self.clip_load >= 0) // we are not currently reloading - if(!self.crouch) // no crouchmelee please + if(actor.clip_load >= 0) // we are not currently reloading + if(!actor.crouch) // no crouchmelee please if(WEP_CVAR(shotgun, secondary) == 1) - if((fire1 && self.WEP_AMMO(SHOTGUN) <= 0 && !(self.items & IT_UNLIMITED_WEAPON_AMMO)) || fire2) - if(weapon_prepareattack(true, WEP_CVAR_SEC(shotgun, refire))) + if((fire1 && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || fire2) + if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(shotgun, refire))) { // attempt forcing playback of the anim by switching to another anim (that we never play) here... - weapon_thinkf(WFRAME_FIRE1, 0, W_Shotgun_Attack2); + weapon_thinkf(actor, WFRAME_FIRE1, 0, W_Shotgun_Attack2); } } METHOD(Shotgun, wr_init, void(entity thiswep)) @@ -318,7 +318,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2) } METHOD(Shotgun, wr_reload, void(entity thiswep)) { - W_Reload(WEP_CVAR_PRI(shotgun, ammo), SND(RELOAD)); // WEAPONTODO + W_Reload(self, WEP_CVAR_PRI(shotgun, ammo), SND(RELOAD)); // WEAPONTODO } METHOD(Shotgun, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 60b9ec6ac..20958c793 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -379,27 +379,27 @@ void W_Tuba_NoteOn(float hittype) self.BUTTON_ATCK2 = 1; } } - METHOD(Tuba, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Tuba, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { if(fire1) - if(weapon_prepareattack(false, WEP_CVAR(tuba, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR(tuba, refire))) { W_Tuba_NoteOn(0); - //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready); - weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); + //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready); + weapon_thinkf(actor, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); } if(fire2) - if(weapon_prepareattack(true, WEP_CVAR(tuba, refire))) + if(weapon_prepareattack(actor, true, WEP_CVAR(tuba, refire))) { W_Tuba_NoteOn(HITTYPE_SECONDARY); - //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready); - weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); + //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready); + weapon_thinkf(actor, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready); } - if(self.tuba_note) + if(actor.tuba_note) { if(!fire1 && !fire2) { - WITH(entity, self, self.tuba_note, W_Tuba_NoteOff()); + WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff()); } } } @@ -435,7 +435,7 @@ void W_Tuba_NoteOn(float hittype) W_SetupShot(self, false, 0, "", 0, 0); Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1); self.weaponentity.state = WS_INUSE; - weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready); + weapon_thinkf(self, WFRAME_RELOAD, 0.5, w_ready); } } METHOD(Tuba, wr_checkammo1, bool(entity thiswep)) diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index bb0283c66..5061af054 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -105,7 +105,7 @@ void W_Vaporizer_Attack(Weapon thiswep) if(!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT))) W_RocketMinsta_Explosion(trace_endpos); - W_DecreaseAmmo(thiswep, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo))); + W_DecreaseAmmo(thiswep, self, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo))); } void W_RocketMinsta_Laser_Explode (void) @@ -244,61 +244,62 @@ void W_RocketMinsta_Attack3 (void) else self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars } - METHOD(Vaporizer, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); // if the laser uses load, we also consider its ammo for reloading - if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && self.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && actor.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(WEP_CVAR(vaporizer, reload_ammo) && self.clip_load < vaporizer_ammo) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + } else if(WEP_CVAR(vaporizer, reload_ammo) && actor.clip_load < vaporizer_ammo) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } - if(fire1 && (self.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(self)) + if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor)) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(vaporizer, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vaporizer, refire))) { W_Vaporizer_Attack(thiswep); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); } } - if(fire2 || (fire1 && !self.ammo_cells && autocvar_g_rm)) + if(fire2 || (fire1 && !actor.ammo_cells && autocvar_g_rm)) { if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2) { bool rapid = autocvar_g_rm_laser_rapid; - if(self.jump_interval <= time && !self.held_down) + if(actor.jump_interval <= time && !actor.held_down) { if(rapid) - self.held_down = true; - self.jump_interval = time + autocvar_g_rm_laser_refire; - self.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay; + actor.held_down = true; + actor.jump_interval = time + autocvar_g_rm_laser_refire; + actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_delay; damage_goodhits = 0; W_RocketMinsta_Attack2(); } - else if(rapid && self.jump_interval2 <= time && self.held_down) + else if(rapid && actor.jump_interval2 <= time && actor.held_down) { - self.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire; + actor.jump_interval2 = time + autocvar_g_rm_laser_rapid_refire; damage_goodhits = 0; W_RocketMinsta_Attack3(); - //weapon_thinkf(WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready); + //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_rm_laser_rapid_animtime, w_ready); } } - else if (self.jump_interval <= time) + else if (actor.jump_interval <= time) { // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib) - self.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(); + actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(); // decrease ammo for the laser? if(WEP_CVAR_SEC(vaporizer, ammo)) - W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(vaporizer, ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(vaporizer, ammo)); // ugly instagib hack to reuse the fire mode of the laser - makevectors(self.v_angle); - int oldwep = self.weapon; // we can't avoid this hack - self.weapon = WEP_BLASTER.m_id; + makevectors(actor.v_angle); + int oldwep = actor.weapon; // we can't avoid this hack + actor.weapon = WEP_BLASTER.m_id; W_Blaster_Attack( + actor, WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(vaporizer, shotangle), WEP_CVAR_SEC(vaporizer, damage), @@ -310,14 +311,14 @@ void W_RocketMinsta_Attack3 (void) WEP_CVAR_SEC(vaporizer, delay), WEP_CVAR_SEC(vaporizer, lifetime) ); - self.weapon = oldwep; + actor.weapon = oldwep; // now do normal refire - weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(vaporizer, animtime), w_ready); } } else - self.held_down = false; + actor.held_down = false; } METHOD(Vaporizer, wr_init, void(entity thiswep)) { @@ -361,7 +362,7 @@ void W_RocketMinsta_Attack3 (void) else used_ammo = vaporizer_ammo; - W_Reload(used_ammo, SND(RELOAD)); + W_Reload(self, used_ammo, SND(RELOAD)); } METHOD(Vaporizer, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 15c10caee..176a2585f 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -128,7 +128,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) //beam and muzzle flash done on client SendCSQCVortexBeamParticle(charge); - W_DecreaseAmmo(thiswep, myammo); + W_DecreaseAmmo(thiswep, self, myammo); } .float vortex_chargepool_pauseregen_finished; @@ -143,54 +143,54 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) self.BUTTON_ATCK2 = true; } } - METHOD(Vortex, wr_think, void(entity thiswep, bool fire1, bool fire2)) + METHOD(Vortex, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { - if(WEP_CVAR(vortex, charge) && self.vortex_charge < WEP_CVAR(vortex, charge_limit)) - self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME); + if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit)) + actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME); if(WEP_CVAR_SEC(vortex, chargepool)) - if(self.vortex_chargepool_ammo < 1) + if(actor.vortex_chargepool_ammo < 1) { - if(self.vortex_chargepool_pauseregen_finished < time) - self.vortex_chargepool_ammo = min(1, self.vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME); - self.pauseregen_finished = max(self.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen)); + if(actor.vortex_chargepool_pauseregen_finished < time) + actor.vortex_chargepool_ammo = min(1, actor.vortex_chargepool_ammo + WEP_CVAR_SEC(vortex, chargepool_regen) * frametime / W_TICSPERFRAME); + actor.pauseregen_finished = max(actor.pauseregen_finished, time + WEP_CVAR_SEC(vortex, chargepool_pause_regen)); } - if(autocvar_g_balance_vortex_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload - Weapon w = get_weaponinfo(self.weapon); + if(autocvar_g_balance_vortex_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo))) { // forced reload + Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { if(fire1) { - if(weapon_prepareattack(false, WEP_CVAR_PRI(vortex, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vortex, refire))) { W_Vortex_Attack(thiswep, 0); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); } } - if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (self.BUTTON_ZOOM | self.BUTTON_ZOOMSCRIPT) : fire2) + if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : fire2) { if(WEP_CVAR(vortex, charge)) { - self.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause); + actor.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause); float dt = frametime / W_TICSPERFRAME; - if(self.vortex_charge < 1) + if(actor.vortex_charge < 1) { if(WEP_CVAR_SEC(vortex, chargepool)) { if(WEP_CVAR_SEC(vortex, ammo)) { // always deplete if secondary is held - self.vortex_chargepool_ammo = max(0, self.vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt); + actor.vortex_chargepool_ammo = max(0, actor.vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt); - dt = min(dt, (1 - self.vortex_charge) / WEP_CVAR(vortex, charge_rate)); - self.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen); - dt = min(dt, self.vortex_chargepool_ammo); + dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate)); + actor.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen); + dt = min(dt, actor.vortex_chargepool_ammo); dt = max(0, dt); - self.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); + actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); } } @@ -198,47 +198,47 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) { if(fire2) // only eat ammo when the button is pressed { - dt = min(dt, (1 - self.vortex_charge) / WEP_CVAR(vortex, charge_rate)); - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate)); + if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if(autocvar_g_balance_vortex_reload_ammo) { - dt = min(dt, (self.clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); + dt = min(dt, (actor.clip_load - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); dt = max(0, dt); if(dt > 0) { - self.clip_load = max(WEP_CVAR_SEC(vortex, ammo), self.clip_load - WEP_CVAR_SEC(vortex, ammo) * dt); + actor.clip_load = max(WEP_CVAR_SEC(vortex, ammo), actor.clip_load - WEP_CVAR_SEC(vortex, ammo) * dt); } - self.(weapon_load[WEP_VORTEX.m_id]) = self.clip_load; + actor.(weapon_load[WEP_VORTEX.m_id]) = actor.clip_load; } else { - dt = min(dt, (self.WEP_AMMO(VORTEX) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); + dt = min(dt, (actor.WEP_AMMO(VORTEX) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo)); dt = max(0, dt); if(dt > 0) { - self.WEP_AMMO(VORTEX) = max(WEP_CVAR_SEC(vortex, ammo), self.WEP_AMMO(VORTEX) - WEP_CVAR_SEC(vortex, ammo) * dt); + actor.WEP_AMMO(VORTEX) = max(WEP_CVAR_SEC(vortex, ammo), actor.WEP_AMMO(VORTEX) - WEP_CVAR_SEC(vortex, ammo) * dt); } } } - self.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); + actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); } } else { - dt = min(dt, (1 - self.vortex_charge) / WEP_CVAR(vortex, charge_rate)); - self.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); + dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate)); + actor.vortex_charge += dt * WEP_CVAR(vortex, charge_rate); } } } else if(WEP_CVAR(vortex, secondary)) { - if(weapon_prepareattack(false, WEP_CVAR_SEC(vortex, refire))) + if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(vortex, refire))) { W_Vortex_Attack(thiswep, 1); - weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready); } } } @@ -282,7 +282,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) } METHOD(Vortex, wr_reload, void(entity thiswep)) { - W_Reload(min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND(RELOAD)); + W_Reload(self, min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND(RELOAD)); } METHOD(Vortex, wr_suicidemessage, int(entity thiswep)) { diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index bccbf6e13..a2cad216d 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2552,7 +2552,7 @@ void PlayerPreThink (void) { self.items &= ~self.items_added; - W_WeaponFrame(); + W_WeaponFrame(self); self.items_added = 0; if(self.items & ITEM_Jetpack.m_itemid) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 251da0d62..426a804cc 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -165,11 +165,11 @@ const float MAX_DAMAGEEXTRARADIUS = 16; // WEAPONTODO .float autoswitch; float client_hasweapon(entity cl, float wpn, float andammo, float complain); -void w_clear(Weapon thiswep, bool fire1, bool fire2); -void w_ready(Weapon thiswep, bool fire1, bool fire2); +void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2); +void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2); // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies) .float weapon_nextthink; -.void(Weapon thiswep, bool fire1, bool fire2) weapon_think; +.void(Weapon thiswep, entity actor, bool fire1, bool fire2) weapon_think; // weapon states (self.weaponentity.state) diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index 5d034870e..56e9f8569 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -842,34 +842,34 @@ float ball_customize() return true; } - METHOD(BallStealer, wr_think, void(BallStealer thiswep, bool fire1, bool fire2)) + METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2)) { if(fire1) - if(weapon_prepareattack(false, autocvar_g_balance_nexball_primary_refire)) + if(weapon_prepareattack(actor, false, autocvar_g_balance_nexball_primary_refire)) if(autocvar_g_nexball_basketball_meter) { if(self.ballcarried && !self.metertime) self.metertime = time; else - weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } else { W_Nexball_Attack(-1); - weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } if(fire2) - if(weapon_prepareattack(true, autocvar_g_balance_nexball_secondary_refire)) + if(weapon_prepareattack(actor, true, autocvar_g_balance_nexball_secondary_refire)) { W_Nexball_Attack2(); - weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready); + weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready); } if(!fire1 && self.metertime && self.ballcarried) { W_Nexball_Attack(time - self.metertime); // DropBall or stealing will set metertime back to 0 - weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } } METHOD(BallStealer, wr_setup, void(BallStealer thiswep)) diff --git a/qcsrc/server/mutators/mutator_overkill.qc b/qcsrc/server/mutators/mutator_overkill.qc index 69c9fffd7..954b498d5 100644 --- a/qcsrc/server/mutators/mutator_overkill.qc +++ b/qcsrc/server/mutators/mutator_overkill.qc @@ -3,7 +3,7 @@ #include "mutator.qh" -void W_Blaster_Attack(float, float, float, float, float, float, float, float, float, float); +void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float); void spawnfunc_weapon_hmg(); void spawnfunc_weapon_rpc(); @@ -149,6 +149,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink) int oldwep = self.weapon; self.weapon = WEP_BLASTER.m_id; W_Blaster_Attack( + self, WEP_BLASTER.m_id | HITTYPE_SECONDARY, WEP_CVAR_SEC(vaporizer, shotangle), WEP_CVAR_SEC(vaporizer, damage), @@ -178,7 +179,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink) } Weapon wpn = get_weaponinfo(self.weapon); if(self.weaponentity.state != WS_CLEAR) - w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); + w_ready(wpn, self, self.BUTTON_ATCK, self.BUTTON_ATCK2); self.weapon_blocked = true; } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index de9512859..208948f28 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -47,7 +47,7 @@ float W_WeaponSpeedFactor() } -void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func); +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func); float CL_Weaponentity_CustomizeEntityForClient() {SELFPARAM(); @@ -434,70 +434,70 @@ void CL_SpawnWeaponentity(entity e) } // Weapon subs -void w_clear(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - if (self.weapon != -1) +void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + if (actor.weapon != -1) { - self.weapon = 0; - self.switchingweapon = 0; + actor.weapon = 0; + actor.switchingweapon = 0; } - if (self.weaponentity) + if (actor.weaponentity) { - self.weaponentity.state = WS_CLEAR; - self.weaponentity.effects = 0; + actor.weaponentity.state = WS_CLEAR; + actor.weaponentity.effects = 0; } } -void w_ready(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); - if (self.weaponentity) - self.weaponentity.state = WS_READY; - weapon_thinkf(WFRAME_IDLE, 1000000, w_ready); +void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ + if (actor.weaponentity) + actor.weaponentity.state = WS_READY; + weapon_thinkf(actor, WFRAME_IDLE, 1000000, w_ready); } .float prevdryfire; .float prevwarntime; -float weapon_prepareattack_checkammo(float secondary) -{SELFPARAM(); - Weapon w = get_weaponinfo(self.weapon); - if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) +bool weapon_prepareattack_checkammo(entity actor, float secondary) +{ + Weapon w = get_weaponinfo(actor.weapon); + if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) if (!w.(secondary ? wr_checkammo2 : wr_checkammo1)(w)) { // always keep the Mine Layer if we placed mines, so that we can detonate them entity mine; - if(self.weapon == WEP_MINE_LAYER.m_id) - for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self) + if(actor.weapon == WEP_MINE_LAYER.m_id) + for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == actor) return false; - if(self.weapon == WEP_SHOTGUN.m_id) + if(actor.weapon == WEP_SHOTGUN.m_id) if(!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow - if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons + if(actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons { - sound (self, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM); - self.prevdryfire = time; + sound (actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM); + actor.prevdryfire = time; } if(w.(secondary ? wr_checkammo1 : wr_checkammo2)(w)) // check if the other firing mode has enough ammo { - if(time - self.prevwarntime > 1) + if(time - actor.prevwarntime > 1) { Send_Notification( NOTIF_ONE, - self, + actor, MSG_MULTI, ITEM_WEAPON_PRIMORSEC, - self.weapon, + actor.weapon, secondary, (1 - secondary) ); } - self.prevwarntime = time; + actor.prevwarntime = time; } else // this weapon is totally unable to fire, switch to another one { - W_SwitchToOtherWeapon(self); + W_SwitchToOtherWeapon(actor); } return false; @@ -505,14 +505,14 @@ float weapon_prepareattack_checkammo(float secondary) return true; } .float race_penalty; -float weapon_prepareattack_check(float secondary, float attacktime) -{SELFPARAM(); - if(!weapon_prepareattack_checkammo(secondary)) +bool weapon_prepareattack_check(entity actor, bool secondary, float attacktime) +{ + if(!weapon_prepareattack_checkammo(actor, secondary)) return false; //if sv_ready_restart_after_countdown is set, don't allow the player to shoot //if all players readied up and the countdown is running - if(time < game_starttime || time < self.race_penalty) { + if(time < game_starttime || time < actor.race_penalty) { return false; } @@ -520,61 +520,57 @@ float weapon_prepareattack_check(float secondary, float attacktime) return false; // do not even think about shooting if switching - if(self.switchweapon != self.weapon) + if(actor.switchweapon != actor.weapon) return false; if(attacktime >= 0) { // don't fire if previous attack is not finished - if (ATTACK_FINISHED(self) > time + self.weapon_frametime * 0.5) + if (ATTACK_FINISHED(actor) > time + actor.weapon_frametime * 0.5) return false; // don't fire while changing weapon - if (self.weaponentity.state != WS_READY) + if (actor.weaponentity.state != WS_READY) return false; } - return true; } -float weapon_prepareattack_do(float secondary, float attacktime) -{SELFPARAM(); - self.weaponentity.state = WS_INUSE; +void weapon_prepareattack_do(entity actor, bool secondary, float attacktime) +{ + actor.weaponentity.state = WS_INUSE; - self.spawnshieldtime = min(self.spawnshieldtime, time); // kill spawn shield when you fire + actor.spawnshieldtime = min(actor.spawnshieldtime, time); // kill spawn shield when you fire // if the weapon hasn't been firing continuously, reset the timer if(attacktime >= 0) { - if (ATTACK_FINISHED(self) < time - self.weapon_frametime * 1.5) + if (ATTACK_FINISHED(actor) < time - actor.weapon_frametime * 1.5) { - ATTACK_FINISHED(self) = time; + ATTACK_FINISHED(actor) = time; //dprint("resetting attack finished to ", ftos(time), "\n"); } - ATTACK_FINISHED(self) = ATTACK_FINISHED(self) + attacktime * W_WeaponRateFactor(); + ATTACK_FINISHED(actor) = ATTACK_FINISHED(actor) + attacktime * W_WeaponRateFactor(); } - self.bulletcounter += 1; - //dprint("attack finished ", ftos(ATTACK_FINISHED(self)), "\n"); - return true; + actor.bulletcounter += 1; + //dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n"); } -float weapon_prepareattack(float secondary, float attacktime) +bool weapon_prepareattack(entity actor, bool secondary, float attacktime) { - if(weapon_prepareattack_check(secondary, attacktime)) - { - weapon_prepareattack_do(secondary, attacktime); + if (weapon_prepareattack_check(actor, secondary, attacktime)) { + weapon_prepareattack_do(actor, secondary, attacktime); return true; } - else - return false; + return false; } -void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func) -{SELFPARAM(); +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func) +{ vector a; vector of, or, ou; float restartanim; if(fr == WFRAME_DONTCHANGE) { - fr = self.weaponentity.wframe; + fr = actor.weaponentity.wframe; restartanim = false; } else if (fr == WFRAME_IDLE) @@ -586,27 +582,27 @@ void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire or = v_right; ou = v_up; - if (self.weaponentity) + if (actor.weaponentity) { - self.weaponentity.wframe = fr; + actor.weaponentity.wframe = fr; a = '0 0 0'; if (fr == WFRAME_IDLE) - a = self.weaponentity.anim_idle; + a = actor.weaponentity.anim_idle; else if (fr == WFRAME_FIRE1) - a = self.weaponentity.anim_fire1; + a = actor.weaponentity.anim_fire1; else if (fr == WFRAME_FIRE2) - a = self.weaponentity.anim_fire2; + a = actor.weaponentity.anim_fire2; else // if (fr == WFRAME_RELOAD) - a = self.weaponentity.anim_reload; + a = actor.weaponentity.anim_reload; a.z *= g_weaponratefactor; - setanim(self.weaponentity, a, restartanim == false, restartanim, restartanim); + setanim(actor.weaponentity, a, restartanim == false, restartanim, restartanim); } v_forward = of; v_right = or; v_up = ou; - if(self.weapon_think == w_ready && func != w_ready && self.weaponentity.state == WS_RAISE) + if(actor.weapon_think == w_ready && func != w_ready && actor.weaponentity.state == WS_RAISE) { backtrace("Tried to override initial weapon think function - should this really happen?"); } @@ -614,31 +610,31 @@ void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire t *= W_WeaponRateFactor(); // VorteX: haste can be added here - if (self.weapon_think == w_ready) + if (actor.weapon_think == w_ready) { - self.weapon_nextthink = time; + actor.weapon_nextthink = time; //dprint("started firing at ", ftos(time), "\n"); } - if (self.weapon_nextthink < time - self.weapon_frametime * 1.5 || self.weapon_nextthink > time + self.weapon_frametime * 1.5) + if (actor.weapon_nextthink < time - actor.weapon_frametime * 1.5 || actor.weapon_nextthink > time + actor.weapon_frametime * 1.5) { - self.weapon_nextthink = time; + actor.weapon_nextthink = time; //dprint("reset weapon animation timer at ", ftos(time), "\n"); } - self.weapon_nextthink = self.weapon_nextthink + t; - self.weapon_think = func; - //dprint("next ", ftos(self.weapon_nextthink), "\n"); + actor.weapon_nextthink = actor.weapon_nextthink + t; + actor.weapon_think = func; + //dprint("next ", ftos(actor.weapon_nextthink), "\n"); if((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t) { - if((self.weapon == WEP_SHOCKWAVE.m_id || self.weapon == WEP_SHOTGUN.m_id) && fr == WFRAME_FIRE2) - animdecide_setaction(self, ANIMACTION_MELEE, restartanim); + 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(self, ANIMACTION_SHOOT, restartanim); + animdecide_setaction(actor, ANIMACTION_SHOOT, restartanim); } else { - if(self.anim_upper_action == ANIMACTION_SHOOT || self.anim_upper_action == ANIMACTION_MELEE) - self.anim_upper_action = 0; + if(actor.anim_upper_action == ANIMACTION_SHOOT || actor.anim_upper_action == ANIMACTION_MELEE) + actor.anim_upper_action = 0; } } @@ -657,87 +653,87 @@ float forbidWeaponUse(entity player) return 0; } -void W_WeaponFrame() -{SELFPARAM(); +void W_WeaponFrame(entity actor) +{ vector fo, ri, up; if (frametime) - self.weapon_frametime = frametime; + actor.weapon_frametime = frametime; - if (!self.weaponentity || self.health < 1) + if (!actor.weaponentity || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands - if(forbidWeaponUse(self)) - if(self.weaponentity.state != WS_CLEAR) + if(forbidWeaponUse(actor)) + if(actor.weaponentity.state != WS_CLEAR) { - Weapon wpn = get_weaponinfo(self.weapon); - w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); + Weapon wpn = get_weaponinfo(actor.weapon); + w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); return; } - if(!self.switchweapon) + if(!actor.switchweapon) { - self.weapon = 0; - self.switchingweapon = 0; - self.weaponentity.state = WS_CLEAR; - self.weaponname = ""; - //self.items &= ~IT_AMMO; + actor.weapon = 0; + actor.switchingweapon = 0; + actor.weaponentity.state = WS_CLEAR; + actor.weaponname = ""; + //actor.items &= ~IT_AMMO; return; } - makevectors(self.v_angle); + makevectors(actor.v_angle); fo = v_forward; // save them in case the weapon think functions change it ri = v_right; up = v_up; // Change weapon - if (self.weapon != self.switchweapon) + if (actor.weapon != actor.switchweapon) { - if (self.weaponentity.state == WS_CLEAR) + if (actor.weaponentity.state == WS_CLEAR) { // end switching! - self.switchingweapon = self.switchweapon; - entity newwep = get_weaponinfo(self.switchweapon); + actor.switchingweapon = actor.switchweapon; + entity newwep = get_weaponinfo(actor.switchweapon); // the two weapon entities will notice this has changed and update their models - self.weapon = self.switchweapon; - self.weaponname = newwep.mdl; - self.bulletcounter = 0; - self.ammo_field = newwep.ammo_field; - Weapon w = get_weaponinfo(self.switchweapon); + actor.weapon = actor.switchweapon; + actor.weaponname = newwep.mdl; + actor.bulletcounter = 0; + actor.ammo_field = newwep.ammo_field; + Weapon w = get_weaponinfo(actor.switchweapon); w.wr_setup(w); - self.weaponentity.state = WS_RAISE; + actor.weaponentity.state = WS_RAISE; // 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 { - self.clip_load = self.(weapon_load[self.switchweapon]); - self.clip_size = newwep.reloading_ammo; + actor.clip_load = actor.(weapon_load[actor.switchweapon]); + actor.clip_size = newwep.reloading_ammo; } else - self.clip_load = self.clip_size = 0; + actor.clip_load = actor.clip_size = 0; - weapon_thinkf(WFRAME_IDLE, newwep.switchdelay_raise, w_ready); + weapon_thinkf(actor, WFRAME_IDLE, newwep.switchdelay_raise, w_ready); } - else if (self.weaponentity.state == WS_DROP) + else if (actor.weaponentity.state == WS_DROP) { // in dropping phase we can switch at any time - self.switchingweapon = self.switchweapon; + actor.switchingweapon = actor.switchweapon; } - else if (self.weaponentity.state == WS_READY) + else if (actor.weaponentity.state == WS_READY) { // start switching! - self.switchingweapon = self.switchweapon; - entity oldwep = get_weaponinfo(self.weapon); + actor.switchingweapon = actor.switchweapon; + entity oldwep = get_weaponinfo(actor.weapon); // set up weapon switch think in the future, and start drop anim #ifndef INDEPENDENT_ATTACK_FINISHED - if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5) + if(ATTACK_FINISHED(actor) <= time + actor.weapon_frametime * 0.5) { #endif - sound(self, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM); - self.weaponentity.state = WS_DROP; - weapon_thinkf(WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); + sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM); + actor.weaponentity.state = WS_DROP; + weapon_thinkf(actor, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); #ifndef INDEPENDENT_ATTACK_FINISHED } #endif @@ -745,11 +741,11 @@ void W_WeaponFrame() } // LordHavoc: network timing test code - //if (self.button0) - // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(self)), " >= ", ftos(self.weapon_nextthink), "\n"); + //if (actor.button0) + // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor)), " >= ", ftos(actor.weapon_nextthink), "\n"); float w; - w = self.weapon; + w = actor.weapon; // call the think code which may fire the weapon // and do so multiple times to resolve framerate dependency issues if the @@ -759,10 +755,10 @@ void W_WeaponFrame() while (c < W_TICSPERFRAME) { c = c + 1; - if(w && !(self.weapons & WepSet_FromWeapon(w))) + if(w && !(actor.weapons & WepSet_FromWeapon(w))) { - if(self.weapon == self.switchweapon) - W_SwitchWeapon_Force(self, w_getbestweapon(self)); + if(actor.weapon == actor.switchweapon) + W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); w = 0; } @@ -771,90 +767,90 @@ void W_WeaponFrame() v_up = up; { - bool key_pressed = self.BUTTON_HOOK; - Weapon wpn = self.offhand; - if (wpn.offhand_think) wpn.offhand_think(wpn, self, key_pressed); + bool key_pressed = actor.BUTTON_HOOK; + Weapon wpn = actor.offhand; + if (wpn.offhand_think) wpn.offhand_think(wpn, actor, key_pressed); } if (w) { - Weapon e = get_weaponinfo(self.weapon); - e.wr_think(e, self.BUTTON_ATCK, self.BUTTON_ATCK2); + Weapon e = get_weaponinfo(actor.weapon); + e.wr_think(e, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); } else { - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); w.wr_gonethink(w); } - if (time + self.weapon_frametime * 0.5 >= self.weapon_nextthink) + if (time + actor.weapon_frametime * 0.5 >= actor.weapon_nextthink) { - if(self.weapon_think) + if(actor.weapon_think) { v_forward = fo; v_right = ri; v_up = up; - Weapon wpn = get_weaponinfo(self.weapon); - self.weapon_think(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); + Weapon wpn = get_weaponinfo(actor.weapon); + actor.weapon_think(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); } else - bprint("\{1}^1ERROR: undefined weapon think function for ", self.netname, "\n"); + bprint("\{1}^1ERROR: undefined weapon think function for ", actor.netname, "\n"); } } } -void W_AttachToShotorg(entity flash, vector offset) -{SELFPARAM(); +void W_AttachToShotorg(entity actor, entity flash, vector offset) +{ entity xflash; - flash.owner = self; + flash.owner = actor; flash.angles_z = random() * 360; - if(gettagindex(self.weaponentity, "shot")) - setattachment(flash, self.weaponentity, "shot"); + if(gettagindex(actor.weaponentity, "shot")) + setattachment(flash, actor.weaponentity, "shot"); else - setattachment(flash, self.weaponentity, "tag_shot"); + setattachment(flash, actor.weaponentity, "tag_shot"); setorigin(flash, offset); xflash = spawn(); copyentity(flash, xflash); - flash.viewmodelforclient = self; + flash.viewmodelforclient = actor; - if(self.weaponentity.oldorigin.x > 0) + if(actor.weaponentity.oldorigin.x > 0) { - setattachment(xflash, self.exteriorweaponentity, ""); - setorigin(xflash, self.weaponentity.oldorigin + offset); + setattachment(xflash, actor.exteriorweaponentity, ""); + setorigin(xflash, actor.weaponentity.oldorigin + offset); } else { - if(gettagindex(self.exteriorweaponentity, "shot")) - setattachment(xflash, self.exteriorweaponentity, "shot"); + if(gettagindex(actor.exteriorweaponentity, "shot")) + setattachment(xflash, actor.exteriorweaponentity, "shot"); else - setattachment(xflash, self.exteriorweaponentity, "tag_shot"); + setattachment(xflash, actor.exteriorweaponentity, "tag_shot"); setorigin(xflash, offset); } } -void W_DecreaseAmmo(Weapon wep, float ammo_use) -{SELFPARAM(); +void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use) +{ if(cvar("g_overkill")) - if(self.ok_use_ammocharge) + if(actor.ok_use_ammocharge) { - ok_DecreaseCharge(self, self.weapon); + ok_DecreaseCharge(actor, actor.weapon); return; // TODO } - if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) + if((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return; // if this weapon is reloadable, decrease its load. Else decrease the player's ammo if(wep.reloading_ammo) { - self.clip_load -= ammo_use; - self.(weapon_load[self.weapon]) = self.clip_load; + actor.clip_load -= ammo_use; + actor.(weapon_load[actor.weapon]) = actor.clip_load; } else if(wep.ammo_field != ammo_none) { - self.(wep.ammo_field) -= ammo_use; - if(self.(wep.ammo_field) < 0) + actor.(wep.ammo_field) -= ammo_use; + if(actor.(wep.ammo_field) < 0) { backtrace(sprintf( "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... " @@ -862,8 +858,8 @@ void W_DecreaseAmmo(Weapon wep, float ammo_use) ammo_use, wep.netname, GetAmmoPicture(wep.ammo_field), - self.netname, - self.(wep.ammo_field) + actor.netname, + actor.(wep.ammo_field) )); } } @@ -875,48 +871,48 @@ void W_DecreaseAmmo(Weapon wep, float ammo_use) .float reload_complain; .string reload_sound; -void W_ReloadedAndReady(Weapon thiswep, bool fire1, bool fire2) -{SELFPARAM(); +void W_ReloadedAndReady(Weapon thiswep, entity actor, bool fire1, bool fire2) +{ // finish the reloading process, and do the ammo transfer - self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading + actor.clip_load = actor.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load - if(!self.reload_ammo_min || self.items & IT_UNLIMITED_WEAPON_AMMO || self.ammo_field == ammo_none) - self.clip_load = self.reload_ammo_amount; + if(!actor.reload_ammo_min || actor.items & IT_UNLIMITED_WEAPON_AMMO || actor.ammo_field == ammo_none) + actor.clip_load = actor.reload_ammo_amount; else { // make sure we don't add more ammo than we have - float load = min(self.reload_ammo_amount - self.clip_load, self.(self.ammo_field)); - self.clip_load += load; - self.(self.ammo_field) -= load; + float load = min(actor.reload_ammo_amount - actor.clip_load, actor.(actor.ammo_field)); + actor.clip_load += load; + actor.(actor.ammo_field) -= load; } - self.(weapon_load[self.weapon]) = self.clip_load; + actor.(weapon_load[actor.weapon]) = actor.clip_load; // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon, // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there, // so your weapon is disabled for a few seconds without reason - //ATTACK_FINISHED(self) -= self.reload_time - 1; + //ATTACK_FINISHED(actor) -= actor.reload_time - 1; - Weapon wpn = get_weaponinfo(self.weapon); - w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); + Weapon wpn = get_weaponinfo(actor.weapon); + w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); } -void W_Reload(float sent_ammo_min, string sent_sound) -{SELFPARAM(); +void W_Reload(entity actor, float sent_ammo_min, string sent_sound) +{ // set global values to work with entity e; - e = get_weaponinfo(self.weapon); + e = get_weaponinfo(actor.weapon); if(cvar("g_overkill")) - if(self.ok_use_ammocharge) + if(actor.ok_use_ammocharge) return; // TODO - self.reload_ammo_min = sent_ammo_min; - self.reload_ammo_amount = e.reloading_ammo; - self.reload_time = e.reloading_time; - self.reload_sound = sent_sound; + actor.reload_ammo_min = sent_ammo_min; + actor.reload_ammo_amount = e.reloading_ammo; + actor.reload_time = e.reloading_time; + actor.reload_sound = sent_sound; // don't reload weapons that don't have the RELOADABLE flag if (!(e.spawnflags & WEP_FLAG_RELOADABLE)) @@ -926,59 +922,59 @@ void W_Reload(float sent_ammo_min, string sent_sound) } // return if reloading is disabled for this weapon - if(!self.reload_ammo_amount) + if(!actor.reload_ammo_amount) return; // our weapon is fully loaded, no need to reload - if (self.clip_load >= self.reload_ammo_amount) + if (actor.clip_load >= actor.reload_ammo_amount) return; // no ammo, so nothing to load - if(self.ammo_field != ammo_none) - if(!self.(self.ammo_field) && self.reload_ammo_min) - if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) + if(actor.ammo_field != ammo_none) + if(!actor.(actor.ammo_field) && actor.reload_ammo_min) + if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { - if(IS_REAL_CLIENT(self) && self.reload_complain < time) + if(IS_REAL_CLIENT(actor) && actor.reload_complain < time) { - play2(self, SND(UNAVAILABLE)); - sprint(self, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(self.weapon), "\n")); - self.reload_complain = time + 1; + play2(actor, SND(UNAVAILABLE)); + sprint(actor, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(actor.weapon), "\n")); + actor.reload_complain = time + 1; } // switch away if the amount of ammo is not enough to keep using this weapon - Weapon w = get_weaponinfo(self.weapon); + Weapon w = get_weaponinfo(actor.weapon); if (!(w.wr_checkammo1(w) + w.wr_checkammo2(w))) { - self.clip_load = -1; // reload later - W_SwitchToOtherWeapon(self); + actor.clip_load = -1; // reload later + W_SwitchToOtherWeapon(actor); } return; } - if (self.weaponentity) + if (actor.weaponentity) { - if (self.weaponentity.wframe == WFRAME_RELOAD) + if (actor.weaponentity.wframe == WFRAME_RELOAD) return; // allow switching away while reloading, but this will cause a new reload! - self.weaponentity.state = WS_READY; + actor.weaponentity.state = WS_READY; } // now begin the reloading process - _sound(self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTEN_NORM); + _sound(actor, CH_WEAPON_SINGLE, actor.reload_sound, VOL_BASE, ATTEN_NORM); // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon, // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there, // so your weapon is disabled for a few seconds without reason - //ATTACK_FINISHED(self) = max(time, ATTACK_FINISHED(self)) + self.reload_time + 1; + //ATTACK_FINISHED(actor) = max(time, ATTACK_FINISHED(actor)) + actor.reload_time + 1; - weapon_thinkf(WFRAME_RELOAD, self.reload_time, W_ReloadedAndReady); + weapon_thinkf(actor, WFRAME_RELOAD, actor.reload_time, W_ReloadedAndReady); - if(self.clip_load < 0) - self.clip_load = 0; - self.old_clip_load = self.clip_load; - self.clip_load = self.(weapon_load[self.weapon]) = -1; + if(actor.clip_load < 0) + actor.clip_load = 0; + actor.old_clip_load = actor.clip_load; + actor.clip_load = actor.(weapon_load[actor.weapon]) = -1; } void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item) diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 9849f9bd4..d3d9f14fa 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -20,26 +20,26 @@ vector CL_Weapon_GetShotOrg(float wpn); float forbidWeaponUse(entity player); -void W_AttachToShotorg(entity flash, vector offset); +void W_AttachToShotorg(entity actor, entity flash, vector offset); -void W_DecreaseAmmo(Weapon wep, float ammo_use); +void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use); void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item); -void W_Reload(float sent_ammo_min, string sent_sound); +void W_Reload(entity actor, float sent_ammo_min, string sent_sound); -void W_WeaponFrame(); +void W_WeaponFrame(entity actor); float W_WeaponRateFactor(); float W_WeaponSpeedFactor(); -float weapon_prepareattack(float secondary, float attacktime); +bool weapon_prepareattack(entity actor, bool secondary, float attacktime); -float weapon_prepareattack_check(float secondary, float attacktime); +bool weapon_prepareattack_check(entity actor, float secondary, float attacktime); -float weapon_prepareattack_do(float secondary, float attacktime); +void weapon_prepareattack_do(entity actor, float secondary, float attacktime); -void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func); +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func); #endif