| 赞 | 27  | 
 
| VIP | 400 | 
 
| 好人卡 | 13 | 
 
| 积分 | 17 | 
 
| 经验 | 69730 | 
 
| 最后登录 | 2025-8-2 | 
 
| 在线时间 | 3039 小时 | 
 
 
 
 
 
Lv3.寻梦者 (暗夜天使) 精灵族の天使 
	- 梦石
 - 0 
 
        - 星屑
 - 1707 
 
        - 在线时间
 - 3039 小时
 
        - 注册时间
 - 2007-3-16
 
        - 帖子
 - 33731
 
 
   
 
 | 
	
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员  
 
x
 
 本帖最后由 精灵使者 于 2014-12-20 20:40 编辑  
 
商店使用默认脚本,与华丽版商店可能冲突。 
修正了脚本关闭的情况下,低于价格的物品仍然可以买的BUG 
修正了购买物品数量的BUG。 
使用方法:在脚本里设置好需要的值,然后在事件里面给相应的东西赋值后开启商店即可。 
   BUY_SELL_SWITCH = 1   #默认此脚本的开启开关号,为0则不使用开关,默认开启 
   BUY_VARIABLE = 2      #买价浮动变量ID号,如果ID号或者其值为0的话则默认卖价 
                         #100的时候也是原卖价,如果是其他数值按照100的比例浮动。 
                         #例如200的时候就是原价的2倍,50的时候是原价的一半。 
   SELL_VARIABLE = 1     #卖价浮动变量ID号,如果ID号或者值为0的的话则是默认卖价 
                         #设置的原理同买价变量(100的时候是原卖价) 
   BUY_MAX_VARIABLE = 3  #购买最高个数变量ID号,如果手持物品超过此数则无法购买, 
                         #购买变量ID号或者值为0的时候是99个,否则则是可以买物品的 
                         #个数。 
  将其设定好以后就可以开始工作了。 
效果截图: 
![]()  
范例工程:
 
商店的变动新.zip
(204.61 KB, 下载次数: 906)
 
脚本如下: 
- #------------------------------------------------------------------------------
 
 - # 商店买卖价、最大值变动脚本 VER 1.3
 
 - #
 
 - # 更新了脚本关闭的情况下,低于价格的物品仍然可以买的BUG(紧急更新)
 
 - # 更新了商店可以买的数目的BUG(紧急更新)
 
 - # 可以使商店变动的脚本。
 
 - # 更新几个可以关闭功能的方法。
 
 - # 制作 by 精灵使者
 
 - #------------------------------------------------------------------------------
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 设定部分
 
 -   #--------------------------------------------------------------------------
 
 -    BUY_SELL_SWITCH = 1   #默认此脚本的开启开关号,为0则不使用开关,默认开启
 
 -    BUY_VARIABLE = 2      #买价浮动变量ID号,如果ID号或者其值为0的话则默认卖价
 
 -                          #100的时候也是原卖价,如果是其他数值按照100的比例浮动。
 
 -                          #例如200的时候就是原价的2倍,50的时候是原价的一半。
 
 -    SELL_VARIABLE = 1     #卖价浮动变量ID号,如果ID号或者值为0的的话则是默认卖价
 
 -                          #设置的原理同买价变量(100的时候是原卖价)
 
 -    BUY_MAX_VARIABLE = 3  #购买最高个数变量ID号,如果手持物品超过此数则无法购买,
 
 -                          #购买变量ID号或者值为0的时候是99个,否则则是可以买物品的
 
 -                          #个数。
 
 -   
 
 - #==============================================================================
 
 - # ■ Scene_Shop
 
 - #------------------------------------------------------------------------------
 
 - #  处理商店画面的类。
 
 - #==============================================================================
 
  
