Skip to content

Commit

Permalink
Basic MZ Selection + SetModel + Win Condition (#127)
Browse files Browse the repository at this point in the history
* basic knockback

* Update zombiereborn.cpp

* Update zombiereborn.cpp

* Update zombiereborn.cpp

* move detour

* add infection

* pawn+controller respawn gamedata

* add resolve_sig

* fix address

* add zspawn command

* mother zombie infection

* setmodel + win condition

* bug fix
  • Loading branch information
EasterLee authored Dec 3, 2023
1 parent b301f60 commit f6b8484
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 69 deletions.
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
"CBaseModelEntity_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, "CBaseModelEntity_SetModel", addresses::CBaseModelEntity_SetModel);
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 @@ -40,11 +40,13 @@ class CEntityInstance;
class CBasePlayerController;
class CCSPlayerController;
class CCSPlayerPawn;
class CBaseModelEntity;
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 *CBaseModelEntity_SetModel)(CBaseModelEntity *pModel, 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);
}
5 changes: 5 additions & 0 deletions src/cs2_sdk/entity/cbasemodelentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ class CBaseModelEntity : public Z_CBaseEntity

SCHEMA_FIELD(CCollisionProperty , m_Collision)
SCHEMA_FIELD(CGlowProperty, m_Glow)

void SetModel(const char *szModel)
{
addresses::CBaseModelEntity_SetModel(this, szModel);
}
};
36 changes: 35 additions & 1 deletion src/cs2_sdk/entity/cgamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CGameRules
{
public:
DECLARE_SCHEMA_CLASS(CGameRules)

};

class CCSGameRules : public CGameRules
Expand All @@ -38,12 +39,45 @@ class CCSGameRules : public CGameRules
SCHEMA_FIELD(int, m_totalRoundsPlayed)
SCHEMA_FIELD(GameTime_t, m_fRoundStartTime)
SCHEMA_FIELD(GameTime_t, m_flRestartRoundTime)

void TerminateRound(float delay, unsigned int reason)
{
addresses::CGameRules_TerminateRound(this, delay, reason, 0, 0);
}
};

class CCSGameRulesProxy : public Z_CBaseEntity
{
public:
DECLARE_SCHEMA_CLASS(CCSGameRulesProxy)

SCHEMA_FIELD(CCSGameRules*, m_pGameRules)
SCHEMA_FIELD(CCSGameRules *, m_pGameRules)
};

enum CSRoundEndReason
{
TargetBombed = 1, /**< Target Successfully Bombed! */

VIPEscaped, /**< The VIP has escaped! - Doesn't exist on CS:GO */
VIPKilled, /**< VIP has been assassinated! - Doesn't exist on CS:GO */

TerroristsEscaped, /**< The terrorists have escaped! */
CTStoppedEscape, /**< The CTs have prevented most of the terrorists from escaping! */
TerroristsStopped, /**< Escaping terrorists have all been neutralized! */
BombDefused, /**< The bomb has been defused! */
CTWin, /**< Counter-Terrorists Win! */
TerroristWin, /**< Terrorists Win! */
Draw, /**< Round Draw! */
HostagesRescued, /**< All Hostages have been rescued! */
TargetSaved, /**< Target has been saved! */
HostagesNotRescued, /**< Hostages have not been rescued! */
TerroristsNotEscaped, /**< Terrorists have not escaped! */
VIPNotEscaped, /**< VIP has not escaped! - Doesn't exist on CS:GO */
GameStart, /**< Game Commencing! */
TerroristsSurrender, /**< Terrorists Surrender */
CTSurrender, /**< CTs Surrender */
TerroristsPlanted, /**< Terrorists Planted the bomb */
CTsReachedHostage, /**< CTs Reached the hostage */
SurvivalWin,
SurvivalDraw
};
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

0 comments on commit f6b8484

Please sign in to comment.