Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
Hello,

I would need a little modification on the shop screen. Currently, the number of equipment in possession only takes into account the equipment in the inventory, not what the characters are equipped with. I would like these to be counted and for the names of the characters wearing them to appear in a different color.

Examples in pictures :

On the first screen, the Iron Claw (Griffe de fer) is in inventory, it puts me in possession of 1.



On the second screen, the Steel Claw (Griffe d'acier) is worn by Érios, but it puts 0 in possession.



I believe the solution is around line 41 of the base script below. Can you help me please?

Code:
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
#  This window displays number of items in possession and the actor's
# equipment on the shop screen.
#==============================================================================

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item = nil
    @page_index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_possession(4, 0)
    draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #--------------------------------------------------------------------------
  def item=(item)
    @item = item
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    draw_text(rect, $game_party.item_number(@item), 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Equipment Information
  #--------------------------------------------------------------------------
  def draw_equip_info(x, y)
    status_members.each_with_index do |actor, i|
      draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)
    end
  end
  #--------------------------------------------------------------------------
  # * Array of Actors for Which to Draw Equipment Information
  #--------------------------------------------------------------------------
  def status_members
    $game_party.members[@page_index * page_size, page_size]
  end
  #--------------------------------------------------------------------------
  # * Number of Actors Displayable at Once
  #--------------------------------------------------------------------------
  def page_size
    return 4
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Number of Pages
  #--------------------------------------------------------------------------
  def page_max
    ($game_party.members.size + page_size - 1) / page_size
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Equipment Information
  #--------------------------------------------------------------------------
  def draw_actor_equip_info(x, y, actor)
    enabled = actor.equippable?(@item)
    change_color(normal_color, enabled)
    draw_text(x, y, 112, line_height, actor.name)
    item1 = current_equipped_item(actor, @item.etype_id)
    draw_actor_param_change(x, y, actor, item1) if enabled
    draw_item_name(item1, x, y + line_height, enabled)
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Parameter Change
  #--------------------------------------------------------------------------
  def draw_actor_param_change(x, y, actor, item1)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)
    change_color(param_change_color(change))
    draw_text(rect, sprintf("%+d", change), 2)
  end
  #--------------------------------------------------------------------------
  # * Get Parameter ID Corresponding to Selected Item
  #    By default, ATK if weapon and DEF if armor.
  #--------------------------------------------------------------------------
  def param_id
    @item.is_a?(RPG::Weapon) ? 2 : 3
  end
  #--------------------------------------------------------------------------
  # * Get Current Equipment
  #    Returns the weaker equipment if there is more than one of the same type,
  #    such as with dual wield.
  #--------------------------------------------------------------------------
  def current_equipped_item(actor, etype_id)
    list = []
    actor.equip_slots.each_with_index do |slot_etype_id, i|
      list.push(actor.equips[i]) if slot_etype_id == etype_id
    end
    list.min_by {|item| item ? item.params[param_id] : 0 }
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_page
  end
  #--------------------------------------------------------------------------
  # * Update Page
  #--------------------------------------------------------------------------
  def update_page
    if visible && Input.trigger?(:A) && page_max > 1
      @page_index = (@page_index + 1) % page_max
      refresh
    end
  end
end

For information, I'm using Yanfly's script : https://yanflychannel.wordpress.com/rmvxa/menu-scripts/ace-shop-options/
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,298
Reaction score
14,275
First Language
English
Primarily Uses
RMMV

I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.



Please remove Yanfly's script from your post, and instead put a link to the page where the script can be found.

I could not view your images. You might want to check that they load properly - maybe remove the .html extension and make sure you have img tags.
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
Ok, I edited the post.

You can click on the images to open them larger.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
a little modification on the shop screen
It's more of an addon, since none of those script account for actor equipment.
But this works.
Ruby:
class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    eqinc = 0
    $game_party.members.any? {|actor| if actor.equips.include?(@item); eqinc += 1; end}
    draw_text(rect, $game_party.item_number(@item) + eqinc, 2)
  end

end

Does not account for dual wield

This works for dual wield
Ruby:
# simple addon to draw the possession of items to include actor equipment

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    eqinc = 0
    $game_party.all_members.each {|actor|
      if actor.equips.include?(@item)
        if actor.dual_wield?
          i1 = nil; i2 = nil
          if actor.equips[0] != nil
            eqinc += 1; i1 = actor.equips[0].id
          end
          if actor.equips[1] != nil
            eqinc+= 1; i2 = actor.equips[1].id
          end
          eqinc -= 1 if i1 != i2
        end
        eqinc += 1
      end
    }
    draw_text(rect, $game_party.item_number(@item) + eqinc, 2)
  end
