.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Others (http://forums.bots-united.com/forumdisplay.php?f=60)
-   -   Counter-Strike game rules (CHalfLifeMultiplay) (http://forums.bots-united.com/showthread.php?t=7556)

Immortal_BLG 07-04-2010 13:48

Counter-Strike game rules (CHalfLifeMultiplay)
 
NOTE: ALL FOR WINDOWS 32!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Pointer to g_pGameRules:
Code:

CHalfLifeMultiplay *g_pGameRules = **reinterpret_cast <CHalfLifeMultiplay ***> (reinterpret_cast <unsigned char *> (MDLL_ServerDeactivate) + 11);
Virtual table:
Code:

Index        | Function definition
-----------------------------------------------------------------------------------------------------
1        | void        CHalfLifeMultiplay::Think(void)
2        | BOOL        CHalfLifeMultiplay::IsAllowedToSpawn(CBaseEntity *)
3        | BOOL        CHalfLifeMultiplay::FAllowFlashlight(void)
4        | BOOL        CHalfLifeMultiplay::FShouldSwitchWeapon(CBasePlayer *,CBasePlayerItem *)
5        | BOOL        CHalfLifeMultiplay::GetNextBestWeapon(CBasePlayer *,CBasePlayerItem *)
6        | BOOL        CHalfLifeMultiplay::IsMultiplayer(void)
7        | BOOL        CHalfLifeMultiplay::IsDeathmatch(void)
8        | BOOL        CGameRules::IsTeamplay(void)
9        | BOOL        CHalfLifeMultiplay::IsCoOp(void)
10        | const char *CGameRules::GetGameDescription(void)
11        | BOOL        CHalfLifeMultiplay::ClientConnected(edict_s *,char const *,char const *,char *)
12        | void        CHalfLifeMultiplay::InitHUD(CBasePlayer *)
13        | void        CHalfLifeMultiplay::ClientDisconnected(edict_s *)
14        | void        CHalfLifeMultiplay::UpdateGameMode(CBasePlayer *)
15        | float      CHalfLifeMultiplay::FlPlayerFallDamage(CBasePlayer *)
16        | BOOL        CHalfLifeMultiplay::FPlayerCanTakeDamage(CBasePlayer *,CBaseEntity *)
17        | BOOL        CGameRules::ShouldAutoAim(CBasePlayer *,edict_s *)
18        | void        CHalfLifeMultiplay::PlayerSpawn(CBasePlayer *)
19        | void        CHalfLifeMultiplay::PlayerThink(CBasePlayer *)
20        | BOOL        CHalfLifeMultiplay::FPlayerCanRespawn(CBasePlayer *)
21        | float      CHalfLifeMultiplay::FlPlayerSpawnTime(CBasePlayer *)
22        | edict_t    CHalfLifeMultiplay::GetPlayerSpawnSpot(CBasePlayer *)
23        | BOOL        CHalfLifeMultiplay::AllowAutoTargetCrosshair(void)
24        | BOOL        CHalfLifeMultiplay::ClientCommand_DeadOrAlive(CBasePlayer *,char const *)
25        | BOOL        CHalfLifeMultiplay::ClientCommand(CBasePlayer *,char const *)
26        | void        CHalfLifeMultiplay::ClientUserInfoChanged(CBasePlayer *,char *)
27        | int        CHalfLifeMultiplay::IPointsForKill(CBasePlayer *,CBasePlayer *)
28        | void        CHalfLifeMultiplay::PlayerKilled(CBasePlayer *,entvars_s *,entvars_s *)
29        | void        CHalfLifeMultiplay::DeathNotice(CBasePlayer *,entvars_s *,entvars_s *)
30        | BOOL        CHalfLifeMultiplay::CanHavePlayerItem(CBasePlayer *,CBasePlayerItem *)
31        | void        CHalfLifeMultiplay::PlayerGotWeapon(CBasePlayer *,CBasePlayerItem *)
32        | int        CHalfLifeMultiplay::WeaponShouldRespawn(CBasePlayerItem *)
33        | float      CHalfLifeMultiplay::FlWeaponRespawnTime(CBasePlayerItem *)
34        | float      CHalfLifeMultiplay::FlWeaponTryRespawn(CBasePlayerItem *)
35        | Vector      CHalfLifeMultiplay::VecWeaponRespawnSpot(CBasePlayerItem *)
36        | BOOL        CHalfLifeMultiplay::CanHaveItem(CBasePlayer *,CItem *)
37        | void        CHalfLifeMultiplay::PlayerGotItem(CBasePlayer *,CItem *)
38        | int        CHalfLifeMultiplay::ItemShouldRespawn(CItem *)
39        | float      CHalfLifeMultiplay::FlItemRespawnTime(CItem *)
40        | Vector      CHalfLifeMultiplay::VecItemRespawnSpot(CItem *)
41        | BOOL        CGameRules::CanHaveAmmo(CBasePlayer *,char const *,int)
42        | void        CHalfLifeMultiplay::PlayerGotAmmo(CBasePlayer *,char *,int)
43        | int        CHalfLifeMultiplay::AmmoShouldRespawn(CBasePlayerAmmo *)
44        | float      CHalfLifeMultiplay::FlAmmoRespawnTime(CBasePlayerAmmo *)
45        | Vector      CHalfLifeMultiplay::VecAmmoRespawnSpot(CBasePlayerAmmo *)
46        | float      CHalfLifeMultiplay::FlHealthChargerRechargeTime(void)
47        | float      CHalfLifeMultiplay::FlHEVChargerRechargeTime(void)
48        | int        CHalfLifeMultiplay::DeadPlayerWeapons(CBasePlayer *)
49        | int        CHalfLifeMultiplay::DeadPlayerAmmo(CBasePlayer *)
50        | const char *CHalfLifeMultiplay::GetTeamID(CBaseEntity *)
51        | int        CHalfLifeMultiplay::PlayerRelationship(CBasePlayer *,CBaseEntity *)
52        | int        CGameRules::GetTeamIndex(char const *)
53        | const char *CGameRules::GetIndexedTeamName(int)
54        | BOOL        CGameRules::IsValidTeam(char const *)
55        | void        CGameRules::ChangePlayerTeam(CBasePlayer *,char const *,int,int)
56        | const char *CGameRules::SetDefaultPlayerTeam(CBasePlayer *)
57        | BOOL        CHalfLifeMultiplay::PlayTextureSounds(void)
58        | BOOL        CHalfLifeMultiplay::FAllowMonsters(void)
59        | BOOL        CHalfLifeMultiplay::EndMultiplayerGame(void)
60        | BOOL        CGameRules::IsFreezePeriod(void)
61        | void        CHalfLifeMultiplay::ServerDeactivate(void)
62        | void        CHalfLifeMultiplay::CheckMapConditions(void)
63        | void        CHalfLifeMultiplay::CleanUpMap(void)
64        | void        CHalfLifeMultiplay::RestartRound(void)
65        | void        CHalfLifeMultiplay::CheckWinConditions(void)
66        | void        CHalfLifeMultiplay::RemoveGuns(void)
67        | void        CHalfLifeMultiplay::GiveC4(void)
68        | void        CHalfLifeMultiplay::ChangeLevel(void)
69        | void        CHalfLifeMultiplay::GoToIntermission(void)

Previous table needed to m_pseudoVirtualTable, see example below - function CHalfLifeMultiplay::IsFlashlightAllowed() (there instead of BOOL (sizeof == 4) can use bool (sizeof == 1) - as I watched, there is no difference).

Headers:
Code:

class CGameRules
{
        protected:
                const void *const *m_pseudoVirtualTable;
};

Code:

class IVoiceGameMgrHelper
{
        protected:
                const void *const *m_pseudoVirtualTable;
};

Code:

class CVoiceGameMgr
{
        protected:
                const void *const *m_pseudoVirtualTable;

        private:
                int                  m_messagePlayerVoiceMask;
                int                  m_messageRequestState;

                IVoiceGameMgrHelper *m_helper;
                int                  m_maxPlayers;
                double              m_updateIntervalTime; // How long since the last update.
};

Code:

class CHalfLifeMultiplay : public CGameRules
{
        public:
                BOOL            m_isFreezePeriod; // TRUE at beginning of round, set to FALSE when the period expires
                BOOL            m_isBombDropped;

                CVoiceGameMgr  m_voiceGameManager;

                float          m_restartRoundTime; // The global time when the round is supposed to end, if this is not 0

                unsigned int    m_UNKNOWN0;

                float          m_roundCount;
                unsigned int    m_roundTime; // (From mp_roundtime) - How many seconds long this round is.
                unsigned int    m_roundTimeSecs; // (Current) round timer - set to 'm_introRoundTime', then 'm_roundTime'.
                unsigned int    m_introRoundTime; // (From mp_freezetime) - How many seconds long the intro round (when players are frozen) is.
                float          m_introRoundCount; // The global time when the intro round ends and the real one starts.
                unsigned int    m_account[2];
                unsigned int    m_playerCount[2]; // The number of players on the team (this is generated at the end of a round)
                unsigned int    m_spawnableNumber[2];
                unsigned int    m_spawnPointCount[2]; // Number of team spawn points.
                unsigned int    m_hostagesRescued;
                unsigned int    m_hostagesTouched;
                unsigned int    m_roundWinStatus; // 1 == CT's won last round, 2 == Terrorists did, 3 == Draw, no winner.
                unsigned short  m_score[2];

                // BOMB MAP VARIABLES....
                bool            m_isTargetBombed; // Whether or not the bomb has been bombed.
                bool            m_isBombDefused; // Whether or not the bomb has been defused.
                bool            m_isMapHasBombTarget;
                bool            m_isMapHasBombZone;

                bool            m_isMapHasBuyZone;
                bool            m_isMapHasRescueZone;
                bool            m_isMapHasEscapeZone;

                unsigned int    m_isMapHasVIPSafetyZone; // 0 = uninitialized; 1 = has VIP safety zone; 2 = DOES not have VIP safetyzone

                unsigned int    m_UNKNOWN1;

                unsigned int    m_c4Timer; // How long from when the C4 is armed until it blows.
                unsigned int    m_c4Guy; // The current Terrorist who has the C4.
                unsigned int    m_loserBonus; // The amount of money the losing team gets.
                unsigned int    m_consecutiveLosesNumber[2]; // The number of rounds the team have lost in a row.
                float          m_maximumIdlePeriod; // For the idle kick functionality. This is tha maximum amount of time that the player has to be idle before being kicked
                unsigned int    m_limitTeams; // Maximum # of players 1 team can have over another.
                bool            m_isLevelInitialized;
                bool            m_isRoundTerminating;
                bool            m_isCompleteReset; // Set to TRUE to have the scores reset next time round restarts.

                float          m_requiredEscapeRatio;
                unsigned int    m_escapersNumber; // Number of escaped terrorist (for escape maps)
                unsigned int    m_haveEscaped;
                bool            m_isCantBuy[2];

                float          m_c4ExplosionRadius;
                unsigned int    m_consecutiveVIP;
                unsigned int    m_weaponsNumber; // (Including smoke grenade)
                unsigned int    m_grenadesNumber; // (Only HE and flashbang grenades)
                unsigned int    m_armorNumber; // (Assault suit and kevlar)
                unsigned int    m_unBalancedRounds; // Keeps track of the # of consecutive rounds that have gone by where one team outnumbers the other team by more than 2.
                unsigned int    m_escapeRoundsNumber; // Keeps track of the # of consecutive rounds of escape played.. Teams will be swapped after 8 rounds.
                unsigned int    m_mapsVotesNumbers[100];
                unsigned int    m_lastPick;

                unsigned int    m_UNKNOWN2;

                unsigned int    m_maximumRounds;
                unsigned int    m_totalRoundsPlayed;
                unsigned int    m_winLimit;
                int            m_allowSpectators;
                float          m_forceCamera;
                float          m_forceChaseCamera;
                float          m_fadeToBlack;
                CBasePlayer    *m_VIP;
                CBasePlayer    *m_VIPQueue[5u];
                float          m_intermissionEndTime;
                float          m_intermissionStartTime;
                BOOL            m_endIntermissionButtonHit;
                float          m_nextPeriodicThinkTime; // (updates every 1 second)
                bool            m_isFirstPlayerConnected; // Set to TRUE to have the scores reset next time round restarts.
                bool            m_isCareerMatch;

                unsigned int    m_UNKNOWN3;
                unsigned int    m_UNKNOWN4;

                int            m_winDifference;

                unsigned int    m_UNKNOWN5;

                bool            m_isShouldSkipSpawn;

        public:
                inline const bool IsFlashlightAllowed (void) const
                {
                        return static_cast <bool (__fastcall *) (const CHalfLifeMultiplay *const /*this*/, int /*dummy*/)> (m_pseudoVirtualTable[3]) (this, 0);
                }
};

Code:

class CHalfLifeTraining : public CHalfLifeMultiplay
{
        public:
                float        m_UNKNOWN7Time;
                unsigned int m_UNKNOWN8;
                unsigned int m_UNKNOWN9;
                unsigned int m_UNKNOWN10;

                bool        m_isShowVGUIMenus;
};

Naked offsets:
Code:

enum Offset_t
{
        Offset_Pointer                                    = 11u, // Offset to 'g_pGameRules' pointer from HLSDK.

        //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        Offset_IsFreezePeriod                              = 4u, // TRUE at beginning of round, set to FALSE when the period expires (as bool, but BOOL)
        Offset_IsBombDropped                              = 8u, // (as bool, but BOOL)

        //--> CVoiceGameMgr START
                Offset_MessagePlayerVoiceMask                  = 6u, // (as int)
                Offset_MessageRequestState                    = 7u, // (as int)
                Offset_Helper                                  = 8u, // (as IVoiceGameMgrHelper *)
                Offset_MaximumPlayers                          = 9u, // (as int)
                Offset_UpdateIntervalTime                      = 10u, // (as double)
        //<-- CVoiceGameMgr END

        Offset_RestartRoundTime                            = 12u, // The global time when the round is supposed to end, if this is not 0 (as float)

////        Offset_UNKNOWN0                                    = 13u, // (as unsigned int)

        Offset_RoundCount                                  = 14u, // (as float)
        Offset_RoundTime                                  = 15u, // (From mp_roundtime) - How many seconds long this round is. (as unsigned int)
        Offset_RoundTimeSecs                              = 16u, // (Current) round timer - set to 'Offset_IntroRoundTime', then 'Offset_RoundTime'. (as unsigned int)
        Offset_IntroRoundTime                              = 17u, // (From mp_freezetime) - How many seconds long the intro round (when players are frozen) is. (as unsigned int)
        Offset_IntroRoundCount                            = 18u, // The global time when the intro round ends and the real one starts. (as float)

        Offset_Account                                    = 19u, // (as unsigned int)
                Offset_AccountTerrorist                        = Offset_Account, // (as unsigned int)
                Offset_AccountCounterTerrorist                = Offset_Account + 1u, // (as unsigned int)

        // The number of players on the team (this is generated at the end of a round)
        Offset_PlayerCount                                = 21u, // (as unsigned int)
                Offset_PlayerCount_Terrorist                  = Offset_PlayerCount, // The number of terrorists on the team (this is generated at the end of a round) (as unsigned int)
                Offset_PlayerCount_CounterTerrorist            = Offset_PlayerCount + 1u, // The number of CTs on the team (this is generated at the end of a round) (as unsigned int)

        Offset_SpawnableNumber                            = 23u, // (as unsigned int)
                Offset_SpawnableNumber_Terrorist              = Offset_SpawnableNumber, // (as unsigned int)
                Offset_SpawnableNumber_CounterTerrorist        = Offset_SpawnableNumber + 1u, // (as unsigned int)

        Offset_SpawnPointCount                            = 25u, // (as unsigned int)
                Offset_SpawnPointCount_Terrorist              = Offset_SpawnPointCount, // Number of Terrorist spawn points. (as unsigned int)
                Offset_SpawnPointCount_CounterTerrorist        = Offset_SpawnPointCount + 1u, // Number of CT spawn points. (as unsigned int)

        Offset_HostagesRescued                            = 27u, // (as unsigned int)
        Offset_HostagesTouched                            = 28u, // (as unsigned int)
        Offset_RoundWinStatus                              = 29u, // 1 == CT's won last round, 2 == Terrorists did, 3 == Draw, no winner. (as unsigned int)

        Offset_Score                                      = 60u, // (as unsigned short)
                Offset_Score_Terrorist                        = Offset_Score + 1u, // (as unsigned short)
                Offset_Score_CounterTerrorist                  = Offset_Score, // (as unsigned short)

        // BOMB MAP VARIABLES
        Offset_IsTargetBombed                              = 124u, // Whether or not the bomb has been bombed. (as bool)
        Offset_IsBombDefused                              = 125u, // Whether or not the bomb has been defused. (as bool)
        Offset_IsMapHasBombTarget                          = 126u, // (as bool)
        Offset_IsMapHasBombZone                            = 127u, // (as bool)

        Offset_IsMapHasBuyZone                            = 128u, // (as bool)
        Offset_IsMapHasRescueZone                          = 129u, // (as bool)
        Offset_IsMapHasEscapeZone                          = 130u, // (as bool)

        Offset_IsMapHasVIPSafetyZone                      = 33u, // 0 = uninitialized; 1 = has VIP safety zone; 2 = DOES not have VIP safetyzone (as unsigned int)
//        Offset_UNKNOWN1                                    = 34u, // (something with trigger_camera in ClientPutInServer()) (as unsigned int)
        Offset_C4Timer                                    = 35u, // How long from when the C4 is armed until it blows. (as unsigned int)
        Offset_C4Guy                                      = 36u, // The current Terrorist who has the C4. (as unsigned int)
        Offset_LoserBonus                                  = 37u, // The amount of money the losing team gets. This scales up as they lose more rounds in a row. (as unsigned int)

        Offset_ConsecutiveLosesNumber                      = 38u, // The number of rounds the CT's have lost in a row. (as unsigned int)
                Offset_ConsecutiveLosesNumber_Terrorist        = Offset_ConsecutiveLosesNumber + 1u, // The number of rounds the Terrorists have lost in a row. (as unsigned int)
                Offset_ConsecutiveLosesNumber_CounterTerrorist = Offset_ConsecutiveLosesNumber, // The number of rounds the CT's have lost in a row. (as unsigned int)

        Offset_MaximumIdlePeriod                          = 40u, // For the idle kick functionality. This is tha maximum amount of time that the player has to be idle before being kicked (as float)
        Offset_LimitTeams                                  = 41u, // Maximum # of players 1 team can have over another. (as unsigned int)
        Offset_IsLevelInitialized                          = 168u, // (as bool)
        Offset_IsRoundTerminating                          = 169u, // (as bool)
        Offset_IsCompleteReset                            = 170u, // Set to TRUE to have the scores reset next time round restarts. (as bool)

        Offset_RequiredEscapeRatio                        = 43u, // (as float)
        Offset_EscapersNumber                              = 44u, // Number of escaped terrorist (for escape maps) (as unsigned int)
        Offset_HaveEscaped                                = 45u, // (as unsigned int)

        // Who can and can't buy.
        Offset_IsCantBuy                                  = 184u, // (as bool)
                Offset_IsCantBuy_Terrorist                    = Offset_IsCantBuy, // (as bool)
                Offset_IsCantBuy_CounterTerrorist              = Offset_IsCantBuy + 1u, // (as bool)

        Offset_C4_ExplosionRadius                          = 47u, // (as float)
        Offset_ConsecutiveVIP                              = 48u, // (as unsigned int)
        Offset_WeaponsNumber                              = 49u, // (Including smoke grenade) (as unsigned int)
        Offset_GrenadesNumber                              = 50u, // (Only HE and flashbang grenades) (as unsigned int)
        Offset_ArmorNumber                                = 51u, // (Assault suit and kevlar) (as unsigned int)
        Offset_UnBalancedRounds                            = 52u, // Keeps track of the # of consecutive rounds that have gone by where one team outnumbers the other team by more than 2. (as unsigned int)
        Offset_EscapeRoundsNumber                          = 53u, // Keeps track of the # of consecutive rounds of escape played.. Teams will be swapped after 8 rounds. (as unsigned int)
        Offset_MapsVotesNumbers                            = 54u, // (as unsigned int *, but unsigned int[100])
        Offset_LastPick                                    = 154u, // (as unsigned int)
////        Offset_UNKNOWN2                                    = 34u, // (as UNKNOWN)
        Offset_MaximumRounds                              = 156u, // (as unsigned int)
        Offset_TotalRoundsPlayed                          = 157u, // (as unsigned int)
        Offset_WinLimit                                    = 158u, // (as unsigned int)
        Offset_AllowSpectators                            = 159u, // (as int)
        Offset_ForceCamera                                = 160u, // (as float)
        Offset_ForceChaseCamera                            = 161u, // (as float)
        Offset_FadeToBlack                                = 162u, // (as float)
        Offset_VIP                                        = 163u, // (as CBasePlayer *)
        Offset_VIPQueue                                    = 164u, // (as CBasePlayer **, but CBasePlayer *[5])
        Offset_IntermissionEndTime                        = 169u, // (as float)
        Offset_IntermissionStartTime                      = 170u, // (as float)
        Offset_EndIntermissionButtonHit                    = 684u, // (as bool, but BOOL)
        Offset_NextPeriodicThinkTime                      = 172u, // (updates every 1 second) (as float)
        Offset_IsFirstPlayerConnected                      = 692u, // Set to TRUE to have the scores reset next time round restarts. (as bool)
        Offset_IsCareerMatch                              = 693u, // (as bool)

//        Offset_UNKNOWN3                                    = 174u, // (as unsigned int)
//        Offset_UNKNOWN4                                    = 175u, // (as unsigned int)
        Offset_WinDifference                              = 176u, // (as int)
//        Offset_UNKNOWN5                                    = 177u, // (as unsigned int)

        Offset_IsShouldSkipSpawn                          = 712u, // (as bool)
        // CHalfLifeMultiplay END

//        Offset_UNKNOWN7Time                                = 180u, // (as float)
////        Offset_UNKNOWN8                                    = 181u, // (as unsigned int)
//        Offset_UNKNOWN9                                    = 182u, // (as unsigned int)
//        Offset_UNKNOWN10                                  = 183u, // (as unsigned int)
        Offset_IsShowVGUIMenus                            = 736u // (as bool)
        // CHalfLifeTraining END
};

Usage:
Code:

reinterpret_cast <as type *> (g_pGameRules)[Offset_*] = value;

Immortal_BLG 10-04-2010 15:32

Re: Counter-Strike game rules (CHalfLifeMultiplay)
 
Should be changed: m_isFirstPlayerConnected/Offset_IsFirstPlayerConnected names to m_isGameCommenced/Offset_IsGameCommenced respectively

The Storm 10-04-2010 18:05

Re: Counter-Strike game rules (CHalfLifeMultiplay)
 
Nice stuff, I'm surpriced that all this methods are virtual. :)

Immortal_BLG 11-04-2010 03:36

Re: Counter-Strike game rules (CHalfLifeMultiplay)
 
There still it is enough not-virtual functions....

The Storm 13-04-2010 22:33

Re: Counter-Strike game rules (CHalfLifeMultiplay)
 
Well calling non-virtual functions will be hard work. :)


All times are GMT +2. The time now is 15:23.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.