Shop Steal free buy problem

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
This should (and hopefully) be the last Shop Steal problem I have.
So as you might know, I'm a amateur at coding, but I can still figure things out (RUBY can make so many more problems)
The problem is that when buying stuff, the items are free when the window opens.
The script only adds code, so I don't know what happened. Here's the bit of code that I think might be the problem (it's basically a modified copy of Window_ShopBuy)
Code:
#==============================================================================
# ** Window_ShopSteal
#------------------------------------------------------------------------------
#  This window displays a list of steal goods on the shop screen.
#==============================================================================

class Window_ShopSteal < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :status_window            # Status window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, height, shop_goods)
    super(x, y, window_width, height)
    @shop_goods = shop_goods
    @money = 0
    refresh
    select(0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 304
  end
  #--------------------------------------------------------------------------
  # * Get Number of Items
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    @data[index]
  end
  #--------------------------------------------------------------------------
  # * Set Party Gold
  #--------------------------------------------------------------------------
  def money=(money)
    @money = money
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Price of Item
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # * Create Item List
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    @price = {}
    @shop_goods.each do |goods|
      case goods[0]
      when 0;  item = $data_items[goods[1]]
      when 1;  item = $data_weapons[goods[1]]
      when 2;  item = $data_armors[goods[1]]
      end
      if item
        @data.push(item)
        @price[item] = goods[2] == 0 ? item.price : goods[3]
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y)
    rect.width -= 4
    draw_text(rect, price(item), 2)
  end
  #--------------------------------------------------------------------------
  # * Set Status Window
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # * Update Help Text
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @status_window.item = item if @status_window
  end
end
I'm just looking for ways to fix the problem, not necessarily asking for someone to find out for me; I still want to improve, and possibly say that I made this script.
If more is needed, I will supply it.
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
647
Reaction score
246
First Language
English
Primarily Uses
N/A
Maybe you need to change
@price = {}
to
@price = []
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,892
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
what exactly are you trying to accomplish here?
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
what exactly are you trying to accomplish here?
I am trying to make a new mechanic that allows you to steal from any shop.
All I need to do is fix a bug where you get one free item from the buy window whenever it's opened, allowing infinite items.
Once this one bug is fixed, it's ready for me and others to properly use. I really want to make this new gameplay feature, though I don't like having to ask for help whenever RUBY refuses to cooperate, but I have to if I want to get anywhere. Though I'm fine with asking where to start a project.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,892
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
I don't really see any problems with the window itself.
where are you calling it *from*?
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
I don't really see any problems with the window itself.
where are you calling it *from*?
If you mean by where it's activated, I use Scene_Shop.
I put it with the Buy and Sell commands, though I mostly copy and pasted the Buy definitions and replaced Buy with Steal.
Do you think you need Scene_Shop's code to find the problem?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,892
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
so, "steal" is a feature within the standard Scene_Shop, which you say you didn't modify except for adding the "steal" option.

*what* is not working?
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
so, "steal" is a feature within the standard Scene_Shop, which you say you didn't modify except for adding the "steal" option.

*what* is not working?
The buy option is not working right, but steal and sell works perfectly fine.
The problem with buy is that it's letting the player take one of any item when you open the buy option, regardless of how much money you have. It corrects itself when you take an item, however goes back when buy is selected. It will take away the required money, but you will still get the item if it's at 0.

Players can abuse this by repeatedly reopening the buy menu after taking the free item.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,892
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
if opening the shop leads into the buy option directly, then you have a problem with the shop *scene* not setting up correctly.
it's supposed to open, hold for command, hold for category, and then open the window for selection.
and, the command is handled by the command window, which then releases control to the scene which then releases control to the category window, WHICH then gives control back to the scene, and the scene moves it to the item window.

Disable your window and put things back as they were, and map what is going where, and when. Then, add your window back.
looks like a flow problem, not a window problem.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
if opening the shop leads into the buy option directly, then you have a problem with the shop *scene* not setting up correctly.
it's supposed to open, hold for command, hold for category, and then open the window for selection.
and, the command is handled by the command window, which then releases control to the scene which then releases control to the category window, WHICH then gives control back to the scene, and the scene moves it to the item window.

Disable your window and put things back as they were, and map what is going where, and when. Then, add your window back.
looks like a flow problem, not a window problem.
Thank you SO MUCH!
I managed to find the problem. Several areas I accidentally deleted, and replaced them with the steal functions. Don't ask me how that happened, I'm just as clueless as you.
Now that the script is functionally perfected, I'm going to post it in some places.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,892
Reaction score
893
First Language
Spanish
Primarily Uses
RMVXA
I had my fair share of headaches with that sequence.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

For anyone who has uploaded a game to Steam and wonders if they actually check your game's build when you first upload it, I can personally vouch for Steam.
6 more towns to make in my game. SIX. not done with interiors yet but SIX EXTERIORS.
what to do when you come across a person that has stated "What if I say, f*** their EULA? I could probably get away with it." concerning asset packs sold here... on this site ...
So a guy enters in a bar and walks up to the counter. He looks the bartender with a mysterious look and asks him...
I've wondered for a while now... what is it about the YED SV plugin that just doesn't do transformations... I feel it's how it looks up the battlers honestly.

Forum statistics

Threads
93,495
Messages
912,980
Members
123,030
Latest member
Galewings
Top