Raised This Month: $7 Target: $400
 1% 

Hostage following the player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-05-2014 , 02:59   Hostage following the player
Reply With Quote #1

Since couple of years I was using in podbot_mm code this, what I found in AMXMODX used as cs_get_hostage_follow function.

Code:
#if !defined __amd64__
         int following = *((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW);
#else
         long following = *((long *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW);
#endif

         if (following == 0)
         {
            if ((HostagesData[i].UserEntIndex > 0) && (HostagesData[i].Alive))
            {
               vecHostPos = pHostage->v.origin;  // KWo - 26.08.2006
               bTakeHostage = true;  // KWo - 26.08.2006

               if (g_i_cv_debuglevel & DEBUG_FL_ENTITIES)
                  ALERT(at_logged, "[DEBUG] UTIL_CheckHostages - Hostage %d lost his user(1).\n", i + 1);
            }
            HostagesData[i].UserEntIndex = 0;
         }
         else
        // Else this is probably a pointer to an entity's edict.
         {
            pEntity = (edict_t*)following;
            if (FNullEnt(pEntity))
            {
               if (g_i_cv_debuglevel & DEBUG_FL_ENTITIES)
                  ALERT(at_logged, "[DEBUG] UTIL_CheckHostages - Unknown error finding hostage parameter.\n");

               HostagesData[i].UserEntIndex = 0;
            }
            else
            {
               HostUser = ENTINDEX(pEntity);
               if (g_i_cv_debuglevel & DEBUG_FL_ENTITIES)  // KWo - 04.05.2014
                  ALERT(at_logged, "[DEBUG] UTIL_CheckHostages - Found hostage's %d usernr - %d.\n", i + 1, HostUser);

               if ((clients[HostUser-1].iFlags & CLIENT_ALIVE) && (clients[HostUser-1].iFlags & CLIENT_USED)
                    && ((clients[HostUser-1].vOrigin - pHostage->v.origin).Length() <= 600.0))
               {
                  HostagesData[i].UserEntIndex = HostUser;

                  if (g_i_cv_debuglevel & DEBUG_FL_ENTITIES)
                     ALERT(at_logged, "[DEBUG] UTIL_CheckHostages - Found hostage's %d user - %s.\n", i + 1, STRING(pEntity->v.netname));
               }
               else
               {
/*
#if !defined __amd64__
                  *((int *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = 0;
#else
                  *((long *)pHostage->pvPrivateData + OFFSET_HOSTAGEFOLLOW) = 0;
#endif
*/
               }
            }
The code works perfectly with CS1.6, but it doesn't with CZERO. The "following" always returns 0 for CZERO, so this is why my bots cannot detect right if the hostage is already "used" by another bot/player to prevent "steel" it from him or to detect right if the hostage lost his "user". I believe this is so from 2013 CS/CZERO update. I just discovered it accidently after some complains of users of podbot mm concering to something else. I was always testing my bots with CS1.6, because I was reading many times at this board everything in CZERO works the same way like in CS1.6 (except extensions CZERO has) - so I was believeing also all OFFSETS for private data should be the same for both games.
Anybody knows what could happen with these offsets for CZERO? How do You guys are discovering these offsets (I mean which way I can narrow down the right offset for OFFSET_HOSTAGEFOLLOW for CZERO?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
swapped
BANNED
Join Date: Mar 2014
Location: OrpheuRegisterHook
Old 05-05-2014 , 03:40   Re: Hostage following the player
Reply With Quote #2

Maybe im wrong but this should be in "Module" section ?
swapped is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-05-2014 , 03:56   Re: Hostage following the player
Reply With Quote #3

CS/CZ is the basically the same, but CZ unlocks features, like improved hostages, drop grenades on death, bots, tutor, etc.

Here, this offset probably doesn't work on CZ hostages. Let me check if I find something.
__________________
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-05-2014 , 15:07   Re: Hostage following the player
Reply With Quote #4

Just to confirm, it's expected this doesn't work. CHostage is derived from CBaseMonster and the offset is actually used by cstrike module is m_hTarget (CBaseMonster, you can see in HLSDK). But indeed, if improved hostages are enabled, it checks another way. It uses another offset from CImprovHostage but I need more times to understand and test this, the output in IDA is weird.
__________________
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-07-2014 , 16:56   Re: Hostage following the player
Reply With Quote #5

Woohoo triple post.

Well, I'm too dumb. It does a simple check in IDA (like return *(m_improv+ 56) == m_improv+ 252)), one line, but the thing it calls members of a class which is derived of another class, etc. It's confusing and I'm not sure what it checks exactly. It probably checks m_followState and m_behavior from CHostageImprov, like: return m_improv->m_behavior.m_state.something (m_parent?) == m_improv->m_followState.something. Unless there is more decompiled code, it's hard to picture (at least for me, but I'm a noob).

Just wondering, why you don't just call these functions directly? For example to check if an hostage follows, you just call: CHostage::IsFollowingSomeone() or to make hostage to follow, calling DoFollow(). Your code would be way more efficient, reliable and readable. You will have to deal with signatures and symbols, but I believe it's worth.

As bonus, some classes header (at right, it's the real offset under linux (real = char-based)) :

CHostage

CHostageImprov

HostageFollowState

HostageStateMachine

SimpleStateMachine

HostageState

SimpleState
__________________

Last edited by Arkshine; 05-07-2014 at 16:58.
Arkshine is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-08-2014 , 11:27   Re: Hostage following the player
Reply With Quote #6

Big thanks for Your time You were trying to figure out my problem. I have to ask somebody at bots-united how to use the info You gave me (classes are out of my head ).
BTW - can You take a look at this problem, too?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 05-11-2014 , 04:28   Re: Hostage following the player
Reply With Quote #7

About this - CHostage::IsFollowingSomeone() - is this working for both CS1.6 and CZERO or I have to write separate codes for CS1.6 and CZERO (because of differences between hostages)?
About that:
Quote:
Originally Posted by Arkshine View Post
You will have to deal with signatures and symbols.
What exactly did You mean - which signatures and symbols I have to deal with?
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.

Last edited by KWo; 05-11-2014 at 04:30.
KWo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-11-2014 , 04:31   Re: Hostage following the player
Reply With Quote #8

Both. Inside this checks first with "m_improv" if not null. But I was meant "IsFollowing". You have actually the both functions.
__________________

Last edited by Arkshine; 05-11-2014 at 04:33.
Arkshine is offline
Reply


Thread Tools
Display Modes

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 03:01.


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