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

Project1

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

[RMVX发布] 商店扩展(商品分类+物品注释+店主对话)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
73
在线时间
122 小时
注册时间
2009-2-7
帖子
55
跳转到指定楼层
1
发表于 2010-10-6 13:25:47 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 discain 于 2011-2-15 21:35 编辑

该功能实分三种
1、商店分类:包括购买和贩卖
2、物品对人物的影响有详细注释
3、店主可以设置对话
PS此脚本借鉴于wangswz DeathKing 的 FSL_SHOP
操作方法:上下键选择商店、左右键切换人物
对话需要设置一下事件,默认开关为81号
事件编写方法如图:

下面为全代码
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 商店扩展描绘◆ VX ◆
  3. #_/----------------------------------------------------------------------------
  4. #_/  借鉴wangswz DeathKing 的 FSL_SHOP
  5. #_/  引用网址: http://rpg.blue/thread-154915-1-1.html
  6. #_/  作者:discain
  7. #_/============================================================================
  8. #_/ 【基本机能】商店拓展
  9. #_/  放在默认脚本之后,Main脚本之前,通过事件指令【商店处理】调用。
  10. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  11. #===============================================================================
  12. #-------------------------------------------------------------------------------
  13. # ▼ 通用配置模块
  14. #-------------------------------------------------------------------------------
  15. module SHOP
  16.     # ◆ 无法装备的提示信息
  17.     Shop_help = "-无法装备-"
  18.    
  19.     # ◆ 无法使用的提示信息
  20.     Shop_help2 = "-无法使用-"
  21.    
  22.     # ◆ 设置atk def spi agi 上升 下降 相等时 图标显示 4个一组
  23.     Shop_icon = [
  24.     120,121,122,123,
  25.     124,125,126,127,
  26.       0,  0,  0,  0
  27.     ]
  28. end
  29. $iftell = 81 #打开对话的开关
  30. #==============================================================================
  31. # ■ Scene_Shop
  32. #------------------------------------------------------------------------------
  33. #  处理商店画面的类。
  34. #==============================================================================
  35. class Scene_Shop < Scene_Base
  36.   #--------------------------------------------------------------------------
  37.   # ● 开始处理
  38.   #--------------------------------------------------------------------------
  39.   def start
  40.     super
  41.     create_menu_background
  42.     create_command_window
  43.     create_command_window2
  44.     @help_window = Window_Help.new
  45.     @help_window.visible = false
  46.     @gold_window = Window_Gold.new(384, 56)
  47.     @gold_window.visible = false
  48.     @buy_window = Window_ShopBuy.new(0, 112)
  49.     @buy_window.active = false
  50.     @buy_window.visible = false
  51.     @buy_window.help_window = @help_window
  52.     @sell_window = Window_ShopSell.new(0, 112, 304, 304) # 贩卖
  53.     @sell_window.active = false
  54.     @sell_window.visible = false
  55.     @sell_window.help_window = @help_window
  56.     @number_window = Window_ShopNumber.new(0, 112)
  57.     @number_window.active = false
  58.     @number_window.visible = false
  59.     @actor_index = 0
  60.     @status_window = Window_ShopAS.new($game_party.members[@actor_index])
  61.     @status_window.visible = false
  62.     $game_switches[$iftell] = false
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 结束处理
  66.   #--------------------------------------------------------------------------
  67.   def terminate
  68.     super
  69.     dispose_menu_background
  70.     dispose_command_window
  71.     dispose_command_window2
  72.     @help_window.dispose
  73.     @gold_window.dispose
  74.     @buy_window.dispose
  75.     @sell_window.dispose
  76.     @number_window.dispose
  77.     @status_window.dispose
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 更新画面
  81.   #--------------------------------------------------------------------------
  82.   def update
  83.     super
  84.     update_menu_background
  85.     @command_window.update
  86.     @command_window2.update
  87.     @help_window.update
  88.     @gold_window.update
  89.     @buy_window.update
  90.     @sell_window.update
  91.     @number_window.update
  92.     @status_window.update
  93.     if @command_window.active
  94.       update_command_selection
  95.     elsif @buy_window.active
  96.       update_buy_selection1
  97.     elsif @sell_window.active
  98.       update_sell_selection
  99.     elsif @number_window.active
  100.       update_number_input
  101.     elsif @command_window2.active
  102.       update_command_selection2
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 生成命令窗口
  107.   #--------------------------------------------------------------------------
  108.   def create_command_window
  109.     s1 = Vocab::ShopBuy
  110.     s2 = Vocab::ShopSell
  111.     s3 = "对话"
  112.     s4 = Vocab::ShopCancel
  113.     @command_window = Window_Command.new(80, [s1, s2, s3, s4], 1)
  114.     @command_window.x = (544 - @command_window.width) / 2
  115.     @command_window.y = (416 - @command_window.height) / 2
  116.     if $game_temp.shop_purchase_only
  117.       @command_window.draw_item(1, false)
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 释放命令窗口
  122.   #--------------------------------------------------------------------------
  123.   def dispose_command_window
  124.     @command_window.dispose
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 更新命令窗口
  128.   #--------------------------------------------------------------------------
  129.   def update_command_selection
  130.     if Input.trigger?(Input::B)
  131.       Sound.play_cancel
  132.       $scene = Scene_Map.new
  133.     elsif Input.trigger?(Input::C)
  134.       case @command_window.index        
  135.       when 0  # 买入
  136.         Sound.play_decision
  137.         @command_window.visible = false
  138.         @command_window.active = false
  139.         @help_window.visible = true
  140.         @gold_window.visible = true
  141.         @command_window2.active = true
  142.         @command_window2.visible = true
  143.         @ifsell = false
  144.       when 1  # 卖出
  145.         if $game_temp.shop_purchase_only
  146.           Sound.play_buzzer
  147.         else
  148.           Sound.play_decision
  149.           @command_window.active = false
  150.           @command_window.visible = false
  151.           @help_window.visible = true
  152.           @gold_window.visible = true
  153.           @command_window2.active = true
  154.           @command_window2.visible = true
  155.           @ifsell = true
  156.         end
  157.       when 2  #对话
  158.         Sound.play_decision
  159.         $game_switches[$iftell] = true
  160.         $scene = Scene_Map.new
  161.       when 3  # 离开
  162.         Sound.play_decision
  163.         $scene = Scene_Map.new
  164.       end
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 生成二级命令窗口
  169.   #--------------------------------------------------------------------------
  170.   def create_command_window2
  171.     s1 = "物品"
  172.     s2 = "武器"
  173.     s3 = "防具"
  174.     s4 = "全部"
  175.     @command_window2 = Window_Command.new(384, [s1, s2, s3, s4], 4)
  176.     @command_window2.x = 0
  177.     @command_window2.y = 56
  178.     @command_window2.active = false
  179.     @command_window2.visible = false
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 释放二级命令窗口
  183.   #--------------------------------------------------------------------------
  184.   def dispose_command_window2
  185.     @command_window2.dispose
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 更新二级命令窗口
  189.   #--------------------------------------------------------------------------
  190.   def update_command_selection2
  191.     if Input.trigger?(Input::B)
  192.       Sound.play_cancel
  193.       @command_window.active = true
  194.       @command_window.visible = true
  195.       @help_window.visible = false
  196.       @gold_window.visible = false
  197.       @command_window2.active = false
  198.       @command_window2.visible = false
  199.       @buy_window.active = false
  200.       @buy_window.visible = false
  201.       @sell_window.active = false
  202.       @sell_window.visible = false
  203.       @status_window.visible = false
  204.       @status_window.item = nil
  205.       return
  206.     elsif Input.trigger?(Input::C)
  207.       case @command_window2.index
  208.       when 0 #物品
  209.         Sound.play_decision
  210.         @command_window2.active = false
  211.         if @ifsell == false
  212.           @buy_window.index = 0
  213.           @buy_window.active = true
  214.           @buy_window.visible = true
  215.           @buy_window.type = 0
  216.           @buy_window.refresh
  217.         else
  218.           @sell_window.index = 0
  219.           @sell_window.active = true
  220.           @sell_window.visible = true
  221.           @sell_window.type = 0
  222.           @sell_window.refresh
  223.         end
  224.         @status_window.visible = true
  225.       when 1 #武器
  226.         Sound.play_decision
  227.         @command_window2.active = false
  228.         if @ifsell == false
  229.           @buy_window.index = 0
  230.           @buy_window.active = true
  231.           @buy_window.visible = true
  232.           @buy_window.type = 1
  233.           @buy_window.refresh
  234.         else
  235.           @sell_window.index = 0
  236.           @sell_window.active = true
  237.           @sell_window.visible = true
  238.           @sell_window.type = 1
  239.           @sell_window.refresh
  240.         end
  241.         @status_window.visible = true
  242.       when 2 #防具
  243.         Sound.play_decision
  244.         @command_window2.active = false
  245.         if @ifsell == false
  246.           @buy_window.index = 0
  247.           @buy_window.active = true
  248.           @buy_window.visible = true
  249.           @buy_window.type = 2
  250.           @buy_window.refresh
  251.         else
  252.           @sell_window.index = 0
  253.           @sell_window.active = true
  254.           @sell_window.visible = true
  255.           @sell_window.type = 2
  256.           @sell_window.refresh
  257.         end
  258.         @status_window.visible = true
  259.       when 3 #全部
  260.         Sound.play_decision
  261.         @command_window2.active = false
  262.         if @ifsell == false
  263.           @buy_window.index = 0
  264.           @buy_window.active = true
  265.           @buy_window.visible = true
  266.           @buy_window.type = 3
  267.           @buy_window.refresh
  268.         else
  269.           @sell_window.index = 0
  270.           @sell_window.active = true
  271.           @sell_window.visible = true
  272.           @sell_window.type = 3
  273.           @sell_window.refresh
  274.         end
  275.         @status_window.visible = true
  276.       end
  277.       @help_window.visible = true
  278.     end
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 更新买入选择
  282.   #--------------------------------------------------------------------------
  283.   def update_buy_selection1
  284.     @status_window.item = @buy_window.item
  285.     if Input.trigger?(Input::B)
  286.       Sound.play_cancel
  287.       @command_window2.active = true
  288.       @buy_window.active = false
  289.       @buy_window.visible = false
  290.       @status_window.visible = false
  291.       @status_window.item = nil
  292.       @help_window.set_text("")
  293.       return
  294.     end
  295.     if Input.trigger?(Input::C)
  296.       @item = @buy_window.item
  297.       number = $game_party.item_number(@item)
  298.       if @item == nil or @item.price > $game_party.gold or number == 99
  299.         Sound.play_buzzer
  300.       else
  301.         Sound.play_decision
  302.         max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  303.         max = [max, 99 - number].min
  304.         @buy_window.active = false
  305.         @buy_window.visible = false
  306.         @number_window.set(@item, max, @item.price)
  307.         @number_window.active = true
  308.         @number_window.visible = true
  309.       end
  310.     end
  311.     if Input.trigger?(Input::RIGHT)
  312.       Sound.play_cursor
  313.       next_actor
  314.     elsif Input.trigger?(Input::LEFT)
  315.       Sound.play_cursor
  316.       prev_actor
  317.     end
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 更新卖出选择
  321.   #--------------------------------------------------------------------------
  322.   def update_sell_selection
  323.     @status_window.item = @sell_window.item
  324.     if Input.trigger?(Input::B)
  325.       Sound.play_cancel
  326.       @command_window2.active = true
  327.       @sell_window.active = false
  328.       @sell_window.visible = false
  329.       @status_window.visible = false
  330.       @status_window.item = nil
  331.       @help_window.set_text("")
  332.     elsif Input.trigger?(Input::C)
  333.       @item = @sell_window.item
  334.       @status_window.item = @item
  335.       if @item == nil or @item.price == 0
  336.         Sound.play_buzzer
  337.       else
  338.         Sound.play_decision
  339.         max = $game_party.item_number(@item)
  340.         @sell_window.active = false
  341.         @sell_window.visible = false
  342.         @number_window.set(@item, max, @item.price / 2)
  343.         @number_window.active = true
  344.         @number_window.visible = true
  345.         @status_window.visible = true
  346.       end
  347.     end
  348.     if Input.trigger?(Input::RIGHT)
  349.       Sound.play_cursor
  350.       next_actor
  351.     elsif Input.trigger?(Input::LEFT)
  352.       Sound.play_cursor
  353.       prev_actor
  354.     end
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ● 切换至下一角色画面
  358.   #--------------------------------------------------------------------------
  359.   def next_actor
  360.     @actor_index += 1
  361.     @actor_index %= $game_party.members.size
  362.     @status_window.actor = ($game_party.members[@actor_index])
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 切换至上一角色画面
  366.   #--------------------------------------------------------------------------
  367.   def prev_actor
  368.     @actor_index += $game_party.members.size - 1
  369.     @actor_index %= $game_party.members.size
  370.     @status_window.actor = ($game_party.members[@actor_index])
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ● 更新数值输入
  374.   #--------------------------------------------------------------------------
  375.   def update_number_input
  376.     if Input.trigger?(Input::B)
  377.       cancel_number_input
  378.     elsif Input.trigger?(Input::C)
  379.       decide_number_input
  380.     end
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # ● 取消数值输入
  384.   #--------------------------------------------------------------------------
  385.   def cancel_number_input
  386.     Sound.play_cancel
  387.     @number_window.active = false
  388.     @number_window.visible = false
  389.     case @command_window.index
  390.     when 0  # 买入
  391.       @buy_window.active = true
  392.       @buy_window.visible = true
  393.     when 1  # 卖出
  394.       @sell_window.active = true
  395.       @sell_window.visible = true
  396.     end
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 确认数值输入
  400.   #--------------------------------------------------------------------------
  401.   def decide_number_input
  402.     Sound.play_shop
  403.     @number_window.active = false
  404.     @number_window.visible = false
  405.     case @command_window.index
  406.     when 0  # 买入
  407.       $game_party.lose_gold(@number_window.number * @item.price)
  408.       $game_party.gain_item(@item, @number_window.number)
  409.       @gold_window.refresh
  410.       @buy_window.refresh
  411.       @status_window.refresh
  412.       @buy_window.active = true
  413.       @buy_window.visible = true
  414.     when 1  # 卖出
  415.       $game_party.gain_gold(@number_window.number * (@item.price / 2))
  416.       $game_party.lose_item(@item, @number_window.number)
  417.       @gold_window.refresh
  418.       @sell_window.refresh
  419.       @status_window.refresh
  420.       @sell_window.active = true
  421.       @sell_window.visible = true
  422.     end
  423.   end
  424. end
  425. #==============================================================================
  426. # ■ Window_ShopBuy
  427. #------------------------------------------------------------------------------
  428. #  商店画面、浏览显示可以购买的商品的窗口。
  429. #==============================================================================
  430. class Window_ShopBuy < Window_Selectable
  431.   #--------------------------------------------------------------------------
  432.   # ● 初始化对像
  433.   #     x      : 窗口 X 座标
  434.   #     y      : 窗口 Y 座标
  435.   #--------------------------------------------------------------------------
  436.   def initialize(x, y)
  437.     super(x, y, 304, 304)
  438.     @shop_goods = $game_temp.shop_goods
  439.     @type = 0
  440.     refresh
  441.     self.index = 0
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ● 商品类型
  445.   #--------------------------------------------------------------------------
  446.   def type=(type)
  447.     if @type != type
  448.       @type = type
  449.       refresh
  450.     end
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 获取商品
  454.   #--------------------------------------------------------------------------
  455.   def item
  456.     if @type == 0
  457.       return @data1[self.index]
  458.     elsif @type == 1
  459.       return @data2[self.index]
  460.     elsif @type == 2
  461.       return @data3[self.index]
  462.     else
  463.       return @data4[self.index]
  464.     end
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 刷新
  468.   #--------------------------------------------------------------------------
  469.   def refresh
  470.     @data1 = []
  471.     @data2 = []
  472.     @data3 = []
  473.     @data4 = []
  474.     for goods_item in @shop_goods
  475.       case goods_item[0]
  476.       when 0
  477.         item = $data_items[goods_item[1]]
  478.         if item != nil
  479.           @data1.push(item)
  480.           @data4.push(item)
  481.         end
  482.       when 1
  483.         item = $data_weapons[goods_item[1]]
  484.         if item != nil
  485.           @data2.push(item)
  486.           @data4.push(item)
  487.         end
  488.       when 2
  489.         item = $data_armors[goods_item[1]]
  490.         if item != nil
  491.           @data3.push(item)
  492.           @data4.push(item)
  493.         end
  494.       end
  495.     end
  496.     if    @type == 0
  497.       @item_max = @data1.size
  498.     elsif @type == 1
  499.       @item_max = @data2.size
  500.     elsif @type == 2
  501.       @item_max = @data3.size
  502.     else
  503.       @item_max = @data4.size
  504.     end
  505.    
  506.     create_contents
  507.     for i in 0...@item_max
  508.       draw_item1(i)
  509.     end
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● 绘制商品
  513.   #     index : 商品索引
  514.   #--------------------------------------------------------------------------
  515.   def draw_item1(index)
  516.     if    @type == 0
  517.       item = @data1[index]
  518.     elsif @type == 1
  519.       item = @data2[index]
  520.     elsif @type == 2
  521.       item = @data3[index]
  522.     else
  523.       item = @data4[index]
  524.     end
  525.     number = $game_party.item_number(item)
  526.     enabled = (item.price <= $game_party.gold and number < 99)
  527.     rect = item_rect(index)
  528.     self.contents.clear_rect(rect)
  529.     draw_item_name(item, rect.x, rect.y, enabled)
  530.     rect.width -= 4
  531.     self.contents.draw_text(rect, item.price, 2)
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # ● 更新帮助窗口文字
  535.   #--------------------------------------------------------------------------
  536.   def update_help
  537.     @help_window.set_text(item == nil ? "" : item.description)
  538.   end
  539. end
  540. #==============================================================================
  541. # ■ Window_ShopSell
  542. #------------------------------------------------------------------------------
  543. #  商店画面、浏览显示可以卖掉的商品的窗口。
  544. #==============================================================================
  545. class Window_ShopSell < Window_Selectable
  546.   #--------------------------------------------------------------------------
  547.   # ● 初始化对像
  548.   #     x      : 窗口 X 座标
  549.   #     y      : 窗口 Y 座标
  550.   #     width  : 窗口宽度
  551.   #     height : 窗口高度
  552.   #--------------------------------------------------------------------------
  553.   def initialize(x, y, width, height)
  554.     super(x, y, width, height)
  555.     refresh
  556.     self.index = 0
  557.   end
  558.   #--------------------------------------------------------------------------
  559.   # ● 商品类型
  560.   #--------------------------------------------------------------------------
  561.   def type=(type)
  562.     if @type != type
  563.       @type = type
  564.       refresh
  565.     end
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 获取商品
  569.   #--------------------------------------------------------------------------
  570.   def item
  571.     if @type == 0
  572.       return @data1[self.index]
  573.     elsif @type == 1
  574.       return @data2[self.index]
  575.     elsif @type == 2
  576.       return @data3[self.index]
  577.     else
  578.       return @data4[self.index]
  579.     end
  580.   end
  581.   #--------------------------------------------------------------------------
  582.   # ● 判断是否为商品
  583.   #     item : 项目
  584.   #--------------------------------------------------------------------------
  585.   def include?(item)
  586.     return item != nil
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ● 判断是否为有效状态
  590.   #     item : item
  591.   #--------------------------------------------------------------------------
  592.   def enable?(item)
  593.     return (item.price > 0)
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● 刷新
  597.   #--------------------------------------------------------------------------
  598.   def refresh
  599.     @data1 = []
  600.     @data2 = []
  601.     @data3 = []
  602.     @data4 = []
  603.     for item in $game_party.items
  604.       next unless include?(item)
  605.       if $data_weapons.include?(item)
  606.         if item != nil
  607.           @data2.push(item)
  608.           @data4.push(item)
  609.         end
  610.       elsif $data_armors.include?(item)
  611.         if item != nil
  612.           @data3.push(item)
  613.           @data4.push(item)
  614.         end
  615.       else
  616.         if item != nil
  617.           @data1.push(item)
  618.           @data4.push(item)
  619.         end
  620.       end
  621.       if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
  622.         self.index = @data4.size - 1
  623.         if @type == 0
  624.           self.index = @data1.size - 1
  625.         elsif @type == 1
  626.           self.index = @data2.size - 1
  627.         elsif @type == 2
  628.           self.index = @data3.size - 1
  629.         end
  630.       end
  631.     end
  632.     if    @type == 0
  633.       @item_max = @data1.size
  634.     elsif @type == 1
  635.       @item_max = @data2.size
  636.     elsif @type == 2
  637.       @item_max = @data3.size
  638.     else
  639.       @item_max = @data4.size
  640.     end
  641.     create_contents
  642.     for i in 0...@item_max
  643.       draw_item2(i)
  644.     end
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ● 绘制项目
  648.   #     index : 商品索引
  649.   #--------------------------------------------------------------------------
  650.   def draw_item2(index)
  651.     if    @type == 0
  652.       item = @data1[index]
  653.     elsif @type == 1
  654.       item = @data2[index]
  655.     elsif @type == 2
  656.       item = @data3[index]
  657.     else
  658.       item = @data4[index]
  659.     end
  660.     rect = item_rect(index)
  661.     self.contents.clear_rect(rect)
  662.     if item != nil
  663.       number = $game_party.item_number(item)
  664.       enabled = enable?(item)
  665.       rect.width -= 4
  666.       draw_item_name(item, rect.x, rect.y, enabled)
  667.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  668.     end
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # ● 更新帮助窗口文字
  672.   #--------------------------------------------------------------------------
  673.   def update_help
  674.     @help_window.set_text(item == nil ? "" : item.description)
  675.   end
  676. end
  677. #==============================================================================
  678. # ■ Window_ShopActorStatus(简称AS)
  679. #------------------------------------------------------------------------------
  680. #  显示角色的状态窗口。
  681. #==============================================================================
  682. class Window_ShopAS < Window_Base
  683.   #--------------------------------------------------------------------------
  684.   # ● 初始化对像
  685.   #     actor : 角色
  686.   #--------------------------------------------------------------------------
  687.   def initialize(actor, item = nil)
  688.     super(304, 112, 240, 304)
  689.     @item = item
  690.     @actor = actor
  691.     refresh
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # ● 刷新
  695.   #--------------------------------------------------------------------------
  696.   def refresh
  697.     self.contents.clear
  698.     draw_Shopface(@actor.face_name, @actor.face_index, 84, 4)
  699.     draw_actor_name(@actor, 4, 0)
  700. draw_actor_graphic(@actor, 192, 56)
  701.    
  702.     if @item != nil
  703.       draw_actor_parameter_change(@actor, 4, 96)
  704.       number = $game_party.item_number(@item)
  705.       self.contents.font.color = system_color
  706.       self.contents.draw_text(4, WLH * 10, 200, WLH, Vocab::Possession)
  707.       self.contents.font.color = normal_color
  708.       self.contents.draw_text(4, WLH * 10, 200, WLH, number, 2)
  709.       if @item.is_a?(RPG::Item) && @item.scope > 0
  710.         draw_item_parameter_change(4, 48)
  711.       elsif @item.is_a?(RPG::Item)
  712.         self.contents.font.color = system_color
  713.         self.contents.draw_text(0, y + 24, 200, WLH, SHOP::Shop_help2, 1)
  714.       end
  715.     end
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ● 绘制物品效果
  719.   #     x     : 绘制点 X 座标
  720.   #     y     : 绘制点 Y 座标
  721.   #--------------------------------------------------------------------------
  722.   def draw_item_parameter_change(x, y)
  723.     if @item.scope > 6
  724.       draw_actor_hp(@actor, x, y)
  725.       draw_actor_mp(@actor, x, y + 24)
  726.       self.contents.font.color = system_color
  727.       self.contents.draw_text(x - 10, y + WLH * 2, 200, WLH, "体力回复/比率  |  灵力回复/比率", 2)
  728.          
  729.       self.contents.font.color = hp_gauge_color1
  730.       self.contents.draw_text(x - 65, y + WLH * 3, 104, WLH, sprintf("%d", @item.hp_recovery), 2)
  731.       self.contents.draw_text(x - 5, y + WLH * 3, 104, WLH, sprintf("%d", @item.hp_recovery_rate)+"%", 2)
  732.       
  733.       self.contents.font.color = mp_gauge_color1
  734.       self.contents.draw_text(x - 60, y + WLH * 3, 200, WLH, sprintf("%d", @item.mp_recovery), 2)
  735.       self.contents.draw_text(x, y + WLH * 3, 200, WLH, sprintf("%d", @item.mp_recovery_rate)+"%", 2)
  736.       
  737.       if @item.parameter_type > 0
  738.         self.contents.font.color = system_color
  739.         self.contents.draw_text(x, y + WLH * 6, 200, WLH, "增加能力")
  740.         self.contents.font.color = normal_color
  741.         case @item.parameter_type
  742.         when 1
  743.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "体", 1)
  744.         when 2
  745.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "灵", 1)
  746.         when 3
  747.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "攻", 1)
  748.         when 4
  749.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "防", 1)
  750.         when 5
  751.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "灵", 1)
  752.         when 6
  753.           self.contents.draw_text(x, y + WLH * 6, 200, WLH, "速", 1)
  754.         end
  755.         self.contents.draw_text(x, y + WLH * 6, 200, WLH, sprintf("%d", @item.parameter_points), 2)
  756.       else
  757.         self.contents.font.color = text_color(7)
  758.         self.contents.draw_text(x, y + WLH * 6, 200, WLH, "增加能力")
  759.       end
  760.     else
  761.       self.contents.font.color = normal_color
  762.       draw_actor_parameter(@actor, x, y, 0)
  763.       draw_actor_parameter(@actor, x, y + 24, 2)
  764.       
  765.       self.contents.font.color = system_color
  766.       self.contents.draw_text(x, y + WLH * 2, 240, WLH, "伤害值  |  物理  |  法术")
  767.       
  768.       self.contents.font.color = normal_color
  769.       self.contents.draw_text(x, y + WLH * 3, 104, WLH, sprintf("%d", @item.base_damage))
  770.       
  771.       self.contents.font.color = hp_gauge_color1
  772.       self.contents.draw_text(x, y + WLH * 3, 105, WLH, sprintf("%d", @item.atk_f), 2)
  773.       
  774.       self.contents.font.color = mp_gauge_color1
  775.       self.contents.draw_text(x, y + WLH * 3, 172, WLH, sprintf("%d", @item.spi_f), 2)
  776.     end
  777.     self.contents.font.color = system_color
  778.     if @item.plus_state_set.size == 0
  779.       self.contents.font.color = text_color(7)
  780.     end
  781.     self.contents.draw_text(x, y + WLH * 4, 200, WLH, "增益")
  782.     self.contents.font.color = system_color
  783.     if @item.minus_state_set.size == 0
  784.       self.contents.font.color = text_color(7)
  785.     end
  786.     self.contents.draw_text(x, y + WLH * 5, 200, WLH, "削减")
  787.     m = 48
  788.     for i in @item.plus_state_set
  789.       draw_icon($data_states.icon_index, x + m, y + WLH * 4)
  790.       break if m == 168
  791.       m += 24
  792.     end
  793.     m = 48
  794.     for i in @item.minus_state_set
  795.       draw_icon($data_states.icon_index, x + m, y + WLH * 5)
  796.       break if m == 168
  797.       m += 24
  798.     end
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # ● 绘制角色当前装备和能力值
  802.   #     actor : 角色
  803.   #     x     : 绘制点 X 座标
  804.   #     y     : 绘制点 Y 座标
  805.   #--------------------------------------------------------------------------
  806.   def draw_actor_parameter_change(actor, x, y)
  807.     return if @item.is_a?(RPG::Item)
  808.     enabled = actor.equippable?(@item)
  809.     if @item.is_a?(RPG::Weapon)
  810.       item1 = weaker_weapon(actor)
  811.     elsif actor.two_swords_style and @item.kind == 0
  812.       item1 = nil
  813.     else
  814.       item1 = actor.equips[1 + @item.kind]
  815.     end
  816.    
  817.     if enabled
  818.       
  819.       atk1 = item1 == nil ? 0 : item1.atk
  820.       atk2 = @item == nil ? 0 : @item.atk
  821.       change = atk2 - atk1
  822.       shop_change(change)
  823.       if change > 0
  824.         draw_icon(SHOP::Shop_icon[0], 108, y + WLH)
  825.       elsif  change < 0
  826.         draw_icon(SHOP::Shop_icon[4], 108, y + WLH)
  827.       else
  828.         draw_icon(SHOP::Shop_icon[8], 108, y + WLH)
  829.       end
  830.       self.contents.draw_text(x, y + WLH, 200, WLH, sprintf("%d", atk2), 2)
  831.       
  832.       def1 = item1 == nil ? 0 : item1.def
  833.       def2 = @item == nil ? 0 : @item.def
  834.       change = def2 - def1
  835.       shop_change(change)
  836.       if change > 0
  837.         draw_icon(SHOP::Shop_icon[1], 108, y + WLH * 2)
  838.       elsif  change < 0
  839.         draw_icon(SHOP::Shop_icon[5], 108, y + WLH * 2)
  840.       else
  841.         draw_icon(SHOP::Shop_icon[9], 108, y + WLH)
  842.       end
  843.       self.contents.draw_text(x, y + WLH * 2, 200, WLH, sprintf("%d", def2), 2)
  844.       
  845.       spi1 = item1 == nil ? 0 : item1.spi
  846.       spi2 = @item == nil ? 0 : @item.spi
  847.       change = spi2 - spi1
  848.       shop_change(change)
  849.       if change > 0
  850.         draw_icon(SHOP::Shop_icon[2], 108, y + WLH * 3)
  851.       elsif  change < 0
  852.         draw_icon(SHOP::Shop_icon[6], 108, y + WLH * 3)
  853.       else
  854.         draw_icon(SHOP::Shop_icon[10], 108, y + WLH)
  855.       end
  856.       self.contents.draw_text(x, y + WLH * 3, 200, WLH, sprintf("%d", spi2), 2)
  857.       
  858.       agi1 = item1 == nil ? 0 : item1.agi
  859.       agi2 = @item == nil ? 0 : @item.agi
  860.       change = agi2 - agi1
  861.       shop_change(change)
  862.       if change > 0
  863.         draw_icon(SHOP::Shop_icon[3], 108, y + WLH * 4)
  864.       elsif  change < 0
  865.         draw_icon(SHOP::Shop_icon[7], 108, y + WLH * 4)
  866.       else
  867.         draw_icon(SHOP::Shop_icon[11], 108, y + WLH)
  868.       end
  869.       self.contents.draw_text(x, y + WLH * 4, 200, WLH, sprintf("%d", agi2), 2)
  870.       
  871.       self.contents.font.color = system_color
  872.       self.contents.draw_text(4, y - 32, 204, WLH, "当前装备")
  873.       
  874.       self.contents.draw_text(x + 32, y + WLH, 200, WLH, sprintf("%d", atk1))
  875.       self.contents.draw_text(x + 32, y + WLH * 2, 200, WLH, sprintf("%d", def1))
  876.       self.contents.draw_text(x + 32, y + WLH * 3, 200, WLH, sprintf("%d", spi1))
  877.       self.contents.draw_text(x + 32, y + WLH * 4, 200, WLH, sprintf("%d", agi1))
  878.       
  879.       self.contents.draw_text(0, y + WLH, 200, WLH, "攻")
  880.       self.contents.draw_text(0, y + WLH * 2, 200, WLH, "防")
  881.       self.contents.draw_text(0, y + WLH * 3, 200, WLH, "精")
  882.       self.contents.draw_text(0, y + WLH * 4, 200, WLH, "速")
  883.       
  884.       if item1 != nil
  885.         self.contents.draw_text(24, y - 10, 208, WLH, item1.name)
  886.         draw_icon(item1.icon_index, 0, y - 10)
  887.       else
  888.         self.contents.draw_text(24, y - 10, 208, WLH, "无")
  889.       end
  890.     else
  891.       self.contents.font.color = normal_color
  892.       self.contents.draw_text(0, y + 24, 200, WLH, SHOP::Shop_help, 1)
  893.     end
  894.   end
  895.   #--------------------------------------------------------------------------
  896.   # ● 判断数值颜色
  897.   #     change : 数值
  898.   #--------------------------------------------------------------------------
  899.   def shop_change(change)
  900.     if change == 0
  901.       self.contents.font.color = normal_color
  902.     else
  903.       self.contents.font.color = change>0 ? power_up_color : power_down_color
  904.     end
  905.   end
  906.   #--------------------------------------------------------------------------
  907.   # ● 获取双刀派角色所装备的武器中较弱的武器
  908.   #     actor : 角色
  909.   #--------------------------------------------------------------------------
  910.   def weaker_weapon(actor)
  911.     if actor.two_swords_style
  912.       weapon1 = actor.weapons[0]
  913.       weapon2 = actor.weapons[1]
  914.       if weapon1 == nil or weapon2 == nil
  915.         return nil
  916.       elsif weapon1.atk < weapon2.atk
  917.         return weapon1
  918.       else
  919.         return weapon2
  920.       end
  921.     else
  922.       return actor.weapons[0]
  923.     end
  924.   end
  925.   #--------------------------------------------------------------------------
  926.   # ● 设置角色
  927.   #     actor : 角色
  928.   #--------------------------------------------------------------------------
  929.   def actor=(actor)
  930.     if @actor != actor
  931.       @actor = actor
  932.       refresh
  933.     end
  934.   end
  935.   #--------------------------------------------------------------------------
  936.   # ● 设置物品
  937.   #     item : 新物品
  938.   #--------------------------------------------------------------------------
  939.   def item=(item)
  940.     if @item != item
  941.       @item = item
  942.       refresh
  943.     end
  944.   end
  945.   #--------------------------------------------------------------------------
  946.   # ● 绘制头像部分图
  947.   #     face_name  : 头像文件名
  948.   #     face_index : 头像号码
  949.   #     x     : 描画目标 X 坐标
  950.   #     y     : 描画目标 Y 坐标
  951.   #     size       : 显示大小
  952.   #--------------------------------------------------------------------------
  953.   def draw_Shopface(face_name, face_index, x, y, size = 96)
  954.     bitmap = Cache.face(face_name)
  955.     rect = Rect.new(0, 0, 0, 0)
  956.     rect.x = face_index % 4 * 96 + (96 - size) / 2
  957.     rect.y = face_index / 4 * 96 + (96 - size) / 2 + size / 4
  958.     rect.width = size
  959.     rect.height = size / 2
  960.     self.contents.blt(x, y, bitmap, rect)
  961.     bitmap.dispose
  962.   end
  963. end
