PDA

View Full Version : Nullify Entity to Guard AI Override



Maestro Fénix
30-03-2016, 03:36 PM
Everybody knows that until the devs finishes the waypoint entities, the "Entity to Guard" keyvalue NPC option is the best way to make your npcs move through obstacles into a defined point (I tested a bunch of soldiers into a maze of 10000 units large, and they manage to reach the center, with only moving through nodes). However, as a cons, the npcs will ignore any enviorement action, so you can shoot them to death, that they will continue running into the point.
I'm fed up that there's no solution, so I decided to use AngelScript to do a workaround until this gets fixed (or add a flag so you can choose if the AI turns to attack you and resume later the movement).


Analyzing the whole process with Developer 2, it seems they use the ForceFollow schedule (which probably will be a modified Follow schedule except is not interrupted on taking damage). So I have an idea:

-With a trigger_condition at the monster entity, it calls a trigger_script on taking damage, that calls an AS function.

-That function seeks the activator entity, then clears the schedule (theorically making them stop).


The problem is that for some unknown reason it doesn't stop as apparently clearing the schedule doesn't make it stop. Neither deleting the guard_ent value from them. But the code apparently works

Code:


void ClearTheSchedule(CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue)
{

CBaseEntity@ entity = pActivator;

CBaseMonster@ pMonster = cast<CBaseMonster@>( entity );

//Monsters only
if( pMonster is null )
{
g_Game.AlertMessage( at_console, "Doesnt work!\n" );
return;
}

pMonster.KeyValue("guard_ent","");
pMonster.StopFollowing(true);
pMonster.ClearSchedule();


g_Game.AlertMessage( at_console, "It works!\n" );
}

I tried both with pActivator and pCaller, but neither of them works. Before trying AS, I tried in Hammer calling a trigger_changevalue to remove the guard_ent value, but it has zero effect.

I would like futher information about how it works, how I could solve this problem and if that code is right (I'm dizzy now, so I'm have doubts).

Solokiller
31-03-2016, 02:50 PM
As long as the monster has a guard ent, it will be forced to head to it.

Clearing CBaseMonster::m_pGuardEnt will cause it to resume using normal AI behavior.

Maestro Fénix
01-04-2016, 12:07 PM
void ClearAISchedule(CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue)
{

CBaseEntity@ entity = pActivator;

CBaseMonster@ pMonster = cast<CBaseMonster@>( entity );

//Monsters only
if( pMonster is null )
{
return;
}

pMonster.m_pGuardEnt = null;
pMonster.m_iszGuardEntName = "";

pMonster.KeyValue("guard_ent","");
pMonster.StopFollowing(true);
pMonster.ClearSchedule();

}

Works perfect, thank you very much. Now I only have to find a way to send an input on enemy killed/out of range so they can restart the trip.