Gigadroid Posted March 29, 2016 Share Posted March 29, 2016 (edited) Hey all! I've encountered a problem with the mod TweakThoseTools, Tweaked. Armor can't VISUALLY break (still equipped while damage reduction is no longer applied). This mod changes how durability is consumed, rather than changing max durability (which then affects Sewing Kit and whatnot), which I think is pretty interesting. Things to know: modmain adds a prefab depending on type of item. E.G.: Spoiler function AddArmorTag(inst) -- Sets up the Tagging function for Armors inst:AddTag("TweakArmor") end AddPrefabPostInit("armor_sanity", AddArmorTag) AddPrefabPostInit("armordragonfly", AddArmorTag) AddPrefabPostInit("armorgrass", AddArmorTag) AddPrefabPostInit("armorlimestone", AddArmorTag) AddPrefabPostInit("armormarble", AddArmorTag) AddPrefabPostInit("armorobsidian", AddArmorTag) AddPrefabPostInit("armorruins", AddArmorTag) AddPrefabPostInit("armorseashell", AddArmorTag) AddPrefabPostInit("armorsnurtleshell", AddArmorTag) AddPrefabPostInit("armorwood", AddArmorTag) AddPrefabPostInit("beefalo_hide", AddArmorTag) AddPrefabPostInit("beehat", AddArmorTag) AddPrefabPostInit("footballhat", AddArmorTag) AddPrefabPostInit("ruinshat", AddArmorTag) AddPrefabPostInit("slurtlehat", AddArmorTag) AddPrefabPostInit("wathgrithrhat", AddArmorTag) Then, the specific armor.lua parts handles the modinfo settings: Spoiler function Armor:SetCondition(amount) self.condition = amount self.inst:PushEvent("percentusedchange", {percent = self:GetPercent()}) if self.condition <= 0 then self.condition = 0 ProfileStatsSet("armor_broke_" .. self.inst.prefab, true) ProfileStatsSet("armor", self.inst.prefab) if METRICS_ENABLED then FightStat_BrokenArmor(self.inst.prefab) end if self.onfinished then self.onfinished() end self.inst:Remove() end end . . . . . . . function Armor:TakeDamage(damage_amount, attacker, weapon) if self:CanResist(attacker, weapon) then local leftover = damage_amount local max_absorbed = damage_amount * self.absorb_percent; local absorbed = math.floor(math.min(max_absorbed, self.condition)) leftover = damage_amount - absorbed ProfileStatsAdd("armor_absorb", absorbed) if METRICS_ENABLED then FightStat_Absorb(absorbed) end --[[MODNOTE: This section deals with the update math, which is where tweak will be applied]]-- --[[self:SetCondition(self.condition - absorbed)]]-- Original Text for this section --[[Get the tags for the item currently being processed, and change our variable to match]]-- local DURABILITYSETTING = "Default" if self.inst:HasTag("TweakClothes") then DURABILITYSETTING = CLOTHING_DURABILITY elseif self.inst:HasTag("TweakWeapon") then DURABILITYSETTING = WEAPON_DURABILITY elseif self.inst:HasTag("TweakStaff") then DURABILITYSETTING = STAFF_DURABILITY elseif self.inst:HasTag("TweakAmulet") then DURABILITYSETTING = AMULET_DURABILITY elseif self.inst:HasTag("TweakTool") then DURABILITYSETTING = TOOL_DURABILITY elseif self.inst:HasTag("TweakGold") then DURABILITYSETTING = GOLD_DURABILITY elseif self.inst:HasTag("TweakTrap") then DURABILITYSETTING = TRAP_DURABILITY elseif self.inst:HasTag("TweakArmor") then DURABILITYSETTING = ARMOR_DURABILITY elseif self.inst:HasTag("TweakLight") then DURABILITYSETTING = LIGHT_DURABILITY elseif self.inst:HasTag("TweakCamping") then DURABILITYSETTING = CAMPING_DURABILITY elseif self.inst:HasTag("TweakBook") then DURABILITYSETTING = BOOK_DURABILITY elseif self.inst:HasTag("TweakJerky") then DURABILITYSETTING = FOOD_PRESERVATION elseif self.inst:HasTag("TweakFood") then DURABILITYSETTING = FOOD_PRESERVATION elseif self.inst:HasTag("TweakBoat") then DURABILITYSETTING = BOAT_DURABILITY end if DURABILITYSETTING ~= "Default" then if DURABILITYSETTING == "Infinite" then self:SetCondition(self.condition) else self:SetCondition(self.condition - (absorbed / DURABILITYSETTING)) end else self:SetCondition(self.condition - absorbed) end ModDeBug(self.inst,self.condition) --[[MODNOTE: Send Debug Message as requested by mod]]-- --[[MODNOTE: End of Modded Section]]-- if self.ontakedamage then self.ontakedamage(self.inst, damage_amount, absorbed, leftover) end if self.absorb_percent >= 1 then return 0 end return leftover else return damage_amount end end Just to be sure I checked finiteuses.lua too: Spoiler function FiniteUses:SetUses(val) local was_positive = self.current > 0 self.current = val self.inst:PushEvent("percentusedchange", {percent = self:GetPercent()}) if self.current <= 0 then self.current = 0 if was_positive and self.onfinished then self.onfinished(self.inst) end end end function FiniteUses:GetUses() return self.current end function FiniteUses:Use(num) --[[MODNOTE: This section deals with the update math, which is where tweak will be applied]]-- --[[self:SetUses(self.current - (num or 1))]]-- Original Text for this section --[[Get the tags for the item currently being processed, and change our variable to match]]-- local DURABILITYSETTING = "Default" if self.inst:HasTag("TweakClothes") then DURABILITYSETTING = CLOTHING_DURABILITY elseif self.inst:HasTag("TweakWeapon") then DURABILITYSETTING = WEAPON_DURABILITY elseif self.inst:HasTag("TweakStaff") then DURABILITYSETTING = STAFF_DURABILITY elseif self.inst:HasTag("TweakAmulet") then DURABILITYSETTING = AMULET_DURABILITY elseif self.inst:HasTag("TweakTool") then DURABILITYSETTING = TOOL_DURABILITY elseif self.inst:HasTag("TweakGold") then DURABILITYSETTING = GOLD_DURABILITY elseif self.inst:HasTag("TweakTrap") then DURABILITYSETTING = TRAP_DURABILITY elseif self.inst:HasTag("TweakArmor") then DURABILITYSETTING = ARMOR_DURABILITY elseif self.inst:HasTag("TweakLight") then DURABILITYSETTING = LIGHT_DURABILITY elseif self.inst:HasTag("TweakCamping") then DURABILITYSETTING = CAMPING_DURABILITY elseif self.inst:HasTag("TweakBook") then DURABILITYSETTING = BOOK_DURABILITY elseif self.inst:HasTag("TweakJerky") then DURABILITYSETTING = FOOD_PRESERVATION elseif self.inst:HasTag("TweakFood") then DURABILITYSETTING = FOOD_PRESERVATION elseif self.inst:HasTag("TweakBoat") then DURABILITYSETTING = BOAT_DURABILITY end if DURABILITYSETTING ~= "Default" then if DURABILITYSETTING == "Infinite" then self:SetUses(self.current) else self:SetUses(self.current - ((num or 1) / DURABILITYSETTING)) end else self:SetUses(self.current - (num or 1)) end ModDeBug(self.inst,self.current) --[[MODNOTE: Send Debug Message as requested by mod]]-- --[[MODNOTE: End of Modded Section]]-- end But I can't seem to find the issue. The armor will just stay at 1% and never break. It doesn't reduce incoming damage also. Can someone please lend a hand? EDIT: Could it be how the mod reduces durability consumption? As in if it is less than one, it can't break. More specifically, in finiteuses.lua: if DURABILITYSETTING ~= "Default" then if DURABILITYSETTING == "Infinite" then self:SetUses(self.current) else self:SetUses(self.current - ((num or 1) / DURABILITYSETTING)) end else self:SetUses(self.current - (num or 1)) end However, I couldn't find any function that handles armor breaking. So I still need help haha Help is very much appreciated. Edited March 29, 2016 by Gigadroid Link to comment https://forums.kleientertainment.com/forums/topic/65866-help-tweakthosetools-unbreakable-armor/ Share on other sites More sharing options...
Mobbstar Posted March 29, 2016 Share Posted March 29, 2016 It doesn't block much damage anymore because its durability is too low. You should contact the mod author about this. By the way, armour does not use finiteuses at all. Link to comment https://forums.kleientertainment.com/forums/topic/65866-help-tweakthosetools-unbreakable-armor/#findComment-740616 Share on other sites More sharing options...
Gigadroid Posted March 29, 2016 Author Share Posted March 29, 2016 (edited) You're referring to this little snippet of code, right? if DURABILITYSETTING ~= "Default" then if DURABILITYSETTING == "Infinite" then self:SetCondition(self.condition) else self:SetCondition(self.condition - (absorbed / DURABILITYSETTING)) end else self:SetCondition(self.condition - absorbed) end But that still doesn't explain why the armor won't break, does it? Edited March 29, 2016 by Gigadroid Link to comment https://forums.kleientertainment.com/forums/topic/65866-help-tweakthosetools-unbreakable-armor/#findComment-740663 Share on other sites More sharing options...
Mobbstar Posted March 29, 2016 Share Posted March 29, 2016 23 minutes ago, Gigadroid said: But that still doesn't explain why the armor won't break, does it? The function "SetCondition" handles this. Check your settings, what modifier are you using? Link to comment https://forums.kleientertainment.com/forums/topic/65866-help-tweakthosetools-unbreakable-armor/#findComment-740667 Share on other sites More sharing options...
Gigadroid Posted March 29, 2016 Author Share Posted March 29, 2016 Just now, Mobbstar said: The function "SetCondition" handles this. Check your settings, what modifier are you using? Ah yeah I saw that too. Figuring out how it works now. I've been using 300% durability which sends data = 3. Link to comment https://forums.kleientertainment.com/forums/topic/65866-help-tweakthosetools-unbreakable-armor/#findComment-740668 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now