Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic MZ Selection + SetModel + Win Condition #127

Merged
merged 17 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ cs2f_rtv_endround 0 // Whether to immediately end the round when RTV succeed
zr_enable 0 // Whether to enable ZR features
zr_knockback_scale 5.0 // Global knockback scale
zr_ztele_max_distance 150.0 // Maximum distance players are allowed to move after starting ztele
zr_ztele_allow_humans 0 // Whether to allow humans to use ztele
zr_ztele_allow_humans 0 // Whether to allow humans to use ztele
zr_infect_spawn_type 1 //Type of Mother Zombies Spawn [0 = MZ spawn where they stand, 1 = MZ get teleported back to spawn on being picked]
zr_infect_spawn_time_min 15 //Minimum time in which Mother Zombies should be picked, after round start
zr_infect_spawn_time_max 15 //Maximum time in which Mother Zombies should be picked, after round start
zr_infect_spawn_mz_ratio 7 //Ratio of all Players to Mother Zombies to be spawned at round start
zr_infect_spawn_mz_min_count 2 //Minimum amount of Mother Zombies to be spawned at round start
13 changes: 13 additions & 0 deletions gamedata/cs2fixes.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@
"windows" "\x40\x53\x48\x83\xEC\x20\x8B\x91\x38\x0B\x00\x00\x48\x8B\xD9"
"linux" "\x8B\x8F\x40\x0E\x00\x00\x83\xF9\xFF\x0F\x84\xD9\x01"
}
// Search "Changes's player's model", look for a function containing 'models/%s.vmdl'. Below V_snprintf is the one
"CBasePlayerPawn_SetModel"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x2A\x48\x89\x7C\x24\x2A\x55\x48\x8B\xEC\x48\x83\xEC\x50\x48\x8B\xF9"
"linux" "\x55\x48\x89\xF2\x48\x89\xE5\x41\x54\x49\x89\xFC\x48\x8D\x7D\xE0\x48\x83\xEC\x18\x48\x8D\x05\x3D\xD7\xBF\x00"
}
"CGameRules_TerminateRound"
{
"library" "server"
"windows" "\x48\x8B\xC4\x4C\x89\x48\x20\x55\x56"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x49\x89\xFD\x41\x54\x53\x48\x81\xEC\xE8\x01\x00\x00"
}
}
"Offsets"
{
Expand Down
2 changes: 2 additions & 0 deletions src/addresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ bool addresses::Initialize(CGameConfig *g_GameConfig)
RESOLVE_SIG(g_GameConfig, "SetGroundEntity", addresses::SetGroundEntity);
RESOLVE_SIG(g_GameConfig, "CCSPlayerController_SwitchTeam", addresses::CCSPlayerController_SwitchTeam);
RESOLVE_SIG(g_GameConfig, "CCSPlayerPawn_Respawn", addresses::CCSPlayerPawn_Respawn);
RESOLVE_SIG(g_GameConfig, "CBasePlayerPawn_SetModel", addresses::CBasePlayerPawn_SetModel);
EasterLee marked this conversation as resolved.
Show resolved Hide resolved
RESOLVE_SIG(g_GameConfig, "UTIL_Remove", addresses::UTIL_Remove);
RESOLVE_SIG(g_GameConfig, "CEntitySystem_AddEntityIOEvent", addresses::CEntitySystem_AddEntityIOEvent);
RESOLVE_SIG(g_GameConfig, "CEntityInstance_AcceptInput", addresses::CEntityInstance_AcceptInput);
RESOLVE_SIG(g_GameConfig, "CGameEntitySystem_FindEntityByClassName", addresses::CGameEntitySystem_FindEntityByClassName);
RESOLVE_SIG(g_GameConfig, "CGameEntitySystem_FindEntityByName", addresses::CGameEntitySystem_FindEntityByName);
RESOLVE_SIG(g_GameConfig, "CGameRules_TerminateRound", addresses::CGameRules_TerminateRound);

return true;
}
4 changes: 4 additions & 0 deletions src/addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ namespace modules

class CEntityInstance;
class CBasePlayerController;
class CBasePlayerPawn;
EasterLee marked this conversation as resolved.
Show resolved Hide resolved
class CCSPlayerController;
class CCSPlayerPawn;
class Z_CBaseEntity;
class CGameConfig;
class CEntitySystem;
class IEntityFindFilter;
struct variant_string_t;
class CGameRules;

namespace addresses
{
Expand All @@ -57,6 +59,7 @@ namespace addresses
inline void(FASTCALL *SetGroundEntity)(Z_CBaseEntity *ent, Z_CBaseEntity *ground);
inline void(FASTCALL *CCSPlayerController_SwitchTeam)(CCSPlayerController *pController, uint32 team);
inline void(FASTCALL *CCSPlayerPawn_Respawn)(CCSPlayerPawn *pPawn);
inline void(FASTCALL *CBasePlayerPawn_SetModel)(CBasePlayerPawn *pPawn, const char *szModel);
inline void(FASTCALL *UTIL_Remove)(CEntityInstance*);

inline void(FASTCALL *CEntitySystem_AddEntityIOEvent)(CEntitySystem *pEntitySystem, CEntityInstance *pTarget, const char *pszInput,
Expand All @@ -70,4 +73,5 @@ namespace addresses
inline Z_CBaseEntity *(FASTCALL *CGameEntitySystem_FindEntityByName)(CEntitySystem *pEntitySystem, CEntityInstance *pStartEntity, const char *szName,
CEntityInstance *pSearchingEntity, CEntityInstance *pActivator, CEntityInstance *pCaller,
IEntityFindFilter *pFilter);
inline void(FASTCALL *CGameRules_TerminateRound)(CGameRules* pGameRules, float delay, unsigned int reason, int64 a4, unsigned int a5);
}
4 changes: 4 additions & 0 deletions src/cs2_sdk/entity/cbaseplayerpawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class CBasePlayerPawn : public CBaseModelEntity
static int offset = g_GameConfig->GetOffset("CBasePlayerPawn_CommitSuicide");
CALL_VIRTUAL(void, offset, this, bExplode, bForce);
}
void SetModel(const char *szModel)
{
addresses::CBasePlayerPawn_SetModel(this, szModel);
}

CBasePlayerController *GetController() { return m_hController.Get(); }
};
5 changes: 5 additions & 0 deletions src/cs2_sdk/entity/cgamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class CGameRules
{
public:
DECLARE_SCHEMA_CLASS(CGameRules)

void TerminateRound(float delay, unsigned int reason)
{
addresses::CGameRules_TerminateRound(this, delay, reason, 0, 0);
}
EasterLee marked this conversation as resolved.
Show resolved Hide resolved
};

class CCSGameRules : public CGameRules
Expand Down
12 changes: 12 additions & 0 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,16 @@ GAME_EVENT_F(round_end)

pPlayer->SetTotalDamage(0);
}
}

GAME_EVENT_F(round_freeze_end)
{
if (g_bEnableZR)
ZR_OnRoundFreezeEnd(pEvent);
}

GAME_EVENT_F(player_death)
{
if (g_bEnableZR)
ZR_OnPlayerDeath(pEvent);
}
Loading