--[[ Changelog V 8.4 : Added a beaver meter V 8.32 : Wetness badge reworked V 8.21 : Fixed the boats health badge V 8.2 : Shipwrecked update Created by Kiopho ------------------------------------------------------------------------------------------------------------------------------]] Assets = { Asset("ATLAS", "images/status_bg.xml"), Asset("ATLAS", "images/beaverbar.xml"), } --------------------------------------------------------------------- _G = GLOBAL _G.package.loaded["aos.modenv"] = env local naughty_on = (GetModConfigData("Naughtiness_state")=="default") local naughty_off = (GetModConfigData("Naughtiness_state")=="off") local temp_on = (GetModConfigData("Temperature_state")=="default") local temp_off = (GetModConfigData("Temperature_state")=="off") local temp_c = (GetModConfigData("Temperature_Unit")=="default") local temp_f = (GetModConfigData("Temperature_Unit")=="fahrenheit") --------------------------------------------------------------------- -- Custom Badges local function BadgeRework(self) local Text = _G.require "widgets/text" local Image = _G.require "widgets/image" local Widget = _G.require "widgets/widget" self:SetScale(.9,.9,1) self.bg = self:AddChild(Image("images/status_bg.xml", "status_bg.tex")) self.bg:SetScale(.4,.43,0) self.bg:SetPosition(-.5,-25,0) self.num:Kill() self.num = self:AddChild(Text(_G.NUMBERFONT, 28)) self.num:SetHAlign(_G.ANCHOR_MIDDLE) self.num:SetPosition(3.5, -40, 0) self.num:SetScale(1,.78,1) self.maxnum = self:AddChild(Text(_G.NUMBERFONT, 35)) self.maxnum:SetPosition(6, 0, 0) self.maxnum:SetScale(1,.78,1) self.maxnum:Hide() oldSetPercent = self.SetPercent function self:SetPercent(val, max) oldSetPercent(self, val, max) self.maxnum:SetString(tostring(math.ceil(max))) end oldOnGainFocus = self.OnGainFocus function self:OnGainFocus() oldOnGainFocus(self) self.maxnum:Show() end oldOnLoseFocus = self.OnLoseFocus function self:OnLoseFocus() oldOnLoseFocus(self) self.maxnum:Hide() self.num:Show() end end --AddClassPostConstruct("widgets/badge", BadgeRework) -- -- Status Display local function StatusDisplaysRework(self) local AoS_NaughtyBadge = _G.require "widgets/aos_naughtybadge" local AoS_TemperatureBadge = _G.require "widgets/aos_temperaturebadge" local AoS_BeaverBadge = _G.require "widgets/aos_beaverbadge" self.brain:SetPosition(0,5,0) self.heart:SetPosition(62,34.5,0) if self.heart.poisonanim then self.heart.poisonanim:SetPosition(0,14.5,0) end self.stomach:SetPosition(-62,33,0) self.stomach.bg:SetPosition(-.5,-23.5,0) self.stomach.num:SetPosition(3.5, -38.5, 0) if self.moisturemeter then self.moisturemeter:SetPosition(0,-88,0) end self.naughty = self:AddChild(AoS_NaughtyBadge(self.owner)) self.naughty:SetNaughty(self.owner.components.kramped:GetNaughtyness(), self.owner.components.kramped:GetLimit()) self.naughty:SetPosition(-59.5,0,0) if naughty_off then self.naughty:Hide() end self.inst:ListenForEvent("temperaturedelta", function(inst) self.temperature:SetTemperature(self.owner.components.temperature:GetCurrent()) end, self.owner) self.temperature = self:AddChild(AoS_TemperatureBadge(self.owner)) self.temperature:SetTemperature(self.owner.components.temperature:GetCurrent()) self.temperature:SetPosition(59.5,0,0) if temp_off then self.temperature:Hide() self.naughty:SetPosition(59.5,0,0) end self.inst:ListenForEvent("naughtydelta", function(inst) self.naughty:SetNaughty(self.owner.components.kramped.GetNaughtyness(), self.owner.components.kramped.GetLimit()) end, self.owner) if self.owner.components.beaverness then self.beavermeter = self:AddChild(AoS_BeaverBadge(self.owner)) self.beavermeter:SetBeaverPercent(self.owner.components.beaverness:GetPercent()) self.beavermeter:SetPosition(0,-52,0) self.inst:ListenForEvent("beavernessdelta", function(inst) self.beavermeter:SetBeaverPercent(self.owner.components.beaverness:GetPercent()) end, self.owner) end end AddClassPostConstruct("widgets/statusdisplays", StatusDisplaysRework) -- -- Status Tweaks local function CustomStatus(self) self.clock.text:SetPosition(5,0,0) self.clock.text:SetScale(.9,.9,0) self.sidepanel:SetPosition(-102,-72,0) end AddClassPostConstruct("widgets/controls", CustomStatus) -- -- Krampometer local function Krampo(self, inst) local naughty_actions = self.actions local naughty_threshold = self.threshold or 0 local oldOnLoad = self.OnLoad function self:OnLoad(data) oldOnLoad(self, data) naughty_actions = self.actions naughty_threshold = self.threshold or 0 end local oldOnUpdate = self.OnUpdate function self:OnUpdate(dt) oldOnUpdate(self, dt) naughty_actions = self.actions self:DoDelta() end local oldOnNaughtyAction = self.OnNaughtyAction function self:OnNaughtyAction(how_naughty) oldOnNaughtyAction(self, how_naughty) naughty_actions = self.actions naughty_threshold = self.threshold self:DoDelta() end function self:GetNaughtyness() return naughty_actions end function self:GetLimit() return naughty_threshold end function self:DoDelta() self.inst:PushEvent("naughtydelta") end end AddComponentPostInit("kramped", Krampo) -- -- WX78 Upgrade Animation Fix local function applyupgrades(inst) local max_upgrades = 15 local upgrades = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil(TUNING.WX78_MIN_HUNGER + upgrades* (TUNING.WX78_MAX_HUNGER - TUNING.WX78_MIN_HUNGER)/max_upgrades) inst.components.health.maxhealth = math.ceil(TUNING.WX78_MIN_HEALTH + upgrades* (TUNING.WX78_MAX_HEALTH - TUNING.WX78_MIN_HEALTH)/max_upgrades) inst.components.sanity.max = math.ceil(TUNING.WX78_MIN_SANITY + upgrades* (TUNING.WX78_MAX_SANITY - TUNING.WX78_MIN_SANITY)/max_upgrades) inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) end local function newoneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == "GEARS" then inst.level = inst.level + 1 applyupgrades(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") inst.HUD.controls.status.heart:PulseGreen() inst.HUD.controls.status.stomach:PulseGreen() inst.HUD.controls.status.brain:PulseGreen() inst.HUD.controls.status.brain:ScaleTo(1.2,.9,.7) inst.HUD.controls.status.heart:ScaleTo(1.2,.9,.7) inst.HUD.controls.status.stomach:ScaleTo(1.2,.9,.7) end end local function wx78eat(inst) inst.components.eater:SetOnEatFn(newoneat) end AddPrefabPostInit("wx78", wx78eat) -- -- Boat Widget Position Fix local function BoatBadgeFix(self) local oldOpen = self.Open function self:Open(container, doer, boatwidget) oldOpen(self, container, doer, boatwidget) local boatbadge = self.boatbadge if self.boatbadge.bg then local boatbadge_bg = self.boatbadge.bg:GetPosition() local boatbadge_num = self.boatbadge.num:GetPosition() self.boatbadge.bg:SetPosition(boatbadge_bg.x, boatbadge_bg.y + 79, 0) self.boatbadge.num:SetPosition(boatbadge_num.x, boatbadge_num.y + 79, 0) self.boatbadge.num:SetScale(.8,.6,0) end end end if _G.IsDLCEnabled(_G.CAPY_DLC) then AddClassPostConstruct("widgets/containerwidget", BoatBadgeFix) end -- -- Controller Status Display Fix local function StatusDisplayNumFix(self) local oldCloseControllerInventory = self.CloseControllerInventory function self:CloseControllerInventory() oldCloseControllerInventory(self) self.controls:ShowStatusNumbers() end end local RPGActive = false for _, moddir in ipairs(_G.KnownModIndex:GetModsToLoad()) do if _G.KnownModIndex:GetModInfo(moddir).name == "RPG HUD" then RPGActive = true elseif _G.KnownModIndex:GetModInfo(moddir).name == "RPG HUD Neat" then RPGActive = true end end if not RPGActive then AddClassPostConstruct("screens/playerhud", StatusDisplayNumFix) end -- -- Wetness Badge local Text = _G.require "widgets/text" local function MoistureBadgeFix(self) self:SetScale(.8,.8,1) self.bg = self:AddChild(_G.Image("images/status_bg.xml", "status_bg.tex")) self.bg:SetScale(.4,.43,0) self.bg:SetPosition(-.5,-25,0) self.bg:Hide() self.num:Kill() self.num = self:AddChild(Text(_G.NUMBERFONT, 28)) self.num:SetHAlign(_G.ANCHOR_MIDDLE) self.num:SetPosition(3.5, -40, 0) self.num:SetScale(1,.78,1) self.num:SetClickable(false) self.num:Hide() local oldOnLoseFocus = self.OnLoseFocus function self:OnLoseFocus() oldOnLoseFocus(self) self.num:Show() end local oldActivate = self.Activate function self:Activate() oldActivate(self) self.num:Show() self.bg:Show() end local oldDeactivate = self.Deactivate function self:Deactivate() oldDeactivate(self) self.num:Hide() self.bg:Hide() end end if _G.IsDLCEnabled(_G.REIGN_OF_GIANTS) or _G.IsDLCEnabled(_G.CAPY_DLC) then AddClassPostConstruct("widgets/moisturemeter", MoistureBadgeFix) end --