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.

[Resolved] Certain Items Don't Appear In ShopSell and MenuItem

Basically i'm wondering how to make it so that certain items don't show up in your inventory, as well as when you are selling your items at shops.
Here's the code that i know i need to change;
Code:
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        @data.push($data_armors[i])
        end
      end
    end

So for example, I don't want armor_id #35 to show up at all, as well as weapon_id #12, and item number #74. How would i code it so that these three items (and possibly more) don't even show up at all.
Thanks in advance,
~RM.

PS: I used the search function and found a topic similar to mine, but the solution there didn't really work out for me. So any suggestions would be great.
 
Possibly the easiest way is to trick the item_number method in Game_Party to not read the numbers when a current switch or something is active.

Here's a quick something:
Code:
class Game_Party
  attr_accessor :hidden_items_list
  attr_accessor :hidden_weapons_list
  attr_accessor :hidden_armors_list
  alias_method :seph_hiddeninventorytrick_gmprty_init, :initialize
  alias_method :seph_hiddeninventorytrick_gmprty_in, :item_number
  alias_method :seph_hiddeninventorytrick_gmprty_wn, :weapon_number
  alias_method :seph_hiddeninventorytrick_gmprty_an, :armor_number
  def initialize
    @hidden_items_list, @hidden_weapons_list, @hidden_armors_list = [], [], []
    seph_hiddeninventorytrick_gmprty_init
  end
  def item_number(id)
    return 0 if @hidden_items_list.include?(id)
    return seph_hiddeninventorytrick_gmprty_in(id)
  end
  def weapon_number(id)
    return 0 if @hidden_weapons_list.include?(id)
    return seph_hiddeninventorytrick_gmprty_wn(id)
  end
  def armor_number(id)
    return 0 if @hidden_armors_list.include?(id)
    return seph_hiddeninventorytrick_gmprty_an(id)
  end
end

From here on out, you just need to call:
Code:
# Add item to no show list
$game_party.hidden_items_list << item_id
# Remove item from list
$game_party.hidden_items_list.delete(item_id)

# For weapons and armors, replace items with weapons or armors


Now, lets say before every time you opened the item scene, you didn't want the items 3 - 6 to show up. The easy way to do this with out events would be to do:
Code:
class Scene_Item
  alias_method :seph_hiddeninventorytrick_scnitm_main, :main
  def main
    [3, 4, 5, 6].each {|i| $game_party.hidden_items_list << i}
    seph_hiddeninventorytrick_scnitm_main
    [3, 4, 5, 6].each {|i| $game_party.hidden_items_list.delete(i)}
  end
end

Let me know if you have any questions and I will do my best to help you.
 
Hmm... I'm getting a few errors on your code snippet in the Game_Party class.

"wrong number of arguments(0 for 1)"

It occurs on these three lines:
return seph_hiddeninventorytrick_gmprty_in
return seph_hiddeninventorytrick_gmprty_wn
return seph_hiddeninventorytrick_gmprty_an
 
Ah, that was a simple fix. I should have seen that as well.
I managed to integrate it into my visual equipment script and everything works quite smoothly now.
Thanks for all your help today (with this problem and the "Always Have Something Equip" thing). I can finally begin cleaning up my code and implementing this into my game!
~Thanks again.
 

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