void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
+// assault game mode: Which team is attacking in this round?
+float assault_attacker_team;
+
// predefined spawnfuncs
void target_objective_decrease_activate(entity this);
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, weaponentity);
}
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(okhmg, refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(okhmg, refire) * W_WeaponRateFactor(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okhmg, refire), W_OverkillHeavyMachineGun_Attack_Auto);
}
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, weaponentity);
}
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(okmachinegun, refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(okmachinegun, refire) * W_WeaponRateFactor(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(okmachinegun, refire), W_OverkillMachineGun_Attack_Auto);
}
if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
{
- int slot = weaponslot(weaponentity);
sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
}
actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
{
this.realowner.cnt = thiswep.m_id;
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(this.realowner, slot) = time;
+ ATTACK_FINISHED(this.realowner, weaponentity) = time;
this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
}
}
if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
{
this.realowner.cnt = thiswep.m_id;
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(this.realowner, slot) = time;
+ ATTACK_FINISHED(this.realowner, weaponentity) = time;
this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
}
}
{
#if 0
// don't switch while guiding a missile
- if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
+ if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
{
ammo_amount = false;
if(WEP_CVAR(devastator, reload_ammo))
W_Hagar_Attack(thiswep, actor, weaponentity);
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor);
int theframe = WFRAME_FIRE1;
entity this = actor.(weaponentity);
if(this)
return;
}
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
W_HLAC_Attack(thiswep, actor, weaponentity);
actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
actor.punchangle_x = random() - 0.5;
actor.punchangle_y = random() - 0.5;
}
- int slot = weaponslot(weaponentity);
// this attack_finished just enforces a cooldown at the end of a burst
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
if(actor.(weaponentity).misc_bulletcounter == 1)
fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, EFFECT_BULLET);
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, weaponentity);
}
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
}
actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
if(actor.(weaponentity).misc_bulletcounter == 0)
{
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready);
}
else
if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
{
own.cnt = thiswep.m_id;
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(own, slot) = time;
+ ATTACK_FINISHED(own, weaponentity) = time;
own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
}
}
if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
{
own.cnt = thiswep.m_id;
- int slot = weaponslot(weaponentity);
- ATTACK_FINISHED(own, slot) = time;
+ ATTACK_FINISHED(own, weaponentity) = time;
own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
}
}
}
METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- //int slot = 0; // TODO: unhardcode
// actually do // don't switch while placing a mine
- //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
+ //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
//{
float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);
float r, af;
Weapon sw = actor.(weaponentity).m_switchweapon; // make it not detect weapon changes as reason to abort firing
- int slot = weaponslot(weaponentity);
- af = ATTACK_FINISHED(actor, slot);
+ af = ATTACK_FINISHED(actor, weaponentity);
actor.(weaponentity).m_switchweapon = actor.(weaponentity).m_weapon;
- ATTACK_FINISHED(actor, slot) = time;
+ ATTACK_FINISHED(actor, weaponentity) = time;
r = weapon_prepareattack(thiswep, actor, weaponentity, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
if(actor.(weaponentity).m_switchweapon == actor.(weaponentity).m_weapon)
actor.(weaponentity).m_switchweapon = sw;
}
else
{
- ATTACK_FINISHED(actor, slot) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
+ ATTACK_FINISHED(actor, weaponentity) = af; // reset attack_finished if we didn't fire, so the last shot enforces the refire time
}
}
// Should it do a weapon combo?
float af, ct, combo_time, combo;
- af = ATTACK_FINISHED(this, 0);
+ af = ATTACK_FINISHED(this, weaponentity);
ct = autocvar_bot_ai_weapon_combo_threshold;
// Bots with no skill will be 4 times more slower than "godlike" bots when doing weapon combos
LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state");
}
}
- else if(ATTACK_FINISHED(this, slot) > time)
+ else if(ATTACK_FINISHED(this, weaponentity) > time)
{
if(f)
{
this.colormod = '8 0 8';
- LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left)");
}
}
else if(this.(weaponentity).tuba_note)
if(!f)
{
this.colormod = '8 8 0';
- LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, weaponentity) - time), " seconds left");
}
}
#else
#define ATTACK_FINISHED_FOR(ent, w, slot) ((ent).attack_finished_single[slot])
#endif
-#define ATTACK_FINISHED(ent, slot) ATTACK_FINISHED_FOR(ent, ent.(weaponentity).m_weapon.m_id, slot)
-
-// assault game mode: Which team is attacking in this round?
-float assault_attacker_team;
+#define ATTACK_FINISHED(ent, w) ATTACK_FINISHED_FOR(ent, ent.(w).m_weapon.m_id, weaponslot(w))
// speedrun: when 1, player auto teleports back when capture timeout happens
.float speedrunning;
if (attacktime >= 0)
{
- int slot = weaponslot(weaponentity);
// don't fire if previous attack is not finished
- if (ATTACK_FINISHED(actor, slot) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
+ if (ATTACK_FINISHED(actor, weaponentity) > time + actor.(weaponentity).weapon_frametime * 0.5) return false;
entity this = actor.(weaponentity);
// don't fire while changing weapon
if (this.state != WS_READY) return false;
// if the weapon hasn't been firing continuously, reset the timer
if (attacktime >= 0)
{
- int slot = weaponslot(weaponentity);
- if (ATTACK_FINISHED(actor, slot) < time - this.weapon_frametime * 1.5)
+ if (ATTACK_FINISHED(actor, weaponentity) < time - this.weapon_frametime * 1.5)
{
- ATTACK_FINISHED(actor, slot) = time;
+ ATTACK_FINISHED(actor, weaponentity) = time;
// dprint("resetting attack finished to ", ftos(time), "\n");
}
float arate = W_WeaponRateFactor(actor);
- ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * arate;
+ ATTACK_FINISHED(actor, weaponentity) = ATTACK_FINISHED(actor, weaponentity) + attacktime * arate;
if(autocvar_g_weaponswitch_debug_alternate && W_DualWielding(actor))
{
+ int slot = weaponslot(weaponentity);
for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot)
{
if(slot == wepslot)
.entity wepent = weaponentities[wepslot];
if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null)
{
- if(ATTACK_FINISHED(actor, wepslot) > time + actor.(wepent).weapon_frametime * 0.5)
+ if(ATTACK_FINISHED(actor, wepent) > time + actor.(wepent).weapon_frametime * 0.5)
continue; // still cooling down!
- if (ATTACK_FINISHED(actor, wepslot) < time - actor.(wepent).weapon_frametime * 1.5)
- ATTACK_FINISHED(actor, wepslot) = time;
- ATTACK_FINISHED(actor, wepslot) = ATTACK_FINISHED(actor, wepslot) + (attacktime * arate) / MAX_WEAPONSLOTS;
+ if (ATTACK_FINISHED(actor, wepent) < time - actor.(wepent).weapon_frametime * 1.5)
+ ATTACK_FINISHED(actor, wepent) = time;
+ ATTACK_FINISHED(actor, wepent) = ATTACK_FINISHED(actor, wepent) + (attacktime * arate) / MAX_WEAPONSLOTS;
}
}
}
}
this.bulletcounter += 1;
- // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n");
+ // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, weaponentity)), "\n");
}
bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
entity oldwep = this.m_weapon;
// set up weapon switch think in the future, and start drop anim
- if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponslot(weaponentity)) <= time + this.weapon_frametime * 0.5)
+ if (INDEPENDENT_ATTACK_FINISHED || ATTACK_FINISHED(actor, weaponentity) <= time + this.weapon_frametime * 0.5)
{
sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
this.state = WS_DROP;
// LordHavoc: network timing test code
// if (actor.button0)
- // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, slot)), " >= ", ftos(this.weapon_nextthink), "\n");
+ // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor, weaponentity)), " >= ", ftos(this.weapon_nextthink), "\n");
Weapon w = this.m_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(actor, slot) -= w_ent.reload_time - 1;
+ // ATTACK_FINISHED(actor, weaponentity) -= w_ent.reload_time - 1;
w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
}
// 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(actor, slot) = max(time, ATTACK_FINISHED(actor, slot)) + this.reload_time + 1;
+ // ATTACK_FINISHED(actor, weaponentity) = max(time, ATTACK_FINISHED(actor, weaponentity)) + this.reload_time + 1;
weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, this.reload_time, W_ReloadedAndReady);