SirPlease / ZoneMod

A Competitive L4D2 Configuration.
71 stars 26 forks source link

tank_and_nowitch_ifier incorrect tank range logic #15

Open devilesk opened 5 years ago

devilesk commented 5 years ago

I think the logic that calculates the random tank % doesn't produce a value in the intended range for some ban range configurations.

For example, the ban range for c5m4_quarter defined in mapinfo is 80 to 100, which leaves 20-80% for what the tank spawn range should be. But, if you trace through the logic, you only end up with 20-65% for the tank spawn.

I don't have the source for your tank_and_nowitch_ifier plugin, but I've compared the decompiled code with the original witch_and_tankifier plugin and it appears to do the same calculation. Here's the relevant code section with c5m4_quarter values plugged in:

new Float:fCvarMinFlow = GetConVarFloat(g_hVsBossFlowMin); = 0.2 new Float:fCvarMaxFlow = GetConVarFloat(g_hVsBossFlowMax); = 0.85

new Float:fMinBanFlow = L4D2_GetMapValueInt("tank_ban_flow_min", -1) / 100.0; = 0.8 new Float:fMaxBanFlow = L4D2_GetMapValueInt("tank_ban_flow_max", -1) / 100.0; = 1 new Float:fBanRange = fMaxBanFlow - fMinBanFlow; =0.2

if (fMinBanFlow > 0 && fMinBanFlow < fCvarMinFlow) False { fBanRange -= (fCvarMinFlow - fMinBanFlow); }

fTankFlow = GetRandomFloat(fCvarMinFlow, fCvarMaxFlow - fBanRange); = GetRandomFloat(0.2, 0.85 - 0.2) = GetRandomFloat(0.2, 0.65)

if (fTankFlow > fMinBanFlow) False, since fTankFlow < 0.65 and fMinBanFlow = 0.8 { fTankFlow += fBanRange; }

devilesk commented 5 years ago

I created a gist containing a modified AdjustBossFlow function that should properly apply the ban range. https://gist.github.com/devilesk/8f4acc14c7fde54aa4d98d047ef86fb6 I've been using it on my server for a few weeks now without issue.