Created
September 9, 2019 03:15
-
-
Save devilesk/8f4acc14c7fde54aa4d98d047ef86fb6 to your computer and use it in GitHub Desktop.
Modified AdjustBossFlow function for tank_and_nowitch_ifier plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javascript implementation to test algorithm: https://jsfiddle.net/c8qdn03e/3/ | |
public Action:AdjustBossFlow(Handle:timer) | |
{ | |
if (InSecondHalfOfRound()) return; | |
decl String:sCurMap[64]; | |
decl dummy; | |
GetCurrentMap(sCurMap, sizeof(sCurMap)); | |
new iCvarMinFlow = RoundFloat(GetConVarFloat(g_hVsBossFlowMin) * 100); | |
new iCvarMaxFlow = RoundFloat(GetConVarFloat(g_hVsBossFlowMax) * 100); | |
new iTankFlow = -1; | |
if (!GetTrieValue(hStaticTankMaps, sCurMap, dummy)) | |
{ | |
#if DEBUG | |
PrintToChatAll("Not static tank map"); | |
#endif | |
new iMinBanFlow = L4D2_GetMapValueInt("tank_ban_flow_min", 0); | |
new iMaxBanFlow = L4D2_GetMapValueInt("tank_ban_flow_max", 0); | |
if (iMaxBanFlow <= 0) | |
{ | |
iMaxBanFlow = iCvarMinFlow - 1; | |
} | |
if (iMinBanFlow <= iCvarMinFlow && iMaxBanFlow >= iCvarMaxFlow) | |
{ | |
#if DEBUG | |
PrintToChatAll("Ban range covers entire flow range. Flow tank disabled."); | |
#endif | |
L4D2Direct_SetVSTankToSpawnThisRound(0, false); | |
L4D2Direct_SetVSTankToSpawnThisRound(1, false); | |
} | |
else | |
{ | |
new iIntervalMin = MAX( iCvarMinFlow, iMinBanFlow ); | |
new iIntervalMax = MIN( iCvarMaxFlow, iMaxBanFlow ); | |
new iPreIntervalLength = iIntervalMin - iCvarMinFlow; | |
new iPostIntervalLength = iCvarMaxFlow - iIntervalMax; | |
new iTankFlowLength = iPreIntervalLength + iPostIntervalLength - 1; | |
iTankFlow = GetRandomInt(0, iTankFlowLength); | |
#if DEBUG | |
PrintToChatAll("iTankFlow_pre: %i", iTankFlow); | |
#endif | |
if (iPreIntervalLength == 0) | |
{ | |
iTankFlow += iMaxBanFlow + 1; | |
} | |
else | |
{ | |
iTankFlow += iCvarMinFlow; | |
if (iPostIntervalLength > 0 && iTankFlow >= iIntervalMin) | |
{ | |
iTankFlow += (iIntervalMax - iIntervalMin + 1); | |
} | |
} | |
new Float:fTankFlow = iTankFlow / 100.0; | |
#if DEBUG | |
PrintToChatAll("fTankFlow_post: %f", fTankFlow); | |
#endif | |
L4D2Direct_SetVSTankToSpawnThisRound(0, true); | |
L4D2Direct_SetVSTankToSpawnThisRound(1, true); | |
L4D2Direct_SetVSTankFlowPercent(0, fTankFlow); | |
L4D2Direct_SetVSTankFlowPercent(1, fTankFlow); | |
} | |
} | |
else | |
{ | |
L4D2Direct_SetVSTankToSpawnThisRound(0, false); | |
L4D2Direct_SetVSTankToSpawnThisRound(1, false); | |
#if DEBUG | |
PrintToChatAll("Static tank map"); | |
#endif | |
} | |
L4D2Direct_SetVSWitchToSpawnThisRound(0, false); | |
L4D2Direct_SetVSWitchToSpawnThisRound(1, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment