From f8a5c5406e0edcd25f0803951798f0d33247469a Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Sun, 22 Sep 2019 19:49:52 +0500 Subject: [PATCH] Regamefixes (#419) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use “ItemInfo” instead of “WeaponInfoStruct” * allow to change m_flRespawnPending (respawn delay) by 3rd party plugins * remove spawn protection on kill (or reset) * fix CVar "mp_kill_filled_spawn" (a forgot check) * cheat impulse 101 max money value (by CVar mp_maxmoney") --- regamedll/dlls/client.cpp | 9 +++++++-- regamedll/dlls/player.cpp | 36 +++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 431056ff..6c00f1b5 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -1550,8 +1550,13 @@ CBaseEntity *EXT_FUNC __API_HOOK(BuyWeaponByWeaponID)(CBasePlayer *pPlayer, Weap pPlayer->AddAccount(-info->cost, RT_PLAYER_BOUGHT_SOMETHING); #ifdef REGAMEDLL_ADD - if (refill_bpammo_weapons.value > 1 && info->ammoType >= AMMO_338MAGNUM && info->ammoType <= AMMO_9MM) { - pPlayer->m_rgAmmo[info->ammoType] = info->maxRounds; + if (refill_bpammo_weapons.value > 1) + { + CBasePlayerItem *pItem = static_cast(pEntity); + + if (pItem) { + pPlayer->GiveAmmo(pItem->iMaxAmmo1(), pItem->pszAmmo1(), pItem->iMaxAmmo1()); + } } #endif diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index d2d427c6..f9461331 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1440,11 +1440,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() #endif #ifdef REGAMEDLL_ADD - auto GiveWeapon = [&](int ammo, char* pszWeaponName) { - GiveNamedItem(pszWeaponName); - const WeaponInfoStruct *pInfo = GetWeaponInfo(pszWeaponName); - if (pInfo) { - GiveAmmo(refill_bpammo_weapons.value != 0.0f ? pInfo->maxRounds : ammo, pInfo->ammoName2); + auto GiveWeapon = [&](int ammo, char *pszWeaponName) { + auto pItem = static_cast(GiveNamedItemEx(pszWeaponName)); + if (pItem) { + GiveAmmo(refill_bpammo_weapons.value != 0.0f ? pItem->iMaxAmmo1() : ammo, pItem->pszAmmo1(), pItem->iMaxAmmo1()); } }; @@ -2169,7 +2168,13 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib) BuyZoneIcon_Clear(this); #ifdef REGAMEDLL_ADD - CSPlayer()->m_flRespawnPending = gpGlobals->time; + if (forcerespawn.value > 0) { + CSPlayer()->m_flRespawnPending = gpGlobals->time + forcerespawn.value; + } + + if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active) { + RemoveSpawnProtection(); + } #endif SetThink(&CBasePlayer::PlayerDeathThink); @@ -4969,6 +4974,11 @@ BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot) if (!pSpot->IsTriggered(pPlayer)) return FALSE; +#ifdef REGAMEDLL_ADD + if (!kill_filled_spawn.value) + return TRUE; +#endif + CBaseEntity *pEntity = nullptr; while ((pEntity = UTIL_FindEntityInSphere(pEntity, pSpot->pev->origin, MAX_PLAYER_USE_RADIUS))) { @@ -5656,6 +5666,12 @@ void CBasePlayer::Reset() WRITE_SHORT(0); WRITE_SHORT(m_iTeam); MESSAGE_END(); + +#ifdef REGAMEDLL_ADD + if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active) { + RemoveSpawnProtection(); + } +#endif } NOXREF void CBasePlayer::SelectNextItem(int iItem) @@ -6135,8 +6151,14 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) } case 101: gEvilImpulse101 = TRUE; + +#ifdef REGAMEDLL_ADD + AddAccount(int(maxmoney.value)); + ALERT(at_console, "Crediting %s with $%i\n", STRING(pev->netname), int(maxmoney.value)); +#else AddAccount(16000); ALERT(at_console, "Crediting %s with $16000\n", STRING(pev->netname)); +#endif break; case 102: CGib::SpawnRandomGibs(pev, 1, 1); @@ -9778,7 +9800,7 @@ void CBasePlayer::PlayerRespawnThink() if (pev->deadflag < DEAD_DYING) return; - if (forcerespawn.value > 0 && gpGlobals->time > (CSPlayer()->m_flRespawnPending + forcerespawn.value)) + if (forcerespawn.value > 0 && gpGlobals->time > CSPlayer()->m_flRespawnPending) { Spawn(); pev->button = 0;