View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-15-2023 , 17:52   Re: [L4D/L4D2] Infected Bots Control (1.0.0)
Reply With Quote #1739

Quote:
Originally Posted by ZBzibing View Post
Code:
l4d_infectedbots_tank_spawn_probability "5","When each time spawn S.I., how much percent of chance to spawn tank"
I've always thought it was inaccurate here and here.
Code:
GetRandomInt(1, 100) <= g_iSpawnTankProbability) 
modify
GetRandomInt(1, 100) >= g_iSpawnTankProbability)
I think it's more accurate to correct for less than
It does not make sense to check if the RNG is greater than the set probability because you will increase its chances. The 5% chance will become 95% if you use ">=" instead of "<=" here. The goal is to get a number that is less than or equal to 5. We want the Tank to have a low chance of spawning.

@HarryPotter I noticed some redundancy in this code block:
PHP Code:
if  (g_bL4D2Version)
{
    if ( ( (
g_bFinaleStarted && g_bTankSpawnFinal == true) || !g_bFinaleStarted ) &&
        
g_iSpawnCounts[SI_TANK] < g_iTankLimit &&
        
GetRandomInt(1100) <= g_iSpawnTankProbability
    {
        return 
7;
    }
    else 
//spawn other S.I.
    
{
        
int generate;
        for(
int i 1<= 3i++)
        {
            
generate GenerateIndex()+1;
            if(
generate 0) break;
        }

        return 
generate;
    }
}
else
{
    if ( ( (
g_bFinaleStarted && g_bTankSpawnFinal == true) || !g_bFinaleStarted ) &&
        
g_iSpawnCounts[SI_TANK] < g_iTankLimit &&
        
GetRandomInt(1100) <= g_iSpawnTankProbability
    {
        return 
7;
    }
    else
    {
        
int generate;
        for(
int i 1<= 3i++)
        {
            
generate GenerateIndex()+1;
            if(
generate 0) break;
        }

        return 
generate;
    }

In both versions of the game, the same logic is being executed. If this is intentional, I suggest removing the game check for this code block. Lines 3696-3735 on Github.
__________________

Last edited by Psyk0tik; 12-15-2023 at 17:57.
Psyk0tik is offline