Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Remove bile effect if Vomit jar out of map (NAV) 2023


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 02-17-2022 , 23:52   [L4D2] Remove bile effect if Vomit jar out of map (NAV) 2023
Reply With Quote #1

If possible, when survivor throws Bile Bomb at the ground, info_goal_infected_chase entity will be created, it makes all the infected in the map chase it.

Bur if survivor throws Bile Bomb out of map where zombie can't reach such as roof and sky,
all common infected just dance and stay where they are.

So my request is "Remove info_goal_infected_chase entity if this entity is out of map (nav)"

I haved tried
Spoiler


Edit: Solved by BHaType
__________________

Last edited by HarryPotter; 06-26-2023 at 05:17.
HarryPotter is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 02-18-2022 , 00:48   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #2

At present, no function has been found that can perfectly determine whether a location is reachable or not.
L4D2_IsReachable, L4D2_NavAreaTravelDistance, L4D2_VScriptWrapper_NavAreaBuildPath
None of these functions work very well

Last edited by sorallll; 02-18-2022 at 00:51.
sorallll is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 02-18-2022 , 01:28   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #3

On failure to detect out of bounds you could possibly watch for bile explosion and 1 second later check a few common if their animation is standing (I think facing the bile bomb?) with the animation of them waiving their arms and not moving. Then if that's the case the bile is out of bounds and delete.

Quote:
but It appears the server will sometimes crash when passing a real players client index
This has been the issue with "L4D2_IsReachable" since that function is designed for Survivor bots. I haven't looked too closely to find any other out of bounds style functions. If you do let me know and I'll add.
__________________
Silvers is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 02-18-2022 , 09:14   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #4

Quote:
Originally Posted by sorallll View Post
At present, no function has been found that can perfectly determine whether a location is reachable or not.
L4D2_IsReachable, L4D2_NavAreaTravelDistance, L4D2_VScriptWrapper_NavAreaBuildPath
None of these functions work very well
Okay...

It seems the only way is to create fake bot and call L4D2_IsReachable(), then kick fake bot on next frame.
__________________
HarryPotter is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 02-18-2022 , 09:34   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #5

Quote:
Originally Posted by HarryPotter View Post
Okay...

It seems the only way is to create fake bot and call L4D2_IsReachable(), then kick fake bot on next frame.
If that works without issues yeah, what if the Survivor team is full of players and unable to create a Survivor bot. This is something that should be added into left4dhooks "L4D2_IsReachable" native. I think a better solution should be found.
__________________
Silvers is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 02-18-2022 , 21:20   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #6

The "Action" method is the most convenient and has 100% accuracy but requires to install Actions extension other methods will still work but not in all situations

Action

Navigation

Left 4 DHooks & VScript
__________________
cry
BHaType is offline
Send a message via AIM to BHaType
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 02-19-2022 , 16:07   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #7

Quote:
Originally Posted by BHaType View Post
The "Action" method is the most convenient and has 100% accuracy but requires to install Actions extension other methods will still work but not in all situations

Action
That is weird, I throw bile at reachable nav or common infected body, the chat still prints
Code:
Infected(1410) can't reach his target...
Infected(1422) can't reach his target...
Infected(1431) can't reach his target...
Infected(1436) can't reach his target...
Infected(1438) can't reach his target...
Infected(1420) can't reach his target...
Infected(1429) can't reach his target...
Infected(1439) can't reach his target...
and all infected just ignore bile jar location.

L4D2 windows dedicated server.
__________________

Last edited by HarryPotter; 02-19-2022 at 16:08.
HarryPotter is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 02-19-2022 , 16:10   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #8

Quote:
Originally Posted by Silvers View Post
If that works without issues yeah, what if the Survivor team is full of players and unable to create a Survivor bot. This is something that should be added into left4dhooks "L4D2_IsReachable" native. I think a better solution should be found.
Here is what I write now, and you are right, if there are 18 survivors, can not create fake bot.

PHP Code:
#pragma semicolon 1
#pragma newdecls required
 
#include <sdktools>
#include <sdkhooks>
#include <multicolors>
#include <left4dhooks>
#undef REQUIRE_PLUGIN
#include <CreateSurvivorBot> //https://forums.alliedmods.net/showpost.php?p=2729883&postcount=16

public Plugin myinfo =
{
    
name "[L4D2] Bile Out Nav Negate",
    
author "HarryPotter",
    
description "If Vomit jar is thrown at the place which is out of map (NAV), negate bile effect",
    
version "1.0",
    
url "https://steamcommunity.com/profiles/76561198026784913"
}

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
EngineVersion test GetEngineVersion();

    if( 
test != Engine_Left4Dead2 )
    {
        
strcopy(errorerr_max"Plugin only supports Left 4 Dead 2.");
        return 
APLRes_SilentFailure;
    }

    return 
APLRes_Success;
}

#define STRINGLENGTH_CLASSES            64
#define MAXENTITIES                     2048
#define CVAR_FLAGS                      FCVAR_NOTIFY
ConVar g_hCvar_Enabled;

