Jump to content

[Help]Hound spawning


Recommended Posts

I'm trying to lower the number of hounds spawned per wave and it doesn't seem to work.From what I understood in the following line

self.houndstorelease = 6 + math.random(6)
6 hounds are spawned with a random addition up to 6 hounds? Correct me if I'm wrong. Well, I tried putting 5 + math.random(2), and I was beyond day 100, and it still spawned more than 7 hounds, it spawned 12-11 usually. What did I do wrong? Or is the source in another place?The function where I edited it.

function Hounded:PlanNextHoundAttack()

local day = GetClock().numcycles		local min_hound_day = 6	if day < min_hound_day then		local min_time = (min_hound_day - day)*TUNING.TOTAL_DAY_TIME		self.timetoattack = min_time + math.random() * TUNING.TOTAL_DAY_TIME * 4		self.houndstorelease = 2		self.warnduration = 2*60	elseif day < 50 then		self.timetoattack = TUNING.TOTAL_DAY_TIME * 3 + math.random() * TUNING.TOTAL_DAY_TIME * 10		self.houndstorelease = 2 + math.random(2)		self.warnduration = 60	elseif day < 100 then		self.timetoattack = TUNING.TOTAL_DAY_TIME * 3 +  math.random() * TUNING.TOTAL_DAY_TIME * 8		self.houndstorelease = 3 + math.random(3)		self.warnduration = 30	else		self.timetoattack = TUNING.TOTAL_DAY_TIME * 3 +  math.random() * TUNING.TOTAL_DAY_TIME * 5		self.houndstorelease = 6 + math.random(6)		self.warnduration = 30	end	end

Edited by Cyde042
Link to comment
Share on other sites

[MENTION=7315]Cyde042[/MENTION]Please use the code tags (even inside spoiler tags) so it is easier to read....Um....self.houndstorelease = 6 + math.random(6) should mean at least 12 plus a random number of addtional.and 5 + math.random(2) should mean at least 7 plus a random number of addtional so maybe you were just unlucky with getting 12 hounds?How far beyond day 100 were you? It seems I recall seeing the seed for the math.random function being set in the main.lua file....not sure that it is tied to thr total number of in game days though...

Link to comment
Share on other sites

[MENTION=7315]Cyde042[/MENTION]Please use the code tags (even inside spoiler tags) so it is easier to read....Um....self.houndstorelease = 6 + math.random(6) should mean at least 12 plus a random number of addtional.and 5 + math.random(2) should mean at least 7 plus a random number of addtional so maybe you were just unlucky with getting 12 hounds?How far beyond day 100 were you? It seems I recall seeing the seed for the math.random function being set in the main.lua file....not sure that it is tied to thr total number of in game days though...

I had to actually wait for the hounds to spawn in order to test this, and the day the growling started was 136Wait...but the random number, doesn't it have a set limit?But how can I make it spawn 5 hounds with an addition up to 2?Ok, the code makes sense, upon saving and quitting the world, it saves the amount of houndstorelease too, so that explained why it kept spawning 12, I changed to 5 and later when another wave came, only 5 of them spawned, what goes for the math.random(6), I think it refers a random number from 0 to 6 Edited by Cyde042
Link to comment
Share on other sites

[MENTION=7315]Cyde042[/MENTION]It would help if I had just double checked the Lua documentation first :S

math.random ([m [, n]])This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].

Not that the above means much to the average person. :DSo yes, math.random(6) returns a number between 1 and 6
Link to comment
Share on other sites

[MENTION=7315]Cyde042[/MENTION]It would help if I had just double checked the Lua documentation first :SNot that the above means much to the average person. :DSo yes, math.random(6) returns a number between 1 and 6

Funny thing that's the article I got the info from :>1 to 6 or 0 to 6?
Link to comment
Share on other sites

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
 Share

×
  • Create New...