Skip to content

Commit

Permalink
634023
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 11, 2024
1 parent 1f8613b commit 3d21a70
Show file tree
Hide file tree
Showing 41 changed files with 56,180 additions and 1,376 deletions.
21 changes: 19 additions & 2 deletions actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ ACTIONS =
USEITEMON = Action({ distance=2, priority=1 }),
STOPUSINGITEM = Action({ priority=1 }),
TAKEITEM = Action(),
TAKESINGLEITEM = Action(),
MAKEBALLOON = Action({ mount_valid=true }),
CASTSPELL = Action({ priority=-1, rmb=true, distance=20, mount_valid=true }),
CAST_POCKETWATCH = Action({ priority=-1, rmb=true, mount_valid=true }), -- to actually use the mounted action, the pocket watch will need the pocketwatch_mountedcast tag
Expand Down Expand Up @@ -2919,12 +2920,28 @@ ACTIONS.TAKEITEM.strfn = function(act)
end

ACTIONS.TAKEITEM.stroverridefn = function(act)
if act.target.prefab == "table_winters_feast" or act.target:HasTag("inventoryitemholder_take") then
if act.target.prefab == "table_winters_feast" or (act.target:HasTag("inventoryitemholder_take") and act.target.takeitem == nil) then
return STRINGS.ACTIONS.TAKEITEM.GENERIC
end

local item = act.target.takeitem ~= nil and act.target.takeitem:value() or nil
return item ~= nil and subfmt(STRINGS.ACTIONS.TAKEITEM.ITEM, { item = item:GetBasicDisplayName() }) or nil
local str = item ~= nil and item:GetBasicDisplayName() or nil

if str ~= nil and item.replica.stackable ~= nil and item.replica.stackable:IsStack() then
str = str.." x"..tostring(item.replica.stackable:StackSize())
end

return str ~= nil and subfmt(STRINGS.ACTIONS.TAKEITEM.ITEM, { item = str }) or nil
end

ACTIONS.TAKESINGLEITEM.fn = function(act)
if act.target.components.inventoryitemholder ~= nil then
return act.target.components.inventoryitemholder:TakeItem(act.doer, false)
end
end

ACTIONS.TAKESINGLEITEM.stroverridefn = function(act)
return STRINGS.ACTIONS.TAKESINGLEITEM
end

ACTIONS.CASTSPELL.strfn = function(act)
Expand Down
2 changes: 2 additions & 0 deletions brains/rabbitkingbrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ function RabbitKingBrain:Create_Aggressive()
self.abilitydata = nil
end
end)),
-- Keep away from other aggressives.
RunAway(self.inst, {fn=function(guy) return guy.components.combat and guy.components.combat:TargetIs(self.inst) and not self.inst.components.combat:TargetIs(guy) or false end, tags={"_combat"}}, IDEAL_TARGET_DISTANCE + 2, IDEAL_TARGET_DISTANCE - 2),
-- Chase after target but maintain distance.
FailIfSuccessDecorator(Leash(self.inst, GetAvoidTargetPos_Aggressive, 2, 0.5, true)),
FailIfSuccessDecorator(Leash(self.inst, GetTargetPos_Aggressive, IDEAL_TARGET_DISTANCE + 2, IDEAL_TARGET_DISTANCE - 2, true)),
Expand Down
20 changes: 19 additions & 1 deletion componentactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,25 @@ local COMPONENT_ACTIONS =

inventoryitemholder = function(inst, doer, actions, right)
if inst:HasTag("inventoryitemholder_take") and not inst:HasTag("fire") then
table.insert(actions, ACTIONS.TAKEITEM)
local item = inst.takeitem ~= nil and inst.takeitem:value() or nil

if item == nil then
table.insert(actions, ACTIONS.TAKEITEM)

return
end

local act =
item.replica.stackable ~= nil and
item.replica.stackable:IsStack() and
(
doer.components.playercontroller ~= nil and
doer.components.playercontroller:IsControlPressed(CONTROL_FORCE_STACK)
) and
ACTIONS.TAKESINGLEITEM or
ACTIONS.TAKEITEM

table.insert(actions, act)
end
end,

Expand Down
4 changes: 0 additions & 4 deletions components/combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,6 @@ function Combat:GetAttacked(attacker, damage, weapon, stimuli, spdamage)
if self.inst.components.rideable ~= nil then
local saddle = self.inst.components.rideable.saddle
if saddle ~= nil then
if saddle.components.damagetyperesist ~= nil then
damagetypemult = saddle.components.damagetyperesist:GetResist(attacker, weapon)
end