int g_iOwner;
static 
int ge_iType[MAXENTITIES+1];

public 
void OnPluginStart()
{    
    
g_hCvar_Enabled CreateConVar("l4d2_bile_out_nav_negate_enable""1""Enable/Disable the plugin.\n0 = Disable, 1 = Enable."CVAR_FLAGStrue0.0true1.0);

    
GetCvars();
    
g_hCvar_Enabled.AddChangeHook(ConVarChanged_Cvars);

    
AutoExecConfig(true"l4d2_bile_out_nav_negate");
}

public 
void ConVarChanged_Cvars(ConVar convar, const char[] oldValue, const char[] newValue)
{
    
GetCvars();
}

bool g_bCvar_Enabled;
void GetCvars()
{
    
g_bCvar_Enabled g_hCvar_Enabled.BoolValue;
}

bool g_bConfig;
public 
void OnConfigsExecuted()
{
    
g_bConfig true;
}

public 
void OnMapEnd()
{
    
g_bConfig false;
}

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if (!
g_bConfig || !g_bCvar_Enabled)
        return;


    if (!
IsValidEntityIndex(entity))
        return;

    
//PrintToChatAll("%d - %s", entity, classname);

    
switch (classname[0])
    {
        case 
'i':
        {
            if (
StrEqual(classname"info_goal_infected_chase"))
                
RequestFrame(OnNextFrameEntIndexToEntRef(entity));
        }
        case 
'v':
        {
            if (
StrEqual(classname"vomitjar_projectile"))
            {
                
SDKHook(entitySDKHook_SpawnPostOnSpawnPost);
            }
        }
    }
}

public 
void OnSpawnPost(int entity)
{
    if( !
IsValidEntity(entity) ) return;
     
    
int client GetEntPropEnt(entityProp_Send"m_hOwnerEntity");

    if(
client <= || !IsClientInGame(client)) 
        return;
        
    
ge_iType[entity] = GetClientUserId(client);
    
//PrintToChatAll("OnSpawnPost() %N throws a bilejar", client);
}

public 
void OnNextFrame(int entityRef)
{
    if (!
g_bCvar_Enabled)
        return;

    
int entity EntRefToEntIndex(entityRef);

    if (
entity == INVALID_ENT_REFERENCE)
        return;

    
float pos[3];
    
GetEntPropVector(entityProp_Send"m_vecOrigin"pos);

    
//PrintToChatAll("%d (%.2f %.2f %.2f), nav: %d", entity, pos[0], pos[1], pos[2], L4D_GetNearestNavArea(pos));
    // if( L4D_GetNearestNavArea(pos) == 0)
    // {
    //     PrintToChatAll("%d is out of map",entity);
    // }

    
int owner GetClientOfUserId(g_iOwner);
    
g_iOwner 0;
    if(
owner && IsClientInGame(owner))
    {
        
int client GetRandomSurvivor(-1,1);
        
int fakeclient;
        if(
client == 0) {
            
fakeclient CreateSurvivorBot();
            if(
fakeclient && IsClientInGame(fakeclient)) client fakeclient;
            else return;
        }

        if(
L4D2_IsReachable(clientpos) == false)
        {
            
CPrintToChatAll("[{olive}TS{default}] {blue}%N{default} throws a {green}bilejar{default} at unreachable location, negate the bile effect."owner);
            
RemoveEntity(entity);
        }

        if(
fakeclient && IsClientInGame(fakeclient)) KickClient(fakeclient"Kicking FakeClient");    
    }
}

public 
void OnEntityDestroyed(int entity)
{
    if (!
g_bConfig || !g_bCvar_Enabled)
        return;

    if (!
IsValidEntityIndex(entity))
        return;

    
char class[STRINGLENGTH_CLASSES];
    
GetEdictClassname(entity, class, sizeof(class));

    if (
strcmp(class, "vomitjar_projectile") != 0) return;  

    
int client ge_iType[entity];
    
ge_iType[entity] = 0;
    
client GetClientOfUserId(client);
    if(
client <= || !IsClientInGame(client)) return;

    
g_iOwner GetClientUserId(client);
    
//PrintToChatAll("%N thros a bilejar", client);
}

bool IsValidEntityIndex(int entity)
{
    return (
MaxClients+<= entity <= GetMaxEntities());

__________________
HarryPotter is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 02-19-2022 , 21:35   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #9

Quote:
Originally Posted by HarryPotter View Post
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
GameData

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
__________________
cry

Last edited by BHaType; 02-19-2022 at 21:38.
BHaType is offline
Send a message via AIM to BHaType
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 02-20-2022 , 00:47   Re: [L4D2] Remove bile effect if Vomit jar out of map (NAV)
Reply With Quote #10

Quote:
Originally Posted by BHaType View Post
Hmm... Game overwrites ChaseVictim property. Try this version
Thanks for your great work, but sadly still doesn't work,

Code:
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
Infected(1431) can't reach his target...
InfectedAttack
Infected(1436) can't reach his target...
InfectedAttack
Infected(1450) can't reach his target...
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
InfectedAttack
__________________
HarryPotter is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:47.


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