kill the sun Posted April 21, 2023 Share Posted April 21, 2023 I tried to set a high freezable resistance(inst.components.freezable:SetResistance(300)) ), but the character can still be frozen by Klaus. And then I tried to directly remove freezable component(inst:Removecomponent("freezable")). It worked, but the game will crash when the player die. Can someone professional help to resolve it, or tell the reason? Link to comment https://forums.kleientertainment.com/forums/topic/147293-how-to-make-a-character-unfrozen%EF%BC%9F/ Share on other sites More sharing options...
-LukaS- Posted April 23, 2023 Share Posted April 23, 2023 You shouldn't directly remove the component from a player and there isn't any specific field to set up immunity to freezing but you could override the 'AddColdness' method of 'freezable' and simply not increase it when called. Make sure to still run the original code when coldness is negative, so it can update the tint. function Freezable:AddColdness(coldness, freezetime, nofreeze) self.coldness = math.max(0, self.coldness + coldness) --V2C: when removing coldness, don't update freeze states here if coldness > 0 then if self:IsFrozen() then self:Freeze(freezetime) elseif self.coldness <= 0 then --not possible? else local resistance = self:ResolveResistance() if self.coldness < resistance then self:StartWearingOff() elseif self.inst.sg ~= nil and (nofreeze or self.inst.sg:HasStateTag("nofreeze")) then self.coldness = resistance self:StartWearingOff() else self:Freeze(freezetime) end end end self:UpdateTint() end "components/freezable.lua" (line 129) 1 Link to comment https://forums.kleientertainment.com/forums/topic/147293-how-to-make-a-character-unfrozen%EF%BC%9F/#findComment-1631538 Share on other sites More sharing options...
kill the sun Posted May 4, 2023 Author Share Posted May 4, 2023 On 4/23/2023 at 10:12 PM, -t- said: You shouldn't directly remove the component from a player and there isn't any specific field to set up immunity to freezing but you could override the 'AddColdness' method of 'freezable' and simply not increase it when called. Make sure to still run the original code when coldness is negative, so it can update the tint. function Freezable:AddColdness(coldness, freezetime, nofreeze) self.coldness = math.max(0, self.coldness + coldness) --V2C: when removing coldness, don't update freeze states here if coldness > 0 then if self:IsFrozen() then self:Freeze(freezetime) elseif self.coldness <= 0 then --not possible? else local resistance = self:ResolveResistance() if self.coldness < resistance then self:StartWearingOff() elseif self.inst.sg ~= nil and (nofreeze or self.inst.sg:HasStateTag("nofreeze")) then self.coldness = resistance self:StartWearingOff() else self:Freeze(freezetime) end end end self:UpdateTint() end "components/freezable.lua" (line 129) thanks! Link to comment https://forums.kleientertainment.com/forums/topic/147293-how-to-make-a-character-unfrozen%EF%BC%9F/#findComment-1633477 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