Jump to content

Recommended Posts

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?

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 1
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!

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