Jump to content

Anyone knows where CK's ice attack frozen time is defined in the codes?


Recommended Posts

I recently found that CK's ice attack applies exactly the same coldness as its frozen time. Each blue gem will increase the coldness applied by 10/9 from 10 and increase frozen time by 10/9 seconds from 10 seconds. 

This works differently from all other ways of applying frozen effect. Players are frozen for 10 or more seconds instead of 3, the latter is the time all other frozen effect lingers on players (except for klaus's 1 sec).

I wonder if this is a bug causing players to be frozen by CK for an unexpected longer time.

Here's the codes I found in crabking.lua, from line 1132~1135. This seemingly defines the coldness CK's ice attack shall apply. I'm not expert so I failed to find where the frozen time is defined.

Spoiler
if target.components.freezable ~= nil then
        target.components.freezable:AddColdness(10,10 + Remap((inst.crab and inst.crab:IsValid() and inst.crab.countgems(inst.crab).blue or 0),0,9,0,10) )
        target.components.freezable:SpawnShatterFX()
    end

The answer can be found in components/freezable.lua:

function Freezable:AddColdness(coldness, freezetime, nofreeze)
	if self.redirectfn ~= nil and self.redirectfn(self.inst, coldness, freezetime, nofreeze) then
		return
	end
    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

-- from mathutil.lua
--Remap a value (i) from one range (a - b) to another (x - y)
function Remap(i, a, b, x, y)
    return (((i - a)/(b - a)) * (y - x)) + x
end

The second argument to the AddColdness method is the freeze time, in this case it is [ 10 +  (10 * number_of_blue_gems/9) ] seconds

26 minutes ago, _zwb said:

The answer can be found in components/freezable.lua:

function Freezable:AddColdness(coldness, freezetime, nofreeze)
	if self.redirectfn ~= nil and self.redirectfn(self.inst, coldness, freezetime, nofreeze) then
		return
	end
    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

-- from mathutil.lua
--Remap a value (i) from one range (a - b) to another (x - y)
function Remap(i, a, b, x, y)
    return (((i - a)/(b - a)) * (y - x)) + x
end

The second argument to the AddColdness method is the freeze time, in this case it is [ 10 +  (10 * number_of_blue_gems/9) ] seconds

Nice. This further proves that CK is a failure.

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...