Quote:
Originally Posted by HarryPotter
That is weird, I throw bile at reachable nav or common infected body, the chat still prints
|
Hmm... Game overwrites ChaseVictim property. Try this version
Code
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <left4dhooks>
#include <actions>
#include <sourcescramble>
MemoryPatch g_hBlockWavingAnimation;
public void OnPluginStart()
{
GameData data = new GameData("l4d2_infected_navigation_out_of_map");
g_hBlockWavingAnimation = MemoryPatch.CreateFromConf(data, "ChaseVictim::Update");
delete data;
}
public void OnActionCreated( BehaviorAction action, int actor, const char[] name )
{
if ( strcmp(name, "ChaseVictim") == 0 )
{
action.OnUpdate = OnUpdate;
action.OnUpdatePost = OnUpdatePost;
}
}
public Action OnUpdate( BehaviorAction chaseVictim, float interval, ActionResult result )
{
if ( chaseVictim.Get(0x4844, NumberType_Int8) != 0 )
return Plugin_Continue;
chaseVictim.Set(0x4844, 0);
BlockWavingAnimation(true);
BehaviorAction attack = chaseVictim.Parent;
if ( attack == INVALID_ACTION )
return Plugin_Continue;
char szAction[ACTION_NAME_LENGTH];
attack.GetName(szAction, sizeof szAction);
PrintToChatAll(szAction);
/* InfectedAttack stores victim handle at 0x34 */
int victim = attack.Get(0x34) & 0xFFF;
if ( !IsValidEntity(victim) )
return Plugin_Continue;
char name[32];
GetEntityClassname(victim, name, sizeof name);
if ( strcmp(name, "info_goal_infected_chase") == 0 )
{
PrintToChatAll("Infected(%i) can't reach his target...", chaseVictim.Actor);
RemoveEntity(victim);
victim = GetRandomSurvivor(1, -1);
if ( victim )
{
/* Go attack random survivor */
attack.Set(0x34, GetEntityHandle(victim));
}
else
{
attack.Set(0x34, -1);
}
}
return Plugin_Continue;
}
public Action OnUpdatePost( BehaviorAction chaseVictim, float interval, ActionResult result )
{
BlockWavingAnimation(false);
return Plugin_Continue;
}
void BlockWavingAnimation( bool block )
{
if ( block )
g_hBlockWavingAnimation.Enable();
else
g_hBlockWavingAnimation.Disable();
}
stock int GetEntityHandle( int entity )
{
return EntIndexToEntRef(entity) & ~(1 << 31);
}
GameData
PHP Code:
"Games"
{
"left4dead2"
{
"MemPatches"
{
"ChaseVictim::Update"
{
"signature" "ChaseVictim::Update"
"linux"
{
"offset" "3916"
"verify" "\x0F\x84\xA7\x02\x00\x00"
}
"windows"
{
"offset" "2427"
"verify" "\x0F\x84\x9C\x00\x00\x00"
}
"patch" "\x90\x90\x90\x90\x90\x90"
}
}
"Signatures"
{
"ChaseVictim::Update"
{
"linux" "@_ZN11ChaseVictim6UpdateEP8Infectedf"
"windows" "\x55\x8B\xEC\x83\xEC\x68\xA1\x2A\x2A\x2A\x2A\x53\x56\x33\xF6\x8B\xD9"
}
}
}
}
Help information for everyone else who wants to find a better solution
Infected starts waving animation at 40EFD0 + 96D (ChaseVictim::Update) it compares ChaseVictim property which stores return value of Path::IsValid function, property getting set from DirectChaseVictim::Update at 3B71B7 and 3B717A (Windows offsets).
Probably the best solution is to detourPost DirectChaseVictim::Update function and check if chasing entity is vomitjar and path for it is unreachable if so delete vomitjar and set property to 1
__________________