复制代码



===================================================================
附范例:RAYFILE下载:点击下载
本地下载: 商店扩展.rar (243.19 KB, 下载次数: 4825)

评分

参与人数 2星屑 +1802 收起 理由
574656549 + 2 伸手党,附件拿来,谢谢
小幽的马甲 + 1800

查看全部评分

Lv1.梦旅人

梦石
0
星屑
50
在线时间
22 小时
注册时间
2010-7-19
帖子
110
2
发表于 2010-10-6 14:22:22 | 只看该作者
店主对话?是在买卖窗口直接对话吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
73
在线时间
122 小时
注册时间
2009-2-7
帖子
55
3
 楼主| 发表于 2010-10-6 14:59:30 | 只看该作者
本帖最后由 discain 于 2010-10-6 15:01 编辑

回复 657048301 的帖子
试试看不就知道了?有点模仿某些游戏(这类的游戏太多了)的方式,就是在点击后可以选择是对话还是买卖东西。

   
回复 支持 反对

使用道具 举报

Lv2.观梦者

花开堪折直须折

梦石
0
星屑
671
在线时间
943 小时
注册时间
2010-7-17
帖子
4963

贵宾

4
发表于 2010-10-15 13:07:08 | 只看该作者
这种好东西,绝对不可以沉哦!
大家好,我叫节操,有一天,我被吃了。
http://forever-dream.5d6d.com
永恒の梦制作组论坛

129993099
永恒の梦制作组QQ群
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-1-14
帖子
21
5
发表于 2010-10-20 09:01:00 | 只看该作者
无图无真相...试试看...
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv2.观梦者 (禁止发言)

梦石
0
星屑
675
在线时间
905 小时
注册时间
2010-11-13
帖子
1023
6
发表于 2011-2-15 17:29:10 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
240
在线时间
10 小时
注册时间
2011-5-13
帖子
4
7
发表于 2011-5-16 16:01:11 | 只看该作者
马克一个

评分

参与人数 1星屑 -40 收起 理由
夕阳武士 -40 连续四次水贴了哦,请注意

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
240
在线时间
63 小时
注册时间
2010-12-14
帖子
56
8
发表于 2011-5-19 18:03:21 | 只看该作者
请问该脚本能与物品分类脚本兼容吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
83 小时
注册时间
2010-10-16
帖子
140
9
发表于 2011-5-27 19:35:03 | 只看该作者
貌似不错吧
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-25 10:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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