end
 
Last edited:

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
Hello. I tested your script by pasting it under the others, but the problem is still there. It doesn't take into account the worn equipment.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
If you're using instance items, then this will never count more than 1. As every piece of armor and weapon is an individual item.
When you go to the shop and buy two of the same item, does it say 2 or 1?
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
I verified, it says 2.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
it says 2
Ok I had to put the instance items script in to test.
Then find what to check for.
This should do the trick
Ruby:
class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    eqinc = 0
    eqitem = nil if $imported["TH_InstanceItems"]
    $game_party.all_members.each {|actor|
      if actor.equips.include?(@item)
        if actor.dual_wield?
          i1 = nil; i2 = nil
          if actor.equips[0] != nil
            eqinc += 1; i1 = actor.equips[0].id
          end
          if actor.equips[1] != nil
            eqinc+= 1; i2 = actor.equips[1].id
          end
          eqinc -= 1 if i1 != i2
        else
          eqinc += 1 if actor.equips[0] != nil
        end
      end
      eqitem = actor.equips.find {|obj| obj && obj.template_id } if $imported["TH_InstanceItems"]
    }
    if $imported["TH_InstanceItems"]
      item = InstanceManager.get_instance(@item)
      if eqitem != nil && item != nil
        if eqitem.etype_id == item.etype_id
          eqinc += 1 if item.template_id == eqitem.template_id
        end
      end
    end
    draw_text(rect, $game_party.item_number(@item) + eqinc, 2)
  end
end
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
I tested but in shop, when I select Buy, I have a crash :

Capture.PNG
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
I have a crash
That's because I didn't account for items. I can easily fix that but I've found another bug. I'm trying to figure out the logic to have the InstanceItems check the equipment if it is equipped. Currently it only checks slot 0. every time, so the possession count is not accurate.
Still working on it.
This is working in my tests so far. Let me know if it works for you.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Yanfly Shop Options add on   ║  Version: 1.02     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Show total count including equips   ║    16 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Requires: Yanfly Engine Ace - Ace Shop Options           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Script adjusts Ace Shop to show the total amount of      ║
# ║ items in party inventory, including equipment.           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 16 Jan 2021 - Initial publish                     ║
# ║ 1.01 - 17 Jan 2021 - Accounted for dual wield            ║
# ║ 1.02 - 18 Jan 2021 - Added support for Hime Instance item║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Follow the Original Authors terms                        ║
# ╚══════════════════════════════════════════════════════════╝

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    eqinc = 0
    $game_party.all_members.each {|actor|
      if actor.equips.include?(@item)
        if actor.dual_wield?
          i1 = nil; i2 = nil
          if actor.equips[0] != nil
            eqinc += 1; i1 = actor.equips[0].id
          end
          if actor.equips[1] != nil
            eqinc+= 1; i2 = actor.equips[1].id
          end
          eqinc -= 1 if i1 != i2
        end
        eqinc += 1
      end
    }
    if $imported["TH_InstanceItems"]
      item = InstanceManager.get_instance(@item)
      eqitem = nil
      $game_party.all_members.each {|actor|
        actor.equip_slots.each_with_index {|e, i|
          if item != nil && item.is_a?(RPG::EquipItem)
            eqitem = actor.equips[i] if e == item.etype_id
          end
        }
      if eqitem != nil && item != nil
        if eqitem.is_a?(RPG::EquipItem) || item.is_a?(RPG::EquipItem)
          if eqitem.etype_id == item.etype_id
            eqinc += 1 if item.template_id == eqitem.template_id
          end
        end
      end
      }
    end
    draw_text(rect, $game_party.item_number(@item) + eqinc, 2)
  end
end
 
Last edited:

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
Yes, it works. Thank you. There is just one little thing to change. When I arrive in the shop and I must select Buy or Sell, the In possession number is not at 0. It seems to me that this number indicates how many characters are there in my team. It's just during the phase where I have to choose Buy, Sell or Quit.

