Skip to content

Commit

Permalink
Merge branch 's1lentq:master' into semiclip-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenKal authored Jul 11, 2023
2 parents 6c36d7b + e1d1c11 commit 4937343
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 115 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_round_restart_delay | 5 | - | - | Number of seconds to delay before restarting a round after a win. |
| mp_hegrenade_penetration | 0 | 0 | 1 | Disable grenade damage through walls.<br/>`0` disabled<br/>`1` enabled |
| mp_nadedrops | 0 | 0 | 2 | Drop a grenade after player death.<br/>`0` disabled<br/>`1` drop first available grenade<br/>`2` drop all grenades |
| mp_weapondrop | 1 | 0 | 3 | Drop player weapon after death.<br/>`0` do not drop weapons after death<br/>`1` drop best/heaviest weapon after death<br/>`2` drop active weapon after death<br/>`3` drop all weapons after death (primary and secondary) |
| mp_ammodrop | 1 | 0 | 2 | Drop ammo on weapon boxes on death or manual drop.<br/>`0` always keep ammo on player<br/>`1` drop all ammo only after death<br/>`2` drop all ammo whenever player drops a weapon |
| mp_roundrespawn_time | 20 | 0 | - | Player cannot respawn until next round if more than N seconds has elapsed since the beginning round.<br />`-1` means no time limit<br /> |
| mp_auto_reload_weapons | 0 | 0 | 1 | Automatically reload each weapon on player spawn.<br/>`0` disabled<br/>`1` enabled |
| mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max.<br/>`0` disabled<br/>`1` refill backpack ammo on player spawn<br/>`2` refill backpack ammo on player spawn and on the purchase of the item |
Expand Down
18 changes: 18 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ mp_hegrenade_penetration "0"
// Default value: "0"
mp_nadedrops "0"
// Drop player weapon after death
// 0 - do not drop weapons after death
// 1 - drop best/heaviest weapon after death (default behaviour)
// 2 - drop active weapon after death
// 3 - drop all weapons after death (primary and secondary)
// NOTE: Grenades are dropped separately depending on mp_nadedrops value
//
// Default value: "1"
mp_weapondrop "1"
// Drop ammo on weapon boxes on death or manual drop
// 0 - always keep ammo on player
// 1 - drop all ammo only after death (default behaviour)
// 2 - drop all ammo whenever player drops a weapon (NOTE: Other weapons may remain without ammo due to same ammo sharing)
//
// Default value: "1"
mp_ammodrop "1"
// Player cannot respawn until next round
// if more than N seconds has elapsed since the beginning round
// -1 - means no time limit
Expand Down
1 change: 1 addition & 0 deletions regamedll/common/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
// Starting from BIT(16) to reserve space for more flags for Engine
#define FTRACE_BULLET BIT(16)
#define FTRACE_FLASH BIT(17)
#define FTRACE_KNIFE BIT(18)

// walkmove modes
#define WALKMOVE_NORMAL 0 // normal walkmove
Expand Down
29 changes: 21 additions & 8 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,20 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov
auto pItem = GetItemByName(pszItemName);
if (pItem)
{
if (FClassnameIs(pItem->pev, "weapon_c4")) {
pPlayer->m_bHasC4 = false;
pPlayer->pev->body = 0;
pPlayer->SetBombIcon(FALSE);
pPlayer->SetProgressBarTime(0);
}

if (pItem->IsWeapon())
{
// These weapons have a unique type of ammo that is used only by them
// If a weapon is removed, its ammo is also reduced, unless the ammo can be used by another weapon
if (!bRemoveAmmo && (IsGrenadeWeapon(pItem->m_iId) || pItem->m_iId == WEAPON_C4))
{
if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0)
pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]--;

// Hold the weapon until it runs out of ammo
if (pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] > 0)
return true; // ammo was reduced, this will be considered a successful result
}

if (pItem == pPlayer->m_pActiveItem) {
((CBasePlayerWeapon *)pItem)->RetireWeapon();
}
Expand All @@ -229,7 +234,15 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov
}
}

