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 action, int actor, const char[] name) { if(strncmp(name, "Survivor", 8) == 0) { if(strcmp(name[8], "Attack") == 0) { action.SelectTargetPoint = on_Attack; } } }
Action on_Attack(BehaviorAction action, Address nextbot, int entity, float vec[3]) { int target = get_entity_from_address(view_as<Address>(entity)); PrintToChatAll("%N:%d", action.Actor, target); return Plugin_Continue; }
int get_entity_from_address(Address addr) { int entity = -1; while((entity = FindEntityByClassname(entity, "*")) != -1) { if(entity >= 0 && GetEntityAddress(entity) == addr) { return entity; } } return -1; }
|