Jump to content

Recommended Posts

My character is a sort of reptile, acclimated to the summer heat and desert sandstorms. I'm trying to figure out how to make him immune to slow down and animation that happens in the desert biome's sandstorm. The one where the character's hands are up, guarding their face from the wind.

Additionally, my character is extremely sensitive to the cold. I'm trying to figure out how to force the character into that sandstorm slow down animation when his body temperature drops below a certain level.

I'm not interested in having the visual benefits of the goggles (I want there to be SOME point to wearing goggles). Just the free mobility you get from them.

I'm going nuts over here. After sifting through 'unevenground' related stuff, the 'carefulwalker' component, the hats.lua prefab... All I've managed to do is make myself even more confused.

edit:

12:11am- So I figured out that "inst.components.playervision.forcegogglevision = true" works but it of course also gives the visual benefits, looks terrible outside of the desert (cuts off periphery).

1:26am-  ...hacked together a crappy script for the cold part using the "groggy" tag and "inst.components.locomotor:SetExternalSpeedMultiplier". It's not EXACTLY what I wanted, but it'll do.

Still hopeless to figuring out the desert perk.

Edited by StealthBeast

Try taking a look through the stormwatcher.lua component. That seems to be the main player sandstorm component. There's a SetSandstormSpeedMultiplier function there, try adding this to your master_postinit:

inst.components.stormwatcher:SetSandstormSpeedMultiplier(1)

As far as I can tell, the stormwatcher component checks to see if you've entered a sandstorm each time you enter a new area, then updates your movement depending on whether or not you have goggle vision or some other stuff. But it'll skip that check if your sandstormspeedmult is not less than 1.

Edited by ShinyMoogle

 My mod character has a similar feature like what you're trying to. Equipping a hat will act like the goggle. 
So "terrible" screen appeared to me. I solved this by just patching HUD not to show the goggle screen.
You can see it right here. But this will be hard to apply it to yours in just copy-pasting.
Because I made my character's classified and call the patching function into that.

Instead, try this code. This will prevent the goggle screen to appear unless your character equips the goggle.
But before, enable the screen and the ability to walk freely in sandstorm by inst.components.playervision.forcegogglevision = true in master_postinit.
And put this function somewhere in your charcter.lua.

local function PatchHUD(inst)
	if inst.HUD ~= nil then -- if this line run in the client(because HUD only exist in the client)
		inst.HUD.gogglesover.ToggleGoggles = function(self, show)
			local owner = self.owner
			local shouldshow = true
			
			if owner ~= nil then
				shouldshow = owner.replica.inventory:EquipHasTag("goggles")
			end

			if show then
				if not self.shown and shouldshow then
					self:Show()
					self:AddChild(self.storm_overlays):MoveToBack()
				end
			elseif self.shown then
				self:Hide()
				self.storm_root:AddChild(self.storm_overlays)
			end
		end
	end
end

Then put the function call in common_postinit.

PatchHUD(inst)

As I mentioned in the comment, inst.HUD only exist in the client. So you should place the function call in the right position.
common_postinit is where before the SetPristine() calls which run in both client and server, and master_postinit is after which run only in the server.

Edited by YakumoYukari

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