RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[REQUEST] Item Durability and the related things

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 87
Let God judge me only !
Hi there,
I know 3 requests in one week should be weird, but please don't mind about my greed  ;D
Here come the Request.
If you ever play some ARPG ( like Diablo or almost MMORPG), you'll find that they have the item system with durability.
Can anyone write the script for the thing just like that ? Weapons reduce durability after each certain hits, armors/helms/shields reduce durability after absorbed certainly amount of damage. And yes, the item durability system should come along with the repair ability ( shop, skill). If one equipment has its durability reach 0 and without the user's care of repairing, then, BOOM, it should vanish ( some certain rare items don't go forever but turn into useless piles of metal until they're specially restored with the x10 cost than ordinary repairing  ;D)
If, possible, I want the jewelry ( rings, necklaces, bracelets,....) has durability, too. But their durability only suffer magic-based damage while armors/helms/shields suffer both physical and magical damage.

There should be some special skill effect that reduce foe's item durability instead of HP/SP. This will teach those careless knucle-heads one or two lessons  ;D
Anyhow, that's the idea. Hope that may interest pro-scripters.
All helps are welcome.  :D
Live how long and when to die. You and me, both we don't have the right to decide that.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Code: [Select]
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/???????? ? KGC_EquipmentBreak?
#_/----------------------------------------------------------------------------
#_/????????????????????
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

$imported = {} if $imported == nil
$imported["EquipmentBreak"] = true

if $game_special_elements == nil
  $game_special_elements = {}
  $data_system = load_data("Data/System.rxdata")
end
# ????????
$game_special_elements["equipment_break"] = /????(\d+)(%|?)/

#==============================================================================
# ? Game_Battler (???? 3)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  alias attack_effect_KGC_EquipmentBreak attack_effect
  def attack_effect(attacker)
    # ???????
    result = attack_effect_KGC_EquipmentBreak(attacker)

    if result && self.damage.is_a?(Numeric)
      # ??????
      attacker.break_equipment(0) if attacker.is_a?(Game_Actor)
      # ??????
      self.break_equipment(1) if self.is_a?(Game_Actor)
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ? ????????
  #--------------------------------------------------------------------------
  alias skill_effect_KGC_EquipmentBreak skill_effect
  def skill_effect(user, skill)
    # ???????
    result = skill_effect_KGC_EquipmentBreak(user, skill)

    # ????????????????
    if result && skill.atk_f > 0 && self.damage.is_a?(Numeric)
      # ??????
      user.break_equipment(0) if user.is_a?(Game_Actor)
      # ??????
      self.break_equipment(1) if self.is_a?(Game_Actor)
    end
    return result
  end
end

#???????????????????????????????????????

#==============================================================================
# ? Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ? ??????????
  #--------------------------------------------------------------------------
  attr_accessor :weapon_broken            # ???????
  attr_accessor :armor_broken             # ???????
  #--------------------------------------------------------------------------
  # ? ??????
  #     actor_id : ???? ID
  #--------------------------------------------------------------------------
  alias setup_KGC_EquipmentBreak setup
  def setup(actor_id)
    # ???????
    setup_KGC_EquipmentBreak(actor_id)

    @weapon_broken, @armor_broken = false, false
  end
  #--------------------------------------------------------------------------
  # ? ???????
  #     type : ???????(0:?? 1:??)
  #--------------------------------------------------------------------------
  def break_equipment(type)
    srand
    case type
    when 0  # ?????
      # ???????????
      if $imported["EquipExtension"] && self.two_swords?
        weapons = []
        self.ts_number.times { |i|
          next if self.weapon_id(i) == 0
          weapons << $data_weapons[self.weapon_id(i)]
        }
      else
        return if self.weapon_id == 0
        weapons = [$data_weapons[self.weapon_id]]
      end
      # ????
      weapons.each { |weapon|
        prob = 0
        weapon.element_set.compact.each { |element|
          if $game_special_elements["equipment_break"] =~ $data_system.elements[element]
            prob = $1.to_i
            break
          end
        }
        if prob != nil && rand(100) < prob
          # ???????ID???
          broken_weapon = weapon.id
          # ?????
          equip(0, 0)
          # ??????????
          $game_party.lose_weapon(broken_weapon, 1)
          # ????????
          @weapon_broken = true
        end
      }
    when 1  # ?????
      st = $imported["EquipExtension"] && self.two_swords? ? self.ts_number : 1
      ed = $imported["EquipExtension"] ? self.equip_type.size : 5
      (st...ed).each { |i|
        armor_id = $imported["EquipExtension"] ? self.armor_id[i] : eval("@armor#{i}_id")
        # ?????????????????
        next if armor_id == nil || armor_id == 0
        # ???????????
        armor = $data_armors[armor_id]
        # ????
        prob = 0
        armor.guard_element_set.compact.each { |element|
          if $game_special_elements["equipment_break"] =~ $data_system.elements[element]
            prob = $1.to_i
            break
          end
        }
        if prob != nil && rand(100) < prob
          # ?????
          equip(i, 0)
          # ??????????
          $game_party.lose_armor(armor_id, 1)
          # ????????
          @armor_broken = true
          prob = nil
        end
      }
    end
  end
end

#???????????????????????????????????????

#==============================================================================
# ? Scene_Battle (???? 4)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ? ?????? (??????? ???? 5 : ??????)
  #--------------------------------------------------------------------------
  alias update_phase4_step5_KGC_EquipmentBreak update_phase4_step5
  def update_phase4_step5
    # ???????
    update_phase4_step5_KGC_EquipmentBreak

    # ??????
    for actor in $game_party.actors
      next if actor == nil
      # ?????????????
      if actor.weapon_broken
        # ????? "Weapon Broken" ???
        actor.damage = "Weapon Broken" if actor.damage == nil
        actor.damage_pop = true
        # ?????????
        @broken = true
      end
      # ?????????????
      if actor.armor_broken
        # ????? "Armor Broken" ???
        actor.damage = "Armor Broken" if actor.damage == nil
        actor.damage_pop = true
        # ?????????
        @broken = true
      end
      # ??????
      actor.weapon_broken = false
      actor.armor_broken = false
    end
    # ???????????
    if @broken
      # ???????????
      @help_window.set_text("?????????", 1)
      # ?? SE ???
      Audio.se_play("Audio/SE/097-Attack09", 80, 50)
      # ???????????
      @wait_count = 20
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????? (??????? ???? 6 : ??????)
  #--------------------------------------------------------------------------
  alias update_phase4_step6_KGC_EquipmentBreak update_phase4_step6
  def update_phase4_step6
    # ???????
    update_phase4_step6_KGC_EquipmentBreak

    # ???????????
    if @broken
      # ???????????
      @help_window.visible = false
      # ????????
      @broken = false
    end
  end
end

Should be something like what you want.

Give credit to KGC

**
Rep:
Level 87
Let God judge me only !
Uh oh this time you didn't blame me  ;D
Well, I guest KGC is a Japanese scripter ?
There's something in a square "?", it may comes to an explaination or something to import.
Can you give me how this script does in use ?
Live how long and when to die. You and me, both we don't have the right to decide that.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
No dumbass, KGC is english, he just types in scripts with japanese because he feels like it.

I have no idea how to setup the script, play around with it yourself. That is the only armor and weapon break skill I know of though.

******
Rep:
Level 91
here is a crazy attempt to make that in an event:

first disable normal attacks (=()

then instead of it make a skill that is the same as normal attack, it will take the hero's str/int/dex/you name it and using it and the monsters' defense it will randomize the damage.

something like:

damage = herostr - targetmonsterdefense
damage = rand(damage*2, damage) - note you'll probably need to make a new variable for damage *2 thing, it's been a while since I made events and I don't have rmxp currently.
then simply reduce the damage from the target's hp, it's possible, but I need rmxp to find the exact lines for that

now that you are done (and know how to use mage's int for better hits now) we can go to the actual system.

in our new skill, which btw costs 0mp to use just like the normal attack, and in every other skill you'll use add a common event, one for each character.

every time you use any it will reduce rand of 0-2 durability from the weapon.
if durability <= 0 then
-unequip weapon
-remove weapon from inventory
-add "broken weapon" item

later on, make a non player character that checks if the player got any of the broken items in their inventory and for a price replaces them with the weapons they once were, that's easy.

back to the complicated stuff we now want to actually check if we even got the same weapon all the time or do we just like breaking stuff.
a common parallel event solves this.

If equip1(you do that for EVERY equipment, isn't it hot?) is equipped to character(do that for every character, that's also fun) then
-equip1flag = on
else
-equip1flag = off

simple!

next we set durabilities
at the games' start set all dura variables to their amount, say 100.
equip1dura = 100
so on.

now you can either make an event that allows a main variable "dura" take the durability of each weapon every time it's switched and when a weapon goes off, it's dura will be set to the dura variable and dura will become the new weapon's dura.

or otherwise, make a common event linked to the durability loss in battle we talked about before, this common event will check the equipped weapon by checking which flag is on, then reduce durability from it and if 0 just break it, it will be a mass if you have many weapons and the biggest downside is that you must limit every weapon into becoming a unique, meaning each weapon can only be found or bought once during the entire game (or twice if you simply make a copy of it but then it's treated as a whole new weapon)

you do the same with armors only that this time instead of the heros' weapons losing dura the monsters will use skills and reduce their opponents armor dura.

YES IT'S COMPLICATED LIKE HELL
yes, I got lost in it while explaining
I tried  to make it before, even with 3-4 weapons it was hell
BUT if you have the time, and have the will, you'll make something no script out there does, making your game unique.

I estimate it to work, and be fully debugged in a matter of 3 days per weapon * characters amount + armor * monsters amount~

If you need help with it, pm me any question and I'll do my best to answer.
using such a system will allow you to easily make 50% reduction of durability skills, fountains of repairing, so on so on, you name it.
Using the script you were offered will probably be a good idea if you lack the time or don't want to invest such amount of it in a game.
be warned: this is one of the hardest to make events and you can get lost in it very easily.

good luck and good hunting.
holy shit my sig was big!

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
A script can do that pretty easy, you just edit the attack to subtract one from the weapon durability, and if it hits zero the player gets the weapon unsuable unless an item is used to restore durability.

******
Rep:
Level 91
but hmm... we are helping someone who hmm... can't script on his own aren't we?   :P
besides using this event you can later on add a weapon/armor refining system relatively easily
and yes, I know scripts can do that too...
but I do encourage game makers to you know... make their own games with their own unique... thingies. (even if they can't script  :o)
holy shit my sig was big!

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
By saying the script is easy, and explaining how one would make it, I'm clearly hinting that I am doing this request.

******
Rep:
Level 91
but I am stupid and not very good at understanding hints that are given by superior scripters of doom  ;9

kay, have fun scripting
holy shit my sig was big!

**
Rep:
Level 87
Let God judge me only !
Well well, I see.
Something interests me with your Event, blueXx. Everything can be done with some complicated event, but they're easier with a script  ;D
You're right. I'm know nothing about scripting, so using script without knowledge should be too risky  :'(

@Falcon : not everyone is as smart and clever as you, I'm really ... dump about scripting  ;9
So I usually looking for scripts with clear instructions come along with it, so I won't be stuck with it. ;D
Anyway, I'll try both, Falcon's and blueXx's. Thks.

(Moan... Why didn't that MA come to my request ?  ;9 I heard that that guy is a talented scripter :blizj:)
Live how long and when to die. You and me, both we don't have the right to decide that.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
You think modern's going to do every fucking request in this forum? And I am making your script. Give me about a week and then bug me with a PM.

**
Rep:
Level 87
Let God judge me only !
Calm down, Falcon :o
Just a comment, I know that MA is busy with bunches of request at the moment  :=:
Well done, my Falcon will script my request. I'll note that in my schedule.
Falcon, take as much time as you need, I'm not in a crazy rush, so just take your time  ;)
Thanks alot  :D
Live how long and when to die. You and me, both we don't have the right to decide that.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, thanks for the compliment, but I am afraid that Falcon is a better scripter then I am  ;D

Trust me, you're better off with him :)

**
Rep:
Level 87
Let God judge me only !
Agreed.

( But he would be my favourite idol if he stops bombarding newbies with tons of heavy rockets  ;D)
Live how long and when to die. You and me, both we don't have the right to decide that.