View Single Post
Author Message
LinLinLin
Senior Member
Join Date: Sep 2021
Old 10-07-2022 , 06:01   [L4D2]Spawn Infected couldn't find position 5 times.
Reply With Quote #1

i have do something like this.
PHP Code:
int cheat_client = -1;
for(
int i 1<= MaxClientsi++) 

    if(
IsClientInGame(i))
    {
         
cheat_client i;
         break;
     }
}
if( !
L4D_GetRandomPZSpawnPosition(cheat_client,class,5,{0.0,0.0,0.0}) )//这个玩家附近的位置, 类型, 次数, 无用的vec
{
    
LogMessage("找位失败, 正在重新找位.");
    
CreateTimer(1.0,Timer_CreateInfectedBotByClass,class,TIMER_FLAG_NO_MAPCHANGE);
    return;
}

int bot CreateFakeClient("Infected Bot");
if( 
bot != )
{
    
ChangeClientTeam(bot,TEAM_INFECTED);
    
KickClient(bot);
    switch(class)
    {
        case 
CLASS_CHARGER
        
CheatCommand(cheat_client"z_spawn_old""charger auto");
        case 
CLASS_HUNTER
        
CheatCommand(cheat_client"z_spawn_old""hunter auto");
        case 
CLASS_JOCKEY
        
CheatCommand(cheat_client"z_spawn_old""jockey auto");
        case 
CLASS_SMOKER
        
CheatCommand(cheat_client"z_spawn_old""smoker auto");
        case 
CLASS_BOOMER
        
CheatCommand(cheat_client"z_spawn_old""boomer auto");
        case 
CLASS_SPITTER
        
CheatCommand(cheat_client"z_spawn_old""spitter auto");
    }

It prevent most of the issue about "couldn't find position", but sometime it happend again.
I guess that maybe check position before spawn is not perfect. Harry said that CreateFakeClient is too expensive, and usually late out in tick.

I look up some .sp file about infected_bot_control, they use SDKCall(NextBotxxxxxxx) to spawn infectedbot, and use the return value of SDKCall to check whether it spawn correctly. But "z_spawn_old" cmd has no return value.

I think DHook z_spawn_old(const CCommand *) , get and check the return value will help, but i don't know how to do this because it return a warning() func in failed and i don't know which type of return is appropriate.

Can someone give a suggestion?
Attached Thumbnails
Click image for larger version

Name:	%3J5L9M}BB8N7SOJ@L]_FGL.png
Views:	128
Size:	11.4 KB
ID:	197272   Click image for larger version

Name:	P@7HRJ{G(MKD]MA3~B{13VP.png
Views:	118
Size:	6.6 KB
ID:	197273  

Last edited by LinLinLin; 10-07-2022 at 15:53.
LinLinLin is offline