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

[L4D] Detect the bot intention


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-05-2021 , 04:48   [L4D] Detect the bot intention
Reply With Quote #1

Hi,

how to check the bot intention?

Like, after boomer vomited, detect is he going:
- to run away
- to come even a bit closer and start attacking by claw.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Zynda
Member
Join Date: Jul 2011
Old 06-05-2021 , 22:38   Re: [L4D] Detect the bot intention
Reply With Quote #2

You can look for the current behavior of the NextBot.
The boomer has a couple of behaviors you can check:

BoomerRetreatToCover (I'm exposed and my vomit is recharging)
BoomerAttack (Victim is close, attack!)

etc.
use "nb_debug BEHAVIOR" to see the current behavior stack and changes to it in real time.

As for getting the data from a plugin I know that "Mutant Tanks" does this sort of check for the TankIdle behavior here.

I also have some code that does something similar that I can dig up if you want more reference.
Zynda is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-06-2021 , 10:51   Re: [L4D] Detect the bot intention
Reply With Quote #3

Hi, Zynda!

I would very appreciate for some examples, surely.

Also, thanks for point me to those Crasher's example. Really, useful !!!
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Zynda
Member
Join Date: Jul 2011
Old 06-07-2021 , 05:49   Re: [L4D] Detect the bot intention
Reply With Quote #4

These are all linux offsets by the way (should be in gamedata really but it's all hardcoded here).

Small methodmap for the Actions:
PHP Code:
#define OFFSET_BEHAVIOR               8
#define OFFSET_PARENT                 12
#define OFFSET_CHILD                  16
#define OFFSET_BURIED                 20
#define OFFSET_COVERING               24

methodmap BehaviorAction
{
    public 
BehaviorAction(Address action)
    {
        return 
view_as<BehaviorAction>(action);
    }

    public 
void GetName(char[] returnStringint maxlength)
    {
        static 
Handle sdkHandle;

        if (
sdkHandle == INVALID_HANDLE)
        {
            
StartPrepSDKCall(SDKCall_Raw);
            
PrepSDKCall_SetVirtual(41);
            
PrepSDKCall_SetReturnInfo(SDKType_StringSDKPass_Pointer);
            
sdkHandle EndPrepSDKCall();
        }

        
SDKCall(sdkHandlethisreturnStringmaxlength);
    }

    
property Address address
    
{
        public 
get()
        {
            return 
view_as<Address>(this);
        }
    }

    
property bool isNull
    
{
        public 
get()
        {
            return 
view_as<Address>(this) == Address_Null;
        }
    }

    
property Address m_behavior // the Behavior this Action is part of
    
{
        public 
get()
        {
            return 
view_as<Address>(LoadFromAddress(view_as<Address>(this) + view_as<Address>(OFFSET_BEHAVIOR), NumberType_Int32));
        }
    }

    
property BehaviorAction m_parent // the Action that contains us
    
{
        public 
get()
        {
            return 
view_as<BehaviorAction>(LoadFromAddress(view_as<Address>(this) + view_as<Address>(OFFSET_PARENT), NumberType_Int32));
        }
    }

    
property BehaviorAction m_child // the ACTIVE Action we contain, top of the stack. Use m_buriedUnderMe, m_coveringMe on the child to traverse to other suspended children
    
{
        public 
get()
        {
            return 
view_as<BehaviorAction>(LoadFromAddress(view_as<Address>(this) + view_as<Address>(OFFSET_CHILD), NumberType_Int32));
        }
    }

    
property BehaviorAction m_buriedUnderMe // the Action just "under" us in the stack that we will resume to when we finish
    
{
        public 
get()
        {
            return 
view_as<BehaviorAction>(LoadFromAddress(view_as<Address>(this) + view_as<Address>(OFFSET_BURIED), NumberType_Int32));
        }
    }

    
property BehaviorAction m_coveringMe // the Action just "above" us in the stack that will resume to us when it finishes
    
{
        public 
get()
        {
            return 
view_as<BehaviorAction>(LoadFromAddress(view_as<Address>(this) + view_as<Address>(OFFSET_COVERING), NumberType_Int32));
        }
    }

And a small use example, GetTopLevelAction will return the name of the current Action, entity can be any NextBot derivative (common infected, witch, survivor bot, special infected).

PHP Code:
void GetTopLevelAction(char[] returnStringint maxlengthint entity)
{
    
Address nextBot         MyNextBotPointer(entity);
    
Address intention       GetIntentionInterface(nextBot);
    
Address behavior        FirstContainedResponder(intention);
    
Address startingAction  FirstContainedResponder(behavior);

    
BehaviorAction action BehaviorAction(startingAction);

    while (
action.m_child.isNull == false)
    {
        
action action.m_child;
    }

    
action.GetName(returnStringmaxlength);
}

Address MyNextBotPointer(int entity)
{
    static 
Handle sdkHandle INVALID_HANDLE;
    if (
sdkHandle == INVALID_HANDLE)
    {
        
StartPrepSDKCall(SDKCall_Entity);
        
PrepSDKCall_SetVirtual(82);
        
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);

        
sdkHandle EndPrepSDKCall();
    }

    return 
view_as<Address>(SDKCall(sdkHandleentity));
}

Address GetIntentionInterface(Address nextBotPointer)
{
    static 
Handle sdkHandle INVALID_HANDLE;
    if (
sdkHandle == INVALID_HANDLE)
    {
        
StartPrepSDKCall(SDKCall_Raw);
        
PrepSDKCall_SetVirtual(50);
        
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);

        
sdkHandle EndPrepSDKCall();
    }

    return 
view_as<Address>(SDKCall(sdkHandlenextBotPointer));
}

Address FirstContainedResponder(Address address)
{
    static 
Handle sdkHandle INVALID_HANDLE;
    if (
sdkHandle == INVALID_HANDLE)
    {
        
StartPrepSDKCall(SDKCall_Raw);
        
PrepSDKCall_SetVirtual(2);
        
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);

        
sdkHandle EndPrepSDKCall();
    }

    return 
view_as<Address>(SDKCall(sdkHandleintentionInterface));

Zynda is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-07-2021 , 06:02   Re: [L4D] Detect the bot intention
Reply With Quote #5

oww, nice structuring.

Really appreciate for such clear examples!

It will be very useful for complementing behavior with various stuff.

Have a nice day!
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 04:18.


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