From 36f51163f869867c5586fc94a43c9ba5cf2d86d3 Mon Sep 17 00:00:00 2001 From: s1lent Date: Tue, 4 Jul 2017 19:44:49 +0700 Subject: [PATCH] Merged changes from Vaqtincha --- regamedll/dlls/bot/cs_bot_manager.cpp | 14 +- regamedll/dlls/bot/cs_bot_manager.h | 2 +- regamedll/dlls/client.cpp | 68 ++---- regamedll/dlls/effects.cpp | 10 +- regamedll/dlls/func_break.cpp | 20 ++ regamedll/dlls/game.cpp | 4 +- regamedll/dlls/gamerules.cpp | 2 +- regamedll/dlls/h_battery.cpp | 43 +++- regamedll/dlls/healthkit.cpp | 31 ++- regamedll/dlls/hostage/hostage.cpp | 2 +- regamedll/dlls/items.cpp | 22 +- regamedll/dlls/multiplay_gamerules.cpp | 17 +- regamedll/dlls/player.cpp | 233 +++++++++++++++----- regamedll/dlls/player.h | 1 + regamedll/dlls/weapons.cpp | 151 ++++++++++--- regamedll/dlls/weapons.h | 2 + regamedll/dlls/wpn_shared/wpn_c4.cpp | 11 + regamedll/dlls/wpn_shared/wpn_flashbang.cpp | 15 ++ 18 files changed, 476 insertions(+), 172 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index f6bd00a3..ee4a050a 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -186,17 +186,15 @@ void CCSBotManager::__MAKE_VHOOK(StartFrame)() } // Return true if the bot can use this weapon -bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const +bool CCSBotManager::IsWeaponUseable(WeaponIdType weaponID) const { - if (item == NULL) - { + if (weaponID == WEAPON_NONE) return false; - } - - if (item->m_iId == WEAPON_C4) + + if (weaponID == WEAPON_C4) return true; - int weaponClass = WeaponIDToWeaponClass(item->m_iId); + int weaponClass = WeaponIDToWeaponClass(weaponID); if ((!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) || (!AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) @@ -207,7 +205,7 @@ bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const #endif || (!AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) || (!AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) - || (!AllowTacticalShield() && item->m_iId == WEAPON_SHIELDGUN) + || (!AllowTacticalShield() && weaponID == WEAPON_SHIELDGUN) || (!AllowPistols() && weaponClass == WEAPONCLASS_PISTOL) || (!AllowGrenades() && weaponClass == WEAPONCLASS_GRENADE)) { diff --git a/regamedll/dlls/bot/cs_bot_manager.h b/regamedll/dlls/bot/cs_bot_manager.h index 2eaeda7b..a6a572a2 100644 --- a/regamedll/dlls/bot/cs_bot_manager.h +++ b/regamedll/dlls/bot/cs_bot_manager.h @@ -212,7 +212,7 @@ public: bool AllowTacticalShield() const { return cv_bot_allow_shield.value != 0.0f; } bool AllowFriendlyFireDamage() const { return friendlyfire.value != 0.0f; } - bool IsWeaponUseable(CBasePlayerItem *item) const; // return true if the bot can use this weapon + bool IsWeaponUseable(WeaponIdType weaponID) const; // return true if the bot can use this weapon bool IsDefenseRushing() const { return m_isDefenseRushing; } // returns true if defense team has "decided" to rush this round bool IsOnDefense(CBasePlayer *player) const; // return true if this player is on "defense" diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 4b345b5b..3a7e20ff 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -426,6 +426,9 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) pPlayer->m_bTeamChanged = false; pPlayer->m_iNumSpawns = 0; +#ifdef REGAMEDLL_FIXES + pPlayer->m_bHasPrimary = false; +#endif CheckStartMoney(); #ifdef REGAMEDLL_ADD @@ -1324,8 +1327,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(), (char *)pItem->pszAmmo1(), pItem->iMaxAmmo1()); + } } #endif @@ -2009,8 +2017,16 @@ bool EXT_FUNC __API_HOOK(BuyGunAmmo)(CBasePlayer *player, CBasePlayerItem *weapo // Purchase the ammo if the player has enough money if (player->m_iAccount >= info->clipCost) { - player->GiveNamedItem(info->ammoName); +#ifndef REGAMEDLL_ADD + player->GiveNamedItem(info->ammoName); // hardcoded buyClipSize & maxRounds +#else + if (player->GiveAmmo(info->buyClipSize, (char *)weapon->pszAmmo1(), weapon->iMaxAmmo1()) == -1) + return false; + + EMIT_SOUND(weapon->edict(), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); +#endif player->AddAccount(-info->clipCost, RT_PLAYER_BOUGHT_SOMETHING); + return true; } @@ -2997,53 +3013,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa if (player->m_bNightVisionOn) { - EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); - WRITE_BYTE(0); // disable nightvision - MESSAGE_END(); - - player->m_bNightVisionOn = false; - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - if (pObserver && pObserver->IsObservingPlayer(player)) - { - EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); // disable nightvision - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } + player->NightVisionToggle(STATUS_NIGHTVISION_OFF, true); } else { - EMIT_SOUND(ENT(player->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, player->pev); - WRITE_BYTE(1); // enable nightvision - MESSAGE_END(); - - player->m_bNightVisionOn = true; - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - if (pObserver && pObserver->IsObservingPlayer(player)) - { - EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); - - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(1); // enable nightvision - MESSAGE_END(); - - pObserver->m_bNightVisionOn = true; - } - } + player->NightVisionToggle(STATUS_NIGHTVISION_ON, true); } } } diff --git a/regamedll/dlls/effects.cpp b/regamedll/dlls/effects.cpp index 206a6337..3a2b4319 100644 --- a/regamedll/dlls/effects.cpp +++ b/regamedll/dlls/effects.cpp @@ -1887,8 +1887,7 @@ void CEnvFunnel::__MAKE_VHOOK(Spawn)() void CEnvBeverage::__MAKE_VHOOK(Precache)() { - PRECACHE_MODEL("models/can.mdl"); - PRECACHE_SOUND("weapons/g_bounce3.wav"); + ; } LINK_ENTITY_TO_CLASS(env_beverage, CEnvBeverage, CCSEnvBeverage) @@ -1917,7 +1916,8 @@ void CEnvBeverage::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCall void CEnvBeverage::__MAKE_VHOOK(Spawn)() { - Precache(); + // Precache(); + pev->solid = SOLID_NOT; pev->effects = EF_NODRAW; pev->frags = 0; @@ -1930,7 +1930,9 @@ void CEnvBeverage::__MAKE_VHOOK(Spawn)() void CItemSoda::__MAKE_VHOOK(Precache)() { - ; + // used by func_break.cpp pSpawnObjects + PRECACHE_MODEL("models/can.mdl"); + PRECACHE_SOUND("weapons/g_bounce3.wav"); } LINK_ENTITY_TO_CLASS(item_sodacan, CItemSoda, CCSItemSoda) diff --git a/regamedll/dlls/func_break.cpp b/regamedll/dlls/func_break.cpp index a87cb5ce..aebb6db9 100644 --- a/regamedll/dlls/func_break.cpp +++ b/regamedll/dlls/func_break.cpp @@ -13,6 +13,7 @@ const char *CBreakable::pSpawnObjects[] = NULL, "item_battery", "item_healthkit", +#ifndef REGAMEDLL_FIXES "weapon_9mmhandgun", "ammo_9mmclip", "weapon_9mmAR", @@ -42,6 +43,14 @@ const char *CBreakable::pSpawnObjects[] = "weapon_tmp", "weapon_g3sg1", "weapon_flashbang" +#else + "item_kevlar", + "item_assaultsuit", + "item_longjump", + "item_sodacan", + "item_antidote", + "item_thighpack" +#endif }; const char *CBreakable::pSoundsWood[] = @@ -835,7 +844,18 @@ void CBreakable::Die() if (m_iszSpawnObject) { +#ifndef REGAMEDLL_FIXES CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict()); +#else + // FIX: entity leak! + CItem *pItem = (CItem *)CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict()); + if (pItem) + { + pItem->pev->spawnflags |= SF_NORESPAWN; + pItem->SetThink(&CBaseEntity::SUB_Remove); + pItem->pev->nextthink = gpGlobals->time + 300; + } +#endif } if (Explodable()) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 5e5177a2..b7906ac9 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -97,7 +97,7 @@ cvar_t sk_scientist_heal3 = { "sk_scientist_heal3", "0", 0, 0.0f, NULL }; #ifdef REGAMEDLL_ADD -cvar_t game_version = { "game_version", APP_VERSION, FCVAR_SERVER, 0.0f, nullptr }; +cvar_t game_version = { "game_version", APP_VERSION, FCVAR_SPONLY | FCVAR_UNLOGGED, 0.0f, nullptr }; cvar_t maxmoney = { "mp_maxmoney", "16000", FCVAR_SERVER, 0.0f, nullptr }; cvar_t round_infinite = { "mp_round_infinite", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t hegrenade_penetration = { "mp_hegrenade_penetration", "0", 0, 0.0f, nullptr }; @@ -133,7 +133,7 @@ void GameDLL_EndRound_f() { CSGameRules()->EndRoundMessage("#Round_Draw", ROUND_END_DRAW); Broadcast("rounddraw"); - CSGameRules()->TerminateRound(5, WINSTATUS_DRAW); + CSGameRules()->TerminateRound(ROUND_BEGIN_DELAY, WINSTATUS_DRAW); } #endif // REGAMEDLL_ADD diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index fe6201cb..8f3fcfbd 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -85,7 +85,7 @@ BOOL CGameRules::__MAKE_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlay return FALSE; } - if (pPlayer->IsBot() && TheCSBots() != NULL && !TheCSBots()->IsWeaponUseable(pWeapon)) + if (pPlayer->IsBot() && TheCSBots() != NULL && !TheCSBots()->IsWeaponUseable((WeaponIdType)pWeapon->m_iId)) { return FALSE; } diff --git a/regamedll/dlls/h_battery.cpp b/regamedll/dlls/h_battery.cpp index cb340e61..4229575b 100644 --- a/regamedll/dlls/h_battery.cpp +++ b/regamedll/dlls/h_battery.cpp @@ -50,7 +50,11 @@ void CRecharge::__MAKE_VHOOK(Spawn)() UTIL_SetSize(pev, pev->mins, pev->maxs); SET_MODEL(ENT(pev), STRING(pev->model)); +#ifdef REGAMEDLL_ADD + m_iJuice = int(pev->armorvalue ? pev->armorvalue : gSkillData.suitchargerCapacity); // "armorvalue" - 0 = default, > 0 = use my value +#else m_iJuice = int(gSkillData.suitchargerCapacity); +#endif pev->frame = 0; } @@ -68,14 +72,22 @@ void CRecharge::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, return; // if there is no juice left, turn it off - if (m_iJuice <= 0) + if (m_iJuice <= 0 +#ifdef REGAMEDLL_FIXES + && pev->frame != 1.0f // don't update ltime +#endif + ) { pev->frame = 1.0f; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise - if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT))) + if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT)) +#ifdef REGAMEDLL_FIXES + || pActivator->pev->armorvalue >= MAX_NORMAL_BATTERY +#endif + ) { if (m_flSoundTime <= gpGlobals->time) { @@ -118,13 +130,23 @@ void CRecharge::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, } // charge the player - if (m_hActivator->pev->armorvalue < 100) +#ifndef REGAMEDLL_FIXES + if (m_hActivator->pev->armorvalue < MAX_NORMAL_BATTERY) +#endif { m_iJuice--; m_hActivator->pev->armorvalue += 1.0f; - if (m_hActivator->pev->armorvalue > 100) - m_hActivator->pev->armorvalue = 100; +#ifdef REGAMEDLL_FIXES + CBasePlayer *pPlayer = static_cast(pActivator); + if (pPlayer && pPlayer->m_iKevlar == ARMOR_NONE) { + pPlayer->m_iKevlar = ARMOR_KEVLAR; + } +#else + if (m_hActivator->pev->armorvalue > MAX_NORMAL_BATTERY) + m_hActivator->pev->armorvalue = MAX_NORMAL_BATTERY; +#endif + } // govern the rate of charge @@ -133,7 +155,11 @@ void CRecharge::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, void CRecharge::Recharge() { +#ifdef REGAMEDLL_ADD + m_iJuice = int(pev->armorvalue ? pev->armorvalue : gSkillData.suitchargerCapacity); +#else m_iJuice = gSkillData.suitchargerCapacity; +#endif pev->frame = 0; SetThink(&CRecharge::SUB_DoNothing); } @@ -146,7 +172,12 @@ void CRecharge::Off() m_iOn = 0; - if (!m_iJuice && (m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime()) > 0) + if (!m_iJuice && +#ifdef REGAMEDLL_FIXES + (m_iReactivate > 0 || // "dmdelay" - 0 = default, > 0 = use my value +#endif + (m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime()) > 0) + ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink(&CRecharge::Recharge); diff --git a/regamedll/dlls/healthkit.cpp b/regamedll/dlls/healthkit.cpp index ebf81f6b..af191ebd 100644 --- a/regamedll/dlls/healthkit.cpp +++ b/regamedll/dlls/healthkit.cpp @@ -89,7 +89,11 @@ void CWallHealth::__MAKE_VHOOK(Spawn)() SET_MODEL(ENT(pev), STRING(pev->model)); +#ifdef REGAMEDLL_ADD + m_iJuice = int(pev->health ? pev->health : gSkillData.suitchargerCapacity); // "health" - 0 = default, > 0 = use my value +#else m_iJuice = int(gSkillData.healthchargerCapacity); +#endif pev->frame = 0.0f; } @@ -111,14 +115,22 @@ void CWallHealth::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCalle return; // if there is no juice left, turn it off - if (m_iJuice <= 0) + if (m_iJuice <= 0 +#ifdef REGAMEDLL_FIXES + && pev->frame != 1.0f // don't update ltime +#endif + ) { pev->frame = 1.0f; Off(); } // if the player doesn't have the suit, or there is no juice left, make the deny noise - if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT))) + if (m_iJuice <= 0 || !(pActivator->pev->weapons & (1 << WEAPON_SUIT)) +#ifdef REGAMEDLL_FIXES + || pActivator->pev->health >= pActivator->pev->max_health +#endif + ) { if (gpGlobals->time >= m_flSoundTime) { @@ -160,7 +172,13 @@ void CWallHealth::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCalle void CWallHealth::Recharge() { EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM); - m_iJuice = gSkillData.healthchargerCapacity; + +#ifdef REGAMEDLL_ADD + m_iJuice = int(pev->health ? pev->health : gSkillData.suitchargerCapacity); +#else + m_iJuice = int(gSkillData.healthchargerCapacity); +#endif + pev->frame = 0.0f; SetThink(&CWallHealth::SUB_DoNothing); } @@ -173,7 +191,12 @@ void CWallHealth::Off() m_iOn = 0; - if (!m_iJuice && ((m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0)) + if (!m_iJuice && +#ifdef REGAMEDLL_FIXES + (m_iReactivate > 0 || // "dmdelay" - 0 = default, > 0 = use my value +#endif + (m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime()) > 0) + ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink(&CWallHealth::Recharge); diff --git a/regamedll/dlls/hostage/hostage.cpp b/regamedll/dlls/hostage/hostage.cpp index 31783774..53f4e433 100644 --- a/regamedll/dlls/hostage/hostage.cpp +++ b/regamedll/dlls/hostage/hostage.cpp @@ -932,7 +932,7 @@ void CHostage::GiveCTTouchBonus(CBasePlayer *pPlayer) m_bTouched = TRUE; CSGameRules()->m_iAccountCT += CSGameRules()->m_rgRewardAccountRules[RR_TOOK_HOSTAGE_ACC]; - pPlayer->AddAccount(REWARD_TOOK_HOSTAGE, RT_HOSTAGE_TOOK); + pPlayer->AddAccount(CSGameRules()->m_rgRewardAccountRules[RR_TOOK_HOSTAGE], RT_HOSTAGE_TOOK); UTIL_LogPrintf("\"%s<%i><%s>\" triggered \"Touched_A_Hostage\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict())); } diff --git a/regamedll/dlls/items.cpp b/regamedll/dlls/items.cpp index 17068782..bbd041ad 100644 --- a/regamedll/dlls/items.cpp +++ b/regamedll/dlls/items.cpp @@ -220,6 +220,10 @@ BOOL CItemBattery::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) pPlayer->pev->armorvalue += gSkillData.batteryCapacity; pPlayer->pev->armorvalue = Q_min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY); +#ifdef REGAMEDLL_FIXES + if (pPlayer->m_iKevlar == ARMOR_NONE) + pPlayer->m_iKevlar = ARMOR_KEVLAR; +#endif EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); @@ -355,10 +359,15 @@ BOOL CItemKevlar::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) return FALSE; #endif +#ifdef REGAMEDLL_FIXES + if (pPlayer->m_iKevlar != ARMOR_NONE && pPlayer->pev->armorvalue >= MAX_NORMAL_BATTERY) + return FALSE; +#endif + if (pPlayer->m_iKevlar == ARMOR_NONE) pPlayer->m_iKevlar = ARMOR_KEVLAR; - pPlayer->pev->armorvalue = 100; + pPlayer->pev->armorvalue = MAX_NORMAL_BATTERY; EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM); MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev); @@ -366,7 +375,11 @@ BOOL CItemKevlar::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) MESSAGE_END(); MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev); +#ifdef REGAMEDLL_FIXES + WRITE_BYTE(pPlayer->m_iKevlar == ARMOR_KEVLAR ? 0 : 1); // 0 = ARMOR_KEVLAR, 1 = ARMOR_VESTHELM +#else WRITE_BYTE(0); +#endif MESSAGE_END(); if (TheTutor) @@ -398,8 +411,13 @@ BOOL CItemAssaultSuit::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer) return FALSE; #endif +#ifdef REGAMEDLL_FIXES + if (pPlayer->m_iKevlar == ARMOR_VESTHELM && pPlayer->pev->armorvalue >= MAX_NORMAL_BATTERY) + return FALSE; +#endif + pPlayer->m_iKevlar = ARMOR_VESTHELM; - pPlayer->pev->armorvalue = 100; + pPlayer->pev->armorvalue = MAX_NORMAL_BATTERY; EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM); diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index d8209b13..7b554b76 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -721,8 +721,21 @@ void EXT_FUNC CHalfLifeMultiplay::__API_VHOOK(CleanUpMap)() #endif // Remove defuse kit +#ifndef REGAMEDLL_FIXES // Old code only removed 4 kits and stopped. UTIL_RemoveOther("item_thighpack"); +#else + // Don't remove level items + CBaseEntity *thighpack = NULL; + while ((thighpack = UTIL_FindEntityByClassname(thighpack, "item_thighpack")) != NULL) + { + if (thighpack->pev->spawnflags & SF_NORESPAWN) + { + thighpack->SetThink(&CBaseEntity::SUB_Remove); + thighpack->pev->nextthink = gpGlobals->time + 0.1; + } + } +#endif #ifdef REGAMEDLL_FIXES UTIL_RemoveOther("gib"); @@ -3504,12 +3517,12 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) { pPlayer->DropPlayerItem("weapon_c4"); } - +#ifndef REGAMEDLL_FIXES if (pPlayer->m_bHasDefuser) { pPlayer->DropPlayerItem("item_thighpack"); } - +#endif if (pPlayer->m_bIsVIP) { m_pVIP = NULL; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 6e88fe70..67ddfc38 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1446,6 +1446,9 @@ void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) if (!pItem) return; + if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] <= 0) + return; + const char *modelName = GetCSModelName(pItem->m_iId); if (modelName) { @@ -1463,17 +1466,6 @@ void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) break; } - auto& ammoNades = pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ]; - if (pItem->m_flStartThrow != 0) - { - if (ammoNades < 2) - return; - - ammoNades--; - } - else if (pItem->m_flReleaseThrow > 0 && ammoNades < 1) - return; - Vector vecAngles = pPlayer->pev->angles; Vector dir(Q_cos(vecAngles.y) * flOffset, Q_sin(vecAngles.y) * flOffset, 0.0f); @@ -1596,10 +1588,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() case CT: { if (!HasRestrictItem(ITEM_KNIFE, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_knife"); + GiveNamedItemEx("weapon_knife"); } if (!HasRestrictItem(ITEM_USP, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_usp"); + GiveNamedItemEx("weapon_usp"); GiveAmmo(m_bIsVIP ? 12 : 24, "45acp"); } @@ -1608,10 +1600,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() case TERRORIST: { if (!HasRestrictItem(ITEM_KNIFE, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_knife"); + GiveNamedItemEx("weapon_knife"); } if (!HasRestrictItem(ITEM_GLOCK18, ITEM_TYPE_EQUIPPED)) { - GiveNamedItem("weapon_glock18"); + GiveNamedItemEx("weapon_glock18"); GiveAmmo(40, "9mm"); } @@ -1715,6 +1707,9 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit) #ifdef REGAMEDLL_FIXES m_iHideHUD |= HIDEHUD_WEAPONS; + + m_bHasNightVision = false; + SendItemStatus(); #endif // send Selected Weapon Message to our client @@ -1825,6 +1820,55 @@ void CBasePlayer::SetProgressBarTime2(int time, float timeElapsed) } } +void CBasePlayer::NightVisionToggle(int status, bool playSound) +{ + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); + WRITE_BYTE(status); + MESSAGE_END(); + + if (status == STATUS_NIGHTVISION_ON) + { + m_bNightVisionOn = true; + + if (playSound) + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + } + else if (status == STATUS_NIGHTVISION_OFF) + { + m_bNightVisionOn = false; + + if (playSound) + EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + } + + for (int i = 1; i <= gpGlobals->maxClients; ++i) + { + CBasePlayer *pObserver = UTIL_PlayerByIndex(i); + + if (pObserver && pObserver->IsObservingPlayer(this)) + { + MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); + WRITE_BYTE(status); + MESSAGE_END(); + + if (status == STATUS_NIGHTVISION_ON) + { + pObserver->m_bNightVisionOn = true; + + if (playSound) + EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_on.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + } + else if (status == STATUS_NIGHTVISION_OFF) + { + pObserver->m_bNightVisionOn = false; + + if (playSound) + EMIT_SOUND(ENT(pObserver->pev), CHAN_ITEM, "items/nvg_off.wav", RANDOM_FLOAT(0.92, 1), ATTN_NORM); + } + } + } +} + void BuyZoneIcon_Set(CBasePlayer *player) { MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, player->pev); @@ -2075,28 +2119,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) g_pGameRules->PlayerKilled(this, pevAttacker, g_pevLastInflictor); } - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - - m_bNightVisionOn = false; - - for (int i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - - if (!pObserver) - continue; - - if (pObserver->IsObservingPlayer(this)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } + NightVisionToggle(STATUS_NIGHTVISION_OFF, false); if (m_pTank) { @@ -2121,26 +2144,48 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) case WEAPON_HEGRENADE: { CHEGrenade *pHEGrenade = static_cast(m_pActiveItem); +#ifdef REGAMEDLL_FIXES + if ((pHEGrenade->m_flStartThrow != 0 || (pev->button & IN_ATTACK)) && m_rgAmmo[ pHEGrenade->m_iPrimaryAmmoType ]) +#else if ((pev->button & IN_ATTACK) && m_rgAmmo[ pHEGrenade->m_iPrimaryAmmoType ]) +#endif { CGrenade::ShootTimed2(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, m_iTeam, pHEGrenade->m_usCreateExplosion); +#ifdef REGAMEDLL_FIXES + --m_rgAmmo[ pHEGrenade->m_iPrimaryAmmoType ]; +#endif } break; } case WEAPON_FLASHBANG: { - if ((pev->button & IN_ATTACK) && m_rgAmmo[ ((CBasePlayerWeapon *)m_pActiveItem)->m_iPrimaryAmmoType ]) + CFlashbang *pFlash = static_cast(m_pActiveItem); +#ifdef REGAMEDLL_FIXES + if ((pFlash->m_flStartThrow != 0 || (pev->button & IN_ATTACK)) && m_rgAmmo[ pFlash->m_iPrimaryAmmoType ]) +#else + if ((pev->button & IN_ATTACK) && m_rgAmmo[ pFlash->m_iPrimaryAmmoType ]) +#endif { CGrenade::ShootTimed(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5); +#ifdef REGAMEDLL_FIXES + --m_rgAmmo[ pFlash->m_iPrimaryAmmoType ]; +#endif } break; } case WEAPON_SMOKEGRENADE: { CSmokeGrenade *pSmoke = static_cast(m_pActiveItem); +#ifdef REGAMEDLL_FIXES + if ((pSmoke->m_flStartThrow != 0 || (pev->button & IN_ATTACK)) && m_rgAmmo[ pSmoke->m_iPrimaryAmmoType ]) +#else if ((pev->button & IN_ATTACK) && m_rgAmmo[ pSmoke->m_iPrimaryAmmoType ]) +#endif { CGrenade::ShootSmokeGrenade(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, pSmoke->m_usCreateSmoke); +#ifdef REGAMEDLL_FIXES + --m_rgAmmo[ pSmoke->m_iPrimaryAmmoType ]; +#endif } break; } @@ -2159,6 +2204,11 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) pev->flags &= ~FL_ONGROUND; +#ifdef REGAMEDLL_FIXES + // FlashlightTurnOff() + pev->effects &= ~EF_DIMLIGHT; +#endif + if (fadetoblack.value == 0.0) { pev->iuser1 = OBS_CHASE_FREE; @@ -2257,14 +2307,26 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) if (m_bHasC4) { DropPlayerItem("weapon_c4"); + // NOTE: It is already does reset inside DropPlayerItem +#ifndef REGAMEDLL_FIXES SetProgressBarTime(0); +#endif } else if (m_bHasDefuser) { m_bHasDefuser = false; pev->body = 0; +#ifndef REGAMEDLL_FIXES GiveNamedItem("item_thighpack"); - +#else + CItem *pItem = (CItem *)CBaseEntity::Create("item_thighpack", pev->origin, pev->angles, edict()); + if (pItem) + { + pItem->pev->spawnflags |= SF_NORESPAWN; + pItem->SetThink(&CBaseEntity::SUB_Remove); + pItem->pev->nextthink = gpGlobals->time + 300; + } +#endif MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); WRITE_BYTE(STATUSICON_HIDE); WRITE_STRING("defuser"); @@ -2297,10 +2359,14 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib) if ((pev->health < -9000 && iGib != GIB_NEVER) || iGib == GIB_ALWAYS) { +#ifndef REGAMEDLL_FIXES pev->solid = SOLID_NOT; +#endif GibMonster(); pev->effects |= EF_NODRAW; +#ifndef REGAMEDLL_FIXES CSGameRules()->CheckWinConditions(); +#endif return; } @@ -3537,6 +3603,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)() pev->solid = SOLID_NOT; pev->flags &= ~FL_ONGROUND; +#ifdef REGAMEDLL_FIXES + // FlashlightTurnOff() + pev->effects &= ~EF_DIMLIGHT; +#endif + SetSuitUpdate(NULL, FALSE, 0); m_iClientHealth = 0; @@ -3558,13 +3629,26 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)() if (m_bHasC4) { DropPlayerItem("weapon_c4"); + // NOTE: It is already does reset inside DropPlayerItem +#ifndef REGAMEDLL_FIXES SetProgressBarTime(0); +#endif } else if (m_bHasDefuser) { m_bHasDefuser = false; pev->body = 0; +#ifndef REGAMEDLL_FIXES GiveNamedItem("item_thighpack"); +#else + CItem *pItem = (CItem *)CBaseEntity::Create("item_thighpack", pev->origin, pev->angles, edict()); + if (pItem) + { + pItem->pev->spawnflags |= SF_NORESPAWN; + pItem->SetThink(&CBaseEntity::SUB_Remove); + pItem->pev->nextthink = gpGlobals->time + 300; + } +#endif MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pev); WRITE_BYTE(STATUSICON_HIDE); @@ -3925,7 +4009,11 @@ void CBasePlayer::PlayerUse() } } +#ifdef REGAMEDLL_FIXES + bool useNewHostages = (!TheNavAreaList.empty() && AreImprovAllowed()); +#else bool useNewHostages = !TheNavAreaList.empty(); +#endif CBaseEntity *pObject = NULL; CBaseEntity *pClosest = NULL; Vector vecLOS; @@ -5256,6 +5344,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() #ifdef REGAMEDLL_FIXES pev->watertype = CONTENTS_EMPTY; pev->waterlevel = 0; + pev->basevelocity = g_vecZero; // pushed by trigger_push #endif m_bitsHUDDamage = -1; @@ -5460,10 +5549,14 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() for (i = 0; i < MAX_AMMO_SLOTS; ++i) m_rgAmmo[i] = 0; - m_bHasPrimary = false; m_bHasNightVision = false; - SendItemStatus(); + +#ifndef REGAMEDLL_FIXES + m_bHasPrimary = false; +#else + m_iHideHUD |= HIDEHUD_WEAPONS; +#endif } else { @@ -5471,25 +5564,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(Spawn)() m_rgAmmoLast[i] = -1; } - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pev); - WRITE_BYTE(0); - MESSAGE_END(); - - m_bNightVisionOn = false; - - for (i = 1; i <= gpGlobals->maxClients; ++i) - { - CBasePlayer *pObserver = UTIL_PlayerByIndex(i); - - if (pObserver && pObserver->IsObservingPlayer(this)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgNVGToggle, NULL, pObserver->pev); - WRITE_BYTE(0); - MESSAGE_END(); - - pObserver->m_bNightVisionOn = false; - } - } + NightVisionToggle(STATUS_NIGHTVISION_OFF, false); m_lastx = m_lasty = 0; @@ -5698,7 +5773,12 @@ void CBasePlayer::Reset() m_bNotKilled = false; +#ifdef REGAMEDLL_FIXES + RemoveAllItems(TRUE); +#else RemoveShield(); +#endif + CheckStartMoney(); AddAccount(startmoney.value, RT_PLAYER_RESET); @@ -6179,8 +6259,13 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) break; case 101: gEvilImpulse101 = TRUE; +#ifdef REGAMEDLL_ADD + AddAccount(int(maxmoney.value)); + ALERT(at_console, "Crediting %s with $%d\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); @@ -6535,6 +6620,13 @@ BOOL EXT_FUNC CBasePlayer::__API_VHOOK(RemovePlayerItem)(CBasePlayerItem *pItem) pev->viewmodel = 0; pev->weaponmodel = 0; + +#ifdef REGAMEDLL_FIXES + // no more weapon + if (pev->weapons == (1 << WEAPON_SUIT)) { + m_iHideHUD |= HIDEHUD_WEAPONS; + } +#endif } else if (m_pLastItem == pItem) m_pLastItem = NULL; @@ -7360,14 +7452,22 @@ void CBasePlayer::UpdateStatusBar() CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); bool isVisiblePlayer = ((TheBots == NULL || !TheBots->IsLineBlockedBySmoke(&pev->origin, &pEntity->pev->origin)) && pEntity->Classify() == CLASS_PLAYER); +#ifdef REGAMEDLL_ADD + bool isFFA = CSGameRules()->IsFreeForAll(); +#endif if (gpGlobals->time >= m_blindUntilTime && isVisiblePlayer) { CBasePlayer *pTarget = (CBasePlayer *)pEntity; newSBarState[ SBAR_ID_TARGETNAME ] = ENTINDEX(pTarget->edict()); +#ifdef REGAMEDLL_ADD + newSBarState[SBAR_ID_TARGETTYPE] = (!isFFA && pTarget->m_iTeam == m_iTeam) ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY; + if ((!isFFA && pTarget->m_iTeam == m_iTeam) || IsObserver()) +#else newSBarState[ SBAR_ID_TARGETTYPE ] = (pTarget->m_iTeam == m_iTeam) ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY; if (pTarget->m_iTeam == m_iTeam || IsObserver()) +#endif { if (playerid.value != PLAYERID_MODE_OFF || IsObserver()) Q_strcpy(sbuf0, "1 %c1: %p2\n2 %h: %i3%%"); @@ -7382,7 +7482,11 @@ void CBasePlayer::UpdateStatusBar() HintMessage("#Hint_spotted_a_friend"); } } +#ifdef REGAMEDLL_ADD + else if (isFFA || !IsObserver()) +#else else if (!IsObserver()) +#endif { if (playerid.value != PLAYERID_MODE_TEAMONLY && playerid.value != PLAYERID_MODE_OFF) Q_strcpy(sbuf0, "1 %c1: %p2"); @@ -7527,6 +7631,13 @@ void EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszItemName) // take item off hud pev->weapons &= ~(1 << pWeapon->m_iId); + +#ifdef REGAMEDLL_FIXES + // no more weapon + if(pev->weapons == (1 << WEAPON_SUIT)) { + m_iHideHUD |= HIDEHUD_WEAPONS; + } +#endif g_pGameRules->GetNextBestWeapon(this, pWeapon); UTIL_MakeVectors(pev->angles); @@ -7777,6 +7888,7 @@ void CBasePlayer::SwitchTeam() SendItemStatus(); SetProgressBarTime(0); +#ifndef REGAMEDLL_FIXES for (int i = 0; i < MAX_ITEM_TYPES; ++i) { m_pActiveItem = m_rgpPlayerItems[ i ]; @@ -7787,6 +7899,7 @@ void CBasePlayer::SwitchTeam() m_rgpPlayerItems[i] = NULL; } } +#endif } szOldTeam = GetTeam(oldTeam); diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 6032c665..d09685e2 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -611,6 +611,7 @@ public: bool IsObservingPlayer(CBasePlayer *pPlayer); bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; } void SendItemStatus(); + void NightVisionToggle(int status, bool playSound); edict_t *EntSelectSpawnPoint(); void SetScoreAttrib(CBasePlayer *dest); void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false); diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 08c78588..beaffeed 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -363,7 +363,10 @@ void W_Precache() UTIL_PrecacheOther("item_antidote"); #ifndef REGAMEDLL_FIXES UTIL_PrecacheOther("item_security"); +#else + UTIL_PrecacheOther("item_sodacan"); #endif + UTIL_PrecacheOther("item_longjump"); UTIL_PrecacheOther("item_kevlar"); UTIL_PrecacheOther("item_assaultsuit"); @@ -1550,6 +1553,10 @@ void CBasePlayerWeapon::__MAKE_VHOOK(RetireWeapon)() m_pPlayer->pev->viewmodel = iStringNull; m_pPlayer->pev->weaponmodel = iStringNull; +#ifdef REGAMEDLL_FIXES + // grenade/c4 switch after throw + Holster(); +#endif g_pGameRules->GetNextBestWeapon(m_pPlayer, this); } @@ -1717,6 +1724,9 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) bool bRemove = true; bool bEmitSound = false; +#ifdef REGAMEDLL_FIXES + static const int ammoGrenade = 1; +#endif // go through my weapons and try to give the usable ones to the player. // it's important the the player be given ammo first, so the weapons code doesn't refuse // to deploy a better weapon that the player may pick up because he has no ammo for it. @@ -1731,7 +1741,7 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) while (pItem) { if ((pPlayer->HasShield() && pItem->m_iId == WEAPON_ELITE) - || (pPlayer->IsBot() && (TheCSBots() != NULL && !TheCSBots()->IsWeaponUseable(pItem)))) + || (pPlayer->IsBot() && (TheCSBots() != NULL && !TheCSBots()->IsWeaponUseable((WeaponIdType)pItem->m_iId)))) { return; } @@ -1830,16 +1840,30 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) auto info = GetWeaponInfo(pGrenade->m_iId); if (info && playerGrenades < info->maxRounds) { - auto pNext = m_rgpPlayerItems[i]->m_pNext; - if (pPlayer->AddPlayerItem(pItem)) + int boxGrenades = m_rgAmmo[ammoGrenade]; + if (playerGrenades >= 1 && boxGrenades > 1) { - pItem->AttachToPlayer(pPlayer); - bEmitSound = true; - } + if (!FStringNull(m_rgiszAmmo[ammoGrenade])) + { + pPlayer->GiveAmmo(1, (char *)STRING(m_rgiszAmmo[ammoGrenade]), info->maxRounds); + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); - // unlink this weapon from the box - m_rgpPlayerItems[i] = pItem = pNext; - continue; + m_rgAmmo[ammoGrenade]--; + } + } + else + { + auto pNext = m_rgpPlayerItems[i]->m_pNext; + if (pPlayer->AddPlayerItem(pItem)) + { + pItem->AttachToPlayer(pPlayer); + bEmitSound = true; + } + + // unlink this weapon from the box + m_rgpPlayerItems[i] = pItem = pNext; + continue; + } } #else @@ -1915,6 +1939,12 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) // there's some ammo of this type. pPlayer->GiveAmmo(m_rgAmmo[n], (char *)STRING(m_rgiszAmmo[n]), MaxAmmoCarry(m_rgiszAmmo[n])); +#ifdef REGAMEDLL_FIXES + if (n == ammoGrenade) + { + EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); + } +#endif // now empty the ammo from the weaponbox since we just gave it to the player m_rgiszAmmo[n] = iStringNull; m_rgAmmo[n] = 0; @@ -2264,20 +2294,20 @@ struct ArmouryItemStruct int giveAmount; int maxRounds; } armouryItemInfo[] = { - { "weapon_mp5navy", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_MP5NAVY - { "weapon_tmp", "9mm", 60, MAX_AMMO_9MM }, // ARMOURY_TMP - { "weapon_p90", "57mm", 50, MAX_AMMO_57MM }, // ARMOURY_P90 - { "weapon_mac10", "45acp", 60, MAX_AMMO_45ACP }, // ARMOURY_MAC10 - { "weapon_ak47", "762Nato", 60, MAX_AMMO_762NATO }, // ARMOURY_AK47 - { "weapon_sg552", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_SG552 - { "weapon_m4a1", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_M4A1 - { "weapon_aug", "556Nato", 60, MAX_AMMO_556NATO }, // ARMOURY_AUG - { "weapon_scout", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_SCOUT - { "weapon_g3sg1", "762Nato", 30, MAX_AMMO_762NATO }, // ARMOURY_G3SG1 - { "weapon_awp", "338Magnum", 20, MAX_AMMO_338MAGNUM }, // ARMOURY_AWP - { "weapon_m3", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_M3 - { "weapon_xm1014", "buckshot", 24, MAX_AMMO_BUCKSHOT }, // ARMOURY_XM1014 - { "weapon_m249", "556NatoBox", 60, MAX_AMMO_556NATOBOX }, // ARMOURY_M249 + { "weapon_mp5navy", "9mm", MAX_AMMO_9MM, MAX_AMMO_9MM }, // ARMOURY_MP5NAVY + { "weapon_tmp", "9mm", MAX_AMMO_9MM, MAX_AMMO_9MM }, // ARMOURY_TMP + { "weapon_p90", "57mm", MAX_AMMO_57MM, MAX_AMMO_57MM }, // ARMOURY_P90 + { "weapon_mac10", "45acp", MAX_AMMO_45ACP, MAX_AMMO_45ACP }, // ARMOURY_MAC10 + { "weapon_ak47", "762Nato", MAX_AMMO_762NATO, MAX_AMMO_762NATO }, // ARMOURY_AK47 + { "weapon_sg552", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_SG552 + { "weapon_m4a1", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_M4A1 + { "weapon_aug", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_AUG + { "weapon_scout", "762Nato", MAX_AMMO_762NATO, MAX_AMMO_762NATO }, // ARMOURY_SCOUT + { "weapon_g3sg1", "762Nato", MAX_AMMO_762NATO, MAX_AMMO_762NATO }, // ARMOURY_G3SG1 + { "weapon_awp", "338Magnum", MAX_AMMO_338MAGNUM, MAX_AMMO_338MAGNUM }, // ARMOURY_AWP + { "weapon_m3", "buckshot", MAX_AMMO_BUCKSHOT, MAX_AMMO_BUCKSHOT }, // ARMOURY_M3 + { "weapon_xm1014", "buckshot", MAX_AMMO_BUCKSHOT, MAX_AMMO_BUCKSHOT }, // ARMOURY_XM1014 + { "weapon_m249", "556NatoBox", MAX_AMMO_556NATOBOX, MAX_AMMO_556NATOBOX }, // ARMOURY_M249 { NULL, NULL, 0, 0 }, // ARMOURY_FLASHBANG { NULL, NULL, 0, 0 }, // ARMOURY_HEGRENADE @@ -2286,16 +2316,16 @@ struct ArmouryItemStruct { NULL, NULL, 0, 0 }, // ARMOURY_SMOKEGRENADE { NULL, NULL, 0, 0 }, // ARMOURY_SHIELD - { "weapon_famas", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_FAMAS - { "weapon_sg550", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_SG550 - { "weapon_galil", "556Nato", 90, MAX_AMMO_556NATO }, // ARMOURY_GALIL - { "weapon_ump45", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_UMP45 - { "weapon_glock18", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_GLOCK18 - { "weapon_usp", "45acp", 100, MAX_AMMO_45ACP }, // ARMOURY_USP - { "weapon_elite", "9mm", 120, MAX_AMMO_9MM }, // ARMOURY_ELITE - { "weapon_fiveseven", "57mm", 100, MAX_AMMO_57MM }, // ARMOURY_FIVESEVEN - { "weapon_p228", "357SIG", 52, MAX_AMMO_357SIG }, // ARMOURY_P228 - { "weapon_deagle", "50AE", 35, MAX_AMMO_50AE }, // ARMOURY_DEAGLE + { "weapon_famas", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_FAMAS + { "weapon_sg550", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_SG550 + { "weapon_galil", "556Nato", MAX_AMMO_556NATO, MAX_AMMO_556NATO }, // ARMOURY_GALIL + { "weapon_ump45", "45acp", MAX_AMMO_45ACP, MAX_AMMO_45ACP }, // ARMOURY_UMP45 + { "weapon_glock18", "9mm", MAX_AMMO_9MM, MAX_AMMO_9MM }, // ARMOURY_GLOCK18 + { "weapon_usp", "45acp", MAX_AMMO_45ACP, MAX_AMMO_45ACP }, // ARMOURY_USP + { "weapon_elite", "9mm", MAX_AMMO_9MM, MAX_AMMO_9MM }, // ARMOURY_ELITE + { "weapon_fiveseven", "57mm", MAX_AMMO_57MM, MAX_AMMO_57MM }, // ARMOURY_FIVESEVEN + { "weapon_p228", "357SIG", MAX_AMMO_357SIG, MAX_AMMO_357SIG }, // ARMOURY_P228 + { "weapon_deagle", "50AE", MAX_AMMO_50AE, MAX_AMMO_50AE }, // ARMOURY_DEAGLE }; void CArmoury::ArmouryTouch(CBaseEntity *pOther) @@ -2308,6 +2338,11 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) if (p->m_bIsVIP) return; +#ifdef REGAMEDLL_FIXES + if (p->IsBot() && m_iItem != ARMOURY_KEVLAR && m_iItem != ARMOURY_ASSAULT && TheCSBots() && !TheCSBots()->IsWeaponUseable(GetWeaponIdByArmoury(m_iItem))) + return; +#endif + #ifdef REGAMEDLL_ADD if (p->HasRestrictItem(GetItemIdByArmoury(m_iItem), ITEM_TYPE_TOUCHED)) return; @@ -2373,8 +2408,14 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) } case ARMOURY_KEVLAR: { +#ifdef REGAMEDLL_FIXES + if (p->m_iKevlar != ARMOR_NONE && p->pev->armorvalue >= MAX_NORMAL_BATTERY) +#else if (p->m_iKevlar == ARMOR_KEVLAR) +#endif + { return; + } p->GiveNamedItem("item_kevlar"); m_iCount--; @@ -2382,8 +2423,14 @@ void CArmoury::ArmouryTouch(CBaseEntity *pOther) } case ARMOURY_ASSAULT: { - if (p->m_iKevlar == ARMOR_VESTHELM) + if (p->m_iKevlar == ARMOR_VESTHELM +#ifdef REGAMEDLL_FIXES + && p->pev->armorvalue >= MAX_NORMAL_BATTERY +#endif + ) + { return; + } p->GiveNamedItem("item_assaultsuit"); m_iCount--; @@ -2470,3 +2517,39 @@ void CBasePlayerWeapon::InstantReload(bool bCanRefillBPAmmo) m_pPlayer->TabulateAmmo(); } + +WeaponIdType GetWeaponIdByArmoury(ArmouryItemPack armoury) +{ + switch (armoury) + { + case ARMOURY_MP5NAVY: return WEAPON_MP5N; + case ARMOURY_TMP: return WEAPON_TMP; + case ARMOURY_P90: return WEAPON_P90; + case ARMOURY_MAC10: return WEAPON_MAC10; + case ARMOURY_AK47: return WEAPON_AK47; + case ARMOURY_SG552: return WEAPON_SG552; + case ARMOURY_M4A1: return WEAPON_M4A1; + case ARMOURY_AUG: return WEAPON_AUG; + case ARMOURY_SCOUT: return WEAPON_SCOUT; + case ARMOURY_G3SG1: return WEAPON_G3SG1; + case ARMOURY_AWP: return WEAPON_AWP; + case ARMOURY_M3: return WEAPON_M3; + case ARMOURY_XM1014: return WEAPON_XM1014; + case ARMOURY_M249: return WEAPON_M249; + case ARMOURY_FLASHBANG: return WEAPON_FLASHBANG; + case ARMOURY_HEGRENADE: return WEAPON_HEGRENADE; + case ARMOURY_SMOKEGRENADE: return WEAPON_SMOKEGRENADE; + case ARMOURY_SHIELD: return WEAPON_SHIELDGUN; + case ARMOURY_GLOCK18: return WEAPON_GLOCK18; + case ARMOURY_USP: return WEAPON_USP; + case ARMOURY_ELITE: return WEAPON_ELITE; + case ARMOURY_FIVESEVEN: return WEAPON_FIVESEVEN; + case ARMOURY_P228: return WEAPON_P228; + case ARMOURY_DEAGLE: return WEAPON_DEAGLE; + case ARMOURY_FAMAS: return WEAPON_FAMAS; + case ARMOURY_SG550: return WEAPON_SG550; + case ARMOURY_GALIL: return WEAPON_GALIL; + case ARMOURY_UMP45: return WEAPON_UMP45; + default: return WEAPON_NONE; + } +} diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 1bb9b1a5..a6c98bec 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -1883,4 +1883,6 @@ void UTIL_PrecacheOtherWeapon2(const char *szClassname); void W_Precache(); BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); +WeaponIdType GetWeaponIdByArmoury(ArmouryItemPack armoury); + #endif // WEAPONS_H diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index ae06d41e..1162f8d2 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -72,6 +72,13 @@ BOOL CC4::__MAKE_VHOOK(Deploy)() void CC4::__MAKE_VHOOK(Holster)(int skiplocal) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f; + +#ifdef REGAMEDLL_FIXES + if (m_bStartedArming) { + m_pPlayer->SetProgressBarTime(0); + } +#endif + m_bStartedArming = false; // stop arming sequence if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) @@ -317,7 +324,11 @@ void CC4::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T EMIT_SOUND(edict(), CHAN_WEAPON, "weapons/c4_plant.wav", VOL_NORM, ATTN_NORM); +#ifdef REGAMEDLL_FIXES + CGrenade::ShootSatchelCharge(pPlayer->pev, pPlayer->pev->origin, Vector(0, 0, 0)); +#else CGrenade::ShootSatchelCharge(m_pPlayer->pev, m_pPlayer->pev->origin, Vector(0, 0, 0)); +#endif CGrenade *pC4 = NULL; while ((pC4 = (CGrenade *)UTIL_FindEntityByClassname(pC4, "grenade"))) diff --git a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp index 6470f087..5c273e8b 100644 --- a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp +++ b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp @@ -217,7 +217,22 @@ void CFlashbang::__MAKE_VHOOK(WeaponIdle)() { // we've finished the throw, restart. m_flStartThrow = 0; +#ifndef REGAMEDLL_FIXES RetireWeapon(); +#else + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) + { + SendWeaponAnim(FLASHBANG_DRAW, UseDecrement() != FALSE); + } + else + { + RetireWeapon(); + return; + } + + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT(10, 15); + m_flReleaseThrow = -1.0f; +#endif } else if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) {