Jump to content

Acid rain can affect items and non-players in areas that have no acid rain


hoxi
  • Pending

I'm reporting this because the new drying racks got some changes to be affected by acid rain in the last hotfix 680689, however, the issue of acid rain applying in areas with no acid rain is present in general, but also for the new drying racks.

 

I reported this a while back, here (this report might be a little outdated by now).

 

And more relatively recently, I made a report about Woby's drying rack here, which can now be closed as hotfix 680689 addressed the issue.

 

With that said, yeah, this is an issue for anything that isn't a player, and there was a change in the last hotfix to make it affect things in drying racks. Problem is that this will still take effect while in the lunar grotto or the archives, where there's no acid rain..

 

As mentioned in the report in the first link, this is an issue with anything that isn't a player and is affected by acid rain in some way, but I'd also like to point out a few things especially due to the last hotfix making acid rain affect drying racks:

  • Perishables don't check for acid rain while inside containers, even if exposed. Drying racks are currently the only exception due to running their own custom logic for it.
  • There's many containers that should count as exposed, but aren't (ocean trawler nets, ocean fishing rods, slingshots, etc).
  • The exposed container mechanic is a bit too specific at times and, is not accounted by some features, like Toadstool's spore clouds. There could also be logic for exposed containers within exposed containers.
  • Not perishable related, but, isn't it weird how acid rain doesn't affect things like armor or rain gear, unless specifically worn by the player..?

 

Instead of having custom acid rain logic for drying racks, something like this could be done for perishable:

local do_acid_sizzle = nil
local exposed_to_acid = nil

local owner = inst.components.inventoryitem ~= nil and inst.components.inventoryitem.owner or nil
if owner == nil and inst.components.occupier ~= nil then
	owner = inst.components.occupier:GetOwner() or nil
end

local pos = owner ~= nil and owner:GetPosition() or inst:GetPosition()

if owner ~= nil then
	-- usual spoilage modifier stuff here

	if not inside_pocket_container
		and TheWorld.state.isacidraining
		and not inst:HasTag("acidrainimmune")
		and owner.components.container ~= nil
		and owner.components.container.isexposed
	then
		-- taken from inventoryitemmoisture.lua
		-- modified very slightly since we always have an exposed container owner if we got here in the first place
		local exposedroot = owner
		while true do
			if exposedroot.components.rideable ~= nil then
				local rider = exposedroot.components.rideable:GetRider()
				if rider ~= nil then
					exposedroot = rider
					break
				end
			end
			local parent = exposedroot.components.inventoryitem ~= nil and exposedroot.components.inventoryitem.owner or nil
			if parent == nil then
				--no more parent, so use our current exposedroot
				break
			elseif parent.components.container ~= nil and parent.components.container.isexposed then
				exposedroot = parent
			else
				--our parent is an unexposed container or inventory (and inventories manage things more separately)
				exposedroot = nil
				break
			end
		end

		if exposedroot ~= nil and exposedroot.components.rainimmunity == nil then
			local root_pos = owner == exposedroot and pos or exposedroot:GetPosition() -- ensure we use the exposed root pos rather than our owner pos

			if TheWorld.Map:CanPointHaveAcidRain(root_pos.x, 0, root_pos.z) then
				do_acid_sizzle = true
				exposed_to_acid = true
			end
		end
	end
else
	-- usual spoilage modifier stuff here

	if TheWorld.state.isacidraining
		and inst.components.rainimmunity == nil
		and not inst:HasTag("acidrainimmune")
		and TheWorld.Map:CanPointHaveAcidRain(pos.x, 0, pos.z)
	then
		exposed_to_acid = true
	end
end

if exposed_to_acid then
	local rate = (inst.components.moisture ~= nil and inst.components.moisture:_GetMoistureRateAssumingRain() or TheWorld.state.precipitationrate)
	local percent_to_reduce = rate * TUNING.ACIDRAIN_PERISHABLE_ROT_PERCENT * dt

	local perish_time = (self.perishtime and self.perishtime > 0 and self.perishtime or 0)
	additional_decay = perish_time * percent_to_reduce
else
	additional_decay = 0
end

-- rest of the function here, including where additional_decay gets used


-- then, at the end of the function

-- sizzle while in containers so that players can see we're being affected
-- valid check must be here in case the item was deleted as a result of the self:Perish() call
if do_acid_sizzle and inst:IsValid() then
	MakeSizzle(inst) -- as in, the one in acidlevel.lua, could be made into a global, just keep in mind TUNING.ACIDRAIN_DAMAGE_TIME * 1.1 might not be the most ideal

	-- you could do something like (self.updatetask ~= nil and self.updatetask.period or TUNING.ACIDRAIN_DAMAGE_TIME) * 1.1
	-- but it won't be the most accurate compared to how the drying rack works right now..
end

Ideally though? The exposed root functionality first introduced in the inventoryitemmoisture component, should be made into a global function. And then have the inventoryitemmoisture and perishable components use it.

Right now, new drying racks are using their own isolated functionality for acid rain, and factor the acid rain calculation into their preserver function. Which.. it works, but it's not the most ideal, and further future cases aren't accounted for..

 

If this gets looked into now, you'd save yourself the headache and only acidinfusible would be left to be updated later to prevent it from applying in areas with no acid rain.

 

Note: there's more about all this I could go into detail but it's gonna make this report way too big.


Steps to Reproduce

For drying racks:

  • Have it be acid raining in the caves.
  • Place a drying rack in the archives or lunar grotto, where there's no acid rain.
  • Put something on the drying rack.
  • Notice how the items will still be affected, while the player isn't.

For items on the ground:

  • Drop perishable items on the ground in areas as mentioned above.
  • Notice how they'll also be affected.

For creatures, mushtrees, etc:

  • Bring (or spawn) an entity that's affected by acid rain to the areas mentioned above.
  • Notice how they'll still be affected.
  • Like 2



User Feedback


There are no comments to display.



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