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.

Making certian items not appear in the item menu and the shop sell menu

NBEOTM

Member

I'm looking for an an edit to Window_ShopSell and Window_item, that makes it so certian items do not appear there, like say if a piece of armor was tagged with element 17 it would not apear under items nor would it pop up when you were selling items.

Thank you
 
Well, for the selling of items... just don't add the item to the store!  :wink:

And as for not showing the item, thats quite simple. First open the script editor and find Window_Item, at line 58 add this:

Code:
# Intructions: Replace "element_id" with the number of the element you don't want displayed in the menu
# Removes tagged items from menu
for item in @data
  case item
  when RPG::Item
    if item.element_set.include?(element_id)
      @data.delete(item)
    end
  when RPG::Weapon
    if item.element_set.include?(element_id)
      @data.delete(item)
    end
  when RPG::Armor
    if item.guard_element_set.include?(element_id)
      @data.delete(item)
    end
  end
end

Uhm, I didn't test it very thoughrougly but it should work.
 
I believe he means when you sell items. You know, the kill monster-get the item-return to town-sell item-get money thing. :P

Well, I'm at school now, so can't help very much. But it should be just like what xBrokenSin said. ^^
SEE YA!!!!!
 
You could make a little module containing arrays for items/weapons/armors and store the id if the item you don't want to appear in those array. Something like that:
Code:
module Items
  Invisible_Weapons = [1,2,3]
...
end

And then, in your item windows, each time you see this
Code:
@data.push(item)
add a condition that prevents the item from being added into the data array.
Based on the previous module, I would do something like that:
Code:
...
@data.push(item) unless Items::Weapons.include?(item.id)
...

Hope it helps!
-Dargor
 
Well, you can directly modify Window_Item, Window_ShopBuy and Window_ShopSell, in this area:

Code:
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      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

All the different classes have that block, or a block very similar to that. Now, let me explain what this does. First, we create an blank list, @data, called an array.

Now, our next part:
Code:
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end

This block passes through all the different items your game has. (Personally, I would have rather granted access to the different keys in the @items hash in $game_party, rather than passing though dozens possibly hundreds of numbers running several test that aren't needed. $game_party.items.each do |item_id, n| would have been more effective basically.)

What you need to modify is this line right here: if $game_party.item_number(i) > 0

From here, you just need to add: && <insert your code here>.

Let say you wanted to only add items that have your element 17. Your code would be:

if $game_party.item_number(i) > 0 && $data_items.element_set.include?(17)

You would do the same thing for items, weapons and armors, just replacing $game_party.item_number, $game_party.weapon_number, $game_party.armor_number respectively and $data_items, $data_weapons and $data_armors respectively as well. You can do this changes in any of your classes.

You can also run different filters by creating a new refresh method, that allows you to pass certain parameters to the method to allow you to have a more dynamic filter that isn't always the same.

Code:
class Window_Item
  def refresh_filter(args = {})
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        # add special args here
        if <code>
          @data << $data_items[i]
        end
     end
     # ...
  end
end

Now I would use a module for testing items with your arguments where it says # add special args here. But that's a little advanced. If you would like to see, I had an old item filtering and sorting system that isn't complete, but I could show you what I have done if you are interested.

Let me know if you need any more help.
 

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