RaymondFoxford Posted November 17, 2017 Share Posted November 17, 2017 Hey guys, I have a problem, my character can causa a meteor shower if his sanity gets too low, and he resets this meteor shower as his sanity drops, this is the code under the: local master_postinit = function(inst) inst:AddComponent("meteorshower") if inst.components.meteorshower.task then --it automatically scheduled a shower inst.components.meteorshower:StopShower() --remove the automatically-scheduled shower end --override the StartCooldown on this particular component instance so it does not schedule more showers after completing one inst.components.meteorshower.StartCooldown = inst.components.meteorshower.StopShower --Watch sanity to know when to trigger the showers inst:ListenForEvent("sanitydelta", function(inst, data) --data provides the oldpercent and newpercent for sanity, so it is easier to do thresholds in percents --... but you could convert like this local oldsanity = data.oldpercent * inst.components.sanity.max local newsanity = data.newpercent * inst.components.sanity.max local level = nil if newsanity <= 0 and oldsanity > 0 or newsanity <= 10 and oldsanity > 10 then level = 3 elseif newsanity <= 20 and oldsanity > 20 then level = 3 elseif newsanity <= 30 and oldsanity > 30 then level = 3 elseif newsanity <= 40 and oldsanity > 40 then level = 3 end if level then --we passed a threshold and need to spawn a shower inst.components.meteorshower:StartShower(level) end end) with this code if his sanity drops from 41 to 40, a meteor shower will happen, but if the sanity rises from 39 to 40, nothing happens. okay, but the biggest problem here is that this works inside caves, it makes no sense at all. I wanted to do something like this: if the character is in the surface, he will cause a meteor shower if his sanity gets too low. But, if the character is inside a cave/ruins, he will cause an earthquake inside the cave/ruins in the same level that he would cause the meteor shower if he were in the surface, of course if his sanity gets too low. it's possible to do something like that? Link to comment https://forums.kleientertainment.com/forums/topic/84333-meteors-and-earthquakes/ Share on other sites More sharing options...
spideswine Posted November 18, 2017 Share Posted November 18, 2017 The telelocator causes earthquakes underground, I'd suggest checking how that works. Link to comment https://forums.kleientertainment.com/forums/topic/84333-meteors-and-earthquakes/#findComment-975858 Share on other sites More sharing options...
Serpens Posted November 19, 2017 Share Posted November 19, 2017 check if TheWorld:HasTag("caves"). If it has, it is cave. Could aslo be "cave" not sure. Simply search game files for similar checks. Link to comment https://forums.kleientertainment.com/forums/topic/84333-meteors-and-earthquakes/#findComment-975971 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now