if (pPlayer->RemovePlayerItem(pItem)) {
if (pPlayer->RemovePlayerItem(pItem))
{
if (FClassnameIs(pItem->pev, "weapon_c4")) {
pPlayer->m_bHasC4 = false;
pPlayer->pev->body = 0;
pPlayer->SetBombIcon(FALSE);
pPlayer->SetProgressBarTime(0);
}

pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
// No more weapon
if ((pPlayer->pev->weapons & ~(1 << WEAPON_SUIT)) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CCSBotManager::CCSBotManager()
char *dataPointer = (char *)LOAD_FILE_FOR_ME((char *)filename, &dataLength);
if (!dataPointer)
{
TheBotProfiles->Init("BotProfile.db");
TheBotProfiles->Init(cv_bot_profile_db.string);
}
else
{
Expand Down
9 changes: 8 additions & 1 deletion regamedll/dlls/career_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,14 @@ void CCareerTask::OnWeaponKill(int weaponId, int weaponClassId, bool headshot, b
if (!pHostage->IsAlive())
continue;

#ifndef REGAMEDLL_FIXES
if (!pHostage->IsFollowingSomeone())
continue;

if (pHostage->m_target == pVictim)
#else
if (pHostage->IsFollowing(pVictim))
#endif
hostagesCount++;
}

Expand Down Expand Up @@ -211,11 +215,14 @@ void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer
{
if (!pHostage->IsAlive())
continue;

#ifndef REGAMEDLL_FIXES
if (!pHostage->IsFollowingSomeone())
continue;

if (pHostage->m_target == pAttacker)
#else
if (pHostage->IsFollowing(pAttacker))
#endif
hostagesCount++;
}

Expand Down
6 changes: 4 additions & 2 deletions regamedll/dlls/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,10 +1737,12 @@ Vector CBlood::BloodPosition(CBaseEntity *pActivator)

void CBlood::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{
const Vector direction = Direction();

if (pev->spawnflags & SF_BLOOD_STREAM)
UTIL_BloodStream(BloodPosition(pActivator), Direction(), (Color() == BLOOD_COLOR_RED) ? 70 : Color(), int(BloodAmount()));
UTIL_BloodStream(BloodPosition(pActivator), direction, (Color() == BLOOD_COLOR_RED) ? 70 : Color(), int(BloodAmount()));
else
UTIL_BloodDrips(BloodPosition(pActivator), Direction(), Color(), int(BloodAmount()));
UTIL_BloodDrips(BloodPosition(pActivator), Color(), int(BloodAmount()));

if (pev->spawnflags & SF_BLOOD_DECAL)
{
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ cvar_t maxmoney = { "mp_maxmoney", "16000", FCVAR_SERVER, 0.0f, nul
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 };
cvar_t nadedrops = { "mp_nadedrops", "0", 0, 0.0f, nullptr };
cvar_t weapondrop = { "mp_weapondrop", "1", 0, 1.0f, nullptr };
cvar_t ammodrop = { "mp_ammodrop", "1", 0, 1.0f, nullptr };
cvar_t roundrespawn_time = { "mp_roundrespawn_time", "20", 0, 20.0f, nullptr };
cvar_t auto_reload_weapons = { "mp_auto_reload_weapons", "0", 0, 0.0f, nullptr };
cvar_t refill_bpammo_weapons = { "mp_refill_bpammo_weapons", "0", 0, 0.0f, nullptr }; // Useful for mods like DeathMatch, GunGame, ZombieMod etc
Expand Down Expand Up @@ -353,6 +355,8 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&round_infinite);
CVAR_REGISTER(&hegrenade_penetration);
CVAR_REGISTER(&nadedrops);
CVAR_REGISTER(&weapondrop);
CVAR_REGISTER(&ammodrop);
CVAR_REGISTER(&roundrespawn_time);
CVAR_REGISTER(&auto_reload_weapons);
CVAR_REGISTER(&refill_bpammo_weapons);
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ extern cvar_t maxmoney;
extern cvar_t round_infinite;
extern cvar_t hegrenade_penetration;
extern cvar_t nadedrops;
extern cvar_t weapondrop;
extern cvar_t ammodrop;
extern cvar_t roundrespawn_time;
extern cvar_t auto_reload_weapons;
extern cvar_t refill_bpammo_weapons;
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ enum
GR_PLR_DROP_AMMO_ALL,
GR_PLR_DROP_AMMO_ACTIVE,
GR_PLR_DROP_AMMO_NO,

#ifdef REGAMEDLL_ADD
GR_PLR_DROP_GUN_BEST,
#endif
};

// custom enum
Expand Down
20 changes: 19 additions & 1 deletion regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4332,11 +4332,29 @@ LINK_HOOK_CLASS_CUSTOM_CHAIN(int, CHalfLifeMultiplay, CSGameRules, DeadPlayerWea

int EXT_FUNC CHalfLifeMultiplay::__API_HOOK(DeadPlayerWeapons)(CBasePlayer *pPlayer)
{
return GR_PLR_DROP_GUN_ACTIVE;
#ifdef REGAMEDLL_ADD
switch ((int)weapondrop.value)
{
case 3:
return GR_PLR_DROP_GUN_ALL;
case 2:
break;
case 1:
return GR_PLR_DROP_GUN_BEST;
default:
return GR_PLR_DROP_GUN_NO;
}
#endif
return GR_PLR_DROP_GUN_ACTIVE; // keep original value in return
}

int CHalfLifeMultiplay::DeadPlayerAmmo(CBasePlayer *pPlayer)
{
#ifdef REGAMEDLL_ADD
if (ammodrop.value == 0.0f)
return GR_PLR_DROP_AMMO_NO;
#endif

return GR_PLR_DROP_AMMO_ACTIVE;
}

Expand Down
Loading

0 comments on commit 4937343

Please sign in to comment.