if saddle.components.saddler ~= nil then
damage, spdamage = saddle.components.saddler:ApplyDamage(damage, attacker, weapon, spdamage)
end
Expand Down
2 changes: 1 addition & 1 deletion components/growable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function Growable:LongUpdate(dt)
end
end

if self.inst:IsValid() and currentstage ~= self.stage then
if self.inst:IsValid() and (self.growonly or currentstage ~= self.stage) then
local stagedata = self:GetCurrentStageData()

if stagedata ~= nil and stagedata.growfn ~= nil then
Expand Down
32 changes: 21 additions & 11 deletions components/inventoryitemholder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,34 +148,44 @@ function InventoryItemHolder:GiveItem(item, giver)
return true
end

function InventoryItemHolder:TakeItem(taker)
function InventoryItemHolder:TakeItem(taker, wholestack)
if wholestack == nil then
wholestack = true
end

if not self:CanTake(taker) then
return false
end

local pos = self.inst:GetPosition()
local item = not wholestack and self.item.components.stackable ~= nil and self.item.components.stackable:Get() or self.item

if item == self.item then
self.inst:RemoveChild(self.item)

self.inst:RemoveChild(self.item)
self.item:RemoveTag("outofreach")

self.item.components.inventoryitem:InheritWorldWetnessAtTarget(self.inst)
self.inst:RemoveEventCallback("onremove", self._onitemremoved, self.item)
end

self.item:RemoveTag("outofreach")
item.components.inventoryitem:InheritWorldWetnessAtTarget(self.inst)

self.inst:RemoveEventCallback("onremove", self._onitemremoved, self.item)
local pos = self.inst:GetPosition()

if taker ~= nil and taker:IsValid() and taker.components.inventory ~= nil then
taker.components.inventory:GiveItem(self.item, nil, pos)
taker.components.inventory:GiveItem(item, nil, pos)
else
self.item.Transform:SetPosition(pos:Get())
self.item.components.inventoryitem:OnDropped(true)
item.Transform:SetPosition(pos:Get())
item.components.inventoryitem:OnDropped(true)
end

if self.onitemtakenfn ~= nil then
-- Be aware that the item might be invalid at this point, in case it gets stacked on taken.
self.onitemtakenfn(self.inst, self.item, taker)
self.onitemtakenfn(self.inst, item, taker, item == self.item)
end

self.item = nil
if item == self.item then
self.item = nil
end

return true
end
Expand Down
2 changes: 1 addition & 1 deletion components/itemmimic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function ItemMimic:LongUpdate(dt)
self._auto_reveal_task = self.inst:DoTaskInTime(remaining, on_timed_out)
else
self._auto_reveal_task = nil
on_timed_out(inst)
on_timed_out(self.inst)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions components/oldager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ end

function OldAger:FastForwardDamageOverTime()
self:OnUpdate(self.damage_remaining / self.damage_per_second)
self:StopDamageOverTime()
end

function OldAger:GetDebugString()
Expand Down
2 changes: 1 addition & 1 deletion components/rabbitkingmanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function self:TryToBecomeAggressive(rabbitking, player)
local players = FindPlayersInRangeSqSortedByDistance(x, y, z, TUNING.RABBITKING_MEATCHECK_DISTANCE_SQ, true)
for _, testplayer in ipairs(players) do
if HasMeatInInventoryFor(testplayer) then
return self:BecomeAggressive(rabbitking, player)
return self:BecomeAggressive(rabbitking, testplayer)
end
end

Expand Down
5 changes: 1 addition & 4 deletions components/saddler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ end

function Saddler:ApplyDamage(damage, attacker, weapon, spdamage)
local damagetypemult = 1
local absorbed_damage = 0

absorbed_damage = damage * self:GetAbsorption()

if self.inst.components.damagetyperesist ~= nil then
damagetypemult = damagetypemult * self.inst.components.damagetyperesist:GetResist(attacker, weapon)
end

damage = damage * damagetypemult

local leftover_damage = damage - absorbed_damage
local leftover_damage = damage - (damage * self:GetAbsorption())

