Raised This Month: $12 Target: $400
 3% 

[ TUT ] Force a team to win


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-11-2014 , 14:05   [ TUT ] Force a team to win
Reply With Quote #1


From the beginning I want to state that I know about the existence of VEN's plugin and tutorial, but it uses an inefficient method with fakeplayers. This time I will try to show you how to do that directly, by changing some game offsets.
I don't have time to write an api for that, anyway if someone want to do it based on the informations from that topic I'll be glad.

The tutorial is for all coders, although it can confuse beginners or make no sense, but I'll do my best to explain everyting.

My ideea is that we can alter the offset that are responsible for round objectives. After that, all we have to do is to call CHalfLifeMultiplay::CheckWinConditions() to make the game take our changes into account.

Firstly, let's look at this function to see what it does and how. You can see it here: https://github.com/Arkshine/CSSDK/bl..._gamerules.cpp

Spoiler


We see that it checks the fallowing offsets:
Code:
m_bBombDefused // the bomb was defused ?
m_bTargetBombed //the target has been bombed ?
If m_bBombDefused is true it means that CT won the round, if m_bTargetBombed is true it means that T won it.

Rember that in order to hook functions from CHalfLifeMultiplay you need to firstly hook InstallGameRules function.

1. Hook InstallGameRules
Code:
new g_pGameRules public plugin_precache() {     OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"), "OnInstallGameRules", OrpheuHookPost) } public OrpheuHookReturn:OnInstallGameRules() {         //Get game rules object because CHalfLifeMultiplay functions need to be retrieved from an object     g_pGameRules = OrpheuGetReturn( ) }

Signature:
Spoiler


2. Hook CHalfLifeMultiplay::CheckWinConditions()
Code:
new OrpheuFunction: CGameRulesCheckWinConditions public plugin_init() {     CGameRulesCheckWinConditionsHook = OrpheuGetFunctionFromObject(g_pGameRules, "CheckWinConditions", "CGameRules") }

Signature:
Spoiler


All of the above signature should go on orpheu/functions folder.

CGameRulesOffsets file

Put it into orpheu/memory.
We will use some of the offsets above, not all of them but it's good to use the entire file.

Now, to make a team to win set the coresponding offset to true and call CheckWinConditions()

Example:
Code:
OrpheuMemorySetAtAddress(g_pGameRules, "m_bTargetBombed", 1, true/false) OrpheuMemorySetAtAddress(g_pGameRules, "m_bBombDefused", 1, true/false) OrpheuCall(CGameRulesCheckWinConditions, g_pGameRules)

I don't have time to go in deep, maybe I'll edit later. I've also uploaded the needed file.

Attached Files
File Type: gz ForceTeamWin.tar.gz (1.2 KB, 257 views)
__________________

Last edited by HamletEagle; 12-11-2014 at 14:08.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-11-2014 , 14:25   Re: [ TUT ] Force a team to win
Reply With Quote #2

I know i need to update plugin (already started), but eh: http://forums.alliedmods.net/showthread.php?p=1122356
__________________
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-11-2014 , 14:27   Re: [ TUT ] Force a team to win
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
I know i need to update plugin (already started), but eh: http://forums.alliedmods.net/showthread.php?p=1122356
Having a tutorial still wont hurt, it's good as info.
__________________

Last edited by HamletEagle; 12-11-2014 at 14:28.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-13-2014 , 06:42   Re: [ TUT ] Force a team to win
Reply With Quote #4

But it's incomplete and kind of wrong.

You refer to the wrong class and code, it should be : https://github.com/Arkshine/CSSDK/bl...ules.cpp#L1931
Then you would see this is not about only bomb and is tricky for others events.

Also CheckWinConditions is a virtual function, no need to create a signature, more reliable to use the index.

At the end, explaining how works the game, why not, but if you don't fully understand what you're saying, there is no point, and will confuse more, which is the case here. So you better rewrite a proper tutorial with keeping in mind a plugin already exists for that.
__________________
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 12-19-2014 , 06:44   Re: [ TUT ] Force a team to win
Reply With Quote #5

Sorry for off-topic but this is sort of related with. Just by curiosity, is it possible to block game commecing without orpheu? Would the fake clients block it? Thanks.
__________________
Jhob94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-19-2014 , 08:03   Re: [ TUT ] Force a team to win
Reply With Quote #6

Quote:
Originally Posted by Jhob94 View Post
Sorry for off-topic but this is sort of related with. Just by curiosity, is it possible to block game commecing without orpheu? Would the fake clients block it? Thanks.
Even if possible why would you use such stupid way with fakeplayers when you have a direct way with orpheu ?
Code:
iif (!m_bFirstConnected && m_iNumSpawnableTerrorist != 0 && m_iNumSpawnableCT != 0)     {         CBasePlayer *pPlayer = NULL;         if (!IsCareer() || ((pPlayer = (CBasePlayer*)UTIL_PlayerByIndex(gpGlobals->maxClients)) != NULL && pPlayer->IsBot()))         {             UTIL_LogPrintf("World triggered \"Game_Commencing\"\n");             m_bFreezePeriod = FALSE;             m_bCompleteReset = true;             EndRoundMessage("#Game_Commencing", Event_Round_Draw);             TerminateRound(IsCareer() ? 0 : 3, WinStatus_Draw);             m_bFirstConnected   = true;             // TODO: Implement me.             // TheBots->OnEvent( EVENT_GAME_COMMENCE, NULL, NULL );         } }
I think that bots trigger game comencing too, from what I understand from the code above, but I may be wrong since idk much c++.
__________________

Last edited by HamletEagle; 12-19-2014 at 08:06.
HamletEagle is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 12-19-2014 , 09:07   Re: [ TUT ] Force a team to win
Reply With Quote #7

The most important question is: Why should i run orpheu in a 24/7 server? Orpheu is an amazing module, indeed. But i will not lose my time with signatures. Because sometimes it might require updates. And i won't be with my server closed till update it. Orpheu might be beautiful, but it isn't something to use in a 24/7 server.
And a fake player wouldn't hurt in a 32 slots server if the only usage of the bot is blocking game commecing.
__________________
Jhob94 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-19-2014 , 09:11   Re: [ TUT ] Force a team to win
Reply With Quote #8

Signature is not going to change, unless steam decide to do a major update (upgrading toolset to compile, it was a special opportunity because of OSX, new compiler has obviously changed the output) or the code of the concerned function is changed. Both are now very unlikely to happen again. And getting signature is very very easy with IDA. It takes few seconds. Your argument doesn't make much sense.
__________________

Last edited by Arkshine; 12-19-2014 at 09:16. Reason: s
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 12-19-2014 , 09:27   Re: [ TUT ] Force a team to win
Reply With Quote #9

Still no sense to use it for only block game commecing. And i don't trust steam, they did an update basickly without tell us to be ready. I won't take that risk.
__________________
Jhob94 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-19-2014 , 09:36   Re: [ TUT ] Force a team to win
Reply With Quote #10

Ok, but this thread is only about doing such stuffs with orpheu, search in other places for a solution with fakeplayers, if possible.

I'm going to update this tutorial and fix everything :crab.
__________________
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode