Equipment Durability

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Equipment Durability Ver. 1.06
Selchar
Introduction
This script allows for giving weapons and armor durability, and either destroying or just unequiping them when that durability reaches 0.

Features
- Adds Weapon durabilty, reduced with each successful attack/skill
- Adds Armor durabilty, reduced when hit  by chance of your choice.
- Can destroy or just unequip at 0 durability for selling/repairing.

Screenshot
How to Use
Place the script below ▼ Materials, below Tsukihime's Instance Items, but above ▼ Main Process. Use the provided notetags to designate which weapons use durability feature.

Script
>Required<
Weapon Durability
Armor Durability
 
Repair Equip Scene
 
Weapon Durability Armthrift Rate

FAQ
Q: What are the terms of use?
A: My terms are, anything goes, while the terms for Tsukihime's scripts can be found here

Credit and Thanks
- Selchar
- Tsukihime for the Instance Items Base

Updates
1/7/14: Added notetag to transform 0 durability equip into something else when destroy_broken_weapon is false.
1/8/14: Moved some methods, small change to weapon break message.
1/11/14: Improved Flexibility of code, added <skill durability mod x: y> notetag, adjusted price based on durability
1/12/14: Fixed durability prices when leveling weapon.
1/16/14: Compatibility with new Instance Items, Add Armor Durability, add Repair Equip Scene
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,562
Reaction score
3,832
First Language
English
https://github.com/Hime-Works/Requests/issues/83

This request can possibly be filled using this script by modifying the way durability is processed and making it more abstract.

The current functionality supported are as follows (there are more, but these are the ones relevant to my suggestion)

1: weapons can have durability

2: weapons can have their own durability costs (undocumented)

Suggestions

Add support for skills to have their own durability costs.

I don't have any thoughts on whether the weapon durability cost and skill durability costs should be combined or not.

The script in its current state basically processes everything related to durability in a single method, which does not allow me to easily add in additional logic.

Personally, I would make it extremely abstract so that each method only has a single responsibility like this, but it may be unnecessary.

Code:
  def process_weapon_durability(item)    return unless can_process_durability?(item)    weapons.each do |wep|      process_weapon_durability(wep, item)    end  end  # I like doing this, because you can't really  # modify the loop up there to add in some extra  # logic before or after certain lines. This is just  # an extra piece of abstraction that allows me to insert  # custom logic before or after it  def process_weapon_durability(weapon, item)    return unless weapon  # I might move this condition into its own method    update_weapon_durability(weapon, item)    # maybe more stuff  end   # Now, this does not really provide much value in terms of flexibility  def update_weapon_durability(weapon, item)    reduce_weapon_durability(weapon, item)    # maybe more stuff  end  # only math related to durability reduction should happen here  def reduce_weapon_durability(weapon, item)    weapon.durability -= get_durability_cost(weapon, item)  end  # only durability calculation should happen here  def get_durability_cost(weapon, item)    weapon.durability_cost  end
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
I'll consider the changes, I was going to get started on updating to durability for all equips, but perhaps that should be given it's own script in favor of overall flexibility, and just improve this one to be more easily extended?

Edit: Not necessary for a separate script because of the <use durability> tag, so I guess I'll be changing this to equipment durability.

Edit: On second thought, going through his request, it's probably for the best to keep them seperate, the armor durability he wants sounds like it would be used at the same time as weapon durability.

I believe skills already have durability costs, it's default to 1 for all skills, which would explain why it decreases even when you guard. I should also do something about renaming conflicts with other scripts that may alter the names, like my equip leveling script, and any affix system that could be implemented. I already updated my equip leveling base with an attempt to pre-empt affix name changes, tho of course it's untested and may change later on.

Edit: Reread the link you provided, I'll think on how to extend durability reduction, the current implementation is rather basic.

UPDATE:

Removed Selchar Module, there is only the TH_Instance module and what's inside that.

Changed method make_max_durability to Repair

Extended process_weapon_durability(item) with the following methods.

Added can_process_weapon_durability(weapon, skill)

Added process_individual_weapon_durability(weapon, skill)

Added weapon_durability_cost(weapon, skill)

Added <skill durability mod x: y> notetag for weapons to modify skill durability costs.

Added Default_Durability_Cost constant, 

Added Price Changes according to durability vs max durability

 

Made modifications to how the name and durability suffix are handled(now compatiable with equip leveling base)

 

Only bugs known related to durability price and leveling up equips, everything else should work.  Kind of rushed that part will look into it.
 
Last edited by a moderator:

harvard1932

Veteran
Veteran
Joined
Nov 29, 2012
Messages
40
Reaction score
10
Primarily Uses
It would be awesome if you can make the durability for equipment dynamic.

LIke: If a weapon didn't have <use durability>. It can be later added with <use durability> so it would be using durability. If that weapon's <use durability> is later remove, then durability would be removed as well.

I think making it this dynamic would be extremely useful; also the reset can make developers make repair function for the item. :)
 

harvard1932

Veteran
Veteran
Joined
Nov 29, 2012
Messages
40
Reaction score
10
Primarily Uses
So yea! The newer version of the script crashes level base script. Because of item name incompatibility
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
There shouldn't be any problems if you have the latest version of both scripts, let met check again in a clean project... Yes, make sure you have the current version of BOTH Durability and Equip Leveling Base.


Edit: I don't see a point in adding durability use sometime after you've acquired a weapon, as for reparing, that is already internally supported. It just needs a scene that allows you to select a piece of equipment and call the repair method, which I'll do after I've made an armor durability version of the script. Oh, I'll have to do a minor update to the repair method to make sure it calls the name update method.
 
Last edited by a moderator:

harvard1932

Veteran
Veteran
Joined
Nov 29, 2012
Messages
40
Reaction score
10
Primarily Uses
Adding durability use sometime after you've acquired a weapon can be used for "broken weapon" function. Like during crafting there is a chance of getting a broken weapon with durability expiration rather than permanent.

Also the de-durability function allows player to make a durability weapon to become permanent, which is a useful function.
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Couldn't you just make 2 copies of the same weapon, one with durability and one without, and have a way of replacing one with the other depending on circumstances? To have a chance of having durability or not doesn't sound like something I should have in the main script, it can be done as an add-on but I'm not sure if it's worth it or not.


Example: You mentioned crafting, you can have the craft script give you the non-durability version on success, or durability version on fail. You can also use crafting to take the durability version and "upgrade" it to the non-durability version. Of course it depends on the crafting script you're using.
 
Last edited by a moderator:

harvard1932

Veteran
Veteran
Joined
Nov 29, 2012
Messages
40
Reaction score
10
Primarily Uses
There isn't a way to replace equipment around like that... And it isn't efficient to have 2 copies of everything
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
As I said it depends on the crafting script you're using. A crafting script takes the components, or ingredients, and replaces them with the result. So it would work perfectly if said crafting script gives you an item based on success or fail. If I add in the ability to randomize the chance of whether or not durability is used, as well as a method to remove it, then I or someone will also have to design a new scene JUST to call the method to remove that durability requirement.


It's possible, but I don't think it is something I'll do myself.
 

harvard1932

Veteran
Veteran
Joined
Nov 29, 2012
Messages
40
Reaction score
10
Primarily Uses
Actually it is much easier.... Because right now if I were to add <use durability> to an item after it is already created. It wouldn't have durability on it.

I just want it so item will get durability on it when I later add <use durability> on the item. 

I think the part to remove the durability can be ignored. 
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Add

class RPG::Weapon attr_accessor :use_durabilityendafter that, you just need a way to access the particular weapon and call the necessary methods. For example this works as a scriptcall for whatever is in actor 1's first equip slot.a = $game_actors[1].equips[0]

a.use_durability = true

a.repair

I won't be making a scene to automate and/or expand it tho.

Edit: You're free to make a request for someone else to make an add-on to this to do what you want exactly.
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Did an update of all of my scripts related to Tsukihime's Instance Items for compatibility and other stuff.  See signature for recommended script order if you use multiple scripts for it.

Also added Armor Durability.  Durability for armor will reduce when you are hit by chance, and you can tag armor with elemental modifiers to manipulate that chance.

Added Durability Equip Repair Scene to go with it all.
 

Kurotsuke

Villager
Member
Joined
Nov 30, 2013
Messages
16
Reaction score
0
First Language
english
Is there a possibility  to damage my weapon/armor or destroy it in an event? It's like this, I wanted an appraise and it failed so It will reduce the durability and can even break the item. .
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
Sounds like you would want a custom scene to select and carry out the appraisal processes, or do you mean appraise a currently equipped equipment?  What would happen on a success?  How much durability would the equipment lose on failure?  A static number or random? Chance of success?  I'm not saying I'll put it together but that is information needed for anyone to tell you if it can be done now, and if so how, or if something custom made needs to be made, either from scratch or using my repair scene as a base to simplify the process.

Edit: Let's throw in appraisal price on the list of things needed to know.
 
Last edited by a moderator:

Kurotsuke

