设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 8710|回复: 17
打印 上一主题 下一主题

[原创发布] 【不是创意的创意】让买卖价格和最大值变动的商店VER1.3

[复制链接]

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

跳转到指定楼层
1
发表于 2008-12-12 00:13:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

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, 下载次数: 905)
脚本如下:

  1. #------------------------------------------------------------------------------
  2. # 商店买卖价、最大值变动脚本 VER 1.3
  3. #
  4. # 更新了脚本关闭的情况下,低于价格的物品仍然可以买的BUG(紧急更新)
  5. # 更新了商店可以买的数目的BUG(紧急更新)
  6. # 可以使商店变动的脚本。
  7. # 更新几个可以关闭功能的方法。
  8. # 制作 by 精灵使者
  9. #------------------------------------------------------------------------------
  10.   #--------------------------------------------------------------------------
  11.   # ● 设定部分
  12.   #--------------------------------------------------------------------------
  13.    BUY_SELL_SWITCH = 1   #默认此脚本的开启开关号,为0则不使用开关,默认开启
  14.    BUY_VARIABLE = 2      #买价浮动变量ID号,如果ID号或者其值为0的话则默认卖价
  15.                          #100的时候也是原卖价,如果是其他数值按照100的比例浮动。
  16.                          #例如200的时候就是原价的2倍,50的时候是原价的一半。
  17.    SELL_VARIABLE = 1     #卖价浮动变量ID号,如果ID号或者值为0的的话则是默认卖价
  18.                          #设置的原理同买价变量(100的时候是原卖价)
  19.    BUY_MAX_VARIABLE = 3  #购买最高个数变量ID号,如果手持物品超过此数则无法购买,
  20.                          #购买变量ID号或者值为0的时候是99个,否则则是可以买物品的
  21.                          #个数。
  22.   
  23. #==============================================================================
  24. # ■ Scene_Shop
  25. #------------------------------------------------------------------------------
  26. #  处理商店画面的类。
  27. #==============================================================================

  28. class Scene_Shop
  29.   #--------------------------------------------------------------------------
  30.   # ● 刷新画面 (购买窗口激活的情况下)
  31.   #--------------------------------------------------------------------------
  32.   def update_buy
  33.     # 设置状态窗口的物品
  34.     @status_window.item = @buy_window.item
  35.     # 按下 B 键的情况下
  36.     if Input.trigger?(Input::B)
  37.       # 演奏取消 SE
  38.       $game_system.se_play($data_system.cancel_se)
  39.       # 窗口状态转向初期模式
  40.       @command_window.active = true
  41.       @dummy_window.visible = true
  42.       @buy_window.active = false
  43.       @buy_window.visible = false
  44.       @status_window.visible = false
  45.       @status_window.item = nil
  46.       # 删除帮助文本
  47.       @help_window.set_text("")
  48.       return
  49.     end
  50.     # 按下 C 键的情况下
  51.     if Input.trigger?(Input::C)
  52.       # 获取物品
  53.       @item = @buy_window.item
  54.       ####################################################################
  55.       # 物品无效的情况下、或者价格在所持金以上的情况下
  56.       if BUY_SELL_SWITCH == 0
  57.       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
  58.         # 演奏冻结 SE
  59.         $game_system.se_play($data_system.buzzer_se)
  60.         return
  61.       end
  62.       elsif !$game_switches[BUY_SELL_SWITCH] or $game_variables[BUY_VARIABLE] == 0
  63.       if @item == nil or @item.price > $game_party.gold
  64.         # 演奏冻结 SE
  65.         $game_system.se_play($data_system.buzzer_se)
  66.         return
  67.       end
  68.       else
  69.       if @item == nil or @item.price * $game_variables[BUY_VARIABLE] / 100 > $game_party.gold
  70.         # 演奏冻结 SE
  71.         $game_system.se_play($data_system.buzzer_se)
  72.         return
  73.       end
  74.     end
  75.     ###################################################
  76.       # 获取物品所持数
  77.       case @item
  78.       when RPG::Item
  79.         number = $game_party.item_number(@item.id)
  80.       when RPG::Weapon
  81.         number = $game_party.weapon_number(@item.id)
  82.       when RPG::Armor
  83.         number = $game_party.armor_number(@item.id)
  84.       end
  85.       # 如果已经拥有了 99 个情况下
  86.       #####################################################
  87.       if BUY_SELL_SWITCH == 0
  88.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  89.       elsif !$game_switches[BUY_SELL_SWITCH] or $game_variables[BUY_MAX_VARIABLE] == 0
  90.         @buy_max = 99
  91.       else
  92.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  93.       end
  94.       if number >= @buy_max
  95.         # 演奏冻结 SE
  96.         $game_system.se_play($data_system.buzzer_se)
  97.         return
  98.       end
  99.       ######################################################
  100.       # 演奏确定 SE
  101.       $game_system.se_play($data_system.decision_se)
  102.       # 计算可以最多购买的数量
  103.       max = @item.price == 0 ? @buy_max : $game_party.gold / @item.price
  104.       max = [max, (@buy_max - number)].min
  105.       # 窗口状态转向数值输入模式
  106.       @buy_window.active = false
  107.       @buy_window.visible = false
  108.       ######################################################
  109.       if BUY_SELL_SWITCH == 0
  110.       @number_window.set(@item, max, @item.price *
  111.       $game_variables[BUY_VARIABLE] / 100)
  112.     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or
  113.       $game_variables[BUY_VARIABLE] == 0
  114.       @number_window.set(@item, max, @item.price)
  115.     else
  116.       @number_window.set(@item, max, @item.price *
  117.       $game_variables[BUY_VARIABLE] / 100)
  118.     end
  119.       #####################################################
  120.       @number_window.active = true
  121.       @number_window.visible = true
  122.     end
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 画面更新 (卖出窗口激活的情况下)
  126.   #--------------------------------------------------------------------------
  127.   def update_sell
  128.     # 按下 B 键的情况下
  129.     if Input.trigger?(Input::B)
  130.       # 演奏取消 SE
  131.       $game_system.se_play($data_system.cancel_se)
  132.       # 窗口状态转向初期模式
  133.       @command_window.active = true
  134.       @dummy_window.visible = true
  135.       @sell_window.active = false
  136.       @sell_window.visible = false
  137.       @status_window.item = nil
  138.       # 删除帮助文本
  139.       @help_window.set_text("")
  140.       return
  141.     end
  142.     # 按下 C 键的情况下
  143.     if Input.trigger?(Input::C)
  144.       # 获取物品
  145.       @item = @sell_window.item
  146.       # 设置状态窗口的物品
  147.       @status_window.item = @item
  148.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  149.       if @item == nil or @item.price == 0
  150.         # 演奏冻结 SE
  151.         $game_system.se_play($data_system.buzzer_se)
  152.         return
  153.       end
  154.       # 演奏确定 SE
  155.       $game_system.se_play($data_system.decision_se)
  156.       # 获取物品的所持数
  157.       case @item
  158.       when RPG::Item
  159.         number = $game_party.item_number(@item.id)
  160.       when RPG::Weapon
  161.         number = $game_party.weapon_number(@item.id)
  162.       when RPG::Armor
  163.         number = $game_party.armor_number(@item.id)
  164.       end
  165.       # 最大卖出个数 = 物品的所持数
  166.       max = number
  167.       # 窗口状态转向个数输入模式
  168.       @sell_window.active = false
  169.       @sell_window.visible = false
  170.       ###############################################################
  171.       if BUY_SELL_SWITCH == 0
  172.         @number_window.set(@item, max, @item.price *
  173.         $game_variables[SELL_VARIABLE] / 100)
  174.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0 or
  175.         $game_variables[SELL_VARIABLE] == 0
  176.         @number_window.set(@item, max, @item.price / 2)
  177.       else
  178.         @number_window.set(@item, max, @item.price *
  179.         $game_variables[SELL_VARIABLE] / 100)
  180.       end
  181.       ###############################################################
  182.       @number_window.active = true
  183.       @number_window.visible = true
  184.       @status_window.visible = true
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 刷新画面 (个数输入窗口激活的情况下)
  189.   #--------------------------------------------------------------------------
  190.   def update_number
  191.     # 按下 B 键的情况下
  192.     if Input.trigger?(Input::B)
  193.       # 演奏取消 SE
  194.       $game_system.se_play($data_system.cancel_se)
  195.       # 设置个数输入窗口为不活动·非可视状态
  196.       @number_window.active = false
  197.       @number_window.visible = false
  198.       # 命令窗口光标位置分支
  199.       case @command_window.index
  200.       when 0  # 购买
  201.         # 窗口状态转向购买模式
  202.         @buy_window.active = true
  203.         @buy_window.visible = true
  204.       when 1  # 卖出
  205.         # 窗口状态转向卖出模式
  206.         @sell_window.active = true
  207.         @sell_window.visible = true
  208.         @status_window.visible = false
  209.       end
  210.       return
  211.     end
  212.     # 按下 C 键的情况下
  213.     if Input.trigger?(Input::C)
  214.       # 演奏商店 SE
  215.       $game_system.se_play($data_system.shop_se)
  216.       # 设置个数输入窗口为不活动·非可视状态
  217.       @number_window.active = false
  218.       @number_window.visible = false
  219.       # 命令窗口光标位置分支
  220.       case @command_window.index
  221.       when 0  # 购买
  222.         # 购买处理
  223.         ###############################################
  224.       if BUY_SELL_SWITCH == 0
  225.         $game_party.lose_gold(@number_window.number * (@item.price *
  226.         $game_variables[BUY_VARIABLE] / 100))
  227.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or
  228.         $game_variables[BUY_VARIABLE] == 0
  229.         $game_party.lose_gold(@number_window.number * @item.price)
  230.       else
  231.         $game_party.lose_gold(@number_window.number * (@item.price *
  232.         $game_variables[BUY_VARIABLE] / 100))
  233.       end
  234.       ###################################################
  235.         case @item
  236.         when RPG::Item
  237.           $game_party.gain_item(@item.id, @number_window.number)
  238.         when RPG::Weapon
  239.           $game_party.gain_weapon(@item.id, @number_window.number)
  240.         when RPG::Armor
  241.           $game_party.gain_armor(@item.id, @number_window.number)
  242.         end
  243.         # 刷新各窗口
  244.         @gold_window.refresh
  245.         @buy_window.refresh
  246.         @status_window.refresh
  247.         # 窗口状态转向购买模式
  248.         @buy_window.active = true
  249.         @buy_window.visible = true
  250.       when 1  # 卖出
  251.         # 卖出处理
  252.         ###############################################################
  253.       if BUY_SELL_SWITCH == 0
  254.         $game_party.gain_gold(@number_window.number * (@item.price *
  255.         $game_variables[SELL_VARIABLE] / 100))
  256.       elsif !$game_switches[BUY_SELL_SWITCH] or SELL_VARIABLE == 0 or
  257.         $game_variables[SELL_VARIABLE] == 0
  258.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  259.       else
  260.         $game_party.gain_gold(@number_window.number * (@item.price *
  261.         $game_variables[SELL_VARIABLE] / 100))
  262.       end
  263.         ##############################################################
  264.         case @item
  265.         when RPG::Item
  266.           $game_party.lose_item(@item.id, @number_window.number)
  267.         when RPG::Weapon
  268.           $game_party.lose_weapon(@item.id, @number_window.number)
  269.         when RPG::Armor
  270.           $game_party.lose_armor(@item.id, @number_window.number)
  271.         end
  272.         # 刷新各窗口
  273.         @gold_window.refresh
  274.         @sell_window.refresh
  275.         @status_window.refresh
  276.         # 窗口状态转向卖出模式
  277.         @sell_window.active = true
  278.         @sell_window.visible = true
  279.         @status_window.visible = false
  280.       end
  281.       return
  282.     end
  283.   end
  284. end
  285. #==============================================================================
  286. # ■ Window_ShopBuy
  287. #------------------------------------------------------------------------------
  288. #  商店画面、浏览显示可以购买的商品的窗口。
  289. #==============================================================================

  290. class Window_ShopBuy < Window_Selectable
  291.   #--------------------------------------------------------------------------
  292.   # ● 描绘项目
  293.   #     index : 项目编号
  294.   #--------------------------------------------------------------------------
  295.   def draw_item(index)
  296.     item = @data[index]
  297.     # 获取物品所持数
  298.     case item
  299.     when RPG::Item
  300.       number = $game_party.item_number(item.id)
  301.     when RPG::Weapon
  302.       number = $game_party.weapon_number(item.id)
  303.     when RPG::Armor
  304.       number = $game_party.armor_number(item.id)
  305.     end
  306.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  307.     # 除此之外的情况设置为无效文字色
  308.     ###############################################################
  309.       if BUY_SELL_SWITCH == 0
  310.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  311.         if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
  312.          self.contents.font.color = normal_color
  313.         else
  314.          self.contents.font.color = disabled_color
  315.         end
  316.       elsif !$game_switches[BUY_SELL_SWITCH] or BUY_MAX_VARIABLE == 0 or
  317.         $game_variables[BUY_VARIABLE] == 0
  318.         @buy_max = 99
  319.         if item.price <= $game_party.gold and number < @buy_max
  320.          self.contents.font.color = normal_color
  321.         else
  322.          self.contents.font.color = disabled_color
  323.         end
  324.       else
  325.         @buy_max = $game_variables[BUY_MAX_VARIABLE]
  326.         if item.price * $game_variables[BUY_VARIABLE] / 100 <= $game_party.gold and number < @buy_max
  327.          self.contents.font.color = normal_color
  328.         else
  329.          self.contents.font.color = disabled_color
  330.         end
  331.       end
  332.     ###############################################################
  333.     x = 4
  334.     y = index * 32
  335.     rect = Rect.new(x, y, self.width - 32, 32)
  336.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  337.     bitmap = RPG::Cache.icon(item.icon_name)
  338.     opacity = self.contents.font.color == normal_color ? 255 : 128
  339.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  340.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  341.     ####################################################
  342.     if BUY_SELL_SWITCH == 0
  343.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  344.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  345.     elsif !$game_switches[BUY_SELL_SWITCH] or BUY_VARIABLE == 0 or
  346.        $game_variables[BUY_VARIABLE] == 0
  347.       self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  348.     else
  349.       self.contents.draw_text(x + 240, y, 88, 32, (item.price *
  350.       $game_variables[BUY_VARIABLE] / 100).to_s, 2)
  351.     end
  352.     #####################################################
  353.   end
  354. end