- class Scene_Shop
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 刷新画面 (购买窗口激活的情况下)
 
 -   #--------------------------------------------------------------------------
 
 -   def update_buy
 
 -     # 设置状态窗口的物品
 
 -     @status_window.item = @buy_window.item
 
 -     # 按下 B 键的情况下
 
 -     if Input.trigger?(Input::B)
 
 -       # 演奏取消 SE
 
 -       $game_system.se_play($data_system.cancel_se)
 
 -       # 窗口状态转向初期模式
 
 -       @command_window.active = true
 
 -       @dummy_window.visible = true
 
 -       @buy_window.active = false
 
 -       @buy_window.visible = false
 
 -       @status_window.visible = false
 
 -       @status_window.item = nil
 
 -       # 删除帮助文本
 
 -       @help_window.set_text("")
 
 -       return
 
 -     end
 
 -     # 按下 C 键的情况下
 
 -     if Input.trigger?(Input::C)
 
 -       # 获取物品
 
 -       @item = @buy_window.item
 
 -       ####################################################################
 
 -       # 物品无效的情况下、或者价格在所持金以上的情况下
 
 -       if BUY_SELL_SWITCH == 0
 
 -       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
 
 -         # 演奏冻结 SE
 
 -         $game_system.se_play($data_system.buzzer_se)
 
 -         return
 
 -       end
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or $game_variables[BUY_VARIABLE] == 0
 
 -       if @item == nil or @item.price > $game_party.gold
 
 -         # 演奏冻结 SE
 
 -         $game_system.se_play($data_system.buzzer_se)
 
 -         return
 
 -       end
 
 -       else 
 
 -       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
 
 -         # 演奏冻结 SE
 
 -         $game_system.se_play($data_system.buzzer_se)
 
 -         return
 
 -       end
 
 -     end
 
 -     ###################################################
 
 -       # 获取物品所持数
 
 -       case @item
 
 -       when RPG::Item
 
 -         number = $game_party.item_number(@item.id)
 
 -       when RPG::Weapon
 
 -         number = $game_party.weapon_number(@item.id)
 
 -       when RPG::Armor
 
 -         number = $game_party.armor_number(@item.id)
 
 -       end
 
 -       # 如果已经拥有了 99 个情况下
 
 -       #####################################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -         @buy_max = $game_variables[BUY_MAX_VARIABLE]
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or $game_variables[BUY_MAX_VARIABLE] == 0
 
 -         @buy_max = 99
 
 -       else
 
 -         @buy_max = $game_variables[BUY_MAX_VARIABLE]
 
 -       end
 
 -       if number >= @buy_max
 
 -         # 演奏冻结 SE
 
 -         $game_system.se_play($data_system.buzzer_se)
 
 -         return
 
 -       end
 
 -       ######################################################
 
 -       # 演奏确定 SE
 
 -       $game_system.se_play($data_system.decision_se)
 
 -       # 计算可以最多购买的数量
 
 -       max = @item.price == 0 ? @buy_max : $game_party.gold / @item.price
 
 -       max = [max, (@buy_max - number)].min
 
 -       # 窗口状态转向数值输入模式
 
 -       @buy_window.active = false
 
 -       @buy_window.visible = false
 
 -       ######################################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -       @number_window.set(@item, max, @item.price * 
 
 -       $game_variables[BUY_VARIABLE] / 100)
 
 -     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or 
 
 -       $game_variables[BUY_VARIABLE] == 0
 
 -       @number_window.set(@item, max, @item.price)
 
 -     else
 
 -       @number_window.set(@item, max, @item.price * 
 
 -       $game_variables[BUY_VARIABLE] / 100)
 
 -     end
 
 -       #####################################################
 
 -       @number_window.active = true
 
 -       @number_window.visible = true
 
 -     end
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 画面更新 (卖出窗口激活的情况下)
 
 -   #--------------------------------------------------------------------------
 
 -   def update_sell
 
 -     # 按下 B 键的情况下
 
 -     if Input.trigger?(Input::B)
 
 -       # 演奏取消 SE
 
 -       $game_system.se_play($data_system.cancel_se)
 
 -       # 窗口状态转向初期模式
 
 -       @command_window.active = true
 
 -       @dummy_window.visible = true
 
 -       @sell_window.active = false
 
 -       @sell_window.visible = false
 
 -       @status_window.item = nil
 
 -       # 删除帮助文本
 
 -       @help_window.set_text("")
 
 -       return
 
 -     end
 
 -     # 按下 C 键的情况下
 
 -     if Input.trigger?(Input::C)
 
 -       # 获取物品
 
 -       @item = @sell_window.item
 
 -       # 设置状态窗口的物品
 
 -       @status_window.item = @item
 
 -       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
 
 -       if @item == nil or @item.price == 0
 
 -         # 演奏冻结 SE
 
 -         $game_system.se_play($data_system.buzzer_se)
 
 -         return
 
 -       end
 
 -       # 演奏确定 SE
 
 -       $game_system.se_play($data_system.decision_se)
 
 -       # 获取物品的所持数
 
 -       case @item
 
 -       when RPG::Item
 
 -         number = $game_party.item_number(@item.id)
 
 -       when RPG::Weapon
 
 -         number = $game_party.weapon_number(@item.id)
 
 -       when RPG::Armor
 
 -         number = $game_party.armor_number(@item.id)
 
 -       end
 
 -       # 最大卖出个数 = 物品的所持数
 
 -       max = number
 
 -       # 窗口状态转向个数输入模式
 
 -       @sell_window.active = false
 
 -       @sell_window.visible = false
 
 -       ###############################################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -         @number_window.set(@item, max, @item.price * 
 
 -         $game_variables[SELL_VARIABLE] / 100)
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0 or
 
 -         $game_variables[SELL_VARIABLE] == 0
 
 -         @number_window.set(@item, max, @item.price / 2)
 
 -       else
 
 -         @number_window.set(@item, max, @item.price * 
 
 -         $game_variables[SELL_VARIABLE] / 100)
 
 -       end
 
 -       ###############################################################
 
 -       @number_window.active = true
 
 -       @number_window.visible = true
 
 -       @status_window.visible = true
 
 -     end
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 刷新画面 (个数输入窗口激活的情况下)
 
 -   #--------------------------------------------------------------------------
 
 -   def update_number
 
 -     # 按下 B 键的情况下
 
 -     if Input.trigger?(Input::B)
 
 -       # 演奏取消 SE
 
 -       $game_system.se_play($data_system.cancel_se)
 
 -       # 设置个数输入窗口为不活动·非可视状态
 
 -       @number_window.active = false
 
 -       @number_window.visible = false
 
 -       # 命令窗口光标位置分支
 
 -       case @command_window.index
 
 -       when 0  # 购买
 
 -         # 窗口状态转向购买模式
 
 -         @buy_window.active = true
 
 -         @buy_window.visible = true
 
 -       when 1  # 卖出
 
 -         # 窗口状态转向卖出模式
 
 -         @sell_window.active = true
 
 -         @sell_window.visible = true
 
 -         @status_window.visible = false
 
 -       end
 
 -       return
 
 -     end
 
 -     # 按下 C 键的情况下
 
 -     if Input.trigger?(Input::C)
 
 -       # 演奏商店 SE
 
 -       $game_system.se_play($data_system.shop_se)
 
 -       # 设置个数输入窗口为不活动·非可视状态
 
 -       @number_window.active = false
 
 -       @number_window.visible = false
 
 -       # 命令窗口光标位置分支
 
 -       case @command_window.index
 
 -       when 0  # 购买
 
 -         # 购买处理
 
 -         ###############################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -         $game_party.lose_gold(@number_window.number * (@item.price * 
 
 -         $game_variables[BUY_VARIABLE] / 100))
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or
 
 -         $game_variables[BUY_VARIABLE] == 0
 
 -         $game_party.lose_gold(@number_window.number * @item.price)
 
 -       else
 
 -         $game_party.lose_gold(@number_window.number * (@item.price * 
 
 -         $game_variables[BUY_VARIABLE] / 100))
 
 -       end
 
 -       ###################################################
 
 -         case @item
 
 -         when RPG::Item
 
 -           $game_party.gain_item(@item.id, @number_window.number)
 
 -         when RPG::Weapon
 
 -           $game_party.gain_weapon(@item.id, @number_window.number)
 
 -         when RPG::Armor
 
 -           $game_party.gain_armor(@item.id, @number_window.number)
 
 -         end
 
 -         # 刷新各窗口
 
 -         @gold_window.refresh
 
 -         @buy_window.refresh
 
 -         @status_window.refresh
 
 -         # 窗口状态转向购买模式
 
 -         @buy_window.active = true
 
 -         @buy_window.visible = true
 
 -       when 1  # 卖出
 
 -         # 卖出处理
 
 -         ###############################################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -         $game_party.gain_gold(@number_window.number * (@item.price *
 
 -         $game_variables[SELL_VARIABLE] / 100))
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0 or
 
 -         $game_variables[SELL_VARIABLE] == 0
 
 -         $game_party.gain_gold(@number_window.number * (@item.price / 2))
 
 -       else
 
 -         $game_party.gain_gold(@number_window.number * (@item.price *
 
 -         $game_variables[SELL_VARIABLE] / 100))
 
 -       end
 
 -         ##############################################################
 
 -         case @item
 
 -         when RPG::Item
 
 -           $game_party.lose_item(@item.id, @number_window.number)
 
 -         when RPG::Weapon
 
 -           $game_party.lose_weapon(@item.id, @number_window.number)
 
 -         when RPG::Armor
 
 -           $game_party.lose_armor(@item.id, @number_window.number)
 
 -         end
 
 -         # 刷新各窗口
 
 -         @gold_window.refresh
 
 -         @sell_window.refresh
 
 -         @status_window.refresh
 
 -         # 窗口状态转向卖出模式
 
 -         @sell_window.active = true
 
 -         @sell_window.visible = true
 
 -         @status_window.visible = false
 
 -       end
 
 -       return
 
 -     end
 
 -   end
 
 - end
 
 - #==============================================================================
 
 - # ■ Window_ShopBuy
 
 - #------------------------------------------------------------------------------
 
 - #  商店画面、浏览显示可以购买的商品的窗口。
 
 - #==============================================================================
 
  
