Raised This Month: $32 Target: $400
 8% 

Solved Help Guys


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aya Supay
Member
Join Date: Nov 2015
Old 10-03-2019 , 22:03   Help Guys
Reply With Quote #1

How can I change the target of the tank when the survivor is incapacitated?

this is a bit of my code

PHP Code:
public void OnPluginStart()
{
    
l4d_chance_attacknext CreateConVar("l4d_chance_attacknext""100.0""chance of continue attack [0.0, 100.0]" );
    
l4d_change_target CreateConVar("l4d_change_target""1""0 = change target, 1 = change target");
    
l4d_range_attack CreateConVar("l4d_range_attack""400.0""attack range");

    
HookEvent("player_incapacitated"eIncap);
}

public 
Action eIncap(Event event, const char[] namebool dontBroadcast)

    
int userid event.GetInt("userid");
    
int victim GetClientOfUserId(userid);
    
int tank event.GetInt("attackerentid");
    if( 
victim && tank 0)
    {
        if(
IsClientInGame(victim) && GetClientTeam(victim)==2)
        {
            
StartAttack(tankvictim);
        }
    }
    return 
Plugin_Continue;     
}

void StartAttack(int tankint victim)

    if(
IsTank(tank) && GetRandomFloat(0.0100.0) < l4d_chance_attacknext.FloatValue)
    { 
        
OnStart(tankvictim);
    } 
}

void OnStart(int entint victim)
{
    if(
IsTank(ent))
    { 
        
GetEntPropVector(entProp_Send"m_vecOrigin"fPos);
        if(
GetConVarInt(l4d_change_target)==1NextVictim GetVictimvictimfPos );
        else if(
IsPlayerIncapped(victim))
        {
            
NextVictim victim;
        }
        if( 
NextVictim )
        {
            
PrintToChatAll("next target is %N"NextVictim);
        }    
    }
}

int GetVictim(int exceptfloat Tpos[3])
{
    
float minDis l4d_range_attack.FloatValue;
    
float ePos[3];
    
int selected 0;
    for( 
int i 1<= MaxClientsi++)
    {
        if( 
IsClientInGame(i) && GetClientTeam(i)==&& IsPlayerAlive(i) && i!=except && !IsPlayerIncapped(i) )
        {
            
GetClientAbsOrigin(iePos);
            
float dis GetVectorDistance(ePosTpos);
            if( 
dis <= minDis )
            {
                
selected i;
                
minDis dis;
            }
        }
    } 
    return 
selected;
}

bool IsPlayerIncapped(int client)
{
    if( 
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == && IsPlayerAlive(client) )
    {
        if (
GetEntProp(clientProp_Send"m_isIncapacitated"1))
            return 
true;
    }
    return 
false;
}

bool IsTank(int client)
{
    if( 
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == )
    {
        
int class = GetEntProp(clientProp_Send"m_zombieClass");
        if( class == 
)
            return 
true;
    }
    return 
false;


Last edited by Aya Supay; 10-04-2019 at 19:00.
Aya Supay is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-04-2019 , 12:20   Re: Help Guys
Reply With Quote #2

1.
Use tEntDev to compare props when tank attacks different targets to find appopriate prop name.
Then, maybe change it OnThink.

2. Kick tank and create new one (clone) and apply point_hurt OnSpawn.

3. Apply vec math OnPlayerRunCmd like it is done by Pan XiaoHai in Evil Witch plugin.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

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 20:47.


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