Also, compared to my initial request, is it possible to change the color of the characters names at the bottom right, in yellow for example, if they wear the equipment selected at the shop ?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
Yes, it works
I found that it really still has issues.
Working on it. Finally got it working for the dual wield without instance items. Now to make it work for instance items.
 

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
Ok, I trust you to optimize the script. The bug that I stated in my previous post is the only one that I have seen.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,914
Reaction score
643
First Language
English
Primarily Uses
RMVXA
optimize the script
Just figured it out. Had it 90% working and just figured out what the last issue was. Had to move one line of code.
I hope this is working for you. A few quick tests on my end seems to work fine.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Yanfly Shop Options add on   ║  Version: 1.03     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Show total count including equips   ║    16 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Requires: Yanfly Engine Ace - Ace Shop Options           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Script adjusts Ace Shop to show the total amount of      ║
# ║ items in party inventory, including equipment.           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 16 Jan 2021 - Initial publish                     ║
# ║ 1.01 - 17 Jan 2021 - Accounted for dual wield            ║
# ║ 1.02 - 18 Jan 2021 - Added support for Hime Instance item║
# ║ 1.03 - 19 Jan 2021 - Fixed dual wield bug                ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Follow the Original Authors terms                        ║
# ╚══════════════════════════════════════════════════════════╝

class Window_ShopStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Draw Quantity Possessed
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    eqinc = 0
    $game_party.all_members.each {|actor|
      if actor.equips.include?(@item)
        eqinc += 1 if !@item.nil?
        eqinc += 1 if actor.dual_wield? && !@item.nil? &&
          @item.is_a?(RPG::Weapon)
        eqinc -= 1 if actor.dual_wield? && !@item.nil? &&
          (actor.equips[0].id != actor.equips[1].id)
      end
    }
    if $imported["TH_InstanceItems"]
      item = InstanceManager.get_instance(@item)
      $game_party.all_members.each {|actor|
      eqitem = nil
        actor.equip_slots.each_with_index {|e, i|
          if item != nil && item.is_a?(RPG::EquipItem)
            eqitem = actor.equips[i] if e == item.etype_id
          end
        }
      if eqitem != nil && item != nil
        if eqitem.is_a?(RPG::EquipItem) || item.is_a?(RPG::EquipItem)
          if eqitem.etype_id == item.etype_id
            eqinc += 1 if item.template_id == eqitem.template_id
            eqinc += 1 if actor.dual_wield? && !item.nil? &&
              item.is_a?(RPG::Weapon) && !actor.equips[1].nil? &&
              actor.equips[1].template_id == item.template_id
            eqinc -= 1 if actor.dual_wield? && !item.nil? && !actor.equips[1].nil? &&
              actor.equips[1].template_id != actor.equips[0].template_id
          end
        end
      end
      }
    end
    draw_text(rect, $game_party.item_number(@item) + eqinc, 2)
  end
end

Got the colors working as well. Struggled for a while until I realized that I needed to check for instance items here as well.
Ruby:
class Window_ShopStatus < Window_Base
  def draw_actor_equip_info(dx, dy, actor)
    enabled = actor.equippable?(@item)
    change_color(normal_color, enabled)
    if $imported["TH_InstanceItems"]
      item = InstanceManager.get_instance(@item)
      eqitem = nil
        actor.equip_slots.each_with_index {|e, i|
          if item != nil && item.is_a?(RPG::EquipItem)
            eqitem = actor.equips[i] if e == item.etype_id
          end
        }
      if eqitem != nil && item != nil
        if eqitem.is_a?(RPG::EquipItem) || item.is_a?(RPG::EquipItem)
          if eqitem.etype_id == item.etype_id
            if eqitem.template_id == item.template_id
              change_color(power_up_color, enabled)
            else
              change_color(normal_color, enabled)
            end
          end
        end
      end
    else
      change_color(power_up_color, enabled) if actor.equips.include?(@item)
    end
    draw_text(dx, dy, contents.width, line_height, actor.name)
    item1 = current_equipped_item(actor, @item.etype_id)
    draw_actor_param_change(dx, dy, actor, item1) if enabled
  end
end
 
Last edited:

Nérylis

Veteran
Veteran
Joined
Feb 14, 2015
Messages
202
Reaction score
3
First Language
French
Primarily Uses
I just tested the two scripts, everything works fine. It's magic ! Thank you very much for your help. I have tested all the menus in my game, there don't seem to be any problems. If I find something, I'll get back to you. But I think everything is Ok.
 

Latest Threads

Latest Posts

Latest Profile Posts

I haven't been on here in forever wow(missed my forum birthday T-T). Anyways, I'm dabbling in BGMs, here's something I'm actually willing to share.

Binge-watched 6 episodes of the Erased anime... And that means I've watched half of it?! Sigh...
I'm bad at base-building games (looking at other players created an aesthetically beautiful base compared to me), but IDK why I keep playing the game and seek more of it.
Pyra and Mythra in smash ultimate are way too OP. They're basically Smash 4 Bayonetta 2.0, and not in a good way. Very toxic and unfair. At least they're hot tho.

Forum statistics

Threads
109,197
Messages
1,042,971
Members
141,700
Latest member
skybola188
Top