Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Condition/State for Armor

I want to write a script that assigns a specific "Condition" rating to every piece of armor. For instance, a freshly crafted platemail breastplate will be at 100%, but after the skill "Cleave Armor" is used against it, the condition drops by a variable amount (say 10 to 20%) and ends up being 87%. In its reduced condition, the armor only offers 87% protection.

I believe I can code most of this, but I have no idea how to isolate a piece of armor. For instance, if I have 3 chainmail coifs in my inventory, how do I specify that the first is at 74%, the second 42%, and the third 100%? By default, does RMXP even keep track of individual instances of armor, weapons, and items?

Thanks for your help! When this script is polished off, I'll post it for all to use.

-tuatha
 
Interesting concept- one I've seen before but is definately missing in RM scripts- the ability to instanciate items. At the moment, you cannot "isolate" a piece of armor. There is a single instance of each item- regardless of quantity. You would have to create a new MyWeapon class (whatever you name it). Rewrite the inventory functions that give you a weapon and remove a weapon to create a new MyWeapon and add that instead (inventory would no longer stack for weapons, at all), and replace pretty much 100% of the original inventory and equipment handling as it pertains to weapons.

I've worked with the weapon system extensively, and can tell you that this is actually not hard to script, just hard to design. You will have to be / become familiar with inventory handling, the item module, etc. But it can be done and once the script structure is laid out, the actual legwork isn't that bad.

Check your PM for more info.
 
To give the player all possibilities, for example selling the older (weaker) armor in a shop while keeping the other you need to rewrite parts of Game_Party and most party of Scene_Shop (and its Windows), Scene_Equip (and its Windows) and Scene_Item (and its Windows) :)
 
Maybe you can make some quick fixes. I created a multiusables items script and i had the same proble as yours. The trick i used is that when you are using a multiusable item, they are sorted by their actual number of uses. Then the item that is used is the item that have the lowest number of uses left.

The number of uses are stored in a array in game_party.

Code:
class Game_Party

   attr_reader :multiusable_items

   alias gm_par_init initialize

   def initialize

     gm_par_init

     @multiusable_items = []

end

 

  #--------------------------------------------------------------------------

  # * Gain Items (or lose)

  #     item_id : item ID

  #     n       : quantity

  #--------------------------------------------------------------------------

  def gain_item(item_id, n)

 

    # Update quantity data in the hash.

    if item_id > 0

     if multiusable?(item_id) and n > 0

       #p 'ok'

       for i in 0..n

        uses = Improved_items['multi_usables'][item_id]

        idn = $game_party.item_number(item_id)+i

        @multiusable_items.push([item_id,uses,uses, idn])

       end

      end

      @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min

    end

  end

 

  #--------------------------------------------------------------------------

  # * Lose Items

  #     item_id : item ID

  #     n       : quantity

  #--------------------------------------------------------------------------

  def lose_item(item_id, n)

     if multiusable?(item_id)

       l = n

        # Ordena segun los usos que quedan

        @multiusable_items.sort! {|a,b|a[1]<=> b[1]} 

        # Flip depenent

       for item in @multiusable_items

        if l == 0

          break

        end

        if item[0] == item_id

          l+=1

          #p'ak'

          @multiusable_items[item[0]][1]-=1

          if @multiusable_items[item[0]][1] == 0

           @multiusable_items.delete(item)

           gain_item(item_id, -1)

          end

        end

       end

      else

       # Reverse the numerical value and call it gain_item

        gain_item(item_id, -n)

      end

    end 

 

  def multiusable?(item_id)

    #p item_id, Improved_items['multi_usables'][item_id]

    return Improved_items['multi_usables'][item_id]

  end

end

   

Its not very polished(you will se some old ideas),but works. Maybe it will give you some ideas.
 
thanks neo, forgot to mention that. While the shop uses game_party methods, so replacing those would hypothetically make it work, you should add a price modifier based on condition.

I would personally do:
price = ((condition == 0) ? (value / 4) : (value / 2) + ((condition / (value / 2)) * 100))

Make sure the shop GUI depicts this change so the user knows exactly why this iron dagger is worth less than the other and doesn't assume they got ripped off by some street peddler selling forgeries.

Another idea I would love to see would be where items of the same condition stack in inventory.
You would probably want to mod scene_equip to disallow equipping broken items. And double check that it doesn't break the battle results screen if they get an item- I've overlooked that in two of my scripts (but they were more intensive than yours), so just be sure to, well, be sure.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top