Page 1 of 1

Random Cooldowns

Posted: Wed Mar 11, 2015 12:48 am
by David Ward
Is there a way to randomize the length of a cooldown?

For example, under the code for defineObject { custommonster, code, etc, code }, there is:

Code: Select all

		   class = "MonsterMove",
			name = "move",
			sound = "rat_swarm_walk",
			cooldown = 3,
Instead of a flat 3 cooldown, is there a way to make it randomize, say, 1 to 5? So when the monster moves, sometimes the cooldown will be noticeably quicker (1 or 2 seconds), other times a lot slower (4 or 5 seconds), or the standard 3, depending on how the dice rolls.

Re: Random Cooldowns

Posted: Wed Mar 11, 2015 2:28 am
by minmay
The cleanest way to do this is probably to add a hidden trait with an onComputeCooldown() hook that returns a random multiplier. Like

Code: Select all

	onComputeCooldown = function(champion, weapon, attack, attackType, level)
		if level > 0 then return 2/3+math.random()*2/3 end
	end,
for a random cooldown multiplier from -33% to +33% (note you might prefer -33% to +50% depending on your statistical goal).

Of course, there is no way to change the item description to show something for the cooldown other than the actual cooldown value, so if you want the item to say "Cooldown: 2.0 to 4.0 seconds" instead of "Cooldown: 3.0 seconds", you're out of luck.

Re: Random Cooldowns

Posted: Wed Mar 11, 2015 3:58 am
by David Ward
Thank you kindly.