}
METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
- Arc_Player_SetHeat(actor, weaponentity);
- Arc_Smoke(thiswep, actor, weaponentity, fire);
-
- bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt));
-
- if (time >= actor.arc_overheat)
- if ((fire & 1) || beam_fire2 || actor.(weaponentity).arc_beam.beam_bursting)
- {
- #if 0
- if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
- {
- #if 0
- if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y)
- weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
- else
- #endif
- weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), w_ready);
- }
- #endif
-
- if((!actor.(weaponentity).arc_beam) || wasfreed(actor.(weaponentity).arc_beam))
- {
- if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(beam_fire2), 0))
- {
- W_Arc_Beam(boolean(beam_fire2), actor, weaponentity);
-
- if(!actor.(weaponentity).arc_BUTTON_ATCK_prev)
- {
- actor.(weaponentity).wframe = WFRAME_FIRE1;
- weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(arc, beam_animtime), W_Arc_Attack);
- actor.(weaponentity).arc_BUTTON_ATCK_prev = true;
- }
- }
- }
-
- return;
- }
- else if(fire & 2)
- {
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
- {
- if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
- if(!(actor.items & IT_UNLIMITED_AMMO))
- {
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
- w_ready(thiswep, actor, weaponentity, fire);
- return;
- }
- int to_shoot = WEP_CVAR(arc, bolt_count);
- if(!(actor.items & IT_UNLIMITED_AMMO))
- {
- float ammo_available = GetResource(actor, thiswep.ammo_type);
- // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
- // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
- float burst_fraction = min(1, ammo_available / WEP_CVAR(arc, bolt_ammo));
- to_shoot = floor(to_shoot * burst_fraction);
-
- // We also don't want to use 3 rounds if there's only 2 left.
- int to_use = min(WEP_CVAR(arc, bolt_ammo), ammo_available);
- W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
- }
-
- // Bursting counts up to 0 from a negative.
- actor.(weaponentity).misc_bulletcounter = -to_shoot;
- W_Arc_Attack_Bolt(thiswep, actor, weaponentity, fire);
- }
- }
-
- if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
- {
- 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, weaponentity) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor);
- }
- actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
-
- #if 0
- if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_arc_secondary_refire))
- {
- W_Arc_Attack2();
- actor.arc_count = autocvar_g_balance_arc_secondary_count;
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
- actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(actor);
- }
- #endif
+ Arc_Player_SetHeat(actor, weaponentity);
+ Arc_Smoke(thiswep, actor, weaponentity, fire);
+
+ bool beam_fire2 = ((fire & 2) && !WEP_CVAR(WEP_ARC, bolt));
+
+ if (time >= actor.arc_overheat)
+ if ((fire & 1) || beam_fire2 || actor.(weaponentity).arc_beam.beam_bursting)
+ {
+ #if 0
+ if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
+ {
+ #if 0
+ if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y)
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, autocvar_g_balance_arc_primary_animtime, w_ready);
+ else
+ #endif
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(WEP_ARC, beam_animtime), w_ready);
+ }
+ #endif
+
+ if((!actor.(weaponentity).arc_beam) || wasfreed(actor.(weaponentity).arc_beam))
+ {
+ if(weapon_prepareattack(thiswep, actor, weaponentity, boolean(beam_fire2), 0))
+ {
+ W_Arc_Beam(boolean(beam_fire2), actor, weaponentity);
+
+ if(!actor.(weaponentity).arc_BUTTON_ATCK_prev)
+ {
+ actor.(weaponentity).wframe = WFRAME_FIRE1;
+ weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, WEP_CVAR(WEP_ARC, beam_animtime), W_Arc_Attack);
+ actor.(weaponentity).arc_BUTTON_ATCK_prev = true;
+ }
+ }
+ }
+
+ return;
+ }
+ else if(fire & 2)
+ {
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
+ {
+ if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
+ if(!(actor.items & IT_UNLIMITED_AMMO))
+ {
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
+ w_ready(thiswep, actor, weaponentity, fire);
+ return;
+ }
- float ammo_available = GetResource(actor, thiswep.ammo_type);
- // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
- // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
- float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_ARC, bolt_ammo));
- int to_shoot = floor(WEP_CVAR(WEP_ARC, bolt_count) * burst_fraction);
-
- // We also don't want to use 3 rounds if there's only 2 left.
- int to_use = min(WEP_CVAR(WEP_ARC, bolt_ammo), ammo_available);
- W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
++ int to_shoot = WEP_CVAR(WEP_ARC, bolt_count);
++ if(!(actor.items & IT_UNLIMITED_AMMO))
++ {
++ float ammo_available = GetResource(actor, thiswep.ammo_type);
++ // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
++ // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
++ float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_ARC, bolt_ammo));
++ to_shoot = floor(to_shoot * burst_fraction);
++
++ // We also don't want to use 3 rounds if there's only 2 left.
++ int to_use = min(WEP_CVAR(WEP_ARC, bolt_ammo), ammo_available);
++ W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
++ }
+
+ // Bursting counts up to 0 from a negative.
+ actor.(weaponentity).misc_bulletcounter = -to_shoot;
+ W_Arc_Attack_Bolt(thiswep, actor, weaponentity, fire);
+ }
+ }
+
+ if(actor.(weaponentity).arc_BUTTON_ATCK_prev)
+ {
+ sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_ARC, beam_animtime), w_ready);
+ ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR(WEP_ARC, beam_refire) * W_WeaponRateFactor(actor);
+ }
+ actor.(weaponentity).arc_BUTTON_ATCK_prev = false;
+
+ #if 0
+ if(fire & 2)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_arc_secondary_refire))
+ {
+ W_Arc_Attack2();
+ actor.arc_count = autocvar_g_balance_arc_secondary_count;
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack);
+ actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(actor);
+ }
+ #endif
}
METHOD(Arc, wr_suicidemessage, Notification(entity thiswep))
{
METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
{
- if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
- PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
- else
- PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
+ if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
+ PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
+ else
+ PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
}
+
METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
- // forced reload - wait until the bulletcounter is 0 so a burst loop can finish
- if(WEP_CVAR(machinegun, reload_ammo)
- && actor.(weaponentity).clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))
- && actor.(weaponentity).misc_bulletcounter >= 0)
- {
- thiswep.wr_reload(thiswep, actor, weaponentity);
- }
- else if(WEP_CVAR(machinegun, mode) == 1)
- {
- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 0;
- W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
- }
-
- // You can "shoot" more rounds than what's "used", and vice versa.
- if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
- {
- if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
- if(!(actor.items & IT_UNLIMITED_AMMO))
- {
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
- w_ready(thiswep, actor, weaponentity, fire);
- return;
- }
-
- float ammo_available;
- if (WEP_CVAR(machinegun, reload_ammo) > 0)
- {
- ammo_available = actor.(weaponentity).clip_load;
- }
- else
- {
- ammo_available = GetResource(actor, thiswep.ammo_type);
- }
-
- int to_shoot = WEP_CVAR(machinegun, burst);
- if(!(actor.items & IT_UNLIMITED_AMMO))
- {
- // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
- // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
- float burst_fraction = min(1, ammo_available / WEP_CVAR(machinegun, burst_ammo));
- to_shoot = floor(to_shoot * burst_fraction);
-
- // We also don't want to use 3 rounds if there's only 2 left.
- int to_use = min(WEP_CVAR(machinegun, burst_ammo), ammo_available);
- W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
- }
-
- // Bursting counts up to 0 from a negative.
- actor.(weaponentity).misc_bulletcounter = -to_shoot;
- W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
- }
- }
- else
- {
-
- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 1;
- W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
- }
-
- if((fire & 2) && WEP_CVAR(machinegun, first))
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 1;
- W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
- }
- }
+ // forced reload - wait until the bulletcounter is 0 so a burst loop can finish
+ if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo)
+ && actor.(weaponentity).clip_load < min(max(WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), WEP_CVAR(WEP_MACHINEGUN, first_ammo)), WEP_CVAR(WEP_MACHINEGUN, burst_ammo))
+ && actor.(weaponentity).misc_bulletcounter >= 0)
+ {
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ }
+ else if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ {
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 0;
+ W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
+ }
+
+ // You can "shoot" more rounds than what's "used", and vice versa.
+ if(fire & 2)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
+ {
+ if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
+ if(!(actor.items & IT_UNLIMITED_AMMO))
+ {
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
+ w_ready(thiswep, actor, weaponentity, fire);
+ return;
+ }
+
+ float ammo_available;
+ if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo) > 0)
+ {
+ ammo_available = actor.(weaponentity).clip_load;
+ }
+ else
+ {
+ ammo_available = GetResource(actor, thiswep.ammo_type);
+ }
+
- // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
- // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
- float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
- int to_shoot = floor(WEP_CVAR(WEP_MACHINEGUN, burst) * burst_fraction);
-
- // We also don't want to use 3 rounds if there's only 2 left.
- int to_use = min(WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available);
- W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
++ int to_shoot = WEP_CVAR(WEP_MACHINEGUN, burst);
++ if(!(actor.items & IT_UNLIMITED_AMMO))
++ {
++ // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
++ // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
++ float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
++ to_shoot = floor(to_shoot * burst_fraction);
++
++ // We also don't want to use 3 rounds if there's only 2 left.
++ int to_use = min(WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available);
++ W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
++ }
+
+ // Bursting counts up to 0 from a negative.
+ actor.(weaponentity).misc_bulletcounter = -to_shoot;
+ W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
+ }
+ }
+ else
+ {
+
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 1;
+ W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), W_MachineGun_Attack_Frame);
+ }
+
+ if((fire & 2) && WEP_CVAR(WEP_MACHINEGUN, first))
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 1;
+ W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(WEP_MACHINEGUN, first_refire), w_ready);
+ }
+ }
}
+
METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount;
- if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, sustained_ammo);
- else
- ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
-
- if(WEP_CVAR(machinegun, reload_ammo))
- {
- if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
- else
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, first_ammo);
- }
- return ammo_amount;
+ float ammo_amount;
+ if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
+ else
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo);
+
+ if(WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
+ {
+ if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, sustained_ammo);
+ else
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo);
+ }
+
+ return ammo_amount;
}
+
METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount;
- float burst_ammo_per_shot = WEP_CVAR(machinegun, burst_ammo) / WEP_CVAR(machinegun, burst);
- if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot;
- else
- ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(machinegun, first_ammo);
-
- if(WEP_CVAR(machinegun, reload_ammo))
- {
- if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= burst_ammo_per_shot;
- else
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(machinegun, first_ammo);
- }
- return ammo_amount;
+ float ammo_amount;
+ float burst_ammo_per_shot = WEP_CVAR(WEP_MACHINEGUN, burst_ammo) / WEP_CVAR(WEP_MACHINEGUN, burst);
+
+ if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot;
+ else
+ ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo);
+
+ if(WEP_CVAR(WEP_MACHINEGUN, reload_ammo))
+ {
+ if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= burst_ammo_per_shot;
+ else
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MACHINEGUN, first_ammo);
+ }
+
+ return ammo_amount;
}
+
METHOD(MachineGun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
if(actor.(weaponentity).misc_bulletcounter < 0)
{
actor.(weaponentity).minelayer_mines = W_MineLayer_Count(actor, weaponentity);
- if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
- {
- // not if we're holding the minelayer without enough ammo, but can detonate existing mines
- bool enough_ammo = (GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo));
- if(actor.items & IT_UNLIMITED_AMMO)
- enough_ammo = true;
- if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && !enough_ammo)) {
- thiswep.wr_reload(thiswep, actor, weaponentity);
- }
- }
- else if(fire & 1)
- {
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire)))
- {
- W_MineLayer_Attack(thiswep, actor, weaponentity);
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
- }
- }
-
- if(fire & 2)
- {
- if(W_MineLayer_PlacedMines(actor, weaponentity, true))
- sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
- }
+ if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(WEP_MINE_LAYER, ammo)) // forced reload
+ {
+ // not if we're holding the minelayer without enough ammo, but can detonate existing mines
- if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResource(actor, thiswep.ammo_type) < WEP_CVAR(WEP_MINE_LAYER, ammo))) {
++ bool enough_ammo = (GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MINE_LAYER, ammo));
++ if(actor.items & IT_UNLIMITED_AMMO)
++ enough_ammo = true;
++ if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && !enough_ammo)) {
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ }
+ }
+ else if(fire & 1)
+ {
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(WEP_MINE_LAYER, refire)))
+ {
+ W_MineLayer_Attack(thiswep, actor, weaponentity);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MINE_LAYER, animtime), w_ready);
+ }
+ }
+
+ if(fire & 2)
+ {
+ if(W_MineLayer_PlacedMines(actor, weaponentity, true))
+ sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
+ }
}
+
METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- // actually do // don't switch while placing a mine
- //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
- //{
- float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);
- return ammo_amount;
- //}
- //return true;
+ // actually do // don't switch while placing a mine
+ //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
+ //{
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(WEP_MINE_LAYER, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(WEP_MINE_LAYER, ammo);
+ return ammo_amount;
+ //}
+ //return true;
}
+
METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- if(W_MineLayer_PlacedMines(actor, weaponentity, false))
- return true;
- else
- return false;
+ if(W_MineLayer_PlacedMines(actor, weaponentity, false))
+ return true;
+ else
+ return false;
}
+
METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor))
{
- for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
- {
- .entity weaponentity = weaponentities[slot];
- actor.(weaponentity).minelayer_mines = 0;
- }
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ actor.(weaponentity).minelayer_mines = 0;
+ }
}
+
METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- W_Reload(actor, weaponentity, WEP_CVAR(minelayer, ammo), SND_RELOAD);
+ W_Reload(actor, weaponentity, WEP_CVAR(WEP_MINE_LAYER, ammo), SND_RELOAD);
}
+
METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep))
{
- return WEAPON_MINELAYER_SUICIDE;
+ return WEAPON_MINELAYER_SUICIDE;
}
+
METHOD(MineLayer, wr_killmessage, Notification(entity thiswep))
{
- return WEAPON_MINELAYER_MURDER;
+ return WEAPON_MINELAYER_MURDER;
}
#endif
METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
- // force reload weapon when clip is empty or insufficent
- if(WEP_CVAR(shotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(shotgun, ammo))
- {
- if(actor.(weaponentity).clip_load >= 0 && (GetResource(actor, thiswep.ammo_type) > 0 || (actor.items & IT_UNLIMITED_AMMO)))
- {
- thiswep.wr_reload(thiswep, actor, weaponentity);
- return;
- }
- }
-
- if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
- {
- if(fire & 1)
- {
- if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
- {
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime)))
- {
- W_Shotgun_Attack(thiswep, actor, weaponentity, true,
- WEP_CVAR_PRI(shotgun, ammo),
- WEP_CVAR_PRI(shotgun, damage),
- WEP_CVAR_PRI(shotgun, damagefalloff_halflife),
- WEP_CVAR_PRI(shotgun, damagefalloff_mindist),
- WEP_CVAR_PRI(shotgun, damagefalloff_maxdist),
- WEP_CVAR_PRI(shotgun, bullets),
- WEP_CVAR_PRI(shotgun, spread),
- WEP_CVAR_PRI(shotgun, spread_pattern),
- WEP_CVAR_PRI(shotgun, spread_pattern_scale),
- WEP_CVAR_PRI(shotgun, solidpenetration),
- WEP_CVAR_PRI(shotgun, force),
- WEP_CVAR_PRI(shotgun, damagefalloff_forcehalflife),
+ // force reload weapon when clip is empty or insufficent
+ if(WEP_CVAR(WEP_SHOTGUN, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(WEP_SHOTGUN, ammo))
+ {
- if(actor.(weaponentity).clip_load >= 0 && GetResource(actor, thiswep.ammo_type) > 0)
++ if(actor.(weaponentity).clip_load >= 0 && (GetResource(actor, thiswep.ammo_type) > 0 || (actor.items & IT_UNLIMITED_AMMO)))
+ {
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ return;
+ }
+ }
+
+ if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
+ {
+ if(fire & 1)
+ {
+ if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
+ {
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_SHOTGUN, animtime)))
+ {
+ W_Shotgun_Attack(thiswep, actor, weaponentity, true,
+ WEP_CVAR_PRI(WEP_SHOTGUN, ammo),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damage),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_halflife),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_mindist),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_maxdist),
+ WEP_CVAR_PRI(WEP_SHOTGUN, bullets),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread_pattern),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread_pattern_scale),
+ WEP_CVAR_PRI(WEP_SHOTGUN, solidpenetration),
+ WEP_CVAR_PRI(WEP_SHOTGUN, force),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_forcehalflife),
EFFECT_BULLET_WEAK);
- actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor);
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready);
- return;
- }
- }
- }
- else if((fire & 2) && WEP_CVAR(shotgun, secondary) == 2)
- {
- if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
- {
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
- {
- W_Shotgun_Attack(thiswep, actor, weaponentity, false,
- WEP_CVAR_PRI(shotgun, ammo),
- WEP_CVAR_PRI(shotgun, damage),
- WEP_CVAR_PRI(shotgun, damagefalloff_halflife),
- WEP_CVAR_PRI(shotgun, damagefalloff_mindist),
- WEP_CVAR_PRI(shotgun, damagefalloff_maxdist),
- WEP_CVAR_PRI(shotgun, bullets),
- WEP_CVAR_PRI(shotgun, spread),
- WEP_CVAR_PRI(shotgun, spread_pattern),
- WEP_CVAR_PRI(shotgun, spread_pattern_scale),
- WEP_CVAR_PRI(shotgun, solidpenetration),
- WEP_CVAR_PRI(shotgun, force),
- WEP_CVAR_PRI(shotgun, damagefalloff_forcehalflife),
+ actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_PRI(WEP_SHOTGUN, refire) * W_WeaponRateFactor(actor);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_SHOTGUN, animtime), w_ready);
+ return;
+ }
+ }
+ }
+ else if((fire & 2) && WEP_CVAR(WEP_SHOTGUN, secondary) == 2)
+ {
+ if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
+ {
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(WEP_SHOTGUN, alt_animtime)))
+ {
+ W_Shotgun_Attack(thiswep, actor, weaponentity, false,
+ WEP_CVAR_PRI(WEP_SHOTGUN, ammo),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damage),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_halflife),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_mindist),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_maxdist),
+ WEP_CVAR_PRI(WEP_SHOTGUN, bullets),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread_pattern),
+ WEP_CVAR_PRI(WEP_SHOTGUN, spread_pattern_scale),
+ WEP_CVAR_PRI(WEP_SHOTGUN, solidpenetration),
+ WEP_CVAR_PRI(WEP_SHOTGUN, force),
+ WEP_CVAR_PRI(WEP_SHOTGUN, damagefalloff_forcehalflife),
EFFECT_BULLET_WEAK);
- actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor);
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1);
- return;
- }
- }
- }
- }
-
- if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
- if(WEP_CVAR(shotgun, secondary) == 1)
- if(((fire & 1) && !IS_BOT_CLIENT(actor) && GetResource(actor, thiswep.ammo_type) <= 0 && actor.(weaponentity).clip_load == 0 && !(actor.items & IT_UNLIMITED_AMMO)) || (fire & 2))
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire)))
- {
- // melee attack
- // attempt forcing playback of the anim by switching to another anim (that we never play) here...
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
- }
+ actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_SEC(WEP_SHOTGUN, alt_refire) * W_WeaponRateFactor(actor);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(WEP_SHOTGUN, alt_animtime), W_Shotgun_Attack3_Frame1);
+ return;
+ }
+ }
+ }
+ }
+
+ if(actor.(weaponentity).clip_load >= 0) // we are not currently reloading
+ if(WEP_CVAR(WEP_SHOTGUN, secondary) == 1)
+ if(((fire & 1) && !IS_BOT_CLIENT(actor) && GetResource(actor, thiswep.ammo_type) <= 0 && actor.(weaponentity).clip_load == 0 && !(actor.items & IT_UNLIMITED_AMMO)) || (fire & 2))
+ if(!WEP_CVAR_SEC(WEP_SHOTGUN, melee_blockedbyfiring) || time >= actor.(weaponentity).shotgun_primarytime)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(WEP_SHOTGUN, refire)))
+ {
+ // melee attack
+ // attempt forcing playback of the anim by switching to another anim (that we never play) here...
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
+ }
}
+
METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
- return ammo_amount;
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(WEP_SHOTGUN, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(WEP_SHOTGUN, ammo);
+ return ammo_amount;
}
+
METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- switch(WEP_CVAR(shotgun, secondary))
- {
- case 1: return true; // melee does not use ammo
- case 2: // secondary triple shot
- {
- float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
- return ammo_amount;
- }
- default: return false; // secondary unavailable
- }
+ switch(WEP_CVAR(WEP_SHOTGUN, secondary))
+ {
+ case 1: return true; // melee does not use ammo
+ case 2: // secondary triple shot
+ {
+ float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(WEP_SHOTGUN, ammo);
+ ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(WEP_SHOTGUN, ammo);
+ return ammo_amount;
+ }
+ default: return false; // secondary unavailable
+ }
}
+
METHOD(Shotgun, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- W_Reload(actor, weaponentity, WEP_CVAR_PRI(shotgun, ammo), SND_RELOAD); // WEAPONTODO
+ W_Reload(actor, weaponentity, WEP_CVAR_PRI(WEP_SHOTGUN, ammo), SND_RELOAD); // WEAPONTODO
}
+
METHOD(Shotgun, wr_suicidemessage, Notification(entity thiswep))
{
- return WEAPON_THINKING_WITH_PORTALS;
+ return WEAPON_THINKING_WITH_PORTALS;
}
+
METHOD(Shotgun, wr_killmessage, Notification(entity thiswep))
{
- if(w_deathtype & HITTYPE_SECONDARY)
- return WEAPON_SHOTGUN_MURDER_SLAP;
- else
- return WEAPON_SHOTGUN_MURDER;
+ if(w_deathtype & HITTYPE_SECONDARY)
+ return WEAPON_SHOTGUN_MURDER_SLAP;
+ else
+ return WEAPON_SHOTGUN_MURDER;
}
#endif