tModLoader Durability

  • Fixed crash bug.
  • Lowered durability for Demonite, Crimtane, and Hallowed tiers.
  • Added manual durability adjustments for specific items via. config file.
  • Added numeric display of durability.
 

Attachments

  • Durability v1.9.0.zip
    16.8 KB · Views: 188
Screen shot of the new system ?
9xjlWnq.jpg

8aT2p
 
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
 
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.
 
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;
        }
    }
 
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:
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...
 
v2.0.0
  • Repairs degrade max durability
  • Smithing hammer rebalanced
  • Valueless items given improved formula for value.
  • Config option to hide bar.
 

Attachments

  • Durability v2.0.0.zip
    17.1 KB · Views: 207
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

  • Durability v2.1.0.zip
    30.9 KB · Views: 194
  • Durability v2.1.1.zip
    30.9 KB · Views: 203
  • Durability v2.2.0.1.zip
    31.3 KB · Views: 211
  • Durability v2.3.0.zip
    44.9 KB · Views: 191
  • Durability v2.3.1.zip
    44.6 KB · Views: 179
Last edited:
Back
Top Bottom