Equipment Durability

Turns out it was as simple as I initially thought, I just didn't take everything into consideration. The following will allow both the skill durability cost mod and the actual skill costs to be decimals. I haven't had any issues so far. If you need anything else changed to floats let me know, the only thing left I can think of atm would be max durability.

Code:
class RPG::Weapon  def skill_durability_mod(skill_id)    if @skill_durability_mod.nil?      @skill_durability_mod = []      $data_skills.each do |i|        next unless i        if @note =~ /<skill[-_ ]?durability[-_ ]?mod[-_ ]?#{i.id.to_s}:\s*(.*)\s*>/i          @skill_durability_mod[i.id] = $1.to_f        else          @skill_durability_mod[i.id] = 0.0        end      end    end    @skill_durability_mod[skill_id]  endendclass RPG::Skill  def weapon_durability_cost    @note =~ /<durability[-_ ]?cost:\s*(.*)\s*>/i ? @durability_cost = $1.to_f : @durability_cost = TH_Instance::Weapon::Default_Durability_Cost.to_f if @durability_cost.nil?    @durability_cost  endend
Everything is great! To make the max durability a decimal would only show bigger settings, it's the opposite of what I'm wanting. Thank you very much, Selchar!
Have you considered something like Fire Emblem Awakening's Armthrift skill where a passive skill or even an accessory can sometimes prevent equipment from losing durability?
Awakening... haven't played that one.  Equipment that can add a chance to avoid reducing Weapon Durability can easily be done I think.  A passive skill that does the same?  It's possible(makes a note to look at how passive skills can be done)

Edit: And done, check the 1st post, or just click the following.

https://drive.google.com/file/d/0BywhvOtY4_H9X0E4WTBaaU1pVzA/edit?usp=sharing
So, I'm having issues with the script...

No, it works, durability works as it should, all items are counted as different entries in the inventory, but my issue is: the script keeps crashing the game I'm working on whenever I'm going to sell items with the Galv Shopping script.

Is there a patch I'm missing? Is it an compatibility issue? Is there an simple fix I haven't seen?

Edit: Also, every single time I use an item(like a potion or something) it crashes the game.
I've look at your Armthrift script, and it seems you forgot to add a method in the skills class which you call in Game_Battler.
Sorry for reviving this, but does anyone know how to make the broken weapon change occur within battle?

You can set an item whose durability has reached 0 to change to another weapon (such as a broken sword), but I've set it up so that a sword switches between three forms whenever the durability runs out. However, when it reaches 0 in battle, the battler has no weapon in combat. (The next form in line does appear in the inventory though, but not equipped)
When i try to use  Tsukihime's Item Instance i get this message: Script 'Game_Party' line103: NoMethodError occured. undefined method '+' for nil:NilClass

How do i fix this?
Hey this is an awesome script, way to go! I was just wondering if there was any way to use an armor's durability in and if statement inside of an event.

For example If body slot armor is 5 then display an image.

Basicly, I have an image of the main character and when they're armor gets damaged I want to use an event to change thier picture to reflect the look of damaged armor
Hi Selchar,

You sir are amazing. I can totally rely on you to make awesome scripts!

I found a possible bug, Seems like Armor Durability doesn't work for anything but the default slots, (i.e. Yanfly's Equip Engine)

When I add more than the default slots it doesn't register it. (It might be an instance item issue too)

Anyway here is some screenshots of my database:

http://i.imgur.com/ysP3f6S.png <-- an example of notetagged correctly.

http://i.imgur.com/carPiso.png < -- another example of notetagged correctly

http://i.imgur.com/HoNgaf2.png <-- yet another example of notetagged correctly (but with a yanfly equip notetag)

Equip Screen:

http://i.imgur.com/NqteV5G.png 

As you can see in the equip screen the bronze gauntlets (along with the sabatons and cloak) doesn't have a durability even though I set it to have some. yet the other ones have durability.

