• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader Durability

Michelangelo42

Terrarian
so far I really enjoy the mod but would it be possible if you could modify the durability to take into account the usetime? weapons that hit really fast just break so quickly
 

Michelangelo42

Terrarian
I also have a ew other ideas...

1) a blacksmith npc that can fix weapons which would cost more depending on how much durability lost and it would cost a bit more then using the tinkerer
2) cange the font color to black. trying to read white 6point font on a light green bar is difficult.
 

hamstar

Steampunker
so far I really enjoy the mod but would it be possible if you could modify the durability to take into account the usetime? weapons that hit really fast just break so quickly
Well, this is what I currently use in consideration of this:
Code:
public void Use( Item item, int hits = 1, double scale_override = 0d ) {
    if( !this.HasDurability( item ) || this.ConcurrentUses >= DurabilityItemInfo.MaxConcurrentUses ) { return; }

    ConfigurationData data = DurabilityMod.Config.Data;
    double wear = (double)hits * (double)data.WearMultiplier;
    int max = DurabilityItemInfo.CalculateWearAndTear( item );

    // If we're not using a pick, scale according to use time (supplements item.value)
    if( scale_override == 0 ) {
        if( ItemHelper.IsPenetratorMelee(item) ) {
            scale_override = 1d;
        } else {
            scale_override = (double)ItemHelper.CalculateStandardUseTime( item ) / 16d;
            scale_override = scale_override <= 0d ? 1d : scale_override;
        }
    }
    wear *= scale_override;

    this.WearAndTear += wear;
    this.ConcurrentUses++;
    this.RecentUseDisplayBarAnimate = 8;

    if( this.WearAndTear >= max ) {
        this.WearAndTear = max;
        this.KillMe( item );
    }
}
And:
Code:
    public static class ItemHelper {
        // ...
        
        private static IDictionary<int, int> ProjPene = new Dictionary<int, int>();

        public static bool IsPenetratorMelee( Item item ) {
            if( item.shoot <= 0 ) { return false; }

            if( !ItemHelper.ProjPene.Keys.Contains( item.shoot ) ) {
                var proj = new Projectile();
                proj.SetDefaults( item.shoot );
                ItemHelper.ProjPene[item.shoot] = proj.penetrate;
            }

            return ItemHelper.ProjPene[item.shoot] == -1 || ItemHelper.ProjPene[item.shoot] >= 3;   // 3 seems fair?
        }


        public static int CalculateStandardUseTime( Item item ) {
            int use_time;

            // No exact science for this one
            if( item.melee ) {
                use_time = item.useAnimation;
            } else {
                use_time = item.useTime;
                if( item.reuseDelay > 0 ) { use_time = (use_time + item.reuseDelay) / 2; }

                if( item.useTime <= 0 || item.useTime == 100 ) {    // 100 = default amount
                    if( item.useAnimation > 0 && item.useAnimation != 100 ) {   // 100 = default amount
                        use_time = item.useAnimation;
                    }
                }
            }

            return use_time;
        }
    }
 

Michelangelo42

Terrarian
ok that makes sense.

I also noticed that there is no way to fix armor... its kind of annoying because armor will cost a lot of material and they end up breaking so fast.... for instance a set of iron is gone after only 400 damage and with way to fix it that's 75 iron gone.

Correction. the only way to fix armor is with using magic dice from the Enemies with Prefixes mod
 
Last edited:

Michelangelo42

Terrarian
Well, this is what I currently use in consideration of this:
Code:
public void Use( Item item, int hits = 1, double scale_override = 0d ) {
    if( !this.HasDurability( item ) || this.ConcurrentUses >= DurabilityItemInfo.MaxConcurrentUses ) { return; }

    ConfigurationData data = DurabilityMod.Config.Data;
    double wear = (double)hits * (double)data.WearMultiplier;
    int max = DurabilityItemInfo.CalculateWearAndTear( item );

    // If we're not using a pick, scale according to use time (supplements item.value)
    if( scale_override == 0 ) {
        if( ItemHelper.IsPenetratorMelee(item) ) {
            scale_override = 1d;
        } else {
            scale_override = (double)ItemHelper.CalculateStandardUseTime( item ) / 16d;
            scale_override = scale_override <= 0d ? 1d : scale_override;
        }
    }
    wear *= scale_override;

    this.WearAndTear += wear;
    this.ConcurrentUses++;
    this.RecentUseDisplayBarAnimate = 8;

    if( this.WearAndTear >= max ) {
        this.WearAndTear = max;
        this.KillMe( item );
    }
}
And:
Code:
    public static class ItemHelper {
        // ...
       
        private static IDictionary<int, int> ProjPene = new Dictionary<int, int>();

        public static bool IsPenetratorMelee( Item item ) {
            if( item.shoot <= 0 ) { return false; }

            if( !ItemHelper.ProjPene.Keys.Contains( item.shoot ) ) {
                var proj = new Projectile();
                proj.SetDefaults( item.shoot );
                ItemHelper.ProjPene[item.shoot] = proj.penetrate;
            }

            return ItemHelper.ProjPene[item.shoot] == -1 || ItemHelper.ProjPene[item.shoot] >= 3;   // 3 seems fair?
        }


        public static int CalculateStandardUseTime( Item item ) {
            int use_time;

            // No exact science for this one
            if( item.melee ) {
                use_time = item.useAnimation;
            } else {
                use_time = item.useTime;
                if( item.reuseDelay > 0 ) { use_time = (use_time + item.reuseDelay) / 2; }

                if( item.useTime <= 0 || item.useTime == 100 ) {    // 100 = default amount
                    if( item.useAnimation > 0 && item.useAnimation != 100 ) {   // 100 = default amount
                        use_time = item.useAnimation;
                    }
                }
            }

            return use_time;
        }
    }
never mind i just relized you can but a smithing hammer to fix armor...
 

hamstar

Steampunker
Special note: Compatibility issues might exist with mods that make use of non-standard item use times (Weapons Out?), or else implement items that aren't deterministic in their base stats (e.g. value, use time, damage, defense).

v2.1.0

  • Changed durability formula to factor in use time.
  • Added simple audio + text cue for items that are about to break.
  • Improved durability display for inventory items.
  • Added new config settings.
  • Added new config presets for special-case items.
  • Fixed certain items being handled incorrectly (harpoons, projectile-casting swords, summon items, magic items with no mana, etc.)
  • Removed meteor drop limit.
  • Config file relocated to Mod Configs subfolder.
  • Numerous bug fixes and code improvements (special thanks to Dark-Assassin's mod fork DurabilityX).

Edit:

v2.1.1

  • Fixed mouse item critical durability warning spam.
Edit Edit:

v2.2.0.1
  • Fixed repairs not saving with item
  • Added tooltip for items with max durability loss
  • Tweaked various config settings
  • Disabled repair recipes when at full durability
  • Removed old config if present ("Durability 1.6.0.json")
  • Altered durability formula: 0.71 * ( (y/4 * x^1.54) / (5 + x) ) + 50
Edit x3:

v2.3.0
  • Modified fishing durability use (catches only)
  • Set ore weapons to have higher durability (except bows/repeaters)
  • Increased durability formula's exponent value
  • Normalized some custom durability adjustments (especially meteor)
  • Armor gives low durability warnings
Edit x4:

v2.3.1
  • Added 'Enabled' config setting (allows disabling mod without unloading)
 

Attachments

Last edited:
Top Bottom