Jump to content

[SOLVED] How to make tools break faster while also destroying resources faster

Recommended Posts

Hopefully the title makes sense. What I'm trying to do with my mod character is make it so he breaks tools faster but he chops trees, mines rocks etc. faster as well because he is very strong and easily breaks man-made and organic materials. I took code from Wigfrid's durability Battlesong and tried to modify it to make it so that tools broke faster but trees fell and rocks broke with like half the uses, however I am getting crashes, the most recent crash being this:


Now I understand that the "weapon" component isn't going to work, but I don't know what to change to make it work. The most recent crash happens when I unequip a tool, oddly. Plus I am not even getting the effect I want.

Here is the code I currently have as well as my character's .lua file attached.

inst:ListenForEvent("equip", function(data)
    if data.eslot == EQUIPSLOTS.HANDS then
        inst.components.weapon.attackwearmultipliers:SetModifier(inst, TUNING.GARAMONDE_DURABILITY_MOD)

inst:ListenForEvent("unequip", function(target, data)
    if data.eslot == EQUIPSLOTS.HANDS then
        inst.components.weapon.attackwearmultipliers:RemoveModifier(inst, TUNING.GARAMONDE_DURABILITY_MOD)

Thanks in advance!


Edited by Garamonde
Link to comment
Share on other sites

use my mod as example:

search for the line "AddComponentPostInit("finiteuses",function(self) -- unlimited weapons/tools" to change the duration only for your prefab. My code changes it for everything with "finiteuses" so also weapons. If you dont wan to change weapons you need to add an if condition to catch all weapons.
Depending on the modsettings the duration can be unlimted, but it can also be higher/less than default.

And for faster work (less needed hits), you can do in your postinit of your character this:
inst.components.workmultiplier:AddMultiplier(GLOBAL.ACTIONS.CHOP, multiplier, "your_unique_naming")

Edited by Serpens
  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...