Left 4 Dead 2

Left 4 Dead 2

Rayman1103's Mutation Mod
tobii.san 14 Jun, 2016 @ 10:30am
Wave mutation stuck on wave 11 bug and possible solution
Let me know if there's anything I can do to help -- I want to help fix the Wave mutation, but I'd hate to have to publish my own thing to the workshop to do so. I would be much more happy to see it fixed here!

BUG:
In Wave mutation, it appears that a tank is supposed to spawn, but it is extremely rare for it to happen. I've only managed to have it happen once out of many games. Nothing will happen and walking around the entire map doesn't help. Only thing to do is manually quit the game.

HOW TO REPRODUCE:
Play any game of Wave mutation to Wave 11 a couple times and watch the tank not spawn and the game will be stuck on Wave 11.

POSSIBLE CAUSE:
On line 363 of vscripts/wave.nut, it says:
Utils.SpawnZombieNearPlayer( Players.AnyAliveSurvivor(), Z_TANK, 1500, 1000 );
That method, which is located in vscript/vslib/utils.net, will try 50 times to randomly find a location that is further away than the minimum distance from a survivor and not within line of sight of a survivor. If unsuccessful, then the method just returns false. I believe this is the cause of the issue - there appears to be no safeguard for if that method fails to spawn a tank.

POSSIBLE SOLUTION 1:
Try to spawn a tank in the existing way and if it fails, then force one to spawn. So something like this...
isTankSpawned := Utils.SpawnZombieNearPlayer( Players.AnyAliveSurvivor(), Z_TANK, 1500, 1000 );
if (!isTankSpawned)
{
Utils.SpawnZombieNearPlayer( Players.AnyAliveSurvivor(), Z_TANK, 1500, 1000, false );
}
Passing false for the 2nd call will force the method to not check for visibility, so the tank may spawn in a fully visible spot. Also, unfortunately that still leaves the possibility that the tank may not spawn... still much better than the game just getting stuck though. Maybe something different/extra is needed, maybe if it fails again, then do Solution #2...

POSSIBLE SOLUTION 2:
Have a number of set places the tank can spawn (preferably on roofs, etc.) and choose one at random. This should guarantee the tank spawns, thus not ruining the game for the players. It could spawn far away, too close, etc., so I don't know how preferred this would be. (side note, on one occasion, the existing spawn method caused the tank to spawn in a place where it couldn't move... so this would solve that issue too)
Last edited by tobii.san; 14 Jun, 2016 @ 11:05am