return true;
}
- METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, int fire))
{
- if(fire1)
+ if(fire & 1)
if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire))
if(autocvar_g_nexball_basketball_meter)
{
W_Nexball_Attack(-1);
weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
- if(fire2)
+ if(fire & 2)
if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
{
W_Nexball_Attack2();
weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
}
- if(!fire1 && self.metertime && self.ballcarried)
+ if(!(fire & 1) && self.metertime && self.ballcarried)
{
W_Nexball_Attack(time - self.metertime);
// DropBall or stealing will set metertime back to 0
void M_Mage_Attack_Spike(vector dir);
void M_Mage_Attack_Push();
-METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bool fire2)) {
- if (fire1)
+METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, int fire)) {
+ if (fire & 1)
if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, false, 0.2)) {
if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range;
actor.enemy = Monster_FindTarget(actor);
M_Mage_Attack_Spike(w_shotdir);
weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
}
- if (fire2)
+ if (fire & 2)
if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, true, 0.5)) {
M_Mage_Attack_Push();
weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
if(random() <= 0.7)
{
Weapon wep = WEP_MAGE_SPIKE;
- wep.wr_think(wep, self, false, true);
+ wep.wr_think(wep, self, 2);
return true;
}
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, self, true, false);
+ wep.wr_think(wep, self, 1);
return true;
}
}
void M_Spider_Attack_Web();
-METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, false, autocvar_g_monster_spider_attack_web_delay)) {
if (!isPlayer) {
actor.spider_web_delay = time + 3;
weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
return;
}
- if (fire2)
+ if (fire & 2)
if (!isPlayer || weapon_prepareattack(thiswep, actor, true, 0.5)) {
if (isPlayer) {
actor.enemy = Monster_FindTarget(actor);
Weapon wep = WEP_SPIDER_ATTACK;
case MONSTER_ATTACK_MELEE:
{
- wep.wr_think(wep, self, false, true);
+ wep.wr_think(wep, self, 2);
return true;
}
case MONSTER_ATTACK_RANGED:
{
- wep.wr_think(wep, self, true, false);
+ wep.wr_think(wep, self, 1);
return true;
}
}
void M_Wyvern_Attack_Fireball_Explode();
void M_Wyvern_Attack_Fireball_Touch();
-METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) {
- if (fire1)
+METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, int fire)) {
+ if (fire & 1)
if (time > actor.attack_finished_single || weapon_prepareattack(thiswep, 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)) {
{
w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin);
Weapon wep = WEP_WYVERN_ATTACK;
- wep.wr_think(wep, self, true, false);
+ wep.wr_think(wep, self, 1);
return true;
}
}
/** (SERVER) called when turret attacks */
METHOD(Turret, tr_attack, void(Turret this)) {
Weapon w = this.m_weapon;
- w.wr_think(w, self, true, false);
+ w.wr_think(w, self, 1);
}
/** (ALL) */
METHOD(Turret, tr_config, void(Turret this)) {
#ifdef SVQC
void turret_initparams(entity);
-METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
#ifdef SVQC
void turret_flac_projectile_think_explode();
-METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
float autocvar_g_turrets_unit_hellion_shot_speed_max;
void turret_hellion_missile_think();
-METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
float autocvar_g_turrets_unit_hk_shot_speed_turnrate;
void turret_hk_missile_think();
-METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, int fire))
{
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
void W_MachineGun_MuzzleFlash();
-METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, int fire))
{
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) {
if (isPlayer) {
turret_initparams(actor);
#ifdef SVQC
-METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, int fire))
{
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) {
if (isPlayer) {
turret_initparams(actor);
.int fireflag;
-METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, int fire))
{
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
#ifdef SVQC
-METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
#ifdef SVQC
entity toast(entity from, float range, float damage);
-METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
#ifdef SVQC
-METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
- if (fire1)
+ if (fire & 1)
if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
// Fix z-aim (for chase mode)
crosshair_trace(player);
w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
- wep1.wr_think(wep1, self, true, false);
+ wep1.wr_think(wep1, self, 1);
}
if(autocvar_g_vehicle_racer_rocket_locktarget)
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, entity actor, bool fire1, bool fire2))
+METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, int fire))
{
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
- if (fire1)
+ if (fire & 1)
if (weapon_prepareattack(thiswep, player, false, autocvar_g_vehicle_racer_cannon_refire)) {
if (veh) {
veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost;
bolt.velocity = normalize(dir) * autocvar_g_vehicle_racer_cannon_speed;
weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready);
}
- if (fire2)
+ if (fire & 2)
if (!isPlayer || weapon_prepareattack(thiswep, 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);
if(player.BUTTON_ATCK)
if (wep1.wr_checkammo1(wep1))
{
- wep1.wr_think(wep1, self, true, false);
+ wep1.wr_think(wep1, self, 1);
}
if(self.vehicle_flags & VHF_SHIELDREGEN)
if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
if(player.BUTTON_ATCK2)
{
- wep2a.wr_think(wep2a, self, false, true);
+ wep2a.wr_think(wep2a, self, 2);
raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
raptor.lip = time;
}
if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
if(player.BUTTON_ATCK2)
{
- wep2b.wr_think(wep2b, self, false, true);
+ wep2b.wr_think(wep2b, self, 2);
raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
raptor.lip = time;
}
float autocvar_g_vehicle_raptor_bomblet_force;
float autocvar_g_vehicle_raptor_bomblet_explode_delay;
-METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
// 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 (fire & 1)
if (weapon_prepareattack(thiswep, player, false, t)) {
if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
vector org = w_shotorg;
float autocvar_g_vehicle_raptor_bombs_refire;
void raptor_bombdrop();
-METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
+METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
- if (fire2)
+ if (fire & 2)
if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_bombs_refire)) {
if (veh) setself(veh);
raptor_bombdrop();
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, entity actor, bool fire1, bool fire2)) {
+METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, int fire)) {
bool isPlayer = IS_PLAYER(actor);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
- if (fire2)
+ if (fire & 2)
if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_flare_refire)) {
for(int i = 0; i < 3; ++i) {
entity _flare = spawn();
/** (SERVER) setup weapon data */
METHOD(Weapon, wr_setup, void(Weapon this)) {}
/** (SERVER) logic to run every frame */
- METHOD(Weapon, wr_think, void(Weapon this, entity actor, bool fire1, bool fire2)) {}
+ METHOD(Weapon, wr_think, void(Weapon this, entity actor, int fire)) {}
/** (SERVER) checks ammo for weapon primary */
METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
/** (SERVER) checks ammo for weapon second */
);
}
}
- METHOD(Arc, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Arc, wr_think, void(entity thiswep, entity actor, int fire))
{
Arc_Player_SetHeat(actor);
Arc_Smoke();
if (time >= actor.arc_overheat)
- if (fire1 || fire2 || actor.arc_beam.beam_bursting)
+ if ((fire & 1) || (fire & 2) || actor.arc_beam.beam_bursting)
{
if(actor.arc_BUTTON_ATCK_prev)
if((!actor.arc_beam) || wasfreed(actor.arc_beam))
{
- if(weapon_prepareattack(thiswep, actor, fire2, 0))
+ if(weapon_prepareattack(thiswep, actor, boolean(fire & 2), 0))
{
- W_Arc_Beam(fire2);
+ W_Arc_Beam(boolean(fire & 2));
if(!actor.arc_BUTTON_ATCK_prev)
{
actor.arc_BUTTON_ATCK_prev = false;
#if 0
- if(fire2)
+ if(fire & 2)
if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_arc_secondary_refire))
{
W_Arc_Attack2();
{ self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
}
- METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, int fire))
{
- if(fire1)
+ if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(blaster, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready);
}
}
- else if(fire2)
+ else if(fire & 2)
{
switch(WEP_CVAR(blaster, secondary))
{
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, entity actor, bool fire1, bool fire2))
+ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, int fire))
{
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(fire & 1)
{
if(actor.crylink_waitrelease != 1)
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(crylink, refire)))
}
}
- if(fire2 && autocvar_g_balance_crylink_secondary)
+ if((fire & 2) && autocvar_g_balance_crylink_secondary)
{
if(actor.crylink_waitrelease != 2)
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(crylink, refire)))
}
}
- if((actor.crylink_waitrelease == 1 && !fire1) || (actor.crylink_waitrelease == 2 && !fire2))
+ if((actor.crylink_waitrelease == 1 && !(fire & 1)) || (actor.crylink_waitrelease == 2 && !(fire & 2)))
{
if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time)
{
}
}
#endif
- METHOD(Devastator, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, int fire))
{
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 {
- if(fire1)
+ if(fire & 1)
{
if(actor.rl_release || WEP_CVAR(devastator, guidestop))
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(devastator, refire)))
else
actor.rl_release = 1;
- if(fire2)
+ if(fire & 2)
if(actor.switchweapon == WEP_DEVASTATOR.m_id)
{
entity rock;
MUTATOR_CALLHOOK(EditProjectile, self, proj);
}
-void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Electro_CheckAttack(Weapon thiswep, entity actor, int fire)
{SELFPARAM();
if(self.electro_count > 1)
if(self.BUTTON_ATCK2)
return;
}
// WEAPONTODO: when the player releases the button, cut down the length of refire2?
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
}
.float bot_secondary_electromooth;
}
}
}
- METHOD(Electro, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Electro, wr_think, void(entity thiswep, entity actor, int fire))
{
if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
{
}
}
- if(fire1)
+ if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
}
}
- else if(fire2)
+ else if(fire & 2)
{
if(time >= actor.electro_secondarytime)
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(electro, refire)))
Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
}
-void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, int fire)
{
W_Fireball_Attack1();
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
}
-void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, int fire)
{
W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
}
-void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, int fire)
{
W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
}
-void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, int fire)
{
W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
}
-void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, int fire)
{SELFPARAM();
W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
}
}
}
- METHOD(Fireball, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Fireball, wr_think, void(entity thiswep, entity actor, int fire))
{
- if(fire1)
+ if(fire & 1)
{
if(time >= actor.fireball_primarytime)
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(fireball, refire)))
{
- W_Fireball_Attack1_Frame0(thiswep, actor, fire1, fire2);
+ W_Fireball_Attack1_Frame0(thiswep, actor, fire);
actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
}
}
- else if(fire2)
+ else if(fire & 2)
{
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(fireball, refire)))
{
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, entity actor, bool fire1, bool fire2))
+ METHOD(Hagar, wr_think, void(entity thiswep, entity actor, int fire))
{
float loadable_secondary;
loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
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 && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
+ } else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hagar, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
}
}
- else if(fire2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
+ else if((fire & 2) && !loadable_secondary && WEP_CVAR(hagar, secondary))
{
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hagar, refire)))
{
}
// weapon frames
-void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, int fire)
{
if(actor.weapon != actor.switchweapon) // abort immediately if switching
{
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
{
self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false);
}
- METHOD(HLAC, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, int fire))
{
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)
+ } else if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hlac, refire)))
{
}
}
- else if(fire2 && WEP_CVAR(hlac, secondary))
+ else if((fire & 2) && WEP_CVAR(hlac, secondary))
{
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hlac, refire)))
{
spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(WEP_HMG.m_id); }
-void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int fire)
{
if (!actor.BUTTON_ATCK)
{
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
else
self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
}
- METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, int fire))
{
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 (fire & 1)
if (weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 0;
- W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
+ W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire);
}
}
}
METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
{
Weapon wep = WEP_HOOK;
- wep.wr_think(wep, actor, key_pressed, false);
+ wep.wr_think(wep, actor, key_pressed ? 1 : 0);
}
ENDCLASS(OffhandHook)
OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); }
MUTATOR_CALLHOOK(EditProjectile, actor, gren);
}
- METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Hook, wr_think, void(entity thiswep, entity actor, int fire))
{
- if (fire1) {
+ if (fire & 1) {
if(!actor.hook)
if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
if(time > actor.hook_refire)
actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
}
- if(fire2)
+ if(fire & 2)
{
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hook, refire)))
{
}
// weapon frames
-void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, int fire)
{
if(actor.weapon != actor.switchweapon) // abort immediately if switching
{
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
if(actor.BUTTON_ATCK)
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
}
-void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, int fire)
{
float machinegun_spread;
- if(!fire1)
+ if(!(fire & 1))
{
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
}
-void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int fire)
{
W_SetupShot(actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
if(!autocvar_g_norecoil)
else
self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
}
- METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, int fire))
{
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);
} else
if(WEP_CVAR(machinegun, mode) == 1)
{
- if(fire1)
+ if(fire & 1)
if(weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 0;
- W_MachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
+ W_MachineGun_Attack_Auto(thiswep, actor, fire);
}
- if(fire2)
+ if(fire & 2)
if(weapon_prepareattack(thiswep, actor, true, 0))
{
Weapon w = get_weaponinfo(actor.weapon);
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo));
actor.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
- W_MachineGun_Attack_Burst(thiswep, actor, fire1, fire2);
+ W_MachineGun_Attack_Burst(thiswep, actor, fire);
}
}
else
{
- if(fire1)
+ if(fire & 1)
if(weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 1;
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
- if(fire2 && WEP_CVAR(machinegun, first))
+ if((fire & 2) && WEP_CVAR(machinegun, first))
if(weapon_prepareattack(thiswep, actor, true, 0))
{
actor.misc_bulletcounter = 1;
if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false;
}
}
- METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, int fire))
{
if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
{
w.wr_reload(w);
}
}
- else if(fire1)
+ else if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(minelayer, refire)))
{
}
}
- if(fire2)
+ if(fire & 2)
{
if(W_MineLayer_PlacedMines(true))
sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
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, entity actor, bool fire1, bool fire2))
+ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, int fire))
{
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)
+ } else if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(mortar, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
}
}
- else if(fire2)
+ else if(fire & 2)
{
if(WEP_CVAR_SEC(mortar, remote_detonateprimary))
{
{
PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
}
- METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, int fire))
{
if(WEP_CVAR(porto, secondary))
{
- if(fire1)
+ if(fire & 1)
if(!actor.porto_current)
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
}
- if(fire2)
+ if(fire & 2)
if(!actor.porto_current)
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(porto, refire)))
{
if(actor.porto_v_angle_held)
{
- if(!fire2)
+ if(!(fire & 2))
{
actor.porto_v_angle_held = 0;
}
else
{
- if(fire2)
+ if(fire & 2)
{
actor.porto_v_angle = actor.v_angle;
actor.porto_v_angle_held = 1;
if(actor.porto_v_angle_held)
makevectors(actor.porto_v_angle); // override the previously set angles
- if(fire1)
+ if(fire & 1)
if(!actor.porto_current)
if(!actor.porto_forbidden)
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
.float rifle_bullethail_frame;
.float rifle_bullethail_animtime;
.float rifle_bullethail_refire;
-void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, int fire)
{
float r, sw, af;
}
}
}
- METHOD(Rifle, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, int fire))
{
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);
} else
{
actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
- if(fire1)
+ if(fire & 1)
if(weapon_prepareattack_check(thiswep, actor, false, WEP_CVAR_PRI(rifle, refire)))
if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
{
W_Rifle_BulletHail(WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
}
- if(fire2)
+ if(fire & 2)
{
if(WEP_CVAR(rifle, secondary))
{
{
self.BUTTON_ATCK = bot_aim(WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false);
}
- METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, int fire))
{
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 (fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(rpc, refire)))
{
}
}
- if (fire2)
+ if (fire & 2)
{
// to-do
}
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, entity actor, bool fire1, bool fire2))
+ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, int fire))
{
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)
+ } else if(fire & 1)
{
if(WEP_CVAR(seeker, type) == 1)
{
}
}
- else if(fire2)
+ else if(fire & 2)
{
if(WEP_CVAR(seeker, type) == 1)
{
}
}
-void W_Shockwave_Melee(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Shockwave_Melee(Weapon thiswep, entity actor, int fire)
{
sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
else
{ self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); }
}
- METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, int fire))
{
- if(fire1)
+ if(fire & 1)
{
if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
{
}
}
}
- else if(fire2)
+ else if(fire & 2)
{
//if(actor.clip_load >= 0) // we are not currently reloading
if(!actor.crouch) // no crouchmelee please
}
}
-void W_Shotgun_Attack2(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Shotgun_Attack2(Weapon thiswep, entity actor, int fire)
{
sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
}
// alternate secondary weapon frames
-void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, int fire)
{
Weapon w = get_weaponinfo(actor.weapon);
if (!w.wr_checkammo2(w))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
}
-void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int fire)
{
Weapon w = get_weaponinfo(actor.weapon);
if (!w.wr_checkammo2(w))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
- w_ready(thiswep, actor, fire1, fire2);
+ w_ready(thiswep, actor, fire);
return;
}
else
self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
}
- METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, int fire))
{
if(WEP_CVAR(shotgun, reload_ammo) && actor.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload
{
}
else
{
- if(fire1)
+ if(fire & 1)
{
if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
{
}
}
}
- else if(fire2 && WEP_CVAR(shotgun, secondary) == 2)
+ else if((fire & 2) && WEP_CVAR(shotgun, secondary) == 2)
{
if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
{
if(actor.clip_load >= 0) // we are not currently reloading
if(!actor.crouch) // no crouchmelee please
if(WEP_CVAR(shotgun, secondary) == 1)
- if((fire1 && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || fire2)
+ if(((fire & 1) && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(shotgun, refire)))
{
// attempt forcing playback of the anim by switching to another anim (that we never play) here...
self.BUTTON_ATCK2 = 1;
}
}
- METHOD(Tuba, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Tuba, wr_think, void(entity thiswep, entity actor, int fire))
{
- if(fire1)
+ if(fire & 1)
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(0);
//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(fire & 2)
if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(HITTYPE_SECONDARY);
}
if(actor.tuba_note)
{
- if(!fire1 && !fire2)
+ if(!(fire & 1) && !(fire & 2))
{
WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff());
}
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, entity actor, bool fire1, bool fire2))
+ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, int fire))
{
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
// if the laser uses load, we also consider its ammo for reloading
Weapon w = get_weaponinfo(actor.weapon);
w.wr_reload(w);
}
- if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
+ if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vaporizer, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
}
}
- if(fire2 || (fire1 && !actor.ammo_cells && autocvar_g_rm))
+ if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm))
{
if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
{
self.BUTTON_ATCK2 = true;
}
}
- METHOD(Vortex, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
+ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, int fire))
{
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);
w.wr_reload(w);
} else
{
- if(fire1)
+ if(fire & 1)
{
if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vortex, refire)))
{
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
}
}
- if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : fire2)
+ if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : (fire & 2))
{
if(WEP_CVAR(vortex, charge))
{
else if(WEP_CVAR_SEC(vortex, ammo))
{
- if(fire2) // only eat ammo when the button is pressed
+ if(fire & 2) // only eat ammo when the button is pressed
{
dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate));
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
#include "../common/weapons/all.qh"
-#define INDEPENDENT_ATTACK_FINISHED
+#define INDEPENDENT_ATTACK_FINISHED 1
#define BUTTON_ATCK button0
#define BUTTON_JUMP button2
// WEAPONTODO
.float autoswitch;
float client_hasweapon(entity cl, float wpn, float andammo, float complain);
-void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2);
-void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2);
+void w_clear(Weapon thiswep, entity actor, int fire);
+void w_ready(Weapon thiswep, entity actor, int fire);
// 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, entity actor, bool fire1, bool fire2) weapon_think;
+.void(Weapon thiswep, entity actor, int fire) weapon_think;
// weapon states (self.weaponentity.state)
}
Weapon wpn = get_weaponinfo(self.weapon);
if(self.weaponentity.state != WS_CLEAR)
- w_ready(wpn, self, self.BUTTON_ATCK, self.BUTTON_ATCK2);
+ w_ready(wpn, self, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0));
self.weapon_blocked = true;
}
}
-void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func);
+void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func);
-float CL_Weaponentity_CustomizeEntityForClient()
+bool CL_Weaponentity_CustomizeEntityForClient()
{
SELFPARAM();
- self.viewmodelforclient = self.owner;
- if (IS_SPEC(other))
- if (other.enemy == self.owner) self.viewmodelforclient = other;
+ this.viewmodelforclient = this.owner;
+ if (IS_SPEC(other) && other.enemy == this.owner) this.viewmodelforclient = other;
return true;
}
*/
// writes:
-// self.origin, self.angles
-// self.weaponentity
-// self.movedir, self.view_ofs
+// this.origin, this.angles
+// this.weaponentity
+// this.movedir, this.view_ofs
// attachment stuff
// anim stuff
// to free:
// call again with ""
// remove the ent
-void CL_WeaponEntity_SetModel(string name)
+void CL_WeaponEntity_SetModel(entity this, string name)
{
- SELFPARAM();
- float v_shot_idx;
if (name != "")
{
// if there is a child entity, hide it until we're sure we use it
- if (self.weaponentity) self.weaponentity.model = "";
- _setmodel(self, W_Model(strcat("v_", name, ".md3")));
- v_shot_idx = gettagindex(self, "shot"); // used later
- if (!v_shot_idx) v_shot_idx = gettagindex(self, "tag_shot");
+ if (this.weaponentity) this.weaponentity.model = "";
+ _setmodel(this, W_Model(strcat("v_", name, ".md3")));
+ int v_shot_idx = gettagindex(this, "shot"); // used later
+ if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot");
- _setmodel(self, W_Model(strcat("h_", name, ".iqm")));
+ _setmodel(this, W_Model(strcat("h_", name, ".iqm")));
// preset some defaults that work great for renamed zym files (which don't need an animinfo)
- self.anim_fire1 = animfixfps(self, '0 1 0.01', '0 0 0');
- self.anim_fire2 = animfixfps(self, '1 1 0.01', '0 0 0');
- self.anim_idle = animfixfps(self, '2 1 0.01', '0 0 0');
- self.anim_reload = animfixfps(self, '3 1 0.01', '0 0 0');
+ this.anim_fire1 = animfixfps(this, '0 1 0.01', '0 0 0');
+ this.anim_fire2 = animfixfps(this, '1 1 0.01', '0 0 0');
+ this.anim_idle = animfixfps(this, '2 1 0.01', '0 0 0');
+ this.anim_reload = animfixfps(this, '3 1 0.01', '0 0 0');
// if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model)
// if we don't, this is a "real" animated model
- if (gettagindex(self, "weapon"))
+ if (gettagindex(this, "weapon"))
{
- if (!self.weaponentity) self.weaponentity = spawn();
- _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
- setattachment(self.weaponentity, self, "weapon");
+ if (!this.weaponentity) this.weaponentity = spawn();
+ _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3")));
+ setattachment(this.weaponentity, this, "weapon");
}
- else if (gettagindex(self, "tag_weapon"))
+ else if (gettagindex(this, "tag_weapon"))
{
- if (!self.weaponentity) self.weaponentity = spawn();
- _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
- setattachment(self.weaponentity, self, "tag_weapon");
+ if (!this.weaponentity) this.weaponentity = spawn();
+ _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3")));
+ setattachment(this.weaponentity, this, "tag_weapon");
}
else
{
- if (self.weaponentity) remove(self.weaponentity);
- self.weaponentity = world;
+ if (this.weaponentity) remove(this.weaponentity);
+ this.weaponentity = world;
}
- setorigin(self, '0 0 0');
- self.angles = '0 0 0';
- self.frame = 0;
- self.viewmodelforclient = world;
+ setorigin(this, '0 0 0');
+ this.angles = '0 0 0';
+ this.frame = 0;
+ this.viewmodelforclient = world;
float idx;
if (v_shot_idx) // v_ model attached to invisible h_ model
{
- self.movedir = gettaginfo(self.weaponentity, v_shot_idx);
+ this.movedir = gettaginfo(this.weaponentity, v_shot_idx);
}
else
{
- idx = gettagindex(self, "shot");
- if (!idx) idx = gettagindex(self, "tag_shot");
+ idx = gettagindex(this, "shot");
+ if (!idx) idx = gettagindex(this, "tag_shot");
if (idx)
{
- self.movedir = gettaginfo(self, idx);
+ this.movedir = gettaginfo(this, idx);
}
else
{
- LOG_INFO("WARNING: weapon model ", self.model,
+ LOG_INFO("WARNING: weapon model ", this.model,
" does not support the 'shot' tag, will display shots TOTALLY wrong\n");
- self.movedir = '0 0 0';
+ this.movedir = '0 0 0';
}
}
- if (self.weaponentity) // v_ model attached to invisible h_ model
+ if (this.weaponentity) // v_ model attached to invisible h_ model
{
- idx = gettagindex(self.weaponentity, "shell");
- if (!idx) idx = gettagindex(self.weaponentity, "tag_shell");
- if (idx) self.spawnorigin = gettaginfo(self.weaponentity, idx);
+ idx = gettagindex(this.weaponentity, "shell");
+ if (!idx) idx = gettagindex(this.weaponentity, "tag_shell");
+ if (idx) this.spawnorigin = gettaginfo(this.weaponentity, idx);
}
else
{
}
if (!idx)
{
- idx = gettagindex(self, "shell");
- if (!idx) idx = gettagindex(self, "tag_shell");
+ idx = gettagindex(this, "shell");
+ if (!idx) idx = gettagindex(this, "tag_shell");
if (idx)
{
- self.spawnorigin = gettaginfo(self, idx);
+ this.spawnorigin = gettaginfo(this, idx);
}
else
{
- LOG_INFO("WARNING: weapon model ", self.model,
+ LOG_INFO("WARNING: weapon model ", this.model,
" does not support the 'shell' tag, will display casings wrong\n");
- self.spawnorigin = self.movedir;
+ this.spawnorigin = this.movedir;
}
}
if (v_shot_idx)
{
- self.oldorigin = '0 0 0'; // use regular attachment
+ this.oldorigin = '0 0 0'; // use regular attachment
}
else
{
- if (self.weaponentity)
+ if (this.weaponentity)
{
- idx = gettagindex(self, "weapon");
- if (!idx) idx = gettagindex(self, "tag_weapon");
+ idx = gettagindex(this, "weapon");
+ if (!idx) idx = gettagindex(this, "tag_weapon");
}
else
{
- idx = gettagindex(self, "handle");
- if (!idx) idx = gettagindex(self, "tag_handle");
+ idx = gettagindex(this, "handle");
+ if (!idx) idx = gettagindex(this, "tag_handle");
}
if (idx)
{
- self.oldorigin = self.movedir - gettaginfo(self, idx);
+ this.oldorigin = this.movedir - gettaginfo(this, idx);
}
else
{
- LOG_INFO("WARNING: weapon model ", self.model,
+ LOG_INFO("WARNING: weapon model ", this.model,
" does not support the 'handle' tag and neither does the v_ model support the 'shot' tag, will display muzzle flashes TOTALLY wrong\n");
- self.oldorigin = '0 0 0'; // there is no way to recover from this
+ this.oldorigin = '0 0 0'; // there is no way to recover from this
}
}
- self.viewmodelforclient = self.owner;
+ this.viewmodelforclient = this.owner;
}
else
{
- self.model = "";
- if (self.weaponentity) remove(self.weaponentity);
- self.weaponentity = world;
- self.movedir = '0 0 0';
- self.spawnorigin = '0 0 0';
- self.oldorigin = '0 0 0';
- self.anim_fire1 = '0 1 0.01';
- self.anim_fire2 = '0 1 0.01';
- self.anim_idle = '0 1 0.01';
- self.anim_reload = '0 1 0.01';
+ this.model = "";
+ if (this.weaponentity) remove(this.weaponentity);
+ this.weaponentity = world;
+ this.movedir = '0 0 0';
+ this.spawnorigin = '0 0 0';
+ this.oldorigin = '0 0 0';
+ this.anim_fire1 = '0 1 0.01';
+ this.anim_fire2 = '0 1 0.01';
+ this.anim_idle = '0 1 0.01';
+ this.anim_reload = '0 1 0.01';
}
- self.view_ofs = '0 0 0';
+ this.view_ofs = '0 0 0';
- if (self.movedir.x >= 0)
+ if (this.movedir.x >= 0)
{
- vector v0;
- v0 = self.movedir;
- self.movedir = shotorg_adjust(v0, false, false, self.owner.cvar_cl_gunalign);
- self.view_ofs = shotorg_adjust(v0, false, true, self.owner.cvar_cl_gunalign) - v0;
+ vector v0 = this.movedir;
+ this.movedir = shotorg_adjust(v0, false, false, this.owner.cvar_cl_gunalign);
+ this.view_ofs = shotorg_adjust(v0, false, true, this.owner.cvar_cl_gunalign) - v0;
}
- self.owner.stat_shotorg = compressShotOrigin(self.movedir);
- self.movedir = decompressShotOrigin(self.owner.stat_shotorg); // make them match perfectly
+ this.owner.stat_shotorg = compressShotOrigin(this.movedir);
+ this.movedir = decompressShotOrigin(this.owner.stat_shotorg); // make them match perfectly
- self.spawnorigin += self.view_ofs; // offset the casings origin by the same amount
+ this.spawnorigin += this.view_ofs; // offset the casings origin by the same amount
// check if an instant weapon switch occurred
- setorigin(self, self.view_ofs);
+ setorigin(this, this.view_ofs);
// reset animstate now
- self.wframe = WFRAME_IDLE;
- setanim(self, self.anim_idle, true, false, true);
+ this.wframe = WFRAME_IDLE;
+ setanim(this, this.anim_idle, true, false, true);
}
vector CL_Weapon_GetShotOrg(float wpn)
{
- SELFPARAM();
entity wi = get_weaponinfo(wpn);
- setself(spawn());
- CL_WeaponEntity_SetModel(wi.mdl);
- vector ret = self.movedir;
- CL_WeaponEntity_SetModel("");
- remove(self);
- setself(this);
+ entity e = spawn();
+ CL_WeaponEntity_SetModel(e, wi.mdl);
+ vector ret = e.movedir;
+ CL_WeaponEntity_SetModel(e, "");
+ remove(e);
return ret;
}
void CL_Weaponentity_Think()
{
SELFPARAM();
- int tb;
- self.nextthink = time;
- if (intermission_running) self.frame = self.anim_idle.x;
- if (self.owner.weaponentity != self)
+ this.nextthink = time;
+ if (intermission_running) this.frame = this.anim_idle.x;
+ if (this.owner.weaponentity != this)
{
- if (self.weaponentity) remove(self.weaponentity);
- remove(self);
+ if (this.weaponentity) remove(this.weaponentity);
+ remove(this);
return;
}
- if (self.owner.deadflag != DEAD_NO)
+ if (this.owner.deadflag != DEAD_NO)
{
- self.model = "";
- if (self.weaponentity) self.weaponentity.model = "";
+ this.model = "";
+ if (this.weaponentity) this.weaponentity.model = "";
return;
}
- if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex
- || self.deadflag != self.owner.deadflag)
+ if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex
+ || this.deadflag != this.owner.deadflag)
{
- self.weaponname = self.owner.weaponname;
- self.dmg = self.owner.modelindex;
- self.deadflag = self.owner.deadflag;
+ this.weaponname = this.owner.weaponname;
+ this.dmg = this.owner.modelindex;
+ this.deadflag = this.owner.deadflag;
- CL_WeaponEntity_SetModel(self.owner.weaponname);
+ CL_WeaponEntity_SetModel(this, this.owner.weaponname);
}
- tb = (self.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
- self.effects = self.owner.effects & EFMASK_CHEAP;
- self.effects &= ~EF_LOWPRECISION;
- self.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it
- self.effects &= ~EF_TELEPORT_BIT;
- self.effects &= ~EF_RESTARTANIM_BIT;
- self.effects |= tb;
-
- if (self.owner.alpha == default_player_alpha) self.alpha = default_weapon_alpha;
- else if (self.owner.alpha != 0) self.alpha = self.owner.alpha;
- else self.alpha = 1;
-
- self.glowmod = self.owner.weaponentity_glowmod;
- self.colormap = self.owner.colormap;
- if (self.weaponentity)
+ int tb = (this.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT));
+ this.effects = this.owner.effects & EFMASK_CHEAP;
+ this.effects &= ~EF_LOWPRECISION;
+ this.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it
+ this.effects &= ~EF_TELEPORT_BIT;
+ this.effects &= ~EF_RESTARTANIM_BIT;
+ this.effects |= tb;
+
+ if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha;
+ else if (this.owner.alpha != 0) this.alpha = this.owner.alpha;
+ else this.alpha = 1;
+
+ this.glowmod = this.owner.weaponentity_glowmod;
+ this.colormap = this.owner.colormap;
+ if (this.weaponentity)
{
- self.weaponentity.effects = self.effects;
- self.weaponentity.alpha = self.alpha;
- self.weaponentity.colormap = self.colormap;
- self.weaponentity.glowmod = self.glowmod;
+ this.weaponentity.effects = this.effects;
+ this.weaponentity.alpha = this.alpha;
+ this.weaponentity.colormap = this.colormap;
+ this.weaponentity.glowmod = this.glowmod;
}
- self.angles = '0 0 0';
+ this.angles = '0 0 0';
- float f = (self.owner.weapon_nextthink - time);
- if (self.state == WS_RAISE && !intermission_running)
+ float f = (this.owner.weapon_nextthink - time);
+ if (this.state == WS_RAISE && !intermission_running)
{
- entity newwep = get_weaponinfo(self.owner.switchweapon);
+ entity newwep = get_weaponinfo(this.owner.switchweapon);
f = f * g_weaponratefactor / max(f, newwep.switchdelay_raise);
- self.angles_x = -90 * f * f;
+ this.angles_x = -90 * f * f;
}
- else if (self.state == WS_DROP && !intermission_running)
+ else if (this.state == WS_DROP && !intermission_running)
{
- entity oldwep = get_weaponinfo(self.owner.weapon);
+ entity oldwep = get_weaponinfo(this.owner.weapon);
f = 1 - f * g_weaponratefactor / max(f, oldwep.switchdelay_drop);
- self.angles_x = -90 * f * f;
+ this.angles_x = -90 * f * f;
}
- else if (self.state == WS_CLEAR)
+ else if (this.state == WS_CLEAR)
{
f = 1;
- self.angles_x = -90 * f * f;
+ this.angles_x = -90 * f * f;
}
}
void CL_ExteriorWeaponentity_Think()
{
SELFPARAM();
- float tag_found;
- self.nextthink = time;
- if (self.owner.exteriorweaponentity != self)
+ this.nextthink = time;
+ if (this.owner.exteriorweaponentity != this)
{
- remove(self);
+ remove(this);
return;
}
- if (self.owner.deadflag != DEAD_NO)
+ if (this.owner.deadflag != DEAD_NO)
{
- self.model = "";
+ this.model = "";
return;
}
- if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex
- || self.deadflag != self.owner.deadflag)
+ if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex
+ || this.deadflag != this.owner.deadflag)
{
- self.weaponname = self.owner.weaponname;
- self.dmg = self.owner.modelindex;
- self.deadflag = self.owner.deadflag;
- if (self.owner.weaponname != "") _setmodel(self, W_Model(strcat("v_", self.owner.weaponname, ".md3")));
- else self.model = "";
-
- if ((tag_found = gettagindex(self.owner, "tag_weapon")))
+ this.weaponname = this.owner.weaponname;
+ this.dmg = this.owner.modelindex;
+ this.deadflag = this.owner.deadflag;
+ if (this.owner.weaponname != "") _setmodel(this, W_Model(strcat("v_", this.owner.weaponname, ".md3")));
+ else this.model = "";
+
+ int tag_found;
+ if ((tag_found = gettagindex(this.owner, "tag_weapon")))
{
- self.tag_index = tag_found;
- self.tag_entity = self.owner;
+ this.tag_index = tag_found;
+ this.tag_entity = this.owner;
}
else
{
- setattachment(self, self.owner, "bip01 r hand");
+ setattachment(this, this.owner, "bip01 r hand");
}
}
- self.effects = self.owner.effects;
- self.effects |= EF_LOWPRECISION;
- self.effects = self.effects & EFMASK_CHEAP; // eat performance
- if (self.owner.alpha == default_player_alpha) self.alpha = default_weapon_alpha;
- else if (self.owner.alpha != 0) self.alpha = self.owner.alpha;
- else self.alpha = 1;
+ this.effects = this.owner.effects;
+ this.effects |= EF_LOWPRECISION;
+ this.effects = this.effects & EFMASK_CHEAP; // eat performance
+ if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha;
+ else if (this.owner.alpha != 0) this.alpha = this.owner.alpha;
+ else this.alpha = 1;
- self.glowmod = self.owner.weaponentity_glowmod;
- self.colormap = self.owner.colormap;
+ this.glowmod = this.owner.weaponentity_glowmod;
+ this.colormap = this.owner.colormap;
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
// spawning weaponentity for client
}
// Weapon subs
-void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void w_clear(Weapon thiswep, entity actor, int fire)
{
if (actor.weapon != -1)
{
}
}
-void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void w_ready(Weapon thiswep, entity actor, int fire)
{
if (actor.weaponentity) actor.weaponentity.state = WS_READY;
weapon_thinkf(actor, WFRAME_IDLE, 1000000, w_ready);
.float prevdryfire;
.float prevwarntime;
-bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondary)
+bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary)
{
if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
bool ammo = false;
else WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
- entity mine;
- if (actor.weapon == WEP_MINE_LAYER.m_id)
- for (mine = world; (mine = find(mine, classname, "mine")); )
+ if (thiswep == WEP_MINE_LAYER)
+ for (entity mine; (mine = find(mine, classname, "mine")); )
if (mine.owner == actor) return false;
- if (actor.weapon == WEP_SHOTGUN.m_id)
- if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false;
- // no clicking, just allow
+ if (thiswep == WEP_SHOTGUN)
+ if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
- if (actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
+ if (thiswep == get_weaponinfo(actor.switchweapon) && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
{
sound(actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
actor.prevdryfire = time;
// check if the other firing mode has enough ammo
bool ammo_other = false;
- if (secondary) WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
- else WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+ if (secondary) WITH(entity, self, actor, ammo_other = thiswep.wr_checkammo1(thiswep));
+ else WITH(entity, self, actor, ammo_other = thiswep.wr_checkammo2(thiswep));
if (ammo_other)
{
if (time - actor.prevwarntime > 1)
actor,
MSG_MULTI,
ITEM_WEAPON_PRIMORSEC,
- actor.weapon,
+ thiswep,
secondary,
(1 - secondary)
);
return false;
}
+
.float race_penalty;
bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, float attacktime)
{
}
return true;
}
+
void weapon_prepareattack_do(entity actor, bool secondary, float attacktime)
{
actor.weaponentity.state = WS_INUSE;
actor.bulletcounter += 1;
// dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n");
}
+
bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime)
{
if (weapon_prepareattack_check(thiswep, actor, secondary, attacktime))
return false;
}
-void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func)
+void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func)
{
- vector a;
- vector of, or, ou;
- float restartanim;
-
+ bool restartanim;
if (fr == WFRAME_DONTCHANGE)
{
fr = actor.weaponentity.wframe;
restartanim = true;
}
- of = v_forward;
- or = v_right;
- ou = v_up;
+ vector of = v_forward;
+ vector or = v_right;
+ vector ou = v_up;
if (actor.weaponentity)
{
actor.weaponentity.wframe = fr;
- a = '0 0 0';
+ vector a = '0 0 0';
if (fr == WFRAME_IDLE) a = actor.weaponentity.anim_idle;
else if (fr == WFRAME_FIRE1) a = actor.weaponentity.anim_fire1;
else if (fr == WFRAME_FIRE2) a = actor.weaponentity.anim_fire2;
}
}
-float forbidWeaponUse(entity player)
+bool forbidWeaponUse(entity player)
{
- if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return 1;
- if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return 1;
- if (player.player_blocked) return 1;
- if (player.frozen) return 1;
- if (player.weapon_blocked) return 1;
- return 0;
+ if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return true;
+ if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return true;
+ if (player.player_blocked) return true;
+ if (player.frozen) return true;
+ if (player.weapon_blocked) return true;
+ return false;
}
.bool hook_switchweapon;
void W_WeaponFrame(entity actor)
{
- vector fo, ri, up;
-
if (frametime) actor.weapon_frametime = frametime;
if (!actor.weaponentity || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands
if (actor.weaponentity.state != WS_CLEAR)
{
Weapon wpn = get_weaponinfo(actor.weapon);
- w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
+ w_ready(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
return;
}
}
}
makevectors(actor.v_angle);
- fo = v_forward; // save them in case the weapon think functions change it
- ri = v_right;
- up = v_up;
+ vector fo = v_forward; // save them in case the weapon think functions change it
+ vector ri = v_right;
+ vector up = v_up;
// Change weapon
if (actor.weapon != 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(actor) <= time + actor.weapon_frametime * 0.5)
- {
-#endif
- 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
- }
+ if (
+#if INDEPENDENT_ATTACK_FINISHED
+ true
+#else
+ ATTACK_FINISHED(actor) <= time + actor.weapon_frametime * 0.5
#endif
+ )
+ {
+ 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);
+ }
}
}
// if (actor.button0)
// print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor)), " >= ", ftos(actor.weapon_nextthink), "\n");
- float w;
- w = actor.weapon;
+ int w = actor.weapon;
// call the think code which may fire the weapon
// and do so multiple times to resolve framerate dependency issues if the
// server framerate is very low and the weapon fire rate very high
- float c;
- c = 0;
+ int c = 0;
while (c < W_TICSPERFRAME)
{
- c = c + 1;
+ c += 1;
if (w && !(actor.weapons & WepSet_FromWeapon(w)))
{
if (actor.weapon == actor.switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
actor.hook_switchweapon = key_pressed;
Weapon h = WEP_HOOK;
block_weapon = (actor.weapon == h.m_id && (actor.BUTTON_ATCK || key_pressed));
- h.wr_think(h, actor, block_weapon, false);
+ h.wr_think(h, actor, block_weapon ? 1 : 0);
}
}
if (w)
{
Weapon e = get_weaponinfo(actor.weapon);
- e.wr_think(e, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
+ e.wr_think(e, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
}
else
{
v_right = ri;
v_up = up;
Weapon wpn = get_weaponinfo(actor.weapon);
- actor.weapon_think(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
+ actor.weapon_think(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
}
else
{
void W_AttachToShotorg(entity actor, entity flash, vector offset)
{
- entity xflash;
flash.owner = actor;
flash.angles_z = random() * 360;
else setattachment(flash, actor.weaponentity, "tag_shot");
setorigin(flash, offset);
- xflash = spawn();
+ entity xflash = spawn();
copyentity(flash, xflash);
flash.viewmodelforclient = actor;
.float reload_complain;
.string reload_sound;
-void W_ReloadedAndReady(Weapon thiswep, entity actor, bool fire1, bool fire2)
+void W_ReloadedAndReady(Weapon thiswep, entity actor, int fire)
{
// finish the reloading process, and do the ammo transfer
// ATTACK_FINISHED(actor) -= actor.reload_time - 1;
Weapon wpn = get_weaponinfo(actor.weapon);
- w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
+ w_ready(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0));
}
void W_Reload(entity actor, float sent_ammo_min, string sent_sound)
{
// set global values to work with
- entity e;
- e = get_weaponinfo(actor.weapon);
+ entity e = get_weaponinfo(actor.weapon);
if (cvar("g_overkill"))
if (actor.ok_use_ammocharge) return;
void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item)
{
- SELFPARAM();
- setself(player);
- weapon_dropevent_item = weapon_item;
Weapon w = get_weaponinfo(weapon_type);
- w.event(w);
- setself(this);
+ weapon_dropevent_item = weapon_item;
+ WITH(entity, self, player, w.event(w));
}
void weapon_prepareattack_do(entity actor, float secondary, float attacktime);
-void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func);
+void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func);
#endif