Feature: ConVars for weapon/item/ammo respawn time (#983)

* `CBasePlayerAmmo`: check spawnflags on `Spawn()`

* `CBasePlayerItem`: check spawnflags on `Materialize()`

* `CBasePlayerItem`: Add `Respawn()` item when hasn't specific spawnflags

* `CBasePlayerItem`: remove `SF_NORESPAWN` flag on `Respawn()`

* Use forgotten `AMMO_RESPAWN_TIME`

* new ConVars: `mp_item_respawn_time`, `mp_weapon_respawn_time`, `mp_ammo_respawn_time`
This commit is contained in:
Sergey Shorokhov 2024-08-03 20:17:52 +03:00 committed by GitHub
parent a202425dd7
commit 9d9c2de1ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 45 additions and 0 deletions

View File

@ -117,6 +117,9 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled | | mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.<br/> `0` disabled<br/>`1` Random players. <br/>`2` All players. | | mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.<br/> `0` disabled<br/>`1` Random players. <br/>`2` All players. |
| mp_location_area_info | 0 | 0 | 3 | Enable location area info.<br/> `0` disabled<br/>`1` show location below HUD radar.<br/>`2` show location in HUD chat. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/>`3` both displayed. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/><br/>`NOTE`: Navigation `maps/.nav` file required and should contain place names<br/>`NOTE`: If option `2` or `3` is enabled, be sure to enable `mp_chat_loc_fallback 1` | | mp_location_area_info | 0 | 0 | 3 | Enable location area info.<br/> `0` disabled<br/>`1` show location below HUD radar.<br/>`2` show location in HUD chat. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/>`3` both displayed. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/><br/>`NOTE`: Navigation `maps/.nav` file required and should contain place names<br/>`NOTE`: If option `2` or `3` is enabled, be sure to enable `mp_chat_loc_fallback 1` |
| mp_item_respawn_time | 30 | 0.0 | - | The respawn time for items (such as health packs, armor, etc.). |
| mp_weapon_respawn_time | 20 | 0.0 | - | The respawn time for weapons. |
| mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. |
</details> </details>
## How to install zBot for CS 1.6? ## How to install zBot for CS 1.6?

18
dist/game.cfg vendored
View File

@ -587,3 +587,21 @@ mp_defuser_allocation "0"
// //
// Default value: "0" // Default value: "0"
mp_location_area_info "0" mp_location_area_info "0"
// The respawn time for items (such as health packs, armor, etc.).
// 0 - disable delay
//
// Default value: "30"
mp_item_respawn_time "30"
// The respawn time for weapons.
// 0 - disable delay
//
// Default value: "20"
mp_weapon_respawn_time "20"
// The respawn time for ammunition.
// 0 - disable delay
//
// Default value: "20"
mp_ammo_respawn_time "20"

View File

@ -181,6 +181,10 @@ cvar_t defuser_allocation = { "mp_defuser_allocation", "0", 0, 0.0f, nullpt
cvar_t location_area_info = { "mp_location_area_info", "0", 0, 0.0f, nullptr }; cvar_t location_area_info = { "mp_location_area_info", "0", 0, 0.0f, nullptr };
cvar_t chat_loc_fallback = { "mp_chat_loc_fallback", "1", 1, 0.0f, nullptr }; cvar_t chat_loc_fallback = { "mp_chat_loc_fallback", "1", 1, 0.0f, nullptr };
cvar_t item_respawn_time = { "mp_item_respawn_time", "30", FCVAR_SERVER, 30.0f, nullptr };
cvar_t weapon_respawn_time = { "mp_weapon_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr };
cvar_t ammo_respawn_time = { "mp_ammo_respawn_time", "20", FCVAR_SERVER, 20.0f, nullptr };
void GameDLL_Version_f() void GameDLL_Version_f()
{ {
if (Q_stricmp(CMD_ARGV(1), "version") != 0) if (Q_stricmp(CMD_ARGV(1), "version") != 0)
@ -446,6 +450,10 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&location_area_info); CVAR_REGISTER(&location_area_info);
CVAR_REGISTER(&chat_loc_fallback); CVAR_REGISTER(&chat_loc_fallback);
CVAR_REGISTER(&item_respawn_time);
CVAR_REGISTER(&weapon_respawn_time);
CVAR_REGISTER(&ammo_respawn_time);
// print version // print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");

View File

@ -204,6 +204,10 @@ extern cvar_t defuser_allocation;
extern cvar_t location_area_info; extern cvar_t location_area_info;
extern cvar_t chat_loc_fallback; extern cvar_t chat_loc_fallback;
extern cvar_t item_respawn_time;
extern cvar_t weapon_respawn_time;
extern cvar_t ammo_respawn_time;
#endif #endif
extern cvar_t scoreboard_showmoney; extern cvar_t scoreboard_showmoney;

View File

@ -4221,7 +4221,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerGotWeapon)(CBasePlayer *pPlay
// What is the time in the future at which this weapon may spawn? // What is the time in the future at which this weapon may spawn?
float CHalfLifeMultiplay::FlWeaponRespawnTime(CBasePlayerItem *pWeapon) float CHalfLifeMultiplay::FlWeaponRespawnTime(CBasePlayerItem *pWeapon)
{ {
#ifdef REGAMEDLL_ADD
return gpGlobals->time + weapon_respawn_time.value;
#else
return gpGlobals->time + WEAPON_RESPAWN_TIME; return gpGlobals->time + WEAPON_RESPAWN_TIME;
#endif
} }
// Returns 0 if the weapon can respawn now, // Returns 0 if the weapon can respawn now,
@ -4289,7 +4293,11 @@ int CHalfLifeMultiplay::ItemShouldRespawn(CItem *pItem)
// At what time in the future may this Item respawn? // At what time in the future may this Item respawn?
float CHalfLifeMultiplay::FlItemRespawnTime(CItem *pItem) float CHalfLifeMultiplay::FlItemRespawnTime(CItem *pItem)
{ {
#ifdef REGAMEDLL_ADD;
return gpGlobals->time + item_respawn_time.value;
#else
return gpGlobals->time + ITEM_RESPAWN_TIME; return gpGlobals->time + ITEM_RESPAWN_TIME;
#endif
} }
// Where should this item respawn? // Where should this item respawn?
@ -4321,7 +4329,11 @@ int CHalfLifeMultiplay::AmmoShouldRespawn(CBasePlayerAmmo *pAmmo)
float CHalfLifeMultiplay::FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) float CHalfLifeMultiplay::FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo)
{ {
#ifdef REGAMEDLL_ADD
return gpGlobals->time + ammo_respawn_time.value;
#else
return gpGlobals->time + AMMO_RESPAWN_TIME; return gpGlobals->time + AMMO_RESPAWN_TIME;
#endif
} }
Vector CHalfLifeMultiplay::VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) Vector CHalfLifeMultiplay::VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo)