AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2/Actions Extensions] How can I get attack target in SurvivorAttack? (https://forums.alliedmods.net/showthread.php?t=346696)

little_froy 03-11-2024 19:26

[L4D2/Actions Extensions] How can I get attack target in SurvivorAttack?
 
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;




All times are GMT -4. The time now is 19:15.

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