Jump to content

What is making Lush Season windy?


Recommended Posts

The porkland prefab adds the worldwind component, but when you check the worldwind component's OnUpdate function, it checks whether or not there is hurricane wind before actually spawning winds - and hamlet does not have hurricane winds. So how does Hamlet's lush season spawn winds?

function WorldWind:OnUpdate(dt)
	if not self.inst then 
		self:Stop()
		return
	end

	self.timeToWindChange = self.timeToWindChange - dt

	if self.timeToWindChange <= 0 then
		self.angle = math.random(0,360)
		self.inst:PushEvent("windchange", {angle=self.angle, velocity=self.velocity})

		self.timeToWindChange = math.random(MIN_TIME_TO_WIND_CHANGE, MAX_TIME_TO_WIND_CHANGE)
	end

	local sm = GetSeasonManager()
	local windspeed = sm:GetHurricaneWindSpeed()
	if windspeed > 0.01 and (sm:IsHurricaneStorm() or (sm.IsWindy and sm:IsWindy()) ) then
		self.windfx_spawn_rate = self.windfx_spawn_rate + self.windfx_spawn_pre_sec * dt
		--print(string.format("wind %f, %4.2f, %4.f", sm:GetHurricaneWindSpeed(), self.windfx_spawn_rate, self:GetWindAngle()))
		if self.windfx_spawn_rate > 1.0 then
			local px, py, pz = GetPlayer().Transform:GetWorldPosition()
			local dx, dz = 16 * UnitRand(), 16 * UnitRand()
			local x, y, z = px + dx, py, pz + dz
			local angle = self:GetWindAngle()

			self:SpawnWindSwirl(x, y, z, windspeed, angle)
			self.windfx_spawn_rate = self.windfx_spawn_rate - 1.0
		end
	end
end

 

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...