Villager
Member
Joined
Nov 30, 2013
Messages
16
Reaction score
0
First Language
english
Yes, I would like the current equipment to be used as appraisal, let's say I will use the default durability then it will have item-affixes, so I'll make random variable , if the variable is correct there will be +1 , then if it was the wrong variable. . the equipment will lose durability or it will break.

Thank you very much :D

Okay, last request. . . how can I reduce durability my game party leader's equipped weapon/armor? I'll use it in a scene where there was an epic war then the leader's armor and weapon got damaged. . that's all thanks for all the help
 
Last edited by a moderator:

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
So you're going to try and event it through script calls, got it, unless you'd like a scene to select a currently equipped equipment(don't know how to do that at this time.  So if eventing... I'll give you a scriptcall that you can modify to suit your purposes

class Game_Interpreter def appraise_equip(actor_id, slot=0, chance=0.5) equip = $game_actors[actor_id].equips[slot] if rand <= chance #What happens with a success goes here. #set_suffix(equip, 62) #Sets a suffix to your equip, from Tsukihime's Affixes return true else #What happens with failure goes here equip.durability -= rand(10)+1 #(loose between 1 and 10 durability if equip.durability < 0 equip.durability = 0 equip.break_by_durability($game_actors[actor_id]) end return false end endendPlace the above code below my durability script(s), possibly under any other instance related scripts. With it you'd make your event to select which actor based on id, maybe choose which equipment slot. Then call the scriptcall with...
 

a = $game_variables[7] #Whatever variable you set the actor id to.s = $game_variables[8] #Whatever variable you set the slot id to if applicableif appraise_equip(a, s) $game_switches[5] = true #Switch you use for eventing after this scriptcall for dialogue/etc...else $game_switches[5] = false#Switch you use for eventing after this scriptcall for dialogue/etc...endThe scriptcall can be just appraise_equip(a) if you only choose actor id, appraise_equip(a, s) for actor id and slot id, or event appraise_equip(a, s, c) to include the chance of success(defaulted to 50% in the snippet I gave, written as 0.1 for 10%, 0.5 for 50%, etc...).  Also that switch in the scriptcall is optional, but I figure easier to give success/fail text that way.  Hope that's close enough to what you wanted.

Remember to look the scriptcall over and give it the correct settings for your project, since I don't know "exactly" what you want or how you're going to use it.
 
Last edited by a moderator:
Joined
Jan 24, 2014
Messages
3
Reaction score
0
First Language
Portuguese
Primarily Uses
Hello, Selchar! Your script is very useful to me, I'm just having an issue with a detail. In the game, I'm setting a float number as "Default_Durability_Cost", and when the script draws some weapons current durability, after it is decreased, the number get lots of decimals. I know that it is a usual computer issue, but, if I'm not mistaken, the number of decimals can be defined. Can that be done in your script?

Thank you!
 

Selchar

Veteran
Veteran
Joined
Dec 28, 2012
Messages
299
Reaction score
81
First Language
English
Primarily Uses
I didn't forsee people using decimals when the default setup was obviously based on integers, but it's possible to do. In the customization area a little below Default_Durability_Cost, you should see


Dur_Suf = ' (%s/%s)'


Change that to


Dur_Suf = ' (%.2f/%s)'


As for durability costs made through the <skill durability mod x: y> notetag, it currently assumes integers, I thought the fix for that would be simple, but it looks like I assumed wrong so if you need that to be decimal based as well, I'll have to have a look to see if I can remedy that for you.
 
Joined
Jan 24, 2014
Messages
3
Reaction score
0
First Language
Portuguese
Primarily Uses
I'm looking for decimals because I don't want too big numbers to be drawn (and I would need that since I have skills with effects applied more than 20 times by a turn, a weapon would be destroyed in a single battle). So if that was possible, it would be much helpful. If it's not, however, things are still fine. I can apply a low number as Default_Durability_Cost, I guess.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Honestly. Didn't sleep for a day. ONCE
Hi! I've been working on some character sprites for my pirate themed game.
Still somewhat new to pixel art, so feedback or inputs would be appreciated ^^
TRIVIA: I love Japanese food and culture! I've never been to Japan, but someday I'm going to go to Tokyo and do some touring, including Disneyland Tokyo and DisneySea! And I even prepared myself for earthquake safety.
The virus really doesn't want us to do this GameJam. v .v' Even if we don't meet the deadline because of it, still plan on making it a game we'll release.
Has anybody else noticed in the freebie Sci-fi tilesets that they have a hologram of Cybertron from Transformers?

Forum statistics

Threads
104,246
Messages
1,004,960
Members
135,764
Latest member
MinazukiYukin
Top