Item_ScheduleRespawnIn(e, game_starttime - time + ITEM_RESPAWNTIME_INITIAL(e));
}
+float Item_GiveAmmoTo(entity item, entity player, .float ammofield, float ammomax)
+{
+ if (!item.ammofield)
+ return FALSE;
+
+ if (item.spawnshieldtime)
+ {
+ if ((player.ammofield < ammomax) || item.pickup_anyway)
+ {
+ player.ammofield = bound(player.ammofield, ammomax, player.ammofield + item.ammo_cells);
+ goto YEAH;
+ }
+ }
+ else if(g_weapon_stay == 2)
+ {
+ float mi = min(item.ammofield, ammomax);
+ if ((player.ammofield < mi) || item.pickup_anyway)
+ {
+ player.ammofield = max(player.ammofield, mi);
+ goto YEAH;
+ }
+ }
+
+ return FALSE;
+
+:YEAH
+ if(ammofield == ammo_fuel)
+ player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
+ if(ammofield == health)
+ player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
+ if(ammofield == armorvalue)
+ player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
+ return TRUE;
+}
+
float Item_GiveTo(entity item, entity player)
{
float _switchweapon;
{
float prevcells = player.ammo_cells;
- if(item.spawnshieldtime)
- {
- if (item.ammo_fuel)
- if (player.ammo_fuel < g_pickup_fuel_max)
- {
- pickedup = TRUE;
- player.ammo_fuel = bound(player.ammo_fuel, g_pickup_fuel_max, player.ammo_fuel + item.ammo_fuel);
- player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
- }
-
- if (item.ammo_cells)
- if (player.ammo_cells < g_pickup_cells_max)
- {
- pickedup = TRUE;
- player.ammo_cells = bound(player.ammo_cells, g_pickup_cells_max, player.ammo_cells + item.ammo_cells);
- }
- }
+ Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max);
+ Item_GiveAmmoTo(item, player, ammo_cells, 999);
if(player.ammo_cells > prevcells)
{
if not(player.weapons & W_WeaponBit(player.switchweapon))
_switchweapon = TRUE;
- if(item.spawnshieldtime)
- {
- if (item.ammo_shells)
- if ((player.ammo_shells < g_pickup_shells_max) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.ammo_shells = bound(player.ammo_shells, g_pickup_shells_max, player.ammo_shells + item.ammo_shells);
- }
- if (item.ammo_nails)
- if ((player.ammo_nails < g_pickup_nails_max) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.ammo_nails = bound(player.ammo_nails, g_pickup_nails_max, player.ammo_nails + item.ammo_nails);
- }
- if (item.ammo_rockets)
- if ((player.ammo_rockets < g_pickup_rockets_max) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.ammo_rockets = bound(player.ammo_rockets, g_pickup_rockets_max, player.ammo_rockets + item.ammo_rockets);
- }
- if (item.ammo_cells)
- if ((player.ammo_cells < g_pickup_cells_max) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.ammo_cells = bound(player.ammo_cells, g_pickup_cells_max, player.ammo_cells + item.ammo_cells);
- }
- if (item.ammo_fuel)
- if ((player.ammo_fuel < g_pickup_fuel_max) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.ammo_fuel = bound(player.ammo_fuel, g_pickup_fuel_max, player.ammo_fuel + item.ammo_fuel);
- player.pauserotfuel_finished = max(player.pauserotfuel_finished, time + autocvar_g_balance_pause_fuel_rot);
- }
- }
+ Item_GiveAmmoTo(item, player, ammo_fuel, g_pickup_fuel_max);
+ Item_GiveAmmoTo(item, player, ammo_shells, g_pickup_shells_max);
+ Item_GiveAmmoTo(item, player, ammo_nails, g_pickup_nails_max);
+ Item_GiveAmmoTo(item, player, ammo_rockets, g_pickup_rockets_max);
+ Item_GiveAmmoTo(item, player, ammo_cells, g_pickup_cells_max);
+ Item_GiveAmmoTo(item, player, health, item.max_health);
+ Item_GiveAmmoTo(item, player, armorvalue, item.max_armorvalue);
if (item.flags & FL_WEAPON)
if ((it = item.weapons - (item.weapons & player.weapons)) || (g_pickup_weapons_anyway))
sprint (player, strcat("You got the ^2", item.netname, "\n"));
}
- if (item.strength_finished)
+ if (item.strength_finished)
{
pickedup = TRUE;
player.strength_finished = max(player.strength_finished, time) + autocvar_g_balance_powerup_strength_time;
pickedup = TRUE;
player.invincible_finished = max(player.invincible_finished, time) + autocvar_g_balance_powerup_invincible_time;
}
-
- if (item.health)
- if ((player.health < item.max_health) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.health = bound(player.health, item.max_health, player.health + item.health);
- player.pauserothealth_finished = max(player.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
- }
- if (item.armorvalue)
- if ((player.armorvalue < item.max_armorvalue) || item.pickup_anyway)
- {
- pickedup = TRUE;
- player.armorvalue = bound(player.armorvalue, item.max_armorvalue, player.armorvalue + item.armorvalue);
- player.pauserotarmor_finished = max(player.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
- }
}
:skip