Selchar's Durability modification

Good afternoon. Hi, I am currently using Selchar Durability script and, essentially, the way the script works is that every time you land a successful hit, it takes durability off the weapon. While the script works as intended, I wanted to ask for assistance as, they way I want to implement it, is that it takes durability when the attack misses or the target evades as well, not only when it lands a successful hit.

I know very few about programming, but like most people working in RPG Maker project I believe, after a while, you get some very basic understanding, which lead me to try to modify the script a bit, specifically, this part:
Spoiler: Modification
#=============================================================================== # On Successful Damage #=============================================================================== alias :process_weapon_durability_mdv :make_damage_value def make_damage_value(user, item) process_weapon_durability_mdv(user, item) user.process_weapon_durability(item) if user.actor? && @result.missed user.process_weapon_durability(item) if user.actor? && @result.evaded user.process_weapon_durability(item) if user.actor? && @result.hit? end
I only added the parts in blue and modified nothing else, it did work, durability started to be reduced by missed chances as well, but after a while, it sort of reverted back to normal for some reason, and stopped reducing durability after missed chances. Is there a more "Permanent" solution to this issue?
First of all, it sounds way better to say that you don't know much about programming. I speak Spanish as well so I did notice that little detail in no time. Poco isn't always translated as few as you first thought.

Talking about details here, if you want something to ALWAYS happen, why do you even bother adding a condition at all?

Just add this:

Ruby:
user.process_weapon_durability(item) if user.actor?

actor? is the only question you should ask at that moment for your enemies never equipped any weapon of sorts.
Moved to: RGSSx Script Support

Your link in the first post doesn't work, and your code has been reformatted because you didn't use code tags. Can you please edit your post and fix both?
First of all, it sounds way better to say that you don't know much about programming. I speak Spanish as well so I did notice that little detail in no time. Poco isn't always translated as few as you first thought.

Talking about details here, if you want something to ALWAYS happen, why do you even bother adding a condition at all?

Just add this:

Ruby:
user.process_weapon_durability(item) if user.actor?

actor? is the only question you should ask at that moment for your enemies never equipped any weapon of sorts.
Actually I already tried that, but with no success. If you leave only "user.actor?", it throws an error at the very moment you start the game, because of that, and, the fact I dont really have much knowledge in scripting, I assumed that removing "If" was an obvious mistake, reason why I didnt mention that in the post. Also, again, not being an expert in scripting, I would assume that your solution would kind of keep the script working essentially the same (if it werent by the fact that the game crashes immediately) as, given how the script currently works, it seems everything starts once you do damage, I assume that because the snippet I shared starts with "def make_damage_value(user, item)", which lead me to think that, rather than removing parts, you would need to add other conditions (evasion and missed). Anyways, if anyone could assist I would appreciate.

@Shaz Will do.
Actually I already tried that, but with no success. If you leave only "user.actor?", it throws an error at the very moment you start the game, because of that, and, the fact I dont really have much knowledge in scripting, I assumed that removing "If" was an obvious mistake, reason why I didnt mention that in the post. Also, again, not being an expert in scripting, I would assume that your solution would kind of keep the script working essentially the same (if it werent by the fact that the game crashes immediately) as, given how the script currently works, it seems everything starts once you do damage, I assume that because the snippet I shared starts with "def make_damage_value(user, item)", which lead me to think that, rather than removing parts, you would need to add other conditions (evasion and missed). Anyways, if anyone could assist I would appreciate.

@Shaz Will do.

At the moment you start the game!?
What the heck did you do there? That's not even supposed to happen!
Are your heroes taking damage right aftert they show up on the map?
Or as soon as they pick a fight!?
I mean, unless you triggered a battle processing scene or used some healing skill or item or map poisoning is in effect or anything the like, that's not supposed to happen.
At the moment you start the game!?
What the heck did you do there? That's not even supposed to happen!
Are your heroes taking damage right aftert they show up on the map?
Or as soon as they pick a fight!?
I mean, unless you triggered a battle processing scene or used some healing skill or item or map poisoning is in effect or anything the like, that's not supposed to happen.
I repeat, for the third or fourth time, I am far from being an expert scripting, the fact is, your proposal does not work, why? I don't know, it makes the game crash at the very beginning, that is the reason why I came here looking for assistance:
1) I am not an scripter.
2) The most logical solutions, and the ones within my limited understanding in scripting, do not work.

Any assistance that could be provided will be appreciated
I suggest you delete the entire script and reload it from the original source, just in case you've accidentally changed something else and are not aware of it. Also, do you have the other required scripts that are mentioned, and are they in the right order?

Play again and make sure you don't get any errors and that the script works as it's meant to.

If you do still get errors, please take a screenshot of the error message. Then go back to the editor, hit F11 and take a screenshot of that window - it should automatically show the script and the line that caused the crash. Post both screenshots so we can take a look.

If you DON'T get any more crashes and the script works correctly, try changing this line
Code:
user.process_weapon_durability(item) if user.actor? && @result.hit?

to this
Code:
user.process_weapon_durability(item) if user.actor? && (@result.hit? || @result.missed || @result.evaded)

and see how it goes.
Actually, create a new project and check if it also crashes. Well, it shouldn't.
It everything works fine, copy files from your current project to that test project. Run it and see if anything goes wrong.

1. The solution I proposed before should have worked unless you did something weird and haven't told us about it. Since you admitted you're no expert on scripting there's a huge possibility you changed or altered something unknowingly.

To be honest, if your project has no custom graphic resources you shouldn't share freely, please post a demo here so we can test it and find the root cause. This would be specially useful if you can't get a chance to take screenshots as Shaz suggested.
I actually have a fix for this, it's for weapons only. Add this as a separate script after the durability scripts.
EDIT: added code tags.

Code:
class Game_Battler < Game_BattlerBase
  alias :process_weapon_durability_miss :item_apply
  def item_apply(user, item)
    process_weapon_durability_miss(user, item)
    user.process_weapon_durability(item) if user.actor? && @result.missed
  end
end
for some weird reason in inserted an emote
because you didn't wrap it in code tags
Thank you all for your help with this, I tried all the solutions offered and this is what I got:

@Shaz: It behaved like the modifications I made initially, so, it worked at the beginning, but then, it just reverted back to normal, without any modification of the script, which really surprises me, because I had never seen a script change the way it behaves without any further modification.

@kyonides : Yeah, in this case I only modified that small part of the script, and actually, tested it several times by removing the script completely, and putting the original back again, modifying only that small part of the script. I read the rest of the script and it seems most of it revolves around the durability itself, not what causes it, and its interaction with Hime's instance items script.

Thanks a lot @cthulhusquid, it worked flawlessly. I have tested it a bit and there doesn't seem to be any issues, working as intended. Thanks again.
I have tested it a bit and there doesn't seem to be any issues, working as intended.
Good to know this works for other people as well.
Good to know this works for other people as well.
Sorry for the late response @Roninator2 , thank you, I assume that you wrote that fix. That issue with Selchar's script not removing durability on failed attacks was a huge issue for me, as I am using it to represent ammo rather than durability, so yeah, skills had to reduce durability regardless if they hit or miss. Thank you again, it really makes a difference

Original thread: https://forums.rpgmakerweb.com/threads/selchars-durability-modification.157470/