复制代码

Lv3.寻梦者 (暗夜天使)

名侦探小柯

梦石
0
星屑
3263
在线时间
3616 小时
注册时间
2006-9-6
帖子
37399

开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

2
发表于 2008-12-12 01:28:12 | 只看该作者
很方便的脚本,
希望和我用的商店脚本别冲突才好……
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

3
 楼主| 发表于 2008-12-12 01:46:49 | 只看该作者
这个是默认的商店脚本,其实其他商店脚本只要照猫画老虎修改就OK
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
10
在线时间
1 小时
注册时间
2008-11-25
帖子
3
4
发表于 2008-12-12 04:39:10 | 只看该作者
前辈莪顶。{/tp}{/tp}{/tp}{/tp}
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

5
 楼主| 发表于 2008-12-12 10:25:30 | 只看该作者
更新到1.1版。恒量设定为0的时候即关闭此项功能。
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6645
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

6
发表于 2008-12-12 10:37:54 | 只看该作者
不错不错{/hx}
刚在提问区看到精灵的广告{/dy},
连接过来顶一下{/hx}











你知道得太多了

回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

7
 楼主| 发表于 2008-12-22 07:15:22 | 只看该作者
我顶一下吧。ONEWATER顺手也帮我发布了吧。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
21 小时
注册时间
2007-7-3
帖子
573
8
发表于 2008-12-23 16:21:40 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

9
 楼主| 发表于 2008-12-24 07:45:45 | 只看该作者
恩哪。变量号可以自定义,适合事件派使用,呵呵
回复 支持 反对

使用道具 举报

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
10
发表于 2009-1-14 23:18:57 | 只看该作者
发布完毕
http://rpg.blue/web/htm/news1240.htm
vip += 2
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 01:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表