Jump to content

Customizable random zombie speeds


ZombiesLoveBrainiacs

Recommended Posts

Choose your own % of Runners, Walkers, Shamblers - and Crawlers! You missed those, didn't you. 

By default, you should get ~5% Runners, 60% Walkers, ~33% Shamblers, and ~2% Crawlers.

 

Only works if you choose "Random" for zombie speeds in Sandbox.

 

Not sure if this is 100% reliable, but it seems to work so far.

 

ZombieSpeeds = {}
ZombieSpeeds.counter = 0 -- counter to delay execution, otherwise it doesn't seem to work

ZombieSpeeds.randomizeSpeed = function(zombie)

	ZombieSpeeds.counter = ZombieSpeeds.counter + 1
	if ZombieSpeeds.counter ~= 200 then
		return
	end
	ZombieSpeeds.counter = 0

	local data = zombie:getModData();

	if data.zombieType == nil then -- we didn't set a zombieType yet
		 -- so lets set a zombieType
		local random = ZombRand(101)
		if random > 98 then
			zombie:toggleCrawling(); -- how to set, not toggle?
			data.zombieType = "crawler"
		-- elseif random > 97 then
		-- 	zombie:setForceFakeDead(true); -- not working?
		-- 	data.zombieType = "fakedead"
		elseif random > 95 then
			data.zombieType = "runner"
		elseif random > 60 then
			data.zombieType = "shambler"
		else
			data.zombieType = "walker"
		end

		 -- now do something with the zombieTypes
		 if data.zombieType == "runner" then
			zombie:changeSpeed(1);
		elseif data.zombieType == "walker" then
			zombie:changeSpeed(2);
		elseif data.zombieType == "shambler" then
			zombie:changeSpeed(3);
		end

		zombie:DoZombieStats() -- doesn't seem to work without applying the stats like this
	end 
	
end

Events.OnZombieUpdate.Add(ZombieSpeeds.randomizeSpeed);

RandomZombieSpeeds.zip

Edited by ZombiesLoveBrainiacs
Link to comment
Share on other sites

  • 1 month later...

To enable fakedead zombies:

zombie:setFakeDead(true)

To make sure a zombie isn't a crawler before toggling crawler:
if zombie:getSeppedMod() >= 0.55 then

    zombie:toggleCrawling()
end

Note that fakedead and crawlers zombies are persistent, so between moving between to cells, and loading saves, the population of them will accumulate.

I find that I have to redo, and possibly reset the zombie speed when moving between cells. So I do this at then end of the equivalent function I use to do what you do:
 

if data.SpecialZedType == "Shambler" then
             if ZombRand(999) == 0
                zombie:changeSpeed(3)
                zombie:DoZombieStats()

            end
        end       
        
        if data.SpecialZedType == "Runner" then
            if ZombRand(999) == 0 then
                zombie:changeSpeed(1);
                zombie:DoZombieStats()
            end
        end

Edited by Planet Algol
I was stoned when I first posted this and included extraneous code.
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...