}
}
-float Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
+bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
{
float amount = GetResource(item, res_type);
if (amount == 0)
return true;
}
-float Item_GiveTo(entity item, entity player)
+bool Item_GiveTo(entity item, entity player)
{
- float pickedup;
-
// if nothing happens to player, just return without taking the item
- pickedup = false;
int _switchweapon = 0;
// in case the player has autoswitch enabled do the following:
// if the player is using their best weapon before items are given, they
}
}
}
- pickedup |= Item_GiveAmmoTo(item, player, RES_HEALTH, item.max_health);
- pickedup |= Item_GiveAmmoTo(item, player, RES_ARMOR, item.max_armorvalue);
- pickedup |= Item_GiveAmmoTo(item, player, RES_SHELLS, g_pickup_shells_max);
- pickedup |= Item_GiveAmmoTo(item, player, RES_BULLETS, g_pickup_nails_max);
- pickedup |= Item_GiveAmmoTo(item, player, RES_ROCKETS, g_pickup_rockets_max);
- pickedup |= Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max);
- pickedup |= Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max);
- pickedup |= Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max);
+ bool pickedup = false;
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_HEALTH, item.max_health);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_ARMOR, item.max_armorvalue);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_SHELLS, g_pickup_shells_max);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_BULLETS, g_pickup_nails_max);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_ROCKETS, g_pickup_rockets_max);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max);
+ pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max);
if (item.itemdef.instanceOfWeaponPickup)
{
WepSet w;
pickedup = true;
if (!pickedup)
- return 0;
+ return false;
// crude hack to enforce switching weapons
if(g_cts && item.itemdef.instanceOfWeaponPickup && !CS(player).cvar_cl_cts_noautoswitch)
if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
W_SwitchWeapon_Force(player, Weapons_from(item.weapon), weaponentity);
}
- return 1;
+ return true;
}
if(_switchweapon)
}
}
- return 1;
+ return true;
}
void Item_Touch(entity this, entity toucher)
/// \param[in] weapon_names Names of weapons to give separated by spaces.
/// \param[in] ammo Entity containing the ammo amount for each possible weapon.
/// \return No return.
-void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names,
- entity ammo_entity);
+void GiveRandomWeapons(entity receiver, int num_weapons, string weapon_names, entity ammo_entity);
-float Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax);
+bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax);
-float Item_GiveTo(entity item, entity player);
+bool Item_GiveTo(entity item, entity player);
void Item_Touch(entity this, entity toucher);