Implement "Not A Picky Eater" trait functionality
- Rename "Unpicky Eater" to "Not a Picky Eater" - Wrap around the `ISEatFoodAction:perform` and `ISToolTipInv:render` methods, adjusting unhappiness and boredom increase if the trait is present. - Reorganize files
This commit is contained in:
parent
cd53ab1a34
commit
da7344d749
4 changed files with 44 additions and 17 deletions
39
media/lua/client/DogFoodIsntThatBad.lua
Normal file
39
media/lua/client/DogFoodIsntThatBad.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
local base_perform = ISEatFoodAction.perform
|
||||
|
||||
function ISEatFoodAction:perform()
|
||||
if getPlayer():getTraits():contains("NotAPickyEater") then
|
||||
self.item:setUnhappyChange(math.min(self.item:getUnhappyChange(), 0))
|
||||
self.item:setBoredomChange(math.min(self.item:getBoredomChange(), 0))
|
||||
print("NotAPickyEater trait active, removing negative effects from food") -- DEBUG
|
||||
end
|
||||
base_perform(self)
|
||||
end
|
||||
|
||||
local base_tooltip_render = ISToolTipInv.render
|
||||
|
||||
function ISToolTipInv:render()
|
||||
local unhappyChange = self.item:getUnhappyChange()
|
||||
local boredomChange = self.item:getBoredomChange()
|
||||
if getPlayer():getTraits():contains("NotAPickyEater") then
|
||||
self.item:setUnhappyChange(math.min(unhappyChange, 0))
|
||||
self.item:setBoredomChange(math.min(boredomChange, 0))
|
||||
end
|
||||
base_tooltip_render(self)
|
||||
if getPlayer():getTraits():contains("NotAPickyEater") then
|
||||
self.item:setUnhappyChange(unhappyChange)
|
||||
self.item:setBoredomChange(boredomChange)
|
||||
end
|
||||
end
|
||||
|
||||
local function initTraits()
|
||||
TraitFactory.addTrait(
|
||||
"NotAPickyEater",
|
||||
getText("UI_trait_NotAPickyEater"),
|
||||
-1,
|
||||
getText("UI_trait_NotAPickyEater_description"),
|
||||
false,
|
||||
false
|
||||
)
|
||||
end
|
||||
|
||||
Events.OnGameBoot.Add(initTraits)
|
||||
Loading…
Add table
Add a link
Reference in a new issue