Any ideas how to fix this? Even if you don't have the time to fix it, if you point me in the right direction I can try my hand at "franken-coding" 😀
Yanfly's Equip Engine correct?  Also you're equipping them using the notetag <starting gear: x>?  If so then it looks like a slight compatibility problem between it and Tsukihime's Instance Items.  If you unequip/reequip them you'll see the durability.  My guess is that at first you are seeing actual Template Items(non-instances).  Unequipping hides them and adds an instance into your inventory(I think).  There are two ways to solve it.

1: Eventing: manually add them to your inventory and equip them.

2: Slightly modify the method used by Yanfly's script.  You can add the following below Yanfly's script and it should fix the problem.

Code:
class Game_Actor < Game_Battler  def equip_extra_starting_equips    for equip_id in actor.extra_starting_equips      armour = $data_armors[equip_id]      next if armour.nil?      etype_id = armour.etype_id      next unless equip_slots.include?(etype_id)      slot_id = empty_slot(etype_id)      #@equips[slot_id].set_equip(etype_id == 0, armour.id) #Original Line, the following is new      $game_party.gain_item(armour, 1)      change_equip(slot_id, armour)    end    refresh  endend
For the line you commented out, you could say

@equips[slot_id].set_equip(etype_id == 0, InstanceManager.get_instance(armour).id)Or, instead of replacing the code, I would do the same as what I did with my "check instances"

Code:
class Game_Actor < Game_Battler    alias :th_instance_items_equip_extra_starting_equips :equip_extra_starting_equips  def equip_extra_starting_equips    check_extra_instance_equips    th_instance_items_equip_extra_starting_equips  end    def check_extra_instance_equips    new_equips = []    actor.extra_starting_equips.each do |equip_id|      armour = $data_armors[equip_id]      next if armour.nil?      etype_id = armour.etype_id      next unless equip_slots.include?(etype_id)      new_armour = InstanceManager.get_instance(armour)            new_equips << new_armour.id    end    actor.extra_starting_equips = new_equips  endend
You're replacing the extra starting equips...but that SHOULDN'T be too much of a problem I think.I will include one of these fixes as a patch on the instance items page as well.

The first approach is correct (the one you used and my alternative) since you're just creating an instance out of a template. The second approach requires further testing.
Thank you both, it works awesomely now. 🙂
Related but unrelated to this script, I sent you a PM Selchar. Tell me what you think about it.
If you were hit by a low sweep or mid slash, how would that affect your iron helm's durability, just as how would a punch affect your iron boots' durability?

What if there were an inclusion/exclusion list, where you specify, say, what attacks do affect the armor's durability, say if you're using a high/low/mid/all system?

Wait, there's the element rate for this script.
If you were hit by a low sweep or mid slash, how would that affect your iron helm's durability, just as how would a punch affect your iron boots' durability?

What if there were an inclusion/exclusion list, where you specify, say, what attacks do affect the armor's durability, say if you're using a high/low/mid/all system?

Wait, there's the element rate for this script.
It still is a good idea. Having different hit places, instead of a random mechanism. What do you mean element rate for this script?
Meaning that you can affect percentage chance at which a skill damages your durability. So you could set the chance to have your helm's durability damaged by skills of the "Low" element to zero. I am not sure how this function works with the multiple-element scripts (which I do use), but I will be testing it out.
I've been looking at this script, and it seems to work pretty well, but would it be possible to damage a weapon outside of combat somehow (probably with a script call)? I have been trying to find a way, but I can't seem to get it to work.

EDIT: I got it to work with this:

equip = $game_actors[1].equips[0]equip.durability -= 1But it doesn't update the suffix in the menu. It updates after I go into battle, however, and by setting a variable to equip.durability I figured out that it is working. Also, the weapon won't break. If I add:

if equip.durability <= 0 equip.durability = 0 equip.break_by_durability($game_actors[1])endIt gives a no mothod error, saying "undefined method 'log_window'". I'm guessing this is because it's not in battle, but I'm not sure.
How would you use the <skill durability mod> tag? I think I'm doing something wrong.

Do I put the tag in the weapon or the skill?
How would you use the <skill durability mod> tag? I think I'm doing something wrong.

Do I put the tag in the weapon or the skill?
Nevermind, figured it out.

Original thread: https://forums.rpgmakerweb.com/threads/equipment-durability.22011/