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;
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;
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);
}
}
// 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;
// Jetpack navigation
if(this.navigation_jetpack_goal)
if(this.goalcurrent==this.navigation_jetpack_goal)
- if(GetResource(this, RES_FUEL))
+ if(GetResource(this, RES_FUEL) > 0 || (this.items & IT_UNLIMITED_AMMO))
{
if(autocvar_bot_debug_goalstack)
{
this.havocbot_stickenemy_time = 0;
}
-float havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon)
+bool havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon)
{
// bots under this skill cannot find unloaded weapons to reload idly when not in combat,
// so skip this for them, or they'll never get to reload their weapons at all.
// if this weapon is scheduled for reloading, don't switch to it during combat
if (this.(weaponentity).weapon_load[new_weapon] < 0)
{
+ if(this.items & IT_UNLIMITED_AMMO)
+ return true;
FOREACH(Weapons, it != WEP_Null, {
if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity))
return true; // other weapon available
if (GetResource(item, RES_HEALTH) && GetResource(player, RES_HEALTH) <= GetResource(this, RES_HEALTH)) {return true;}
if (GetResource(item, RES_ARMOR) && GetResource(player, RES_ARMOR) <= GetResource(this, RES_ARMOR)) {return true;}
if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;}
+ if (item.itemdef.instanceOfPowerup) {return true;}
+ if (this.items & IT_UNLIMITED_AMMO) {return true;}
if (GetResource(item, RES_SHELLS) && GetResource(player, RES_SHELLS) <= GetResource(this, RES_SHELLS)) {return true;}
if (GetResource(item, RES_BULLETS) && GetResource(player, RES_BULLETS) <= GetResource(this, RES_BULLETS)) {return true;}
if (GetResource(item, RES_ROCKETS) && GetResource(player, RES_ROCKETS) <= GetResource(this, RES_ROCKETS)) {return true;}
if (GetResource(item, RES_CELLS) && GetResource(player, RES_CELLS) <= GetResource(this, RES_CELLS)) {return true;}
if (GetResource(item, RES_PLASMA) && GetResource(player, RES_PLASMA) <= GetResource(this, RES_PLASMA)) {return true;}
- if (item.itemdef.instanceOfPowerup) {return true;}
return false;
};
if(!cvar("g_use_ammunition"))
start_items |= IT_UNLIMITED_AMMO;
- if(start_items & IT_UNLIMITED_AMMO)
- {
- start_ammo_shells = 999;
- start_ammo_nails = 999;
- start_ammo_rockets = 999;
- start_ammo_cells = 999;
- start_ammo_plasma = 999;
- start_ammo_fuel = 999;
- }
- else
- {
- start_ammo_shells = cvar("g_start_ammo_shells");
- start_ammo_nails = cvar("g_start_ammo_nails");
- start_ammo_rockets = cvar("g_start_ammo_rockets");
- start_ammo_cells = cvar("g_start_ammo_cells");
- start_ammo_plasma = cvar("g_start_ammo_plasma");
- start_ammo_fuel = cvar("g_start_ammo_fuel");
- random_start_weapons_count = cvar("g_random_start_weapons_count");
- SetResource(random_start_ammo, RES_SHELLS, cvar("g_random_start_shells"));
- SetResource(random_start_ammo, RES_BULLETS, cvar("g_random_start_bullets"));
- SetResource(random_start_ammo, RES_ROCKETS, cvar("g_random_start_rockets"));
- SetResource(random_start_ammo, RES_CELLS, cvar("g_random_start_cells"));
- SetResource(random_start_ammo, RES_PLASMA, cvar("g_random_start_plasma"));
- }
+ start_ammo_shells = cvar("g_start_ammo_shells");
+ start_ammo_nails = cvar("g_start_ammo_nails");
+ start_ammo_rockets = cvar("g_start_ammo_rockets");
+ start_ammo_cells = cvar("g_start_ammo_cells");
+ start_ammo_plasma = cvar("g_start_ammo_plasma");
+ start_ammo_fuel = cvar("g_start_ammo_fuel");
+ random_start_weapons_count = cvar("g_random_start_weapons_count");
+ SetResource(random_start_ammo, RES_SHELLS, cvar("g_random_start_shells"));
+ SetResource(random_start_ammo, RES_BULLETS, cvar("g_random_start_bullets"));
+ SetResource(random_start_ammo, RES_ROCKETS, cvar("g_random_start_rockets"));
+ SetResource(random_start_ammo, RES_CELLS, cvar("g_random_start_cells"));
+ SetResource(random_start_ammo, RES_PLASMA, cvar("g_random_start_plasma"));
warmup_start_ammo_shells = start_ammo_shells;
warmup_start_ammo_nails = start_ammo_nails;