SERVER: Fix automatic reload not always functioning

This commit is contained in:
MotoLegacy 2023-11-05 17:08:55 -05:00
parent 8935f1889d
commit 8bdf2e2f1f
3 changed files with 21 additions and 12 deletions

View file

@ -523,32 +523,41 @@ float() PU_CarpenterRequirement =
//
void() PU_MaxAmmo =
{
entity players;
entity tempe;
tempe = find(world, classname, "player");
players = find(world, classname, "player");
while(tempe) {
while(players) {
if (!tempe.downed) {
if (!players.downed) {
// Fill all weapons
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
tempe.weapons[i].weapon_reserve = getWeaponAmmo(tempe.weapons[i].weapon_id);
players.weapons[i].weapon_reserve = getWeaponAmmo(players.weapons[i].weapon_id);
}
// Give Grenades
tempe.primary_grenades = 4;
players.primary_grenades = 4;
// Give Betties
if (tempe.grenades & 2) tempe.secondary_grenades = 2;
if (players.grenades & 2) players.secondary_grenades = 2;
} else {
// Reset shots fired, fill 2 mags into reserve.
tempe.teslacount = 0;
tempe.currentammo = getWeaponMag(tempe.weapon) * 2;
players.teslacount = 0;
players.weapons[0].weapon_reserve = getWeaponMag(players.weapon) * 2;
}
// Force the player to reload if their mag is empty
if (players.weapons[0].weapon_magazine == 0 || players.weapons[0].weapon_magazine_left == 0) {
tempe = self;
self = players;
W_Reload(S_BOTH);
self = tempe;
}
// MAX AMMO! text
#ifdef FTE
ScrollText("MAX AMMO!", tempe);
ScrollText("MAX AMMO!", players);
#else
@ -556,7 +565,7 @@ void() PU_MaxAmmo =
#endif // FTE
tempe = find(tempe, classname, "player");
players = find(players, classname, "player");
}
};

View file

@ -181,7 +181,7 @@ void (float animation_type, void(optional float t) end_function, float playback_
break;
}
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = self.knife_delay = time + duration + 0.2;
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = self.knife_delay = time + duration;
UpdateVmodel(self.weaponmodel, GetWepSkin(self.weapon));
self.weapon2model = GetWeapon2Model(self.weapon);

View file

@ -94,7 +94,7 @@ void() ReturnWeaponModel =
UpdateV2model(self.weapon2model, GetWepSkin(self.weapon));
// Always try to reload after any action.
if (self.weapons[0].weapon_magazine == 0 && self.weapons[0].weapon_reserve != 0)
if ((self.weapons[0].weapon_magazine == 0 || self.weapons[0].weapon_magazine_left == 0) && self.weapons[0].weapon_reserve != 0)
W_Reload(S_BOTH);
// If the person is swapping, play the sprint anim if they're sprinting after swap. Otherwise it plays idle