Raised This Month: $2 Target: $400
 0% 

Solved [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 05-09-2020 , 23:34   [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
Reply With Quote #1

Hello, everypony, I have a "commentary_zombie_spawner" entity that spawns a random special infected (smoker, boomer, tank, hunter).

PHP Code:
if ( infected )
        {
            
int rand;
            
//force choose a random infected of desired ones in l4d_nomercy_elevator_infected...
            
while ( (rand=GetRandomInt(04))!=)
            {
                if ( (
1<<rand) & infected )
                {
                    
//Spawn random special infected...
                    
FormatEx(sCommandsizeof(sCommand), "OnUseLocked elev_infected:SpawnZombie:%s:0.0:1"sInfectedName[rand]);
                    
SetVariantString(sCommand);
                    
AcceptEntityInput(entity"AddOutput");
                    
                    
SetVariantString("OnUseLocked elev_infected:Disable:0.0:-1");
                    
AcceptEntityInput(entity"AddOutput");
                    
                    
SetVariantString("OnUseLocked !self:Disable:0.0:-1");
                    
AcceptEntityInput(entity"AddOutput");
                    break;
                }
            }
        } 
In this code, i created a "commentary_zombie_spawner" entity, its targetname is "elev_infected".
It spawns a random special infected.
I would like to get that infected's entity in a variable for post proccessing (making it invisible, change render color, set custom health, ignite, etc).
Any idea?? Thanks in advance

Last edited by axelnieves2012; 05-12-2020 at 23:49.
axelnieves2012 is offline
Marttt
Senior Member
Join Date: Jan 2019
Old 05-10-2020 , 10:47   Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
Reply With Quote #2

You can try to get the entity on "EntityCreated" by checking the entity's name in the next frame.
Maybe it helps.
__________________
Marttt is offline
xZk
Senior Member
Join Date: Nov 2017
Location: cl
Old 05-10-2020 , 21:47   Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
Reply With Quote #3

I think that through this entity it is not possible, perhaps comparing the same spawn position, but it would be unsafe. I recommend using left4dhooks, using these natives since it returns their entity id:
PHP Code:
// Spawns a Tank
native int L4D2_SpawnTank(const float vecPos[3], const float vecAng[3]);

// Spawns a Special Infected
native int L4D2_SpawnSpecial(int zombieClass, const float vecPos[3], const float vecAng[3]);

// Spawns a Witch
native int L4D2_SpawnWitch(const float vecPos[3], const float vecAng[3]); 

Last edited by xZk; 05-10-2020 at 21:47.
xZk is offline
Silvers
AlliedModders Donor
Join Date: Aug 2010
Location: SpaceX
Old 05-11-2020 , 05:33   Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
Reply With Quote #4

You could do something like:

PHP Code:
// Global
bool g_bWatch;

// Where your previous code was:
HookSingleEntityOutput(client"OnUseLocked"OnUseLockedtrue);

// When triggered
public void OnUseLocked(const char[] outputint callerint activatorfloat delay)
{
    
AcceptEntityInput(caller"Disable");
    
g_bWatch true;
    
// Spawn zombie
    
g_bWatch false;
}

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if( 
g_bWatch && strcmp(classname"infected") == )
    {
        
SDKHook(entitySDKHook_SpawnPostSpawnPost);
    }
}

public 
void SpawnPost(int entity)
{
    
// Stuff

__________________
Silvers is offline
axelnieves2012
Senior Member
Join Date: Oct 2014
Location: Argentina
Old 05-12-2020 , 23:48   Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
Reply With Quote #5

Thanks everybody for answering me. i completely forgot about left4dhooks spawn method. I started working with it recently. I have an idea, maybe this weekend I update my code
axelnieves2012 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 05:24.


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