Shop Steal (UPDATED)

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
Finally finished it!
No more known bugs!
IT'S FUNCTIONALLY PERFECT!
NOW UPDATED TO BE MORE USER-FRIENDLY
This allows the player to steal items from any shop in your game. The player has a 47% success chance, but the other 53% is up to you to decide!

How stealing works: You select the new steal tab in the shop, select the item you want, then hope to god that you got that item.

How to make the consequence: If the player fails the dice roll, then switch 21 is set to true. I will let you figure out what to do with that switch in the events; I usually make Parallel Processes that swap 21 with the other switch.

How to change the switch/success chance: Change the values under preferences.

Contact me about any problems

Warning: May not work with other shop scripts



Terms
Please give credit to me if you're using this, even if you modify this or merged it with another shop script, give credit to all those who were involved.
If you got questions or small modification request regarding this, let me know. Also let me know if you want to use this in your own shop script.



Place under materials, but above main
Code:
#========================PREFERENCES=============================

$dice = 47 #THE PERCENTAGE CHANCE OF SUCCESS

$activation_switch = 21 #THE SWITCH THAT'S SET TO TRUE ON FAIL

#================================================================






#============================CREDIT==============================

#GIVE CREDIT TO TRIACULAR, REGARDLESS OF CIRCUMSTANCES

#================================================================








module Vocab
    ShopSteal       = "Steal"
end

