View Single Post
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 03-11-2024 , 19:26   [L4D2/Actions Extensions] How can I get attack target in SurvivorAttack?
Reply With Quote #1

action.Get(0x34) & 0xFFF not works for this. How can I get attack target? I want to prevent some attack.

PHP Code:
public void OnActionCreated(BehaviorAction actionint actor, const char[] name)
{
    if(
strncmp(name"Survivor"8) == 0)
    {
        if(
strcmp(name[8], "Attack") == 0)
        {
            
action.SelectTargetPoint on_Attack;
        }
    }
}

Action on_Attack(BehaviorAction actionAddress nextbotint entityfloat vec[3])
{
    
int target get_entity_from_address(view_as<Address>(entity));
    
PrintToChatAll("%N:%d"action.Actortarget);
    return 
Plugin_Continue;
}

int get_entity_from_address(Address addr)
{
    
int entity = -1;
    while((
entity FindEntityByClassname(entity"*")) != -1)
    {
        if(
entity >= && GetEntityAddress(entity) == addr)
        {
            return 
entity;
        }
    }
    return -
1;


Last edited by little_froy; 03-12-2024 at 04:42.
little_froy is offline