AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"? (https://forums.alliedmods.net/showthread.php?t=324226)

axelnieves2012 05-09-2020 23:34

[L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
 
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

Marttt 05-10-2020 10:47

Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
 
You can try to get the entity on "EntityCreated" by checking the entity's name in the next frame.
Maybe it helps.

xZk 05-10-2020 21:47

Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
 
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]); 


Silvers 05-11-2020 05:33

Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
 
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



axelnieves2012 05-12-2020 23:48

Re: [L4D] How do I get an Special Infected created by "commentary_zombie_spawner"?
 
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


All times are GMT -4. The time now is 22:31.

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