class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Prepare
  #--------------------------------------------------------------------------
  def prepare(goods, purchase_only)
    @goods = goods
    @purchase_only = purchase_only
  end
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_gold_window
    create_command_window
    create_dummy_window
    create_number_window
    create_status_window
    create_buy_window
    create_category_window
    create_sell_window
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:steal,  method(:command_steal))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Dummy Window
  #--------------------------------------------------------------------------
  def create_dummy_window
    wy = @command_window.y + @command_window.height
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # * Create Quantity Input Window
  #--------------------------------------------------------------------------
  def create_number_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @number_window = Window_ShopNumber.new(0, wy, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * Create Purchase Window
  #--------------------------------------------------------------------------
  def create_buy_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
    @buy_window.viewport = @viewport
    @buy_window.help_window = @help_window
    @buy_window.status_window = @status_window
    @buy_window.hide
    @buy_window.set_handler(:ok,     method(:on_buy_ok))
    @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Category Window
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_ItemCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @dummy_window.y
    @category_window.hide.deactivate
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:on_category_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Sell Window
  #--------------------------------------------------------------------------
  def create_sell_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
    @sell_window.viewport = @viewport
    @sell_window.help_window = @help_window
    @sell_window.hide
    @sell_window.set_handler(:ok,     method(:on_sell_ok))
    @sell_window.set_handler(:cancel, method(:on_sell_cancel))
    @category_window.item_window = @sell_window
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def activate_buy_window
    @buy_window.money = money
    @buy_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Activate Sell Window
  #--------------------------------------------------------------------------
  def activate_sell_window
    @category_window.show
    @sell_window.refresh
    @sell_window.show.activate
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * [Buy] Command
  #--------------------------------------------------------------------------
  def command_buy
    @dummy_window.hide
    activate_buy_window
  end
 
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
 
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
 
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
 
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
 
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
 
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $dice
      $game_party.gain_item(@item, 1)
    else
      $game_switches[$activation_switch] = true
      SceneManager.goto(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * [Sell] Command
  #--------------------------------------------------------------------------
  def command_sell
    @dummy_window.hide
    @category_window.show.activate
    @sell_window.show
    @sell_window.unselect
    @sell_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_buy_ok
    money
    @item = @buy_window.item
    @buy_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # * Buy [Cancel]
  #--------------------------------------------------------------------------
  def on_buy_cancel
    @command_window.activate
    @dummy_window.show
    @buy_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category [OK]
  #--------------------------------------------------------------------------
  def on_category_ok
    activate_sell_window
    @sell_window.select(0)
  end
  #--------------------------------------------------------------------------
  # * Category [Cancel]
  #--------------------------------------------------------------------------
  def on_category_cancel
    @command_window.activate
    @dummy_window.show
    @category_window.hide
    @sell_window.hide
  end
  #--------------------------------------------------------------------------
  # * Sell [OK]
  #--------------------------------------------------------------------------
  def on_sell_ok
    @item = @sell_window.item
    @status_window.item = @item
    @category_window.hide
    @sell_window.hide
    @number_window.set(@item, max_sell, selling_price, currency_unit)
    @number_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Sell [Cancel]
  #--------------------------------------------------------------------------
  def on_sell_cancel
    @sell_window.unselect
    @category_window.activate
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def on_number_ok
    Sound.play_shop
    case @command_window.current_symbol
    when :buy
      do_buy(@number_window.number)
    when :sell
      do_sell(@number_window.number)
    when :steal
      do_steal(@number_window.number)
    end
    end_number_input
    @gold_window.refresh
    @status_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [Cancel]
  #--------------------------------------------------------------------------
  def on_number_cancel
    Sound.play_cancel
    end_number_input
  end
  #--------------------------------------------------------------------------
  # * Execute Purchase
  #--------------------------------------------------------------------------
  def do_buy(number)
    $game_party.lose_gold(number * buying_price)
    $game_party.gain_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Execute Sale
  #--------------------------------------------------------------------------
  def do_sell(number)
    $game_party.gain_gold(number * selling_price)
    $game_party.lose_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Made By Triacular
  #--------------------------------------------------------------------------
  def end_number_input
    @number_window.hide
    case @command_window.current_symbol
    when :buy
      activate_buy_window
    when :sell
      activate_sell_window
    when :steal
      activate_steal_window
    end
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Buyable
  #--------------------------------------------------------------------------
  def max_buy
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
    buying_price == 0 ? max : [max, money / buying_price].min
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Sellable
  #--------------------------------------------------------------------------
  def max_sell
    $game_party.item_number(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Party Gold
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # * Get Purchase Price
  #--------------------------------------------------------------------------
  def buying_price
    @buy_window.price(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Sale Price
  #--------------------------------------------------------------------------
  def selling_price
    @item.price / 2
  end
end


class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_width, purchase_only)
    @window_width = window_width
    @purchase_only = purchase_only
    super(0, 0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    @window_width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 3
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    add_command(Vocab::ShopSteal,  :steal)
    add_command(Vocab::ShopCancel, :cancel)
  end
end


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 Activation State of Selection Item
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
  # * Get Price of Item
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------
  # * 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
 
Last edited:

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
Is there any way you can update the script to where the player can level up his "steal" ability and have the chance of successful stealing raise with X amount of successful steals?
In other words: You start out as a level 1 thief, with 20% chance of the stealing being successful. With 5 successful steals, you go up to level 2, with 25% chance of successful steals. Then you'll need to successfully steal 6 more times to go to level 3 with 30% chance of successful steals, steal 7 more times to go to level 4 thief, and so on.
And another thing that'd be cool is if certain items are more difficult to steal depending on your thief level.

Well anyways, it's a cool script regardless. Good work
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
Is there any way you can update the script to where the player can level up his "steal" ability and have the chance of successful stealing raise with X amount of successful steals?
In other words: You start out as a level 1 thief, with 20% chance of the stealing being successful. With 5 successful steals, you go up to level 2, with 25% chance of successful steals. Then you'll need to successfully steal 6 more times to go to level 3 with 30% chance of successful steals, steal 7 more times to go to level 4 thief, and so on.
And another thing that'd be cool is if certain items are more difficult to steal depending on your thief level.

Well anyways, it's a cool script regardless. Good work
I can probably make a Shop Steal addon that lets you link your chances to a stat, like LUK. But making it like what you said would take a ton of time.
Though you can request another person to make an addon that can do both of those functions. All they need to really do is calculate the prices & steal level, plus add a way to gauge your steal level. So if you do want to ask someone else to make the addon/modification, the main thing to note in the request is to use $dice to affect chances.

Though I do like the idea! I was even planning on making chances based on price.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
1,853
Reaction score
408
First Language
English
Primarily Uses
RMVXA
Would it be possible to use a variable to add onto the difficulty? When your thief goes up a level add 5 to the variable which would raise the success rate?
Is it possible to have it so that only specific classes can do this? I don't see that in the script.
 
Last edited:

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
Would it be possible to use a variable to add onto the difficulty? When you thief goes up a level add 5 to the variable which would raise the success rate?
Is it possible to have it so that only specific classes can do this? I don't see that in the script.
Yes, it's very possible!
All I need to look up is how to check a character's LV. Every time shop is opened, it will check the LV of the first character of the party.
Though if you want to make the little modification, go ahead! I might even update this again, seeing how some people are interested in the idea.
 

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
If you can't then I understand, but I think this request might be a bit simpler...
Could you make it so that I can disable the script with a switch? There are some items that are so valuable, it'd be broken if the player can just steal them. So if there was a disable switch, I can put the rarer items in another shop, then reenable the script once you exit that shop.
If you can't do it, then I have a back up plan of simply not selling those rare items in the shop processing menu, but rather in a choice list. But it'd be nice if they could all be in the shop processing menu.
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
42
Reaction score
19
First Language
Portuguese
Primarily Uses
Other
Yes, it's very possible!
All I need to look up is how to check a character's LV. Every time shop is opened, it will check the LV of the first character of the party.
Though if you want to make the little modification, go ahead! I might even update this again, seeing how some people are interested in the idea.
I like the ideas proposed by the others.
I am also a scripter, can I modify this script and see what can I achieve with it?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,645
Reaction score
5,284
First Language
Indonesian
Primarily Uses
RMVXA
A little tip for the code. If you're not going to make a change, don't include in the code.
For example, the method "prepare" is not modified. So you can remove it.

Also, maybe try to understand how aliasing works.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
I like the ideas proposed by the others.
I am also a scripter, can I modify this script and see what can I achieve with it?
Go ahead!
That's why I made the preferences global variables.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
If you can't then I understand, but I think this request might be a bit simpler...
Could you make it so that I can disable the script with a switch? There are some items that are so valuable, it'd be broken if the player can just steal them. So if there was a disable switch, I can put the rarer items in another shop, then reenable the script once you exit that shop.
If you can't do it, then I have a back up plan of simply not selling those rare items in the shop processing menu, but rather in a choice list. But it'd be nice if they could all be in the shop processing menu.
I'll give it a try! Should be pretty easy to disable the option with an event switch.
 

Triacular

Villager
Member
Joined
Jan 13, 2019
Messages
27
Reaction score
5
First Language
English
Primarily Uses
RMVXA
If you can't then I understand, but I think this request might be a bit simpler...
Could you make it so that I can disable the script with a switch? There are some items that are so valuable, it'd be broken if the player can just steal them. So if there was a disable switch, I can put the rarer items in another shop, then reenable the script once you exit that shop.
If you can't do it, then I have a back up plan of simply not selling those rare items in the shop processing menu, but rather in a choice list. But it'd be nice if they could all be in the shop processing menu.
Ok I finished a modification that let's you enable and disable the steal option. (It's off by default)
If I made it so you can't steal certain items, I would need to mod the editor.
Code:
#========================PREFERENCES=============================

$dice = 47 #THE PERCENTAGE CHANCE OF SUCCESS

$activation_switch = 21 #THE SWITCH THAT'S SET TO TRUE ON FAIL

#================================================================


#=============================SPECIAL============================

$steal_enabler = 1 #THE GAME SWITCH THAT ENABLES AND DISABLES THE STEAL COMMAND

#================================================================

#============================CREDIT==============================

#GIVE CREDIT TO TRIACULAR, REGARDLESS OF CIRCUMSTANCES

#================================================================








module Vocab
    ShopSteal       = "Steal"
end

class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Prepare
  #--------------------------------------------------------------------------
  def prepare(goods, purchase_only)
    @goods = goods
    @purchase_only = purchase_only
  end
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_gold_window
    create_command_window
    create_dummy_window
    create_number_window
    create_status_window
    create_buy_window
    create_category_window
    create_sell_window
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:steal,  method(:command_steal))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Dummy Window
  #--------------------------------------------------------------------------
  def create_dummy_window
    wy = @command_window.y + @command_window.height
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # * Create Quantity Input Window
  #--------------------------------------------------------------------------
  def create_number_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @number_window = Window_ShopNumber.new(0, wy, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * Create Purchase Window
  #--------------------------------------------------------------------------
  def create_buy_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
    @buy_window.viewport = @viewport
    @buy_window.help_window = @help_window
    @buy_window.status_window = @status_window
    @buy_window.hide
    @buy_window.set_handler(:ok,     method(:on_buy_ok))
    @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Category Window
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_ItemCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @dummy_window.y
    @category_window.hide.deactivate
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:on_category_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Sell Window
  #--------------------------------------------------------------------------
  def create_sell_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
    @sell_window.viewport = @viewport
    @sell_window.help_window = @help_window
    @sell_window.hide
    @sell_window.set_handler(:ok,     method(:on_sell_ok))
    @sell_window.set_handler(:cancel, method(:on_sell_cancel))
    @category_window.item_window = @sell_window
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def activate_buy_window
    @buy_window.money = money
    @buy_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Activate Sell Window
  #--------------------------------------------------------------------------
  def activate_sell_window
    @category_window.show
    @sell_window.refresh
    @sell_window.show.activate
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * [Buy] Command
  #--------------------------------------------------------------------------
  def command_buy
    @dummy_window.hide
    activate_buy_window
  end
 
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
 
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
 
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
 
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
 
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
 
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $dice
      $game_party.gain_item(@item, 1)
    else
      $game_switches[$activation_switch] = true
      SceneManager.goto(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * [Sell] Command
  #--------------------------------------------------------------------------
  def command_sell
    @dummy_window.hide
    @category_window.show.activate
    @sell_window.show
    @sell_window.unselect
    @sell_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_buy_ok
    money
    @item = @buy_window.item
    @buy_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # * Buy [Cancel]
  #--------------------------------------------------------------------------
  def on_buy_cancel
    @command_window.activate
    @dummy_window.show
    @buy_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category [OK]
  #--------------------------------------------------------------------------
  def on_category_ok
    activate_sell_window
    @sell_window.select(0)
  end
  #--------------------------------------------------------------------------
  # * Category [Cancel]
  #--------------------------------------------------------------------------
  def on_category_cancel
    @command_window.activate
    @dummy_window.show
    @category_window.hide
    @sell_window.hide
  end
  #--------------------------------------------------------------------------
  # * Sell [OK]
  #--------------------------------------------------------------------------
  def on_sell_ok
    @item = @sell_window.item
    @status_window.item = @item
    @category_window.hide
    @sell_window.hide
    @number_window.set(@item, max_sell, selling_price, currency_unit)
    @number_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Sell [Cancel]
  #--------------------------------------------------------------------------
  def on_sell_cancel
    @sell_window.unselect
    @category_window.activate
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def on_number_ok
    Sound.play_shop
    case @command_window.current_symbol
    when :buy
      do_buy(@number_window.number)
    when :sell
      do_sell(@number_window.number)
    when :steal
      do_steal(@number_window.number)
    end
    end_number_input
    @gold_window.refresh
    @status_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [Cancel]
  #--------------------------------------------------------------------------
  def on_number_cancel
    Sound.play_cancel
    end_number_input
  end
  #--------------------------------------------------------------------------
  # * Execute Purchase
  #--------------------------------------------------------------------------
  def do_buy(number)
    $game_party.lose_gold(number * buying_price)
    $game_party.gain_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Execute Sale
  #--------------------------------------------------------------------------
  def do_sell(number)
    $game_party.gain_gold(number * selling_price)
    $game_party.lose_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Made By Triacular
  #--------------------------------------------------------------------------
  def end_number_input
    @number_window.hide
    case @command_window.current_symbol
    when :buy
      activate_buy_window
    when :sell
      activate_sell_window
    when :steal
      activate_steal_window
    end
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Buyable
  #--------------------------------------------------------------------------
  def max_buy
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
    buying_price == 0 ? max : [max, money / buying_price].min
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Sellable
  #--------------------------------------------------------------------------
  def max_sell
    $game_party.item_number(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Party Gold
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # * Get Purchase Price
  #--------------------------------------------------------------------------
  def buying_price
    @buy_window.price(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Sale Price
  #--------------------------------------------------------------------------
  def selling_price
    @item.price / 2
  end
end


class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_width, purchase_only)
    @window_width = window_width
    @purchase_only = purchase_only
    super(0, 0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    @window_width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 3
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    if $game_switches[$steal_enabler] == true
      add_command(Vocab::ShopSteal,  :steal)
    end
    add_command(Vocab::ShopCancel, :cancel)
  end
end


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 Activation State of Selection Item
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
  # * Get Price of Item
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------
  # * 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
 

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
Ok I finished a modification that let's you enable and disable the steal option. (It's off by default)
If I made it so you can't steal certain items, I would need to mod the editor.
Code:
#========================PREFERENCES=============================

$dice = 47 #THE PERCENTAGE CHANCE OF SUCCESS

$activation_switch = 21 #THE SWITCH THAT'S SET TO TRUE ON FAIL

#================================================================


#=============================SPECIAL============================

$steal_enabler = 1 #THE GAME SWITCH THAT ENABLES AND DISABLES THE STEAL COMMAND

#================================================================

#============================CREDIT==============================

#GIVE CREDIT TO TRIACULAR, REGARDLESS OF CIRCUMSTANCES

#================================================================








module Vocab
    ShopSteal       = "Steal"
end

class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Prepare
  #--------------------------------------------------------------------------
  def prepare(goods, purchase_only)
    @goods = goods
    @purchase_only = purchase_only
  end
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_gold_window
    create_command_window
    create_dummy_window
    create_number_window
    create_status_window
    create_buy_window
    create_category_window
    create_sell_window
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:steal,  method(:command_steal))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * Create Dummy Window
  #--------------------------------------------------------------------------
  def create_dummy_window
    wy = @command_window.y + @command_window.height
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # * Create Quantity Input Window
  #--------------------------------------------------------------------------
  def create_number_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @number_window = Window_ShopNumber.new(0, wy, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * Create Purchase Window
  #--------------------------------------------------------------------------
  def create_buy_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
    @buy_window.viewport = @viewport
    @buy_window.help_window = @help_window
    @buy_window.status_window = @status_window
    @buy_window.hide
    @buy_window.set_handler(:ok,     method(:on_buy_ok))
    @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Category Window
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_ItemCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @dummy_window.y
    @category_window.hide.deactivate
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:on_category_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Sell Window
  #--------------------------------------------------------------------------
  def create_sell_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height - wy
    @sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
    @sell_window.viewport = @viewport
    @sell_window.help_window = @help_window
    @sell_window.hide
    @sell_window.set_handler(:ok,     method(:on_sell_ok))
    @sell_window.set_handler(:cancel, method(:on_sell_cancel))
    @category_window.item_window = @sell_window
  end
  #--------------------------------------------------------------------------
  # * Activate Purchase Window
  #--------------------------------------------------------------------------
  def activate_buy_window
    @buy_window.money = money
    @buy_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Activate Sell Window
  #--------------------------------------------------------------------------
  def activate_sell_window
    @category_window.show
    @sell_window.refresh
    @sell_window.show.activate
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # * [Buy] Command
  #--------------------------------------------------------------------------
  def command_buy
    @dummy_window.hide
    activate_buy_window
  end
 
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
 
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
 
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
 
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
 
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
 
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $dice
      $game_party.gain_item(@item, 1)
    else
      $game_switches[$activation_switch] = true
      SceneManager.goto(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * [Sell] Command
  #--------------------------------------------------------------------------
  def command_sell
    @dummy_window.hide
    @category_window.show.activate
    @sell_window.show
    @sell_window.unselect
    @sell_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Buy [OK]
  #--------------------------------------------------------------------------
  def on_buy_ok
    money
    @item = @buy_window.item
    @buy_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # * Buy [Cancel]
  #--------------------------------------------------------------------------
  def on_buy_cancel
    @command_window.activate
    @dummy_window.show
    @buy_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category [OK]
  #--------------------------------------------------------------------------
  def on_category_ok
    activate_sell_window
    @sell_window.select(0)
  end
  #--------------------------------------------------------------------------
  # * Category [Cancel]
  #--------------------------------------------------------------------------
  def on_category_cancel
    @command_window.activate
    @dummy_window.show
    @category_window.hide
    @sell_window.hide
  end
  #--------------------------------------------------------------------------
  # * Sell [OK]
  #--------------------------------------------------------------------------
  def on_sell_ok
    @item = @sell_window.item
    @status_window.item = @item
    @category_window.hide
    @sell_window.hide
    @number_window.set(@item, max_sell, selling_price, currency_unit)
    @number_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Sell [Cancel]
  #--------------------------------------------------------------------------
  def on_sell_cancel
    @sell_window.unselect
    @category_window.activate
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def on_number_ok
    Sound.play_shop
    case @command_window.current_symbol
    when :buy
      do_buy(@number_window.number)
    when :sell
      do_sell(@number_window.number)
    when :steal
      do_steal(@number_window.number)
    end
    end_number_input
    @gold_window.refresh
    @status_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [Cancel]
  #--------------------------------------------------------------------------
  def on_number_cancel
    Sound.play_cancel
    end_number_input
  end
  #--------------------------------------------------------------------------
  # * Execute Purchase
  #--------------------------------------------------------------------------
  def do_buy(number)
    $game_party.lose_gold(number * buying_price)
    $game_party.gain_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Execute Sale
  #--------------------------------------------------------------------------
  def do_sell(number)
    $game_party.gain_gold(number * selling_price)
    $game_party.lose_item(@item, number)
  end
  #--------------------------------------------------------------------------
  # * Made By Triacular
  #--------------------------------------------------------------------------
  def end_number_input
    @number_window.hide
    case @command_window.current_symbol
    when :buy
      activate_buy_window
    when :sell
      activate_sell_window
    when :steal
      activate_steal_window
    end
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Buyable
  #--------------------------------------------------------------------------
  def max_buy
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
    buying_price == 0 ? max : [max, money / buying_price].min
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Quantity Sellable
  #--------------------------------------------------------------------------
  def max_sell
    $game_party.item_number(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Party Gold
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # Get Currency Unit
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # * Get Purchase Price
  #--------------------------------------------------------------------------
  def buying_price
    @buy_window.price(@item)
  end
  #--------------------------------------------------------------------------
  # * Get Sale Price
  #--------------------------------------------------------------------------
  def selling_price
    @item.price / 2
  end
end


class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_width, purchase_only)
    @window_width = window_width
    @purchase_only = purchase_only
    super(0, 0)
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    @window_width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 3
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    if $game_switches[$steal_enabler] == true
      add_command(Vocab::ShopSteal,  :steal)
    end
    add_command(Vocab::ShopCancel, :cancel)
  end
end


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 Activation State of Selection Item
  #--------------------------------------------------------------------------
 
  #--------------------------------------------------------------------------
  # * Get Price of Item
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # * Display in Enabled State?
  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------
  # * 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
Awesome! I'll test it out now.
EDIT: It works! Thank you very much :)
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
1,853
Reaction score
408
First Language
English
Primarily Uses
RMVXA
If you don't mind, I cleaned it up.
Code:
#==============================================================================
#
# ▼ Triacular - Steal Shop v1.04
# -- Last Updated: 2012.02.19
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows stealing of items in scene shop, made for RPG Maker VX Ace.
#
# Must give credit to Triacular
# free for non-commercial and commercial uses
#==============================================================================
#==============================================================================
# ▼ Versions Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019-01-26 - Initial script                         - Triacular
# 2019-01-27 - Reduced duplicate parts                - Triacular
# 2019-02-12 - Added switch to disable script         - Triacular
# 2019-02-13 - Added alias, removed global switches   - Roninator2
#==============================================================================

#========================PREFERENCES=============================
module TRIACULAR
  module STEALSHOP
    DICE = 20 # variable for % chance steal will succeed
    STEAL = 21 # switch you will use when steal fails
    ENABLE = 22 # switch to use to enable script. True = on
  end
end
#================================================================ 

#==============================================================================
# ** Vocab
#------------------------------------------------------------------------------
#  This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================

module Vocab
  ShopSteal       = "Steal"
end

#==============================================================================
# ** Window_ShopCommand
#------------------------------------------------------------------------------
#  This window is for selecting buy/sell on the shop screen.
#==============================================================================

class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias r2_make_cl_m2dfff98   make_command_list
  def make_command_list
    r2_make_cl_m2dfff98
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      add_command(Vocab::ShopSteal,  :steal)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      return 4
    else
      return 3
    end
  end
end

#==============================================================================
# ** 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

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================
class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias r2_start_45nf3  start
  def start
    r2_start_45nf3
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias r2_create_cw_64rgu  create_command_window
  def create_command_window
    r2_create_cw_64rgu
    @command_window.set_handler(:steal,  method(:command_steal))
  end
  #--------------------------------------------------------------------------
  # * [Steal] Command
  #--------------------------------------------------------------------------
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
  #--------------------------------------------------------------------------
  # * Category Steal [Cancel]
  #--------------------------------------------------------------------------
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category Steal [OK]
  #--------------------------------------------------------------------------
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # * Create Steal Window
  #--------------------------------------------------------------------------
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Execute Steal
  #--------------------------------------------------------------------------
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $game_variables[TRIACULAR::STEALSHOP::DICE]
      $game_party.gain_item(@item, 1)
    else
      $game_switches[TRIACULAR::STEALSHOP::STEAL] = true
      SceneManager.goto(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  alias r2_on_number_ok_bwvm45    on_number_ok
  def on_number_ok
    r2_on_number_ok_bwvm45
    case @command_window.current_symbol
    when :steal
      do_steal(@number_window.number)
    end
  end
  #--------------------------------------------------------------------------
  # * Exit Quantity Input
  #--------------------------------------------------------------------------
  alias r2_end_number_input_mtr23  end_number_input
  def end_number_input
    r2_end_number_input_mtr23
    case @command_window.current_symbol
    when :steal
      activate_steal_window
    end
  end
end

*UPDATE
added in a variable for perfect chance.
Useful if you want items or equipment to change the chance for success.
(provided you have a way to add that onto equipment)
 
Last edited:

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
If you don't mind, I cleaned it up.
Code:
#==============================================================================
#
# ▼ Triacular - Steal Shop v1.04
# -- Last Updated: 2012.02.19
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows stealing of items in scene shop, made for RPG Maker VX Ace.
#
# Must give credit to Triacular
# free for non-commercial and commercial uses
#==============================================================================
#==============================================================================
# ▼ Versions Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019-01-26 - Initial script                         - Triacular
# 2019-01-27 - Reduced duplicate parts                - Triacular
# 2019-02-12 - Added switch to disable script         - Triacular
# 2019-02-13 - Added alias, removed global switches   - Roninator2
#==============================================================================

#========================PREFERENCES=============================
module TRIACULAR
  module STEALSHOP
    DICE = 20 # variable for % chance steal will succeed
    STEAL = 21 # switch you will use when steal fails
    ENABLE = 22 # switch to use to enable script. True = on
  end
end
#================================================================

#==============================================================================
# ** Vocab
#------------------------------------------------------------------------------
#  This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================

module Vocab
  ShopSteal       = "Steal"
end

#==============================================================================
# ** Window_ShopCommand
#------------------------------------------------------------------------------
#  This window is for selecting buy/sell on the shop screen.
#==============================================================================

class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias r2_make_cl_m2dfff98   make_command_list
  def make_command_list
    r2_make_cl_m2dfff98
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      add_command(Vocab::ShopSteal,  :steal)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      return 4
    else
      return 3
    end
  end
end

#==============================================================================
# ** 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

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================
class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias r2_start_45nf3  start
  def start
    r2_start_45nf3
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias r2_create_cw_64rgu  create_command_window
  def create_command_window
    r2_create_cw_64rgu
    @command_window.set_handler(:steal,  method(:command_steal))
  end
  #--------------------------------------------------------------------------
  # * [Steal] Command
  #--------------------------------------------------------------------------
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
  #--------------------------------------------------------------------------
  # * Category Steal [Cancel]
  #--------------------------------------------------------------------------
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category Steal [OK]
  #--------------------------------------------------------------------------
  def on_steal_ok
    @item = @steal_window.item
    @steal_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # * Create Steal Window
  #--------------------------------------------------------------------------
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Execute Steal
  #--------------------------------------------------------------------------
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $game_variables[TRIACULAR::STEALSHOP::DICE]
      $game_party.gain_item(@item, 1)
    else
      $game_switches[TRIACULAR::STEALSHOP::STEAL] = true
      SceneManager.goto(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  alias r2_on_number_ok_bwvm45    on_number_ok
  def on_number_ok
    r2_on_number_ok_bwvm45
    case @command_window.current_symbol
    when :steal
      do_steal(@number_window.number)
    end
  end
  #--------------------------------------------------------------------------
  # * Exit Quantity Input
  #--------------------------------------------------------------------------
  alias r2_end_number_input_mtr23  end_number_input
  def end_number_input
    r2_end_number_input_mtr23
    case @command_window.current_symbol
    when :steal
      activate_steal_window
    end
  end
end

*UPDATE
added in a variable for perfect chance.
Useful if you want items or equipment to change the chance for success.
(provided you have a way to add that onto equipment)
Hey, so I finally updated the Steal script to your edit because the original one from Triacular wasn't working; the "Steal" command was not showing. So I entered your edit into my game, and had the same issue. Then I found out that my script order was the problem, and I simply put the Steal script below all of my other ones.

However: with your edit, my steals always fail, even when I set the percentage of success to 100. I put Triacular's script back in and the steal worked again. So I was wondering if Triacular's original script is fine to use, even if it isn't aliased? It works as intended.

Either way, I just wanted to let you and anyone else who stumbles across this thread know that your edit causes the steals to always fail.

Also, the "Last Update" date should be 2019.02.13, not 2012.02.19 :p

EDIT: Aaaand of course, I misunderstood all along. The "Dice" is now a variable that I have to set. :rswt Wow am I dumb. Now it works perfectly, and I can allow the player to level up his thief stats, which is awesome. Sorry for the inconvenience, lol...
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
1,853
Reaction score
408
First Language
English
Primarily Uses
RMVXA
with your edit, my steals always fail,
That's interesting as it works for me perfectly.

But I see that you worked it out. Good. At least for my version I assume?

*EDIT I also just made another small change if you want that. I set it so that it does not show the number window. It just does the steal for the item you have highlighted.
 

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
That's interesting as it works for me perfectly.

But I see that you worked it out. Good. At least for my version I assume?

*EDIT I also just made another small change if you want that. I set it so that it does not show the number window. It just does the steal for the item you have highlighted.
Yeah, it works great after I figured it out, haha.
Sure, I'd be happy to have the change!

Also, do you know of any script that shows variables in the status menu? Like Yanfly's Actor Variables for MV... but for VXAce
I'd like to put the Steal Variable in the status menu. It'll be a Thief stat, if that makes sense?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
1,853
Reaction score
408
First Language
English
Primarily Uses
RMVXA
Code:
#==============================================================================
#
# ▼ Triacular - Steal Shop v1.05
# -- Last Updated: 2019.03.03
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows stealing of items in scene shop, made for RPG Maker VX Ace.
#
# Please give credit to Triacular
# free for non-commercial and commercial uses
#==============================================================================
#==============================================================================
# ▼ Versions Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019-01-26 - Initial script                         - Triacular
# 2019-01-27 - Reduced duplicate parts                - Triacular
# 2019-02-12 - Added switch to disable script         - Triacular
# 2019-02-13 - Added alias, removed global switches   - Roninator2
# 2019-03-03 - Changed to not show the number window  - Roninator2
#==============================================================================

#========================PREFERENCES=============================
module TRIACULAR
  module STEALSHOP
    DICE = 20 # variable for % chance steal will succeed
    STEAL = 21 # switch you will use when steal fails
    ENABLE = 22 # switch to use to enable script. True = on
  end
end
#================================================================

#==============================================================================
# ** Vocab
#------------------------------------------------------------------------------
#  This module defines terms and messages. It defines some data as constant
# variables. Terms in the database are obtained from $data_system.
#==============================================================================

module Vocab
  ShopSteal       = "Steal"
end

#==============================================================================
# ** Window_ShopCommand
#------------------------------------------------------------------------------
#  This window is for selecting buy/sell on the shop screen.
#==============================================================================

class Window_ShopCommand < Window_HorzCommand
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias r2_make_cl_m2dfff98   make_command_list
  def make_command_list
    r2_make_cl_m2dfff98
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      add_command(Vocab::ShopSteal,  :steal)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    if $game_switches[TRIACULAR::STEALSHOP::ENABLE] == true
      return 4
    else
      return 3
    end
  end
end

#==============================================================================
# ** 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

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  This class performs shop screen processing.
#==============================================================================
class Scene_Shop < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias r2_start_45nf3  start
  def start
    r2_start_45nf3
    create_steal_window
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias r2_create_cw_64rgu  create_command_window
  def create_command_window
    r2_create_cw_64rgu
    @command_window.set_handler(:steal,  method(:command_steal))
  end
  #--------------------------------------------------------------------------
  # * [Steal] Command
  #--------------------------------------------------------------------------
  def command_steal
    @dummy_window.hide
    activate_steal_window
  end
  #--------------------------------------------------------------------------
  # * Category Steal [Cancel]
  #--------------------------------------------------------------------------
  def on_steal_cancel
    @command_window.activate
    @dummy_window.show
    @steal_window.hide
    @status_window.hide
    @status_window.item = nil
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # * Category Steal [OK]
  #--------------------------------------------------------------------------
  def on_steal_ok
    @item = @steal_window.item
    do_steal(1)
  end
  #--------------------------------------------------------------------------
  # * Create Steal Window
  #--------------------------------------------------------------------------
  def create_steal_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @steal_window = Window_ShopSteal.new(0, wy, wh, @goods)
    @steal_window.viewport = @viewport
    @steal_window.help_window = @help_window
    @steal_window.status_window = @status_window
    @steal_window.hide
    @steal_window.set_handler(:ok,     method(:on_steal_ok))
    @steal_window.set_handler(:cancel, method(:on_steal_cancel))
  end
  #--------------------------------------------------------------------------
  # * Quantity Input [OK]
  #--------------------------------------------------------------------------
  def activate_steal_window
    @steal_window.show.activate
    @status_window.show
  end
  #--------------------------------------------------------------------------
  # * Execute Steal
  #--------------------------------------------------------------------------
  def do_steal(number)
    life_or_death = rand(100)
    if life_or_death <= $game_variables[TRIACULAR::STEALSHOP::DICE]
      $game_party.gain_item(@item, 1)
      activate_steal_window
    else
      $game_switches[TRIACULAR::STEALSHOP::STEAL] = true
      SceneManager.goto(Scene_Map)
    end
  end
end
@HikariJake
Status menu no, but this....
https://forums.rpgmakerweb.com/index.php?threads/show-a-textbox-with-variable-counters.98255/
 
Last edited:

Romanticist

Veteran
Veteran
Joined
Oct 8, 2015
Messages
215
Reaction score
116
First Language
English
Primarily Uses
RMVXA
#==============================================================================
#
# ▼ Triacular - Steal Shop v1.05
# -- Last Updated: 2012.02.19
# -- Level: Easy, Normal
# -- Requires: n/a
The date is still wrong :kaodes:
But other than that, it looks great. :LZScheeze:

And hmm, I can probably do something cool with that variable menu. Thanks for linking it!
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
42
Reaction score
19
First Language
Portuguese
Primarily Uses
Other
I added some features on top of @Roninator2 's changes.

Here it is:
Code:
#==============================================================================
#
# ▼ Triacular - Steal Shop v1.06
# -- Last Updated: 2019.03.13
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows stealing of items in scene shop, made for RPG Maker VX Ace.
#
# Please give credit to Triacular
# free for non-commercial and commercial uses
#==============================================================================
($imported ||= {})[:Triacular_ShopSteal] = 1.06
#==============================================================================
# ▼ Versions Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019-01-26 - Initial script                         - Triacular
# 2019-01-27 - Reduced duplicate parts                - Triacular
# 2019-02-12 - Added switch to disable script         - Triacular
# 2019-02-13 - Added alias, removed global switches   - Roninator2
# 2019-03-03 - Changed to not show the number window  - Roninator2
# 2019-03-13 - Several Changes. Listed below          - CaRaCrAzY_Petrassi
#   ▼ [Compatibility]
#     Moved all classes inside a namespace module
#     Added version data to $imported global variable
#   ▼ [Convenience]
#     Moved constants to the module root
#     Transformed the DICE constant into VARIABLE_STEAL_BONUS
#   ▼ [Features]
#     Displays the Stealing Success rate insteand of item's price.
#     Added a constant for controling the [steal] command's position in the list
#     Added a switch to enable or disable steal command mid-game
#     Added a constant for inputing a formula for General Stealing Success Rate
#     Entries in the shop that has zero percent chance of stealing are disabled
#     Added notetag support for editing Custom Stealing Success Rate formulas
#     Added a constant for controlling the Maximum Stealing Success Rate
#==============================================================================
#==============================================================================
# ▼ Notetags
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script support the following notetags:
#
#-------------------------------------------------------------------------------
#   <steal: x>
#-------------------------------------------------------------------------------
#   This will add a custom calculation method for a particular item. This
#   means that the default Success Rate formula will be replaced for this one.
#     x : formula
#
#   Considerations about the Formula:
#   The formula is an actual piece of code that will be evaluated, its final
#   output must be a number between zero and one that will be converted into a
#   percentage; and these are the following values that will be passed to it:
#     a : Game Party   (Same thing as $game_party)
#     b : item         (The item itself)
#     p : item's price (converted to float, used for calculating divisions)
#
#   Examples:
#   <steal: a.agi / p> 
#   <steal: 0.5>
#   <steal: a.agi / (a.agi + p / 10.0)>
#==============================================================================

#===============================================================================
# ** TRIACULAR
#-------------------------------------------------------------------------------
#   Module used for namespacing the Shop Steal System
#   Everything about this system is contained inside this module.
#===============================================================================

module TRIACULAR
  #-----------------------------------------------------------------------------
  # * ID of the Switch that enables the script
  #-----------------------------------------------------------------------------
  SWITCH_ENABLE        = 22     
 
  #-----------------------------------------------------------------------------
  # * ID of the Switch that will become ON when stealing fails
  #-----------------------------------------------------------------------------
  SWITCH_STEAL         = 21     

  #-----------------------------------------------------------------------------
  # * ID of the Switch that enable/disable the shop's [Steal] command at runtime
  #-----------------------------------------------------------------------------
  SWITCH_COMMAND       = 23     

  #-----------------------------------------------------------------------------
  # * ID of the Variable responsible for giving a percent bonus to steal chance
  #-----------------------------------------------------------------------------
  VARIABLE_STEAL_BONUS = 20     
 
  #-----------------------------------------------------------------------------
  # * [Steal] command's name in the Shop's command list
  #-----------------------------------------------------------------------------
  VOCAB_STEAL          = "Steal" 
 
  #-----------------------------------------------------------------------------
  # * Steal command's position at Shop's command list
  #   Useful if you want the [Steal] command to appear between [Buy] or [Sell]
  #-----------------------------------------------------------------------------
  COMMAND_POSITION     = 2       
 
  #-----------------------------------------------------------------------------
  # * Dynamically increases the number of columns in Shop's command list to fit
  #   the [Steal] command entry.
  #-----------------------------------------------------------------------------
  DYNAMIC_COL_COUNT    = true   
 
  #-----------------------------------------------------------------------------
  # * General Stealing Success Rate formula usef for all items lacking a Custom
  #   Stealing Formula notetag.
  #-----------------------------------------------------------------------------
  #     a : Game Party (Same thing as $game_party)
  #     b : item
  #     p : item's price (converted to float, used for calculating divisions)
  #-----------------------------------------------------------------------------
  STEAL_FORMULA        = "a.agi / p"
 
  #-----------------------------------------------------------------------------
  # * Maximum Stealing Rate chance
  #-----------------------------------------------------------------------------
  STEAL_RATE_CAP       = 0.9
 
  #==============================================================================
  # ** Window_ShopCommand
  #------------------------------------------------------------------------------
  #  Wraping and redefining methods inside Window_ShopCommand class
  #==============================================================================
 
  class ::Window_ShopCommand
    #--------------------------------------------------------------------------
    # * Create Command List
    #--------------------------------------------------------------------------
    alias r2_make_cl_m2dfff98   make_command_list
    def make_command_list
      r2_make_cl_m2dfff98
      if $game_switches[SWITCH_ENABLE]
        enabled  = $game_switches[SWITCH_COMMAND]
        position = COMMAND_POSITION
        Steal.insert_command(@list, position, VOCAB_STEAL, :steal, enabled)
      end
    end 
    #--------------------------------------------------------------------------
    # * Get Digit Count
    #--------------------------------------------------------------------------
    alias cc_cm_majdffh46   col_max
    def col_max
      cc_cm_majdffh46 + ($game_switches[SWITCH_ENABLE] ? 1 : 0)
    end if DYNAMIC_COL_COUNT
  end
 
  #=============================================================================
  # ** Scene_Shop
  #-----------------------------------------------------------------------------
  #   Wraping and redefining methods inside Scene_Shop class
  #=============================================================================

  class ::Scene_Shop
    #--------------------------------------------------------------------------
    # * Start Processing
    #--------------------------------------------------------------------------
    alias r2_start_45nf3  start
    def start
      r2_start_45nf3
      create_steal_window
    end
    #--------------------------------------------------------------------------
    # * Create Command Window
    #--------------------------------------------------------------------------
    alias r2_create_cw_64rgu  create_command_window
    def create_command_window
      r2_create_cw_64rgu
      @command_window.set_handler(:steal, method(:command_steal))
    end
    #--------------------------------------------------------------------------
    # * Create Steal Window
    #--------------------------------------------------------------------------
    def create_steal_window
      wy                          = @dummy_window.y
      wh                          = @dummy_window.height
      @steal_window               = Window_ShopSteal.new(0, wy, wh, @goods)
      @steal_window.viewport      = @viewport
      @steal_window.help_window   = @help_window
      @steal_window.status_window = @status_window
      @steal_window.hide
      @steal_window.set_handler(:ok,     method(:on_steal_ok))
      @steal_window.set_handler(:cancel, method(:on_steal_cancel))
    end
    #--------------------------------------------------------------------------
    # * The current selected item
    #--------------------------------------------------------------------------
    def item
      @steal_window.item
    end
    #--------------------------------------------------------------------------
    # * [Steal] Command
    #--------------------------------------------------------------------------
    def command_steal
      @dummy_window.hide
      activate_steal_window
    end
    #--------------------------------------------------------------------------
    # * Category Steal [Cancel]
    #--------------------------------------------------------------------------
    def on_steal_cancel
      @command_window.activate
      @dummy_window.show
      @steal_window.hide
      @status_window.hide
      @status_window.item = nil
      @help_window.clear
    end
    #--------------------------------------------------------------------------
    # * Category Steal [OK]
    #--------------------------------------------------------------------------
    def on_steal_ok
      do_steal(1)
    end
    #--------------------------------------------------------------------------
    # * Quantity Input [OK]
    #--------------------------------------------------------------------------
    def activate_steal_window
      @steal_window.show.activate
      @status_window.show
    end
    #--------------------------------------------------------------------------
    # * Execute Steal
    #--------------------------------------------------------------------------
    def do_steal(number)
      if rand <= item.rate
        $game_party.gain_item(item, number)
        activate_steal_window
      else
        $game_switches[SWITCH_STEAL] = true
        SceneManager.goto(Scene_Map)
      end
    end
  end
 
  #=============================================================================
  # ** RPG::BaseItem
  #-----------------------------------------------------------------------------
  #  Class containing steal data to be inserted into RPG::BaseItem
  #  Used almost exclusively to extract notetags about stealing.
  #=============================================================================
 
  class ::RPG::BaseItem
    #-------------------------------------------------------------------------
    # * Calculates the chances of stealing this item
    #-------------------------------------------------------------------------
    def rate
      rate = steal_rate_formula.($game_party, self, price.to_f)
      rate += $game_variables[VARIABLE_STEAL_BONUS] / 100.0
      [[rate, 0].max, STEAL_RATE_CAP].min
    end
    #---------------------------------------------------------------------------
    # * Formula for calculating the chances of stealing this item from a shop
    #---------------------------------------------------------------------------
    def steal_rate_formula
      @steal_rate_formula ||= retrieve_steal_rate_data
    end
    #---------------------------------------------------------------------------
    # * Steal Rate formula from a retrieved notetag
    #---------------------------------------------------------------------------
    def retrieve_steal_rate_data
      if match_data = steal_rate_tag
        eval("lambda {|a, b, p| #{match_data[:value]} }")
      else
        Steal.default_rate
      end
    end
    #---------------------------------------------------------------------------
    # * Match_data from all matches of <steal: formula>
    #---------------------------------------------------------------------------
    def steal_rate_tag
      Notetag.scan_tags(note, :steal).first
    end
  end

  #=============================================================================
  # ** 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
      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
    #--------------------------------------------------------------------------
    # * Get Activation State of Selection Item
    #--------------------------------------------------------------------------
    def current_item_enabled?
      enable?(@data[index])
    end
    #--------------------------------------------------------------------------
    # * Get Price of Item
    #--------------------------------------------------------------------------
    def price(item)
      @price[item]
    end
    #--------------------------------------------------------------------------
    # * Display in Enabled State?
    #--------------------------------------------------------------------------
    def enable?(item)
      item && price(item) > 0 && !$game_party.item_max?(item)
    end
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
      make_item_list
      create_contents
      draw_all_items
    end
    #--------------------------------------------------------------------------
    # * Create Item List
    #--------------------------------------------------------------------------
    def make_item_list
      containers = [$data_items, $data_weapons, $data_armors]
      @data = @shop_goods.map { |goods| item = containers[goods[0]][goods[1]] }
      @price = Hash[@data.map { |item| [item, item.rate] }]
    end
    #--------------------------------------------------------------------------
    # * Draw Item
    #--------------------------------------------------------------------------
    def draw_item(index)
      item = @data[index]
      rect = item_rect(index)
      draw_item_name(item, rect.x, rect.y, enable?(item))
      rect.width -= 4
      draw_text(rect, "#{(price(item) * 100).to_i}%", 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
 
  #=============================================================================
  # ** Steal
  #-----------------------------------------------------------------------------
  #  Class containing system's additional data
  #=============================================================================
 
  module Steal
    #-------------------------------------------------------------------------
    # * Default Stealing Success formula defined at the start of the script.
    #   This formula is used for items lacking a <steal:formula> Notetag.
    #-------------------------------------------------------------------------
    def self.default_rate
      @default_rate ||= eval("lambda {|a, b, p| #{STEAL_FORMULA} }")
    end
    #-------------------------------------------------------------------------
    # * Inserts a command in any position of a command list
    #-------------------------------------------------------------------------
    def self.insert_command(list, position, name, symbol, enabled)
      command = {name: name, symbol: symbol, enabled: enabled}
      list.insert([[position, 0].max, list.size].min, command)
    end
  end
 
  #=============================================================================
  # ** Notetag
  #-----------------------------------------------------------------------------
  #  Module for extrating Notetags
  #=============================================================================
 
  module Notetag
    #-------------------------------------------------------------------------
    # * Extracts notetag data matching the given pattern type
    #-------------------------------------------------------------------------
    #     note : The note field or string
    #     tag  : The tag's name i.e. :Expertise will search for <Expertise>
    #-------------------------------------------------------------------------
    def self.scan_tags(note, tag)
      note.to_enum(:scan, single(tag)).map { Regexp.last_match }
    end
    #-------------------------------------------------------------------------
    # * Regex for retrieving a notetag containing only one value
    #     <tag_name:value>
    #-------------------------------------------------------------------------
    def self.single(tag_name)
      %r{
        (?: <\s*#{tag_name}\s*) # < tag_name    the tag name
        (?: :\s*(?<value>.+?))  # : value       the second value
        (?: \s*\/?>)            # />            the tag closing
      }ix
    end
  end
end

#-------------------------------------------------------------------------------
# End of script.
#-------------------------------------------------------------------------------

I wish I had more time to add more features, but that will have to wait :frown:
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

It took me 6 retries to get the color of Yoshi I wanted. 30 mins of recording. 30 mins of voice work. Probably another 20 mins of waiting in between takes. But finally I got him...
I bought a 2 week emergency food supply. And people are already making fun of me :( I'll be fed for a bit while they go hungry when food supplies get cut(for whatever reason).
Start of semester today. This is going to be a long one.
Can't wait for the next Sonichu
Birdhouses are usually made of wood. Birds typically live in trees. Trees are wood. Birdhouses are made of birdhouses.

Forum statistics

Threads
93,674
Messages
914,487
Members
123,265
Latest member
karqui
Top