- class Window_ShopBuy < Window_Selectable
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 描绘项目
 
 -   #     index : 项目编号
 
 -   #--------------------------------------------------------------------------
 
 -   def draw_item(index)
 
 -     item = @data[index]
 
 -     # 获取物品所持数
 
 -     case item
 
 -     when RPG::Item
 
 -       number = $game_party.item_number(item.id)
 
 -     when RPG::Weapon
 
 -       number = $game_party.weapon_number(item.id)
 
 -     when RPG::Armor
 
 -       number = $game_party.armor_number(item.id)
 
 -     end
 
 -     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
 
 -     # 除此之外的情况设置为无效文字色
 
 -     ###############################################################
 
 -       if BUY_SELL_SWITCH == 0
 
 -         @buy_max = $game_variables[BUY_MAX_VARIABLE]
 
 -         if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
 
 -          self.contents.font.color = normal_color
 
 -         else
 
 -          self.contents.font.color = disabled_color
 
 -         end
 
 -       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_MAX_VARIABLE == 0 or
 
 -         $game_variables[BUY_VARIABLE] == 0
 
 -         @buy_max = 99
 
 -         if item.price <= $game_party.gold and number < @buy_max
 
 -          self.contents.font.color = normal_color
 
 -         else
 
 -          self.contents.font.color = disabled_color
 
 -         end
 
 -       else
 
 -         @buy_max = $game_variables[BUY_MAX_VARIABLE]
 
 -         if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
 
 -          self.contents.font.color = normal_color
 
 -         else
 
 -          self.contents.font.color = disabled_color
 
 -         end
 
 -       end
 
 -     ###############################################################
 
 -     x = 4
 
 -     y = index * 32
 
 -     rect = Rect.new(x, y, self.width - 32, 32)
 
 -     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
 
 -     bitmap = RPG::Cache.icon(item.icon_name)
 
 -     opacity = self.contents.font.color == normal_color ? 255 : 128
 
 -     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
 
 -     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
 
 -     ####################################################
 
 -     if BUY_SELL_SWITCH == 0
 
 -       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
 
 -       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
 
 -     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or
 
 -        $game_variables[BUY_VARIABLE] == 0
 
 -       self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
 
 -     else
 
 -       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
 
 -       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
 
 -     end
 
 -     #####################################################
 
 -   end
 
 - end
 
 
  复制代码 |   
 
 
 
 |