-- Apply special damage.
if spdamage ~= nil then
Expand Down
31 changes: 14 additions & 17 deletions components/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ return Class(function(self, inst)
local function CalculatePrecipitationRate()
if _precipmode:value() == PRECIP_MODES.always then
return .1 + perlin(0, _noisetime:value() * .1, 0) * .9
elseif _preciptype:value() ~= PRECIP_TYPES.none and _preciptype:value() ~= PRECIP_TYPES.lunarhail and _precipmode:value() ~= PRECIP_MODES.never then
elseif _preciptype:value() ~= PRECIP_TYPES.none and _precipmode:value() ~= PRECIP_MODES.never then
local p = math.max(0, math.min(1, (_moisture:value() - _moisturefloor:value()) / (_moistureceil:value() - _moisturefloor:value())))
local rate = MIN_PRECIP_RATE + (1 - MIN_PRECIP_RATE) * math.sin(p * PI)
return math.min(rate, _peakprecipitationrate:value())
Expand All @@ -427,16 +427,15 @@ return Class(function(self, inst)
end or nil

local StopPrecipitation = _ismastersim and function()
if _preciptype:value() == PRECIP_TYPES.lunarhail then return end

_moisture:set(_moisturefloor:value())
_moistureceil:set(RandomizeMoistureCeil())

if _preciptype:value() ~= PRECIP_TYPES.lunarhail then
_preciptype:set(PRECIP_TYPES.none)
end
_preciptype:set(PRECIP_TYPES.none)
end or nil

local StartLunarHail = _ismastersim and function()
StopPrecipitation()
_lunarhaillevel:set(LUNAR_HAIL_CEIL)
_preciptype:set(PRECIP_TYPES.lunarhail)
end or nil
Expand All @@ -454,18 +453,10 @@ return Class(function(self, inst)
end

local function CalculateLight()
if _preciptype:value() == PRECIP_TYPES.lunarhail then
local dynrange = _daylight and SEASON_DYNRANGE_DAY[_season] or SEASON_DYNRANGE_NIGHT[_season]

local p = 1 - CalculateLunarHailRate()
p = easing.inQuad(p, 0, 1, 1)

return p * dynrange + 1 - dynrange
end

if _precipmode:value() == PRECIP_MODES.never then
if _precipmode:value() == PRECIP_MODES.never and _preciptype:value() ~= PRECIP_TYPES.lunarhail then
return 1
end

local season = _season
local snowlight = _preciptype:value() == PRECIP_TYPES.snow
local dynrange = snowlight and (_daylight and SEASON_DYNRANGE_DAY["winter"] or SEASON_DYNRANGE_NIGHT["winter"])
Expand All @@ -474,10 +465,16 @@ return Class(function(self, inst)
if _precipmode:value() == PRECIP_MODES.always then
return 1 - dynrange
end
local p = 1 - math.min(math.max((_moisture:value() - _moisturefloor:value()) / (_moistureceil:value() - _moisturefloor:value()), 0), 1)

local p = math.min(math.max((_moisture:value() - _moisturefloor:value()) / (_moistureceil:value() - _moisturefloor:value()), 0), 1)
local p2 = _preciptype:value() == PRECIP_TYPES.lunarhail and CalculateLunarHailRate() or 0

p = 1 - math.max(p, p2)

if _preciptype:value() ~= PRECIP_TYPES.none then
p = easing.inQuad(p, 0, 1, 1)
end

return p * dynrange + 1 - dynrange
end

Expand Down Expand Up @@ -923,7 +920,7 @@ return Class(function(self, inst)
_world.components.riftspawner:IsLunarPortalActive() and
_preciptype:value() ~= PRECIP_TYPES.lunarhail
then
-- Increave _lunarhaillevel
-- Increase _lunarhaillevel
local lunarhail = _lunarhaillevel:value() + LUNAR_HAIL_EVENT_RATE.COOLDOWN * dt
if lunarhail >= LUNAR_HAIL_CEIL then
if _ismastersim then
Expand Down
4 changes: 2 additions & 2 deletions debugkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ GLOBAL_KEY_BINDINGS =
end
},
{
binding = { key = KEY_H, SHIFT=true },
--binding = { key = KEY_H, SHIFT=true },
name = function()
local on_off = TheFrontEnd.debugMenu.history:IsEnabled() and "OFF" or "ON"
return "Turn "..on_off.." History Recording"
Expand Down Expand Up @@ -332,7 +332,7 @@ WINDOW_KEY_BINDINGS =
end
},
{
binding = { key = KEY_H },
--binding = { key = KEY_H },
name = "History",
fn = function()
if not CAN_USE_DBUI or Profile:GetThreadedRenderEnabled() then
Expand Down
Loading

0 comments on commit 3d21a70

Please sign in to comment.