查看: 2472|回复: 5

[已经解决] 真实商店系统能和完美物品系统结合吗。单把重复删了没用

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2015-12-11 01:10:59 | 显示全部楼层 |阅读模式

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

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

×
感觉这两系统就有相相互相城的效果。一起用效果是好几倍。
可惜他们不兼容。

完美物品系统
  1. #==============================================================================
  2. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  3. # ■ 使用方法写在发布页
  4. #==============================================================================
  5. =begin

  6. 部分可能在制作中用到的核心算法:

  7. 角色(Game_Actor):
  8. 属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1
  9. 属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0]
  10. 函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空
  11. 函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。
  12.       item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具
  13. 函数:item_amount,返回现有负重物品数量
  14. 函数:have_item?(item),判断是否拥有某物
  15. 函数:item_full?,判断背包是不是满了


  16. 队伍(Game_Party):
  17. 属性:max_amount,最大背包中物品数量
  18. 属性:now_amount,背包中现有物品数量
  19. 函数:item_full?,判断背包是否放满
  20. 函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用

  21. =end
  22. #==============================================================================
  23. # ■ Game_Actor
  24. #------------------------------------------------------------------------------
  25. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  26. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  27. #==============================================================================
  28. class Game_Actor < Game_Battler
  29.   attr_accessor :max_size
  30.   attr_reader   :items
  31.   #--------------------------------------------------------------------------
  32.   # ● 设置
  33.   #     actor_id : 角色 ID
  34.   #--------------------------------------------------------------------------
  35.   alias final_items_setup setup
  36.   def setup(actor_id)
  37.     final_items_setup(actor_id)   
  38.     #--角色自带的物品建立
  39.     @max_size = 8
  40.     @items = []        
  41.     if @weapon_id >0
  42.       @items.push($data_weapons[@weapon_id])
  43.     end
  44.     if @armor1_id >0
  45.       @items.push($data_armors[@armor1_id])
  46.     end
  47.     if @armor2_id >0
  48.       @items.push($data_armors[@armor2_id])
  49.     end
  50.     if @armor3_id >0
  51.       @items.push($data_armors[@armor3_id])
  52.     end
  53.     if @armor4_id >0
  54.       @items.push($data_armors[@armor4_id])
  55.     end
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 测试装备是否正确,如果不正确就设置为空
  59.   #--------------------------------------------------------------------------
  60.   def judge_equip
  61.     if @armor1_id>0
  62.       unless @items.include?($data_armors[@armor1_id])
  63.         @armor1_id = 0
  64.       end
  65.     end
  66.     if @armor2_id>0
  67.       unless @items.include?($data_armors[@armor2_id])
  68.         @armor2_id = 0
  69.       end
  70.     end
  71.     if @armor3_id>0
  72.       unless @items.include?($data_armors[@armor3_id])
  73.         @armor3_id = 0
  74.       end
  75.     end
  76.     if @armor4_id>0
  77.       unless @items.include?($data_armors[@armor4_id])
  78.         @armor4_id = 0
  79.       end
  80.     end
  81.     if @weapon_id>0
  82.       unless @items.include?($data_weapons[@weapon_id])
  83.         @weapon_id = 0
  84.       end
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● 增加物品 (减少)
  89.   #     item_id : 物品 ID
  90.   #     n       : true是增加,false是减少
  91.   #     kind    : 种类,1是物品,2是武器,3是防具
  92.   #--------------------------------------------------------------------------
  93.   def gain_item(item_id, kind=1, n=true)
  94.     return if item_full?
  95.     if kind == 1
  96.       if item_id > 0 and n==true
  97.         @items.push($data_items[item_id])
  98.       elsif item_id >0 and n==false
  99.         @items.delete($data_items[item_id])
  100.       end
  101.     end
  102.     if kind == 2
  103.       if item_id > 0 and n==true
  104.         @items.push($data_weapons[item_id])
  105.       elsif item_id > 0 and n==false
  106.         @items.push($data_weapons[item_id])
  107.       end
  108.     end
  109.     if kind == 3
  110.       if item_id > 0 and n==true
  111.         @items.push($data_armors[item_id])
  112.       elsif item_id > 0 and n==true
  113.         @items.push($data_armors[item_id])
  114.       end
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 返回物品数量
  119.   #--------------------------------------------------------------------------  
  120.   def item_amount
  121.     return @items.size
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 判断是否拥有物品
  125.   #--------------------------------------------------------------------------  
  126.   def have_item?(item)
  127.     return @items.include?(item)
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 判断是否物品满了
  131.   #--------------------------------------------------------------------------  
  132.   def item_full?
  133.     return true if @items.size>=@max_size
  134.     return false
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 变更装备
  138.   #     equip_type : 装备类型
  139.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  140.   #--------------------------------------------------------------------------
  141.   def equip(equip_type, id)
  142.     case equip_type
  143.     when 0  # 武器
  144.       if id >= 0
  145.         @weapon_id = id
  146.       end
  147.     when 1  # 盾
  148.       if id >= 0
  149.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  150.         @armor1_id = id
  151.       end
  152.     when 2  # 头
  153.       if id >= 0
  154.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  155.         @armor2_id = id
  156.       end
  157.     when 3  # 身体
  158.       if id >= 0
  159.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  160.         @armor3_id = id
  161.       end
  162.     when 4  # 装饰品
  163.       if id >= 0
  164.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  165.         @armor4_id = id
  166.       end
  167.     end
  168.   end  
  169. end

  170. #==============================================================================
  171. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  172. # ■ 使用方法写在发布页
  173. #==============================================================================
  174. # ■ Game_Party
  175. #------------------------------------------------------------------------------
  176. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  177. # 请参考 $game_party。
  178. #==============================================================================

  179. class Game_Party
  180.   #--------------------------------------------------------------------------
  181.   # ● 定义实例变量
  182.   #--------------------------------------------------------------------------
  183.   attr_accessor :max_amount
  184.   attr_reader   :now_amount
  185.   #--------------------------------------------------------------------------
  186.   # ● 初始化对像
  187.   #--------------------------------------------------------------------------
  188.   alias final_item_initialize initialize
  189.   def initialize
  190.     final_item_initialize
  191.     @max_amount = 15
  192.     @now_amount = 0
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   #--------------------------------------------------------------------------
  196.   def item_full?
  197.     return true if @now_amount>=@max_amount
  198.     return false
  199.   end
  200.   def refresh_item_amount
  201.     @now_amount = 0
  202.     for i in 1...$data_items.size
  203.       if $game_party.item_number(i) > 0
  204.         @now_amount += $game_party.item_number(i)
  205.       end
  206.     end
  207.     for i in 1...$data_weapons.size
  208.       if $game_party.weapon_number(i) > 0
  209.         @now_amount += $game_party.weapon_number(i)
  210.       end
  211.     end
  212.     for i in 1...$data_armors.size
  213.       if $game_party.armor_number(i) > 0
  214.         @now_amount += $game_party.armor_number(i)
  215.       end
  216.     end
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 增加物品 (减少)
  220.   #     item_id : 物品 ID
  221.   #     n       : 个数
  222.   #--------------------------------------------------------------------------
  223.   def gain_item(item_id, n)
  224.     # 更新 hash 的个数数据
  225.     if item_id > 0
  226.       @items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min
  227.       refresh_item_amount
  228.     end
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 增加武器 (减少)
  232.   #     weapon_id : 武器 ID
  233.   #     n         : 个数
  234.   #--------------------------------------------------------------------------
  235.   def gain_weapon(weapon_id, n)
  236.     # 更新 hash 的个数数据
  237.     if weapon_id > 0
  238.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min
  239.       refresh_item_amount
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 增加防具 (减少)
  244.   #     armor_id : 防具 ID
  245.   #     n        : 个数
  246.   #--------------------------------------------------------------------------
  247.   def gain_armor(armor_id, n)
  248.     # 更新 hash 的个数数据
  249.     if armor_id > 0
  250.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min
  251.       refresh_item_amount
  252.     end
  253.   end  
  254.   #--------------------------------------------------------------------------
  255.   # ● 判断物品可以使用
  256.   #     item_id : 物品 ID
  257.   #--------------------------------------------------------------------------
  258.   def item_can_use?(item_id)
  259.     # 物品个数为 0 的情况
  260.     #if item_number(item_id) == 0
  261.       # 不能使用
  262.       #return false
  263.     #end
  264.     # 获取可以使用的时候
  265.     occasion = $data_items[item_id].occasion
  266.     # 战斗的情况
  267.     if $game_temp.in_battle
  268.       # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
  269.       return (occasion == 0 or occasion == 1)
  270.     end
  271.     # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
  272.     return (occasion == 0 or occasion == 2)
  273.   end  
  274. end

  275. #==============================================================================
  276. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  277. # ■ 使用方法写在发布页
  278. #==============================================================================
  279. # ■ Window_Command
  280. #------------------------------------------------------------------------------
  281. #  一般的命令选择行窗口。
  282. #==============================================================================

  283. class Window_Command < Window_Selectable
  284.   #--------------------------------------------------------------------------
  285.   # ● 项目有效化
  286.   #     index : 项目编号
  287.   #--------------------------------------------------------------------------  
  288.   def enable_item(index)
  289.     draw_item(index, normal_color)
  290.   end
  291. end

  292. #==============================================================================
  293. # ■ Window_Item
  294. #------------------------------------------------------------------------------
  295. #  物品画面、战斗画面、显示浏览物品的窗口。
  296. #==============================================================================

  297. class Window_Item < Window_Selectable
  298.   #--------------------------------------------------------------------------
  299.   # ● 初始化对像
  300.   #--------------------------------------------------------------------------
  301.   def initialize(actor=nil)
  302.     @actor=actor
  303.     super(0, 64, 640, 416)
  304.     @column_max = 1
  305.     refresh
  306.     self.index = 0
  307.     # 战斗中的情况下将窗口移至中央并将其半透明化
  308.     if $game_temp.in_battle
  309.       self.y = 64
  310.       self.height = 256
  311.       self.back_opacity = 160
  312.     end
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ● 获取物品
  316.   #--------------------------------------------------------------------------
  317.   def item
  318.     return @data[self.index]
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● 刷新
  322.   #--------------------------------------------------------------------------
  323.   def refresh
  324.     if self.contents != nil
  325.       self.contents.dispose
  326.       self.contents = nil
  327.     end
  328.     @data = []
  329.     # 添加报务

  330.     if @actor==nil   
  331.       for i in 1...$data_items.size
  332.         if $game_party.item_number(i) > 0
  333.           for pushtimes in 0...$game_party.item_number(i)
  334.             @data.push($data_items[i])
  335.           end
  336.         end
  337.       end
  338.       for i in 1...$data_weapons.size
  339.         if $game_party.weapon_number(i) > 0
  340.           for pushtimes in 0...$game_party.weapon_number(i)
  341.             @data.push($data_weapons[i])
  342.           end
  343.         end
  344.       end
  345.       for i in 1...$data_armors.size
  346.         if $game_party.armor_number(i) > 0
  347.           for pushtimes in 0...$game_party.armor_number(i)
  348.             @data.push($data_armors[i])
  349.           end
  350.         end
  351.       end
  352.     else
  353.       for i in [email]0...@actor.items.size[/email]
  354.         if @actor.items[i].is_a?(RPG::Item)
  355.           @data.push(@actor.items[i])
  356.         else         
  357.           if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor)
  358.             if @actor.items[i].name==$data_items[@actor.items[i].id].name
  359.               @data.push($data_items[@actor.items[i].id])
  360.               next
  361.             else
  362.               @data.push(@actor.items[i])
  363.               next
  364.             end
  365.           end
  366.         end
  367.       end
  368.     end
  369.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  370.     @item_max = @data.size
  371.     if @item_max > 0
  372.       self.contents = Bitmap.new(width - 32, row_max * 32)
  373.       self.contents.font.size = 20
  374.       for i in 0...@item_max
  375.         draw_item(i)
  376.       end
  377.     end
  378.   end
  379.   #--------------------------------------------------------------------------
  380.   # ● 描绘项目
  381.   #     index : 项目编号
  382.   #--------------------------------------------------------------------------
  383.   def draw_item(index)
  384.     if @actor==nil
  385.       item = @data[index]
  386.       x = 4
  387.       y = index * 32
  388.       rect = Rect.new(x, y, self.width - 32, 32)
  389.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  390.       bitmap = RPG::Cache.icon(item.icon_name)
  391.       opacity = self.contents.font.color == normal_color ? 255 : 128
  392.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  393.       self.contents.font.size = 20
  394.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  395.       self.contents.font.size = 14
  396.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 0)
  397.     else
  398.       item = @data[index]
  399.       #if item.is_a?(RPG::Item) and
  400.         #$game_party.item_can_use?(item.id)
  401.         #self.contents.font.color = normal_color
  402.       #else
  403.         #self.contents.font.color = disabled_color
  404.       #end
  405.       x = 4
  406.       y = index * 32
  407.       rect = Rect.new(x, y, self.width - 32, 32)
  408.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  409.       bitmap = RPG::Cache.icon(item.icon_name)
  410.       opacity = self.contents.font.color == normal_color ? 255 : 128
  411.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  412.       self.contents.font.size = 20
  413.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  414.       self.contents.font.size = 14
  415.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s, 0)
  416.     end
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 刷新帮助文本
  420.   #--------------------------------------------------------------------------
  421.   def update_help
  422.     @help_window.set_text(item)
  423.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  424.     #@help_window.contents.font.size = 18
  425.     #if @actor==nil
  426.     #  @help_window.set_text(self.item == nil ? ""+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s : self.item.description+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s )
  427.     #else
  428.     #  @help_window.set_text(@actor.name+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s)
  429.     #end
  430.   end
  431.   def dispose
  432.     super
  433.     @actor.judge_equip if @actor != nil
  434.   end
  435. end

  436. #==============================================================================
  437. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  438. # ■ 使用方法写在发布页
  439. #============================================================================
  440. # ■ Window_EquipItem
  441. #------------------------------------------------------------------------------
  442. #  装备画面、显示浏览变更装备的候补物品的窗口。
  443. #==============================================================================

  444. class Window_EquipItem < Window_Selectable
  445.   #--------------------------------------------------------------------------
  446.   # ● 刷新
  447.   #--------------------------------------------------------------------------
  448.   def refresh
  449.     if self.contents != nil
  450.       self.contents.dispose
  451.       self.contents = nil
  452.     end
  453.     @data = []

  454.     # 添加可以装备的武器
  455.     if @equip_type == 0
  456.       weapon_set = $data_classes[@actor.class_id].weapon_set
  457.       for item in @actor.items
  458.         if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id)
  459.           @data.push(item)
  460.         end
  461.       end
  462.     end
  463.     # 添加可以装备的防具
  464.     if @equip_type != 0
  465.       armor_set = $data_classes[@actor.class_id].armor_set
  466.       for item in @actor.items
  467.         if item.is_a?(RPG::Armor) and armor_set.include?(item.id)
  468.           if item.kind == @equip_type-1
  469.             @data.push(item)
  470.           end
  471.         end
  472.       end
  473.     end
  474.     # 添加空白
  475.     @data.push(nil)
  476.     # 生成位图、描绘全部项目
  477.     @item_max = @data.size
  478.     self.contents = Bitmap.new(width - 32, row_max * 32)
  479.     for i in 0...@item_max-1
  480.       draw_item(i)
  481.     end
  482.   end
  483.   #--------------------------------------------------------------------------
  484.   # ● 项目的描绘
  485.   #     index : 项目符号
  486.   #--------------------------------------------------------------------------
  487.   def draw_item(index)
  488.     item = @data[index]
  489.     x = 4 + index % 2 * (288 + 32)
  490.     y = index / 2 * 32
  491.     bitmap = RPG::Cache.icon(item.icon_name)
  492.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  493.     self.contents.font.color = normal_color
  494.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  495.   end
  496. end

  497. #==============================================================================
  498. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  499. # ■ 使用方法写在发布页
  500. #==============================================================================
  501. # ■ Window_ShopStatus_New
  502. #------------------------------------------------------------------------------
  503. #  商店画面、显示物品所持数与角色装备的窗口。
  504. #==============================================================================

  505. class Window_ShopStatus_New < Window_Selectable
  506.   #--------------------------------------------------------------------------
  507.   # ● 初始化对像
  508.   #--------------------------------------------------------------------------
  509.   def initialize
  510.     super(368, 128, 272, 352)
  511.     self.contents = Bitmap.new(width - 32, height - 32)
  512.     self.contents.font.size = 18
  513.     @item = nil
  514.     @item_max = $game_party.actors.size + 1
  515.     refresh
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● 刷新
  519.   #--------------------------------------------------------------------------
  520.   def refresh
  521.     self.contents.clear

  522.     if @item == nil
  523.       return
  524.     end
  525.     case @item
  526.     when RPG::Item
  527.       number = $game_party.item_number(@item.id)
  528.     when RPG::Weapon
  529.       number = $game_party.weapon_number(@item.id)
  530.     when RPG::Armor
  531.       number = $game_party.armor_number(@item.id)
  532.     end
  533.     self.contents.font.color = system_color
  534.     self.contents.draw_text(4, 0, 200, 32, "队伍中本物品数:")
  535.     self.contents.font.color = normal_color
  536.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  537.     self.contents.font.color = system_color
  538.     self.contents.draw_text(4, 32, 200, 32, "队伍目前物品数:")
  539.     self.contents.font.color = normal_color
  540.     self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2)
  541.     #if @item.is_a?(RPG::Item)
  542.       #return
  543.     #end
  544.     # 添加装备品信息
  545.     for i in 0...$game_party.actors.size
  546.       actor = $game_party.actors[i]
  547.       self.contents.font.color = Color.new(255,255,0)
  548.       self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ")
  549.       self.contents.font.color = normal_color
  550.       self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2)
  551.       # 获取当前的装备品
  552.       unless @item == nil or @item.is_a?(RPG::Item)
  553.         if @item.is_a?(RPG::Weapon)
  554.           item1 = $data_weapons[actor.weapon_id]
  555.         elsif @item.kind == 0
  556.           item1 = $data_armors[actor.armor1_id]
  557.         elsif @item.kind == 1
  558.           item1 = $data_armors[actor.armor2_id]
  559.         elsif @item.kind == 2
  560.           item1 = $data_armors[actor.armor3_id]
  561.         else
  562.           item1 = $data_armors[actor.armor4_id]
  563.         end
  564.         # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  565.         if actor.equippable?(@item)
  566.           self.contents.font.color = normal_color
  567.         else
  568.           self.contents.font.color = disabled_color
  569.         end        
  570.         # 描绘角色名字
  571.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  572.         # 可以装备的情况
  573.         if actor.equippable?(@item)
  574.           # 武器的情况
  575.           if @item.is_a?(RPG::Weapon)
  576.             atk1 = item1 != nil ? item1.atk : 0
  577.             atk2 = @item != nil ? @item.atk : 0
  578.             change = atk2 - atk1
  579.           end
  580.           # 防具的情况
  581.           if @item.is_a?(RPG::Armor)
  582.             pdef1 = item1 != nil ? item1.pdef : 0
  583.             mdef1 = item1 != nil ? item1.mdef : 0
  584.             pdef2 = @item != nil ? @item.pdef : 0
  585.             mdef2 = @item != nil ? @item.mdef : 0
  586.             change = pdef2 - pdef1 + mdef2 - mdef1
  587.           end
  588.           # 描绘能力值变化
  589.           self.contents.draw_text(124, 96 + 64 * i, 112, 32,
  590.             sprintf("%+d", change), 2)
  591.         end
  592.         # 描绘物品
  593.         if item1 != nil
  594.           x = 4
  595.           y = 64 + 64 * i + 32
  596.           bitmap = RPG::Cache.icon(item1.icon_name)
  597.           opacity = self.contents.font.color == normal_color ? 255 : 128
  598.           self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  599.           self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  600.         end
  601.       else
  602.         self.contents.font.color = normal_color
  603.         # 描绘角色名字
  604.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  605.       end
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 设置物品
  610.   #     item : 新的物品
  611.   #--------------------------------------------------------------------------
  612.   def item=(item)
  613.     if @item != item
  614.       @item = item
  615.       refresh
  616.     end
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● 刷新光标矩形
  620.   #--------------------------------------------------------------------------
  621.   def update_cursor_rect
  622.     if @index < 0
  623.       self.cursor_rect.empty
  624.     else
  625.       self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
  626.     end
  627.   end
  628. end

  629. #==============================================================================
  630. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  631. # ■ 使用方法写在发布页
  632. #==============================================================================
  633. # ■ Scene_Menu
  634. #------------------------------------------------------------------------------
  635. #  处理菜单画面的类。
  636. #==============================================================================

  637. class Scene_Menu
  638.   #--------------------------------------------------------------------------
  639.   # ● 初始化对像
  640.   #     menu_index : 命令光标的初期位置
  641.   #--------------------------------------------------------------------------
  642.   def initialize(menu_index = 0)
  643.     @menu_index = menu_index

  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● 主处理
  647.   #--------------------------------------------------------------------------
  648.   def main
  649.         @menu_com = Sprite.new
  650.     @menu_com.bitmap = RPG::Cache.picture("自己做背景.png")  
  651.     @menu_com.opacity = 100
  652.     # 生成命令窗口
  653.     s1 = $data_system.words.item
  654.     s2 = $data_system.words.skill
  655.     s3 = $data_system.words.equip
  656.     s4 = "状态"
  657.     s5 = "存档"
  658.     s6 = "CG"
  659.     s7 = "结束游戏"
  660.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  661.     @command_window.index = @menu_index
  662.     @item_command_window = Window_Command.new(160,["队伍物品","个人物品"])
  663.     @item_command_window.x = 120
  664.     @item_command_window.visible = false
  665.     @item_command_window.active = false
  666.     @item_command_window.z = 999
  667.      @command_window.opacity = 0
  668.       # 同伴人数为 0 的情况下
  669.     if $game_party.actors.size == 0
  670.       # 物品、特技、装备、状态无效化
  671.       @command_window.disable_item(0)
  672.       @command_window.disable_item(1)
  673.       @command_window.disable_item(2)
  674.       @command_window.disable_item(3)
  675.     end
  676.     # 禁止存档的情况下
  677.     if $game_system.save_disabled
  678.       # 存档无效
  679.       @command_window.disable_item(4)
  680.     end
  681.     # 生成游戏时间窗口
  682.     @playtime_window = Window_PlayTime.new
  683.     @playtime_window.x = 0
  684.     @playtime_window.y = 224
  685.    
  686.    
  687.    
  688.         # 生成犯罪窗口
  689.     @fanzui_window = Window_Fanzui.new
  690.     @fanzui_window.x = 0
  691.     @fanzui_window.y = 200

  692.    
  693.    
  694.     # 生成步数窗口
  695.     @steps_window = Window_Steps.new
  696.     @steps_window.x = 0
  697.     @steps_window.y = 320
  698.     # 生成金钱窗口
  699.     @gold_window = Window_Gold.new
  700.     @gold_window.x = 0
  701.     @gold_window.y = 416
  702.     # 生成状态窗口
  703.     @status_window = Window_MenuStatus.new
  704.     @status_window.x = 160
  705.     @status_window.y = 0
  706.     # 执行过渡
  707.     Graphics.transition
  708.     # 主循环
  709.     loop do
  710.       # 刷新游戏画面
  711.       Graphics.update
  712.       # 刷新输入信息
  713.       Input.update
  714.       # 刷新画面
  715.       update
  716.       # 如果切换画面就中断循环
  717.       if $scene != self
  718.         break
  719.       end
  720.     end
  721.     # 准备过渡
  722.     Graphics.freeze
  723.     # 释放窗口
  724.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  725.     @menu_com.dispose
  726.    
  727.    
  728.     @fanzui_window.dispose
  729.    
  730.    
  731.     @command_window.dispose
  732.     @playtime_window.dispose
  733.     @steps_window.dispose
  734.     @gold_window.dispose
  735.     @status_window.dispose
  736.     @item_command_window.dispose
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● 刷新画面
  740.   #--------------------------------------------------------------------------
  741.   def update
  742.     # 刷新窗口
  743.     @command_window.update
  744.     @playtime_window.update
  745.     @steps_window.update
  746.     @gold_window.update
  747.     @status_window.update
  748.     @item_command_window.update
  749.     # 命令窗口被激活的情况下: 调用 update_command
  750.     if @command_window.active
  751.       update_command
  752.       return
  753.     end
  754.     # 状态窗口被激活的情况下: 调用 update_status
  755.     if @status_window.active
  756.       update_status
  757.       return
  758.     end
  759.     if @item_command_window.active
  760.       update_item_command
  761.       return
  762.     end
  763.   end
  764.   def update_item_command
  765.     if Input.trigger?(Input::B)
  766.       $game_system.se_play($data_system.cancel_se)
  767.       @item_command_window.active = false
  768.       @item_command_window.visible = false
  769.       @command_window.active = true
  770.     end
  771.     if Input.trigger?(Input::C)
  772.       case @item_command_window.index
  773.       when 0
  774.         $game_system.se_play($data_system.decision_se)
  775.         $scene = Scene_Item.new
  776.       when 1
  777.         # 演奏确定 SE
  778.         $game_system.se_play($data_system.decision_se)
  779.         # 激活状态窗口
  780.         @item_command_window.active = false
  781.         @item_command_window.visible = false
  782.         @status_window.active = true
  783.         @status_window.index = 0
  784.       end
  785.     end
  786.   end
  787.   #--------------------------------------------------------------------------
  788.   # ● 刷新画面 (命令窗口被激活的情况下)
  789.   #--------------------------------------------------------------------------
  790.   def update_command
  791.     # 按下 B 键的情况下
  792.     if Input.trigger?(Input::B)
  793.       # 演奏取消 SE
  794.       $game_system.se_play($data_system.cancel_se)
  795.       # 切换的地图画面
  796.       $scene = Scene_Map.new
  797.       return
  798.     end
  799.     # 按下 C 键的情况下
  800.     if Input.trigger?(Input::C)
  801.       # 同伴人数为 0、存档、游戏结束以外的场合
  802.       if $game_party.actors.size == 0 and @command_window.index < 4
  803.         # 演奏冻结 SE
  804.         $game_system.se_play($data_system.buzzer_se)
  805.         return
  806.       end
  807.       # 命令窗口的光标位置分支
  808.       case @command_window.index
  809.       when 0  # 物品
  810.         # 演奏确定 SE
  811.         $game_system.se_play($data_system.decision_se)
  812.         # 激活状态窗口
  813.         @command_window.active = false
  814.         @item_command_window.active = true
  815.         @item_command_window.index = 0
  816.         @item_command_window.visible = true
  817.       when 1  # 特技
  818.         # 演奏确定 SE
  819.         $game_system.se_play($data_system.decision_se)
  820.         # 激活状态窗口
  821.         @command_window.active = false
  822.         @status_window.active = true
  823.         @status_window.index = 0
  824.       when 2  # 装备
  825.         # 演奏确定 SE
  826.         $game_system.se_play($data_system.decision_se)
  827.         # 激活状态窗口
  828.         @command_window.active = false
  829.         @status_window.active = true
  830.         @status_window.index = 0
  831.       when 3  # 状态
  832.         # 演奏确定 SE
  833.         $game_system.se_play($data_system.decision_se)
  834.         # 激活状态窗口
  835.         @command_window.active = false
  836.         @status_window.active = true
  837.         @status_window.index = 0
  838.       when 4  # 存档
  839.         # 禁止存档的情况下
  840.         if $game_system.save_disabled
  841.           # 演奏冻结 SE
  842.           $game_system.se_play($data_system.buzzer_se)
  843.           return
  844.         end
  845.         # 演奏确定 SE
  846.         $game_system.se_play($data_system.decision_se)
  847.         # 切换到存档画面
  848.         $scene = Scene_Save.new
  849.         ##########################
  850.            when 5  # CG
  851.            $scene = Scene_Picture_Gallery.new
  852.            ############################
  853.       when 6  # 游戏结束
  854.         # 演奏确定 SE
  855.         $game_system.se_play($data_system.decision_se)
  856.         # 切换到游戏结束画面
  857.         $scene = Scene_End.new
  858.       end
  859.       return
  860.     end
  861.   end
  862.   #--------------------------------------------------------------------------
  863.   # ● 刷新画面 (状态窗口被激活的情况下)
  864.   #--------------------------------------------------------------------------
  865.   def update_status
  866.     # 按下 B 键的情况下
  867.     if Input.trigger?(Input::B)
  868.       # 演奏取消 SE
  869.       $game_system.se_play($data_system.cancel_se)
  870.       # 激活命令窗口
  871.       @command_window.active = true
  872.       @status_window.active = false
  873.       @status_window.index = -1
  874.       return
  875.     end
  876.     # 按下 C 键的情况下
  877.     if Input.trigger?(Input::C)
  878.       # 命令窗口的光标位置分支
  879.       case @command_window.index
  880.       when 0  # 物品        
  881.         $game_system.se_play($data_system.decision_se)
  882.         $scene = Scene_Item.new($game_party.actors[@status_window.index])
  883.       when 1  # 特技
  884.         # 本角色的行动限制在 2 以上的情况下
  885.         if $game_party.actors[@status_window.index].restriction >= 2
  886.           # 演奏冻结 SE
  887.           $game_system.se_play($data_system.buzzer_se)
  888.           return
  889.         end
  890.         # 演奏确定 SE
  891.         $game_system.se_play($data_system.decision_se)
  892.         # 切换到特技画面
  893.         $scene = Scene_Skill.new(@status_window.index)
  894.       when 2  # 装备
  895.         # 演奏确定 SE
  896.         $game_system.se_play($data_system.decision_se)
  897.         # 切换的装备画面
  898.         $scene = Scene_Equip.new(@status_window.index)
  899.       when 3  # 状态
  900.         # 演奏确定 SE
  901.         $game_system.se_play($data_system.decision_se)
  902.         # 切换到状态画面
  903.         $scene = Scene_Status.new(@status_window.index)
  904.       end
  905.       return
  906.     end
  907.   end
  908. end

  909. #==============================================================================
  910. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  911. # ■ 使用方法写在发布页
  912. #==============================================================================
  913. # ■ Scene_Item
  914. #------------------------------------------------------------------------------
  915. #  处理物品画面的类。
  916. #==============================================================================

  917. class Scene_Item

  918.   #★——添加定义
  919.   def initialize(actor = nil)
  920.     @actor = actor
  921.   end

  922.   #--------------------------------------------------------------------------
  923.   # ● 主处理
  924.   #--------------------------------------------------------------------------
  925.   def main
  926.         @menu_com = Sprite.new
  927.     @menu_com.bitmap = RPG::Cache.picture("技能窗口.png")  

  928.     # 生成帮助窗口、物品窗口
  929.     @help_window = Window_Help.new
  930.     @item_window = Window_Item.new(@actor)
  931.     # 关联帮助窗口
  932.     @item_window.help_window = @help_window
  933.     # 生成目标窗口 (设置为不可见・不活动)
  934.     @target_window = Window_Target.new
  935.     @target_window.visible = false
  936.     @target_window.active = false
  937.     if @actor==nil
  938.       @command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"])
  939.     else
  940.       @command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回队伍"])
  941.     end
  942.     @command_window.x = 240
  943.     @command_window.y = 180
  944.     @command_window.visible = false
  945.     @command_window.active = false
  946.     @command_window.z = 999
  947.     @target_window.z = 10000
  948.     # 执行过度
  949.     Graphics.transition
  950.     # 主循环
  951.     loop do
  952.       # 刷新游戏画面
  953.       Graphics.update
  954.       # 刷新输入信息
  955.       Input.update
  956.       # 刷新画面
  957.       update
  958.       # 如果画面切换就中断循环
  959.       if $scene != self
  960.         break
  961.       end
  962.     end
  963.     # 装备过渡
  964.     Graphics.freeze
  965.     # 释放窗口
  966.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  967.     @menu_com.dispose

  968.     @help_window.dispose
  969.     @item_window.dispose
  970.     @target_window.dispose
  971.     @command_window.dispose
  972.   end
  973.   #--------------------------------------------------------------------------
  974.   # ● 刷新画面
  975.   #--------------------------------------------------------------------------
  976.   def update
  977.     # 刷新窗口
  978.     @help_window.update
  979.     @item_window.update
  980.     @target_window.update
  981.     @command_window.update
  982.     # 物品窗口被激活的情况下: 调用 update_item
  983.     if @item_window.active
  984.       update_item
  985.       return
  986.     end
  987.     # 目标窗口被激活的情况下: 调用 update_target
  988.     if @target_window.active
  989.       update_target
  990.       return
  991.     end
  992.     if @command_window.active
  993.       update_command
  994.       return
  995.     end
  996.   end
  997.   #--------------------------------------------------------------------------
  998.   # ● 刷新画面
  999.   #--------------------------------------------------------------------------
  1000.   def update_command
  1001.     # 按下 B 键的情况下
  1002.     if Input.trigger?(Input::B)
  1003.       # 演奏取消 SE
  1004.       $game_system.se_play($data_system.cancel_se)
  1005.       # 切换到菜单画面
  1006.       @command_window.visible = false
  1007.       @command_window.active = false
  1008.       @item_window.active = true
  1009.       return
  1010.     end
  1011.     # 按下 C 键的情况下
  1012.     if Input.trigger?(Input::C)
  1013.       case @command_window.index
  1014.       when 0
  1015.         # 获取物品窗口当前选中的物品数据
  1016.         @item = @item_window.item
  1017.         # 不使用物品的情况下
  1018.         if @actor == nil
  1019.           $game_system.se_play($data_system.buzzer_se)
  1020.           return
  1021.         end
  1022.         unless @item.is_a?(RPG::Item)
  1023.           # 演奏冻结 SE
  1024.           $game_system.se_play($data_system.buzzer_se)
  1025.           return
  1026.         end
  1027.         # 不能使用的情况下
  1028.         unless $game_party.item_can_use?(@item.id)
  1029.           # 演奏冻结 SE
  1030.           $game_system.se_play($data_system.buzzer_se)
  1031.           return
  1032.         end
  1033.         # 演奏确定 SE
  1034.         $game_system.se_play($data_system.decision_se)
  1035.         # 效果范围是我方的情况下
  1036.         if @item.scope >= 3
  1037.           # 激活目标窗口
  1038.           @command_window.active = false
  1039.           @target_window.x = (@item_window.index + 1) % 2 * 304
  1040.           @target_window.visible = true
  1041.           @target_window.active = true
  1042.           # 设置效果范围 (单体/全体) 的对应光标位置
  1043.           if @item.scope == 4 || @item.scope == 6
  1044.             @target_window.index = -1
  1045.           else
  1046.             @target_window.index = 0
  1047.           end
  1048.         # 效果在我方以外的情况下
  1049.         else
  1050.           # 公共事件 ID 有效的情况下
  1051.           if @item.common_event_id > 0
  1052.             # 预约调用公共事件
  1053.             $game_temp.common_event_id = @item.common_event_id
  1054.             # 演奏物品使用时的 SE
  1055.             $game_system.se_play(@item.menu_se)
  1056.             # 消耗品的情况下
  1057.             if @item.consumable
  1058.               # 使用的物品数减 1
  1059.               if @actor==nil
  1060.                 $game_party.lose_item(@item.id, 1)
  1061.               else
  1062.                 @actor.items.delete_at(@item_window.index)
  1063.               end
  1064.               # 再描绘物品窗口的项目
  1065.               @item_window.draw_item(@item_window.index)
  1066.             end
  1067.             # 切换到地图画面
  1068.             $scene = Scene_Map.new
  1069.             return
  1070.           end
  1071.         end
  1072.         return
  1073.       when 1
  1074.         $game_system.se_play($data_system.decision_se)
  1075.         @command_window.active = false
  1076.         @target_window.visible = true
  1077.         @target_window.index = 0
  1078.         @target_window.active = true
  1079.       when 2
  1080.         $game_system.se_play($data_system.load_se)
  1081.         if @actor != nil
  1082.           @actor.items.delete_at(@item_window.index)
  1083.           @actor.judge_equip
  1084.         else
  1085.           if @item_window.item.is_a?(RPG::Item)
  1086.             $game_party.gain_item(@item_window.item.id,-1)
  1087.           end
  1088.           if @item_window.item.is_a?(RPG::Weapon)
  1089.             $game_party.gain_weapon(@item_window.item.id,-1)
  1090.           end
  1091.           if @item_window.item.is_a?(RPG::Armor)
  1092.             $game_party.gain_armor(@item_window.item.id,-1)
  1093.           end
  1094.         end
  1095.         # 切换到菜单画面
  1096.         @command_window.visible = false
  1097.         @command_window.active = false
  1098.         @item_window.refresh
  1099.         @item_window.active = true
  1100.       when 3
  1101.         if $game_party.item_full?
  1102.           $game_system.se_play($data_system.cancel_se)
  1103.           return
  1104.         end
  1105.         $game_system.se_play($data_system.decision_se)
  1106.         if @item_window.item.is_a?(RPG::Item)
  1107.           $game_party.gain_item(@item_window.item.id,1)
  1108.         end
  1109.         if @item_window.item.is_a?(RPG::Weapon)
  1110.           $game_party.gain_weapon(@item_window.item.id,1)
  1111.         end
  1112.         if @item_window.item.is_a?(RPG::Armor)
  1113.           $game_party.gain_armor(@item_window.item.id,1)
  1114.         end
  1115.         @actor.items.delete_at(@item_window.index)
  1116.         # 切换到菜单画面
  1117.         @command_window.visible = false
  1118.         @command_window.active = false
  1119.         @item_window.refresh
  1120.         @item_window.active = true
  1121.       end
  1122.     end
  1123.   end  
  1124.   #--------------------------------------------------------------------------
  1125.   # ● 刷新画面 (物品窗口被激活的情况下)
  1126.   #--------------------------------------------------------------------------
  1127.   def update_item
  1128.     # 按下 B 键的情况下
  1129.     if Input.trigger?(Input::B)
  1130.       # 演奏取消 SE
  1131.       $game_system.se_play($data_system.cancel_se)
  1132.       # 切换到菜单画面
  1133.       $scene = Scene_Menu.new(0)
  1134.       return
  1135.     end
  1136.     # 按下 C 键的情况下
  1137.     if Input.trigger?(Input::C)
  1138.       # 获取物品窗口当前选中的物品数据
  1139.       @item = @item_window.item
  1140.       $game_system.se_play($data_system.decision_se)
  1141.       if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil
  1142.         @command_window.enable_item(0)
  1143.       else
  1144.         @command_window.disable_item(0)
  1145.       end
  1146.       @command_window.index = 0
  1147.       @command_window.visible = true
  1148.       @command_window.active = true
  1149.       @item_window.active = false
  1150.       return
  1151.     end
  1152.     # 按下 R 键的情况下
  1153.     if Input.trigger?(Input::R)
  1154.       $game_system.se_play($data_system.cursor_se)
  1155.       actor_index = 0
  1156.       for i in 0...$game_party.actors.size
  1157.         if @actor==$game_party.actors[i]
  1158.           actor_index = i
  1159.           break
  1160.         end
  1161.       end
  1162.       actor_index += 1
  1163.       actor_index %= $game_party.actors.size
  1164.       # 切换到别的特技画面
  1165.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1166.       return
  1167.     end
  1168.     # 按下 L 键的情况下
  1169.     if Input.trigger?(Input::L)
  1170.       # 演奏光标 SE
  1171.       $game_system.se_play($data_system.cursor_se)      
  1172.       actor_index = 0
  1173.       for i in 0...$game_party.actors.size
  1174.         if @actor==$game_party.actors[i]
  1175.           actor_index = i
  1176.           break
  1177.         end
  1178.       end
  1179.       actor_index -= 1
  1180.       actor_index %= $game_party.actors.size
  1181.       # 切换到别的特技画面
  1182.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1183.       return
  1184.     end
  1185.   end
  1186.   #--------------------------------------------------------------------------
  1187.   # ● 刷新画面 (目标窗口被激活的情况下)
  1188.   #--------------------------------------------------------------------------
  1189.   def update_target
  1190.     # 按下 B 键的情况下
  1191.     if Input.trigger?(Input::B)
  1192.       # 演奏取消 SE
  1193.       $game_system.se_play($data_system.cancel_se)
  1194.       # 由于物品用完而不能使用的场合
  1195.       unless $game_party.item_can_use?(@item.id)
  1196.         # 再次生成物品窗口的内容
  1197.         @item_window.refresh
  1198.       end
  1199.       # 删除目标窗口
  1200.       @command_window.active = true
  1201.       @target_window.visible = false
  1202.       @target_window.active = false
  1203.       return
  1204.     end
  1205.     # 按下 C 键的情况下
  1206.     if Input.trigger?(Input::C)
  1207.       if @command_window.index==0
  1208.         # 目标是全体的情况下
  1209.         if @target_window.index == -1
  1210.           # 对同伴全体应用物品使用效果
  1211.           used = false
  1212.           for i in $game_party.actors
  1213.             used |= i.item_effect(@item)
  1214.           end
  1215.         end
  1216.         # 目标是单体的情况下
  1217.         if @target_window.index >= 0
  1218.           # 对目标角色应用物品的使用效果
  1219.           target = $game_party.actors[@target_window.index]
  1220.           used = target.item_effect(@item)
  1221.         end
  1222.         # 使用物品的情况下
  1223.         if used
  1224.           # 演奏物品使用时的 SE
  1225.           $game_system.se_play(@item.menu_se)
  1226.           # 消耗品的情况下
  1227.           if @item.consumable

  1228.             if @actor == nil
  1229.               # 使用的物品数减 1
  1230.               $game_party.lose_item(@item.id, 1)
  1231.             else
  1232.               @actor.items.delete_at(@item_window.index)
  1233.             end

  1234.             # 再描绘物品窗口的项目
  1235.             @item_window.draw_item(@item_window.index)
  1236.           end
  1237.           # 再生成目标窗口的内容
  1238.           @target_window.refresh
  1239.           # 全灭的情况下
  1240.           if $game_party.all_dead?
  1241.             # 切换到游戏结束画面
  1242.             $scene = Scene_Gameover.new
  1243.             return
  1244.           end
  1245.           # 公共事件 ID 有效的情况下
  1246.           if @item.common_event_id > 0
  1247.             # 预约调用公共事件
  1248.             $game_temp.common_event_id = @item.common_event_id
  1249.             # 切换到地图画面
  1250.             $scene = Scene_Map.new
  1251.             return
  1252.           end
  1253.           @item_window.refresh
  1254.           @item_window.index -= 1 if @item_window.index >0
  1255.         end
  1256.         # 无法使用物品的情况下
  1257.         unless used
  1258.           # 演奏冻结 SE
  1259.           $game_system.se_play($data_system.buzzer_se)
  1260.         end
  1261.         return
  1262.       end
  1263.       if @command_window.index==1
  1264.         if $game_party.actors[@target_window.index].item_full?
  1265.           $game_system.se_play($data_system.buzzer_se)
  1266.           return
  1267.         end
  1268.         if @actor != nil
  1269.           @actor.items.delete_at(@item_window.index)
  1270.         else
  1271.           if @item_window.item.is_a?(RPG::Item)
  1272.             $game_party.lose_item(@item_window.item.id, 1)
  1273.           elsif @item_window.item.is_a?(RPG::Weapon)
  1274.             $game_party.lose_weapon(@item_window.item.id, 1)
  1275.           elsif @item_window.item.is_a?(RPG::Armor)
  1276.             $game_party.lose_armor(@item_window.item.id, 1)
  1277.           end
  1278.         end
  1279.         $game_system.se_play($data_system.decision_se)
  1280.         $game_party.actors[@target_window.index].items.push(@item_window.item)
  1281.         @item_window.refresh
  1282.         @item_window.index -= 1 if @item_window.index>0
  1283.         @item_window.active = true
  1284.         @command_window.visible = false
  1285.         @command_window.active = false
  1286.         @command_window.index = 0
  1287.         @target_window.visible = false
  1288.         @target_window.active = false
  1289.       end
  1290.     end
  1291.   end
  1292. end

  1293. #==============================================================================
  1294. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1295. # ■ 使用方法写在发布页
  1296. #==============================================================================
  1297. # ■ Scene_Battle (分割定义 3)
  1298. #------------------------------------------------------------------------------
  1299. #  处理战斗画面的类。
  1300. #==============================================================================

  1301. class Scene_Battle
  1302.   #--------------------------------------------------------------------------
  1303.   # ● 开始选择物品
  1304.   #--------------------------------------------------------------------------
  1305.   def start_item_select
  1306.     # 无效化角色指令窗口
  1307.     @actor_command_window.active = false
  1308.     @actor_command_window.visible = false
  1309.     # 生成物品窗口
  1310.     @item_window = Window_Item.new($game_party.actors[@actor_index])
  1311.     # 关联帮助窗口
  1312.     #@item_window.help_window = @help_window
  1313.     @item_window.help_window =  Window_Help.new#★★★★★★★★★★★★
  1314.     # 无效化角色指令窗口
  1315.     @actor_command_window.active = false
  1316.     @actor_command_window.visible = false
  1317.   end
  1318.   #--------------------------------------------------------------------------
  1319.   # ● 刷新画面 (角色命令回合 : 选择物品)
  1320.   #--------------------------------------------------------------------------
  1321.   def update_phase3_item_select
  1322.     # 设置物品窗口为可视状态
  1323.     @item_window.visible = true
  1324.     # 刷新物品窗口
  1325.     @item_window.update
  1326.     # 按下 B 键的情况下
  1327.     if Input.trigger?(Input::B)
  1328.       # 演奏取消 SE
  1329.       $game_system.se_play($data_system.cancel_se)
  1330.       # 选择物品结束
  1331.       end_item_select
  1332.       return
  1333.     end
  1334.     # 按下 C 键的情况下
  1335.     if Input.trigger?(Input::C)
  1336.       # 获取物品窗口现在选择的物品资料
  1337.       @item = @item_window.item
  1338.       unless @item.is_a?(RPG::Item)
  1339.         # 演奏冻结 SE
  1340.         $game_system.se_play($data_system.buzzer_se)
  1341.         return
  1342.       end
  1343.       # 无法使用的情况下
  1344.       unless $game_party.item_can_use?(@item.id)
  1345.         # 演奏冻结 SE
  1346.         $game_system.se_play($data_system.buzzer_se)
  1347.         return
  1348.       end
  1349.       # 演奏确定 SE
  1350.       $game_system.se_play($data_system.decision_se)

  1351.       # 设置行动
  1352.       @active_battler.current_action.item_id = @item.id
  1353.       
  1354.                         # 消耗品的情况下
  1355.             if @item.consumable
  1356.               # 使用的物品数减 1
  1357.               $game_party.actors[@actor_index].gain_item(@item.id, 1, n=false)
  1358.               $game_party.gain_item(@item.id, 1)
  1359.               end

  1360.       # 设置物品窗口为不可见状态
  1361.       @item_window.visible = false
  1362.           # 效果范围是敌单体的情况下
  1363.       if @item.scope == 1
  1364.         # 开始选择敌人
  1365.         start_enemy_select
  1366.       # 效果范围是我方单体的情况下
  1367.       elsif @item.scope == 3 or @item.scope == 5
  1368.         # 开始选择角色
  1369.         start_actor_select
  1370.       # 效果范围不是单体的情况下
  1371.       else
  1372.         # 物品选择结束
  1373.         end_item_select
  1374.         # 转到下一位角色的指令输入
  1375.         phase3_next_actor
  1376.       end
  1377.       return
  1378.     end
  1379.   end
  1380. end

  1381. #==============================================================================
  1382. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1383. # ■ 使用方法写在发布页
  1384. #==============================================================================
  1385. # ■ Scene_Shop
  1386. #------------------------------------------------------------------------------
  1387. #  处理商店画面的类。
  1388. #==============================================================================

  1389. class Scene_Shop
  1390.   #--------------------------------------------------------------------------
  1391.   # ● 主处理
  1392.   #--------------------------------------------------------------------------
  1393.   def main

  1394.     @type = 0   

  1395.     # 生成帮助窗口
  1396.     #@help_window = Window_Help.new
  1397.     @help_window = Window_Help.new#★★★★★★★★★★★★★★★★
  1398.     # 生成指令窗口
  1399.     @command_window = Window_ShopCommand.new
  1400.     # 生成金钱窗口
  1401.     @gold_window = Window_Gold.new
  1402.     @gold_window.x = 480
  1403.     @gold_window.y = 64
  1404.     # 生成时间窗口
  1405.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  1406.     # 生成购买窗口
  1407.     @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
  1408.     @buy_window.active = false
  1409.     @buy_window.visible = false
  1410.     @buy_window.help_window = @help_window
  1411.     # 生成卖出窗口
  1412.     @sell_window = Window_ShopSell.new
  1413.     @sell_window.active = false
  1414.     @sell_window.visible = false
  1415.     @sell_window.help_window = @help_window
  1416.     # 生成状态窗口
  1417.     @status_window = Window_ShopStatus_New.new
  1418.     @status_window.visible = false
  1419.     @status_window.index = -1
  1420.     # 执行过渡
  1421.     Graphics.transition
  1422.     # 主循环
  1423.     loop do
  1424.       # 刷新游戏画面
  1425.       Graphics.update
  1426.       # 刷新输入信息
  1427.       Input.update
  1428.       # 刷新画面
  1429.       update
  1430.       # 如果画面切换的话就中断循环
  1431.       if $scene != self
  1432.         break
  1433.       end
  1434.     end
  1435.     # 准备过渡
  1436.     Graphics.freeze
  1437.     # 释放窗口
  1438.     @help_window.dispose
  1439.     @command_window.dispose
  1440.     @gold_window.dispose
  1441.     @dummy_window.dispose
  1442.     @buy_window.dispose
  1443.     @sell_window.dispose
  1444.     @status_window.dispose
  1445.   end
  1446.   #--------------------------------------------------------------------------
  1447.   # ● 刷新画面
  1448.   #--------------------------------------------------------------------------
  1449.   def update
  1450.     # 刷新窗口
  1451.     @help_window.update
  1452.     @command_window.update
  1453.     @gold_window.update
  1454.     @dummy_window.update
  1455.     @buy_window.update
  1456.     @sell_window.update
  1457.     @status_window.update
  1458.     # 指令窗口激活的情况下: 调用 update_command
  1459.     if @command_window.active
  1460.       @help_window.visible=false
  1461.       update_command
  1462.       return
  1463.     end
  1464.     # 购买窗口激活的情况下: 调用 update_buy
  1465.     if @buy_window.active
  1466. # 修改開始
  1467.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1468.       if @buy_window.item==nil#★★★★★★★★★★★★★★★★
  1469.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1470.       end #★★★★★★★★★★★★★★★★     
  1471.       update_buy
  1472.       return
  1473.     end
  1474.     # 卖出窗口激活的情况下: 调用 update_sell
  1475.     if @sell_window.active
  1476. # 修改開始
  1477.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1478.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1479.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1480.       end #★★★★★★★★★★★★★★★★
  1481. # 修改終了
  1482.       update_sell
  1483.       return
  1484.     end
  1485.     if @type==1
  1486. # 修改開始
  1487.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1488.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1489.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1490.       end #★★★★★★★★★★★★★★★★
  1491. # 修改終了
  1492.       update_st1
  1493.       return
  1494.     end
  1495.   end

  1496.   def update_st1
  1497.     if Input.trigger?(Input::B)
  1498.       $game_system.se_play($data_system.cancel_se)
  1499.       @buy_window.active = true
  1500.       @type = 0
  1501.       @status_window.index = -1
  1502.       @status_window.active = false
  1503.       return
  1504.     end
  1505.     if Input.trigger?(Input::C)
  1506.       if @status_window.index == 0        
  1507.         if $game_party.item_full?
  1508.           $game_system.se_play($data_system.cancel_se)
  1509.           return
  1510.         end        
  1511.         # 演奏商店 SE
  1512.         $game_system.se_play($data_system.shop_se)
  1513.         $game_party.lose_gold(@item.price)
  1514.         case @item
  1515.         when RPG::Item
  1516.           $game_party.gain_item(@item.id, 1)
  1517.         when RPG::Weapon
  1518.           $game_party.gain_weapon(@item.id, 1)
  1519.         when RPG::Armor
  1520.           $game_party.gain_armor(@item.id, 1)
  1521.         end
  1522.         # 刷新各窗口
  1523.         @gold_window.refresh
  1524.         @buy_window.refresh
  1525.         @status_window.refresh
  1526.         # 窗口状态转向购买模式
  1527.         @buy_window.active = true
  1528.         @buy_window.visible = true
  1529.         @status_window.active = false
  1530.         @status_window.index = -1
  1531.         @type = 0
  1532.       else
  1533.         if $game_party.actors[@status_window.index-1].item_full?
  1534.           $game_system.se_play($data_system.cancel_se)
  1535.           return
  1536.         end        
  1537.         # 演奏商店 SE
  1538.         $game_system.se_play($data_system.shop_se)
  1539.         $game_party.lose_gold(@item.price)
  1540.         case @item
  1541.         when RPG::Item
  1542.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 1)
  1543.         when RPG::Weapon
  1544.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 2)
  1545.         when RPG::Armor
  1546.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 3)
  1547.         end
  1548.         # 刷新各窗口
  1549.         @gold_window.refresh
  1550.         @buy_window.refresh
  1551.         @status_window.refresh
  1552.         # 窗口状态转向购买模式
  1553.         @buy_window.active = true
  1554.         @status_window.active = false
  1555.         @type = 0
  1556.         @status_window.index = -1
  1557.       end
  1558.     end
  1559.   end
  1560.   #--------------------------------------------------------------------------
  1561.   # ● 刷新画面 (指令窗口激活的情况下)
  1562.   #--------------------------------------------------------------------------
  1563.   def update_command
  1564.     # 按下 B 键的情况下
  1565.     if Input.trigger?(Input::B)
  1566.       # 演奏取消 SE
  1567.       $game_system.se_play($data_system.cancel_se)
  1568.       # 切换到地图画面
  1569.       $scene = Scene_Map.new
  1570.       return
  1571.     end
  1572.     # 按下 C 键的情况下
  1573.     if Input.trigger?(Input::C)
  1574.       # 命令窗口光标位置分支
  1575.       case @command_window.index
  1576.       when 0  # 购买
  1577.         # 演奏确定 SE
  1578.         $game_system.se_play($data_system.decision_se)
  1579.         # 窗口状态转向购买模式
  1580.         @command_window.active = false
  1581.         @dummy_window.visible = false
  1582.         @buy_window.active = true
  1583.         @buy_window.visible = true
  1584.         @buy_window.refresh
  1585.         @status_window.visible = true
  1586.       when 1  # 卖出
  1587.         # 演奏确定 SE
  1588.         $game_system.se_play($data_system.decision_se)
  1589.         # 窗口状态转向卖出模式
  1590.         @command_window.active = false
  1591.         @dummy_window.visible = false
  1592.         @sell_window.active = true
  1593.         @sell_window.visible = true
  1594.         @sell_window.refresh
  1595.       when 2  # 取消
  1596.         # 演奏确定 SE
  1597.         $game_system.se_play($data_system.decision_se)
  1598.         # 切换到地图画面
  1599.         $scene = Scene_Map.new
  1600.       end
  1601.       return
  1602.     end
  1603.   end
  1604.   #--------------------------------------------------------------------------
  1605.   # ● 刷新画面 (购买窗口激活的情况下)
  1606.   #--------------------------------------------------------------------------
  1607.   def update_buy
  1608.     # 设置状态窗口的物品
  1609.     @status_window.item = @buy_window.item
  1610.     # 按下 B 键的情况下
  1611.     if Input.trigger?(Input::B)
  1612.       # 演奏取消 SE
  1613.       $game_system.se_play($data_system.cancel_se)
  1614.       # 窗口状态转向初期模式
  1615.       @command_window.active = true
  1616.       @dummy_window.visible = true
  1617.       @buy_window.active = false
  1618.       @buy_window.visible = false
  1619.       @status_window.visible = false
  1620.       @status_window.item = nil
  1621.       # 删除帮助文本
  1622.       @help_window.set_text("")
  1623.       return
  1624.     end
  1625.     # 按下 C 键的情况下
  1626.     if Input.trigger?(Input::C)
  1627.       # 获取物品
  1628.       @item = @buy_window.item
  1629.       # 物品无效的情况下、或者价格在所持金以上的情况下
  1630.       if @item == nil or @item.price > $game_party.gold
  1631.         # 演奏冻结 SE
  1632.         $game_system.se_play($data_system.buzzer_se)
  1633.         return
  1634.       end
  1635.       # 获取物品所持数
  1636.       #case @item
  1637.       #when RPG::Item
  1638.         #number = $game_party.item_number(@item.id)
  1639.       #when RPG::Weapon
  1640.         #number = $game_party.weapon_number(@item.id)
  1641.       #when RPG::Armor
  1642.         #number = $game_party.armor_number(@item.id)
  1643.       #end
  1644.       # 如果已经拥有了 99 个情况下
  1645.       #if number == 99
  1646.         # 演奏冻结 SE
  1647.         #$game_system.se_play($data_system.buzzer_se)
  1648.         #return
  1649.       #end
  1650.       # 演奏确定 SE
  1651.       $game_system.se_play($data_system.decision_se)
  1652.       # 计算可以最多购买的数量
  1653.       #max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  1654.       #max = [max, 99 - number].min
  1655.       # 窗口状态转向数值输入模式
  1656.       #@buy_window.active = false
  1657.       #@buy_window.visible = false
  1658.       #@number_window.set(@item, max, @item.price)
  1659.       #@number_window.active = true
  1660.       #@number_window.visible = true
  1661.       @buy_window.active = false
  1662.       @status_window.index = 0
  1663.       @type = 1
  1664.       @status_window.active = true
  1665.     end
  1666.   end
  1667.   #--------------------------------------------------------------------------
  1668.   # ● 画面更新 (卖出窗口激活的情况下)
  1669.   #--------------------------------------------------------------------------
  1670.   def update_sell
  1671.     # 按下 B 键的情况下
  1672.     if Input.trigger?(Input::B)
  1673.       # 演奏取消 SE
  1674.       $game_system.se_play($data_system.cancel_se)
  1675.       # 窗口状态转向初期模式
  1676.       @command_window.active = true
  1677.       @dummy_window.visible = true
  1678.       @sell_window.active = false
  1679.       @sell_window.visible = false
  1680.       @status_window.item = nil
  1681.       # 删除帮助文本
  1682.       @help_window.set_text("")
  1683.       return
  1684.     end
  1685.     # 按下 C 键的情况下
  1686.     if Input.trigger?(Input::C)
  1687.       # 获取物品
  1688.       @item = @sell_window.item
  1689.       # 设置状态窗口的物品
  1690.       @status_window.item = @item
  1691.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  1692.       if @item == nil or @item.price == 0
  1693.         # 演奏冻结 SE
  1694.         $game_system.se_play($data_system.buzzer_se)
  1695.         return
  1696.       end
  1697.       # 演奏确定 SE
  1698.       $game_system.se_play($data_system.decision_se)      
  1699.       # 卖出处理
  1700.       $game_party.gain_gold(@item.price / 2)
  1701.       case @item
  1702.       when RPG::Item
  1703.         $game_party.lose_item(@item.id, 1)
  1704.       when RPG::Weapon
  1705.         $game_party.lose_weapon(@item.id, 1)
  1706.       when RPG::Armor
  1707.         $game_party.lose_armor(@item.id, 1)
  1708.       end
  1709.       # 刷新各窗口
  1710.       @gold_window.refresh
  1711.       @sell_window.refresh
  1712.       @status_window.refresh
  1713.     end
  1714.   end
  1715. end
复制代码



真实商店
  1. #==============================================================================
  2. # 本脚本来自[url]www.66rpg.com[/url],转载和使用请保留此信息  
  3. # 脚本名:真实商店,脚本作者:柳柳  
  4. #==============================================================================
  5. #  
  6. # 功能:  
  7. #  
  8. # 买进卖出的物品在商店有所体现,卖出后会在商店可买物品中出现,物品有数量限制  
  9. # 商店可进货出货————总之就是模拟真实商店。  
  10. #   
  11. # 这个脚本和原装商店并不冲突,两个商店可以并存。  
  12. #  
  13. # 使用方法:  
  14. #  
  15. # 1、在下面被井号框起来的中间部分,设置初期物品。格式如下:  
  16. #    @goods[商店编号] = [ [种类,ID,可卖数量] ,  [种类,ID,可卖数量]......]  
  17. #    其中种类,0为道具,1为武器,2为防具;ID是数据库编号  
  18. #  
  19. # 2、调用:$scene = Scene_Shop_Va.new(商店编号)   
  20. #    比如你可以直接测试$scene = Scene_Shop_Va.new(1),已经设置好了。  
  21. #  
  22. # 3、商店出货:$game_system.shop_change(商店编号,种类,ID,数量)  
  23. #    如果是进货,把数量设置为负数即可  
  24. #  
  25. #==============================================================================
  26. # ■ Scene_Shop  
  27. #------------------------------------------------------------------------------  
  28. #  处理商店画面的类。  
  29. #==============================================================================
  30. class Game_System  
  31. attr_accessor :goods   
  32. alias vaule_shop_66RPG_initialize initialize  
  33. def initialize  
  34.    vaule_shop_66RPG_initialize  
  35.    @goods = []  
  36. ###########################################################################  
  37.    # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量  
  38.    @goods[1] = [[0,1,15],[0,2,10],[1,2,3]]   
  39.    @goods[2] = [[0,3,8],[1,4,1],[1,2,1],[1,3,1],[1,4,1]]   
  40.    @goods[3] = [[0,5,2],[1,3,1],[1,2,3]]   
  41. ###########################################################################  
  42. end  
  43. def shop_change(shop,kind,id,delnumber)  
  44.    dl = delnumber  
  45.    for dt in $game_system.goods[shop]  
  46.      if (dt[0]==kind) and (dt[1]==id)  
  47.        dt[2] -= dl  
  48.        dt[2] = [dt[2],99].min  
  49.        if dt[2] == 0  
  50.          $game_system.goods[shop].delete(dt)  
  51.        end  
  52.        return  
  53.      end  
  54.    end  
  55.    $game_system.goods[shop].push([kind,id,-delnumber])  
  56. end  
  57. end
  58. class Scene_Shop_Va  
  59. def initialize(shop_number)  
  60.    # 当前商店编号  
  61.    @shop_now = shop_number      
  62. end   
  63. #--------------------------------------------------------------------------  
  64. # ● 主处理  
  65. #--------------------------------------------------------------------------  
  66. def main  
  67.    # 生成帮助窗口  
  68.    @help_window = Window_Help.new  
  69.    # 生成指令窗口  
  70.    @command_window = Window_ShopCommand.new  
  71.    # 生成金钱窗口  
  72.    @gold_window = Window_Gold.new  
  73.    @gold_window.x = 480  
  74.    @gold_window.y = 64  
  75.    # 生成时间窗口  
  76.    @dummy_window = Window_Base.new(0, 128, 640, 352)  
  77.    # 生成购买窗口  
  78.    @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])  
  79.    @buy_window.active = false  
  80.    @buy_window.visible = false  
  81.    @buy_window.help_window = @help_window  
  82.    # 生成卖出窗口  
  83.    @sell_window = Window_ShopSell.new  
  84.    @sell_window.active = false  
  85.    @sell_window.visible = false  
  86.    @sell_window.help_window = @help_window  
  87.    # 生成数量输入窗口  
  88.    @number_window = Window_ShopNumber.new  
  89.    @number_window.active = false  
  90.    @number_window.visible = false  
  91.    # 生成状态窗口  
  92.    @status_window = Window_ShopStatus.new  
  93.    @status_window.visible = false  
  94.    # 执行过渡  
  95.    Graphics.transition  
  96.    # 主循环  
  97.    loop do  
  98.      # 刷新游戏画面  
  99.      Graphics.update  
  100.      # 刷新输入信息  
  101.      Input.update  
  102.      # 刷新画面  
  103.      update  
  104.      # 如果画面切换的话就中断循环  
  105.      if $scene != self  
  106.        break  
  107.      end  
  108.    end  
  109.    # 准备过渡  
  110.    Graphics.freeze  
  111.    # 释放窗口  
  112.    @help_window.dispose  
  113.    @command_window.dispose  
  114.    @gold_window.dispose  
  115.    @dummy_window.dispose  
  116.    @buy_window.dispose  
  117.    @sell_window.dispose  
  118.    @number_window.dispose  
  119.    @status_window.dispose  
  120. end  
  121. #--------------------------------------------------------------------------  
  122. # ● 刷新画面  
  123. #--------------------------------------------------------------------------  
  124. def update  
  125.    # 刷新窗口  
  126.    @help_window.update  
  127.    @command_window.update  
  128.    @gold_window.update  
  129.    @dummy_window.update  
  130.    @buy_window.update  
  131.    @sell_window.update  
  132.    @number_window.update  
  133.    @status_window.update  
  134.    # 指令窗口激活的情况下: 调用 update_command  
  135.    if @command_window.active  
  136.      update_command  
  137.      return  
  138.    end  
  139.    # 购买窗口激活的情况下: 调用 update_buy  
  140.    if @buy_window.active  
  141.      update_buy  
  142.      return  
  143.    end  
  144.    # 卖出窗口激活的情况下: 调用 update_sell  
  145.    if @sell_window.active  
  146.      update_sell  
  147.      return  
  148.    end  
  149.    # 个数输入窗口激活的情况下: 调用 update_number  
  150.    if @number_window.active  
  151.      update_number  
  152.      return  
  153.    end  
  154. end  
  155. #--------------------------------------------------------------------------  
  156. # ● 刷新画面 (指令窗口激活的情况下)  
  157. #--------------------------------------------------------------------------  
  158. def update_command  
  159.    # 按下 B 键的情况下  
  160.    if Input.trigger?(Input::B)  
  161.      # 演奏取消 SE  
  162.      $game_system.se_play($data_system.cancel_se)  
  163.      # 切换到地图画面  
  164.      $scene = Scene_Map.new  
  165.      return  
  166.    end  
  167.    # 按下 C 键的情况下  
  168.    if Input.trigger?(Input::C)  
  169.      # 命令窗口光标位置分支  
  170.      case @command_window.index  
  171.      when 0  # 购买  
  172.        # 演奏确定 SE  
  173.        $game_system.se_play($data_system.decision_se)  
  174.        # 窗口状态转向购买模式  
  175.        @command_window.active = false  
  176.        @dummy_window.visible = false  
  177.        @buy_window.active = true  
  178.        @buy_window.visible = true  
  179.        @buy_window.refresh  
  180.        @status_window.visible = true  
  181.      when 1  # 卖出  
  182.        # 演奏确定 SE  
  183.        $game_system.se_play($data_system.decision_se)  
  184.        # 窗口状态转向卖出模式  
  185.        @command_window.active = false  
  186.        @dummy_window.visible = false  
  187.        @sell_window.active = true  
  188.        @sell_window.visible = true  
  189.        @sell_window.refresh  
  190.      when 2  # 取消  
  191.        # 演奏确定 SE  
  192.        $game_system.se_play($data_system.decision_se)  
  193.        # 切换到地图画面  
  194.        $scene = Scene_Map.new  
  195.      end  
  196.      return  
  197.    end  
  198. end  
  199. #--------------------------------------------------------------------------  
  200. # ● 刷新画面 (购买窗口激活的情况下)  
  201. #--------------------------------------------------------------------------  
  202. def update_buy  
  203.    # 设置状态窗口的物品  
  204.    @status_window.item = @buy_window.item  
  205.    # 按下 B 键的情况下  
  206.    if Input.trigger?(Input::B)  
  207.      # 演奏取消 SE  
  208.      $game_system.se_play($data_system.cancel_se)  
  209.      # 窗口状态转向初期模式  
  210.      @command_window.active = true  
  211.      @dummy_window.visible = true  
  212.      @buy_window.active = false  
  213.      @buy_window.visible = false  
  214.      @status_window.visible = false  
  215.      @status_window.item = nil  
  216.      # 删除帮助文本  
  217.      @help_window.set_text("")  
  218.      return  
  219.    end  
  220.    # 按下 C 键的情况下  
  221.    if Input.trigger?(Input::C)  
  222.      # 获取物品  
  223.      @item = @buy_window.item  
  224.      # 物品无效的情况下、或者价格在所持金以上的情况下  
  225.      if @item == nil or @item.price > $game_party.gold  
  226.        # 演奏冻结 SE  
  227.        $game_system.se_play($data_system.buzzer_se)  
  228.        return  
  229.      end  
  230.      # 获取物品所持数  
  231.      case @item  
  232.      when RPG::Item  
  233.        number = $game_party.item_number(@item.id)  
  234.      when RPG::Weapon  
  235.        number = $game_party.weapon_number(@item.id)  
  236.      when RPG::Armor  
  237.        number = $game_party.armor_number(@item.id)  
  238.      end  
  239.      # 如果已经拥有了 99 个情况下  
  240.      if number == 99  
  241.        # 演奏冻结 SE  
  242.        $game_system.se_play($data_system.buzzer_se)  
  243.        return  
  244.      end  
  245.      # 演奏确定 SE  
  246.      $game_system.se_play($data_system.decision_se)  
  247.      # 计算可以最多购买的数量  
  248.      max = @item.price == 0 ? 99 : $game_party.gold / @item.price  
  249.      max = [[max, 99 - number].min,@buy_window.item_number].min  
  250.      # 窗口状态转向数值输入模式  
  251.      @buy_window.active = false  
  252.      @buy_window.visible = false  
  253.      @number_window.set(@item, max, @item.price)  
  254.      @number_window.active = true  
  255.      @number_window.visible = true  
  256.    end  
  257. end  
  258. #--------------------------------------------------------------------------  
  259. # ● 画面更新 (卖出窗口激活的情况下)  
  260. #--------------------------------------------------------------------------  
  261. def update_sell  
  262.    # 按下 B 键的情况下  
  263.    if Input.trigger?(Input::B)  
  264.      # 演奏取消 SE  
  265.      $game_system.se_play($data_system.cancel_se)  
  266.      # 窗口状态转向初期模式  
  267.      @command_window.active = true  
  268.      @dummy_window.visible = true  
  269.      @sell_window.active = false  
  270.      @sell_window.visible = false  
  271.      @status_window.item = nil  
  272.      # 删除帮助文本  
  273.      @help_window.set_text("")  
  274.      return  
  275.    end  
  276.    # 按下 C 键的情况下  
  277.    if Input.trigger?(Input::C)  
  278.      # 获取物品  
  279.      @item = @sell_window.item  
  280.      # 设置状态窗口的物品  
  281.      @status_window.item = @item  
  282.      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下  
  283.      if @item == nil or @item.price == 0  
  284.        # 演奏冻结 SE  
  285.        $game_system.se_play($data_system.buzzer_se)  
  286.        return  
  287.      end  
  288.      # 演奏确定 SE  
  289.      $game_system.se_play($data_system.decision_se)  
  290.      # 获取物品的所持数  
  291.      case @item  
  292.      when RPG::Item  
  293.        number = $game_party.item_number(@item.id)  
  294.      when RPG::Weapon  
  295.        number = $game_party.weapon_number(@item.id)  
  296.      when RPG::Armor  
  297.        number = $game_party.armor_number(@item.id)  
  298.      end  
  299.      # 最大卖出个数 = 物品的所持数  
  300.      max = number  
  301.      # 窗口状态转向个数输入模式  
  302.      @sell_window.active = false  
  303.      @sell_window.visible = false  
  304.      @number_window.set(@item, max, @item.price / 2)  
  305.      @number_window.active = true  
  306.      @number_window.visible = true  
  307.      @status_window.visible = true  
  308.    end  
  309. end  
  310. #--------------------------------------------------------------------------  
  311. # ● 刷新画面 (个数输入窗口激活的情况下)  
  312. #--------------------------------------------------------------------------  
  313. def update_number  
  314.    # 按下 B 键的情况下  
  315.    if Input.trigger?(Input::B)  
  316.      # 演奏取消 SE  
  317.      $game_system.se_play($data_system.cancel_se)  
  318.      # 设置个数输入窗口为不活动·非可视状态  
  319.      @number_window.active = false  
  320.      @number_window.visible = false  
  321.      # 命令窗口光标位置分支  
  322.      case @command_window.index  
  323.      when 0  # 购买  
  324.        # 窗口状态转向购买模式  
  325.        @buy_window.active = true  
  326.        @buy_window.visible = true  
  327.      when 1  # 卖出  
  328.        # 窗口状态转向卖出模式  
  329.        @sell_window.active = true  
  330.        @sell_window.visible = true  
  331.        @status_window.visible = false  
  332.      end  
  333.      return  
  334.    end  
  335.    # 按下 C 键的情况下  
  336.    if Input.trigger?(Input::C)  
  337.      # 演奏商店 SE  
  338.      $game_system.se_play($data_system.shop_se)  
  339.      # 设置个数输入窗口为不活动·非可视状态  
  340.      @number_window.active = false  
  341.      @number_window.visible = false  
  342.      # 命令窗口光标位置分支  
  343.      case @command_window.index  
  344.      when 0  # 购买  
  345.        # 购买处理  
  346.        temp = 0  
  347.        $game_party.lose_gold(@number_window.number * @item.price)  
  348.        case @item  
  349.        when RPG::Item  
  350.          $game_party.gain_item(@item.id, @number_window.number)  
  351.        when RPG::Weapon  
  352.          $game_party.gain_weapon(@item.id, @number_window.number)  
  353.          temp = 1  
  354.        when RPG::Armor  
  355.          $game_party.gain_armor(@item.id, @number_window.number)  
  356.          temp = 2  
  357.        end  
  358.        goods_del(temp,@item.id,@number_window.number)  
  359.        # 刷新各窗口  
  360.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  361.        @buy_window.help_window = @help_window
  362.        @gold_window.refresh  
  363.        @buy_window.refresh  
  364.        @status_window.refresh  
  365.        # 窗口状态转向购买模式  
  366.        @buy_window.active = true  
  367.        @buy_window.visible = true  
  368.      when 1  # 卖出  
  369.        # 卖出处理  
  370.        $game_party.gain_gold(@number_window.number * (@item.price / 2))  
  371.        temp = 0  
  372.        case @item  
  373.        when RPG::Item  
  374.          $game_party.lose_item(@item.id, @number_window.number)  
  375.        when RPG::Weapon  
  376.          $game_party.lose_weapon(@item.id, @number_window.number)  
  377.          temp = 1  
  378.        when RPG::Armor  
  379.          $game_party.lose_armor(@item.id, @number_window.number)  
  380.          temp = 2  
  381.        end  
  382.        # 刷新各窗口  
  383.        goods_del(temp,@item.id,[email]-@number_window.number[/email])  
  384.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])  
  385.        @buy_window.active = false  
  386.        @buy_window.visible = false  
  387.        @buy_window.help_window = @help_window  
  388.        @gold_window.refresh  
  389.        @sell_window.refresh  
  390.        @status_window.refresh  
  391.        # 窗口状态转向卖出模式  
  392.        @sell_window.active = true  
  393.        @sell_window.visible = true  
  394.        @status_window.visible = false  
  395.      end  
  396.      return  
  397.    end  
  398. end  
  399. # 删除可出售商品内容  
  400. def goods_del(kind,id,delnumber)  
  401.    dl = delnumber  
  402.    for dt in $game_system.goods[@shop_now]  
  403.      if (dt[0]==kind) and (dt[1]==id)  
  404.        dt[2] -= dl  
  405.        dt[2] = [dt[2],99].min  
  406.        if dt[2] == 0  
  407.          $game_system.goods[@shop_now].delete(dt)  
  408.        end  
  409.        return  
  410.      end  
  411.    end  
  412.    $game_system.goods[@shop_now].push([kind,id,-delnumber])  
  413. end  
  414. end
  415. #==============================================================================
  416. # ■ Window_ShopBuy_Va  
  417. #------------------------------------------------------------------------------  
  418. #  商店画面、浏览显示可以购买的商品的窗口。  
  419. #==============================================================================
  420. class Window_ShopBuy_Va < Window_Selectable  
  421. attr_accessor :shop_goods  
  422. #--------------------------------------------------------------------------  
  423. # ● 初始化对像  
  424. #     shop_goods : 商品  
  425. #--------------------------------------------------------------------------  
  426. def initialize(shop_goods)  
  427.    super(0, 128, 368, 352)  
  428.    @shop_goods = shop_goods  
  429.    refresh  
  430.    self.index = 0  
  431. end  
  432. #--------------------------------------------------------------------------  
  433. # ● 获取物品  
  434. #--------------------------------------------------------------------------  
  435. def item  
  436.    return @data[self.index]  
  437. end  
  438. #--------------------------------------------------------------------------  
  439. # ● 获取物品  
  440. #--------------------------------------------------------------------------  
  441. def item_number  
  442.    return @data_number[self.index]  
  443. end  
  444. #--------------------------------------------------------------------------  
  445. # ● 刷新  
  446. #--------------------------------------------------------------------------  
  447. def refresh  
  448.    if self.contents != nil  
  449.      self.contents.dispose  
  450.      self.contents = nil  
  451.    end  
  452.    @data = []  
  453.    @data_number = []  
  454.    for goods_item in @shop_goods  
  455.      case goods_item[0]  
  456.      when 0  
  457.        item = $data_items[goods_item[1]]  
  458.      when 1  
  459.        item = $data_weapons[goods_item[1]]  
  460.      when 2  
  461.        item = $data_armors[goods_item[1]]  
  462.      end  
  463.      if (item != nil) and (goods_item[2] != 0)  
  464.        @data.push(item)  
  465.        @data_number.push(goods_item[2])  
  466.      else  
  467.        @data.delete(item)  
  468.      end  
  469.    end  
  470.    # 如果项目数不是 0 就生成位图、描绘全部项目  
  471.    @item_max = @data.size  
  472.    if @item_max > 0  
  473.      self.contents = Bitmap.new(width - 32, row_max * 32)  
  474.      for i in 0...@item_max  
  475.        draw_item(i)  
  476.      end  
  477.    end  
  478. end  
  479. #--------------------------------------------------------------------------  
  480. # ● 描绘羡慕  
  481. #     index : 项目编号  
  482. #--------------------------------------------------------------------------  
  483. def draw_item(index)  
  484.    item = @data[index]  
  485.    # 获取物品所持数  
  486.    case item  
  487.    when RPG::Item  
  488.      number = $game_party.item_number(item.id)  
  489.    when RPG::Weapon  
  490.      number = $game_party.weapon_number(item.id)  
  491.    when RPG::Armor  
  492.      number = $game_party.armor_number(item.id)  
  493.    end  
  494.    # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色  
  495.    # 除此之外的情况设置为无效文字色  
  496.    if item.price <= $game_party.gold and number < 99  
  497.      self.contents.font.color = normal_color  
  498.    else  
  499.      self.contents.font.color = disabled_color  
  500.    end  
  501.    x = 4  
  502.    y = index * 32  
  503.    rect = Rect.new(x, y, self.width - 32, 32)  
  504.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))  
  505.    bitmap = RPG::Cache.icon(item.icon_name)  
  506.    opacity = self.contents.font.color == normal_color ? 255 : 128  
  507.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)  
  508.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)  
  509.    self.contents.draw_text(x + 240, y, 88, 32, "剩  ", 2)  
  510.    self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)  
  511.    self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)  
  512. end  
  513. #--------------------------------------------------------------------------  
  514. # ● 刷新帮助文本  
  515. #--------------------------------------------------------------------------  
  516. def update_help  
  517.    @help_window.set_text(self.item == nil ? "" : self.item.description)  
  518. end  
  519. end
  520. #==============================================================================
  521. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  522. #==============================================================================
复制代码
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2015-12-11 20:34:30 | 显示全部楼层
本帖最后由 yang1zhi 于 2015-12-11 23:33 编辑

结合后其他都没问题了,就是真实商店的数量在购买后没有减少

现在购买后能减少数量了。不过一次购买就减2

购买后减少也正常了,现在是购买给队伍的个人不减数量了
购买已经正常了,现在是卖出后商店没有增加库存
整合好了,劳动的成果


结合后脚本
  1. #==============================================================================
  2. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  3. # ■ 使用方法写在发布页

  4. #修改者:杨志(yang1zhi)
  5. #==============================================================================
  6. =begin

  7. 部分可能在制作中用到的核心算法:

  8. 角色(Game_Actor):
  9. 属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1
  10. 属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0]
  11. 函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空
  12. 函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。
  13.       item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具
  14. 函数:item_amount,返回现有负重物品数量
  15. 函数:have_item?(item),判断是否拥有某物
  16. 函数:item_full?,判断背包是不是满了


  17. 队伍(Game_Party):
  18. 属性:max_amount,最大背包中物品数量
  19. 属性:now_amount,背包中现有物品数量
  20. 函数:item_full?,判断背包是否放满
  21. 函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用

  22. =end
  23. #==============================================================================
  24. # ■ Game_Actor
  25. #------------------------------------------------------------------------------
  26. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  27. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  28. #==============================================================================
  29. class Game_Actor < Game_Battler
  30.   attr_accessor :max_size
  31.   attr_reader   :items
  32.   #--------------------------------------------------------------------------
  33.   # ● 设置
  34.   #     actor_id : 角色 ID
  35.   #--------------------------------------------------------------------------
  36.   alias final_items_setup setup
  37.   def setup(actor_id)
  38.     final_items_setup(actor_id)   
  39.     #--角色自带的物品建立
  40.     @max_size = 8
  41.     @items = []        
  42.     if @weapon_id >0
  43.       @items.push($data_weapons[@weapon_id])
  44.     end
  45.     if @armor1_id >0
  46.       @items.push($data_armors[@armor1_id])
  47.     end
  48.     if @armor2_id >0
  49.       @items.push($data_armors[@armor2_id])
  50.     end
  51.     if @armor3_id >0
  52.       @items.push($data_armors[@armor3_id])
  53.     end
  54.     if @armor4_id >0
  55.       @items.push($data_armors[@armor4_id])
  56.     end
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 测试装备是否正确,如果不正确就设置为空
  60.   #--------------------------------------------------------------------------
  61.   def judge_equip
  62.     if @armor1_id>0
  63.       unless @items.include?($data_armors[@armor1_id])
  64.         @armor1_id = 0
  65.       end
  66.     end
  67.     if @armor2_id>0
  68.       unless @items.include?($data_armors[@armor2_id])
  69.         @armor2_id = 0
  70.       end
  71.     end
  72.     if @armor3_id>0
  73.       unless @items.include?($data_armors[@armor3_id])
  74.         @armor3_id = 0
  75.       end
  76.     end
  77.     if @armor4_id>0
  78.       unless @items.include?($data_armors[@armor4_id])
  79.         @armor4_id = 0
  80.       end
  81.     end
  82.     if @weapon_id>0
  83.       unless @items.include?($data_weapons[@weapon_id])
  84.         @weapon_id = 0
  85.       end
  86.     end
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 增加物品 (减少)
  90.   #     item_id : 物品 ID
  91.   #     n       : true是增加,false是减少
  92.   #     kind    : 种类,1是物品,2是武器,3是防具
  93.   #--------------------------------------------------------------------------
  94.   def gain_item(item_id, kind=1, n=true)
  95.     return if item_full?
  96.     if kind == 1
  97.       if item_id > 0 and n==true
  98.         @items.push($data_items[item_id])
  99.       elsif item_id >0 and n==false
  100.         @items.delete($data_items[item_id])
  101.       end
  102.     end
  103.     if kind == 2
  104.       if item_id > 0 and n==true
  105.         @items.push($data_weapons[item_id])
  106.       elsif item_id > 0 and n==false
  107.         @items.push($data_weapons[item_id])
  108.       end
  109.     end
  110.     if kind == 3
  111.       if item_id > 0 and n==true
  112.         @items.push($data_armors[item_id])
  113.       elsif item_id > 0 and n==true
  114.         @items.push($data_armors[item_id])
  115.       end
  116.     end
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 返回物品数量
  120.   #--------------------------------------------------------------------------  
  121.   def item_amount
  122.     return @items.size
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 判断是否拥有物品
  126.   #--------------------------------------------------------------------------  
  127.   def have_item?(item)
  128.     return @items.include?(item)
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 判断是否物品满了
  132.   #--------------------------------------------------------------------------  
  133.   def item_full?
  134.     return true if @items.size>=@max_size
  135.     return false
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 变更装备
  139.   #     equip_type : 装备类型
  140.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  141.   #--------------------------------------------------------------------------
  142.   def equip(equip_type, id)
  143.     case equip_type
  144.     when 0  # 武器
  145.       if id >= 0
  146.         @weapon_id = id
  147.       end
  148.     when 1  # 盾
  149.       if id >= 0
  150.         update_auto_state($data_armors[@armor1_id], $data_armors[id])
  151.         @armor1_id = id
  152.       end
  153.     when 2  # 头
  154.       if id >= 0
  155.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  156.         @armor2_id = id
  157.       end
  158.     when 3  # 身体
  159.       if id >= 0
  160.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  161.         @armor3_id = id
  162.       end
  163.     when 4  # 装饰品
  164.       if id >= 0
  165.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  166.         @armor4_id = id
  167.       end
  168.     end
  169.   end  
  170. end

  171. #==============================================================================
  172. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  173. # ■ 使用方法写在发布页
  174. #==============================================================================
  175. # ■ Game_Party
  176. #------------------------------------------------------------------------------
  177. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  178. # 请参考 $game_party。
  179. #==============================================================================

  180. class Game_Party
  181.   #--------------------------------------------------------------------------
  182.   # ● 定义实例变量
  183.   #--------------------------------------------------------------------------
  184.   attr_accessor :max_amount
  185.   attr_reader   :now_amount
  186.   #--------------------------------------------------------------------------
  187.   # ● 初始化对像
  188.   #--------------------------------------------------------------------------
  189.   alias final_item_initialize initialize
  190.   def initialize
  191.     final_item_initialize
  192.     @max_amount = 15
  193.     @now_amount = 0
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   #--------------------------------------------------------------------------
  197.   def item_full?
  198.     return true if @now_amount>=@max_amount
  199.     return false
  200.   end
  201.   def refresh_item_amount
  202.     @now_amount = 0
  203.     for i in 1...$data_items.size
  204.       if $game_party.item_number(i) > 0
  205.         @now_amount += $game_party.item_number(i)
  206.       end
  207.     end
  208.     for i in 1...$data_weapons.size
  209.       if $game_party.weapon_number(i) > 0
  210.         @now_amount += $game_party.weapon_number(i)
  211.       end
  212.     end
  213.     for i in 1...$data_armors.size
  214.       if $game_party.armor_number(i) > 0
  215.         @now_amount += $game_party.armor_number(i)
  216.       end
  217.     end
  218.   end
  219.   #--------------------------------------------------------------------------
  220.   # ● 增加物品 (减少)
  221.   #     item_id : 物品 ID
  222.   #     n       : 个数
  223.   #--------------------------------------------------------------------------
  224.   def gain_item(item_id, n)
  225.     # 更新 hash 的个数数据
  226.     if item_id > 0
  227.       @items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min
  228.       refresh_item_amount
  229.     end
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 增加武器 (减少)
  233.   #     weapon_id : 武器 ID
  234.   #     n         : 个数
  235.   #--------------------------------------------------------------------------
  236.   def gain_weapon(weapon_id, n)
  237.     # 更新 hash 的个数数据
  238.     if weapon_id > 0
  239.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min
  240.       refresh_item_amount
  241.     end
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 增加防具 (减少)
  245.   #     armor_id : 防具 ID
  246.   #     n        : 个数
  247.   #--------------------------------------------------------------------------
  248.   def gain_armor(armor_id, n)
  249.     # 更新 hash 的个数数据
  250.     if armor_id > 0
  251.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min
  252.       refresh_item_amount
  253.     end
  254.   end  
  255.   #--------------------------------------------------------------------------
  256.   # ● 判断物品可以使用
  257.   #     item_id : 物品 ID
  258.   #--------------------------------------------------------------------------
  259.   def item_can_use?(item_id)
  260.     # 物品个数为 0 的情况
  261.     #if item_number(item_id) == 0
  262.       # 不能使用
  263.       #return false
  264.     #end
  265.     # 获取可以使用的时候
  266.     occasion = $data_items[item_id].occasion
  267.     # 战斗的情况
  268.     if $game_temp.in_battle
  269.       # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
  270.       return (occasion == 0 or occasion == 1)
  271.     end
  272.     # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
  273.     return (occasion == 0 or occasion == 2)
  274.   end  
  275. end

  276. #==============================================================================
  277. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  278. # ■ 使用方法写在发布页
  279. #==============================================================================
  280. # ■ Window_Command
  281. #------------------------------------------------------------------------------
  282. #  一般的命令选择行窗口。
  283. #==============================================================================

  284. class Window_Command < Window_Selectable
  285.   #--------------------------------------------------------------------------
  286.   # ● 项目有效化
  287.   #     index : 项目编号
  288.   #--------------------------------------------------------------------------  
  289.   def enable_item(index)
  290.     draw_item(index, normal_color)
  291.   end
  292. end

  293. #==============================================================================
  294. # ■ Window_Item
  295. #------------------------------------------------------------------------------
  296. #  物品画面、战斗画面、显示浏览物品的窗口。
  297. #==============================================================================

  298. class Window_Item < Window_Selectable
  299.   #--------------------------------------------------------------------------
  300.   # ● 初始化对像
  301.   #--------------------------------------------------------------------------
  302.   def initialize(actor=nil)
  303.     @actor=actor
  304.     super(0, 64, 640, 416)
  305.     @column_max = 1
  306.     refresh
  307.     self.index = 0
  308.     # 战斗中的情况下将窗口移至中央并将其半透明化
  309.     if $game_temp.in_battle
  310.       self.y = 64
  311.       self.height = 256
  312.       self.back_opacity = 160
  313.     end
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 获取物品
  317.   #--------------------------------------------------------------------------
  318.   def item
  319.     return @data[self.index]
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 刷新
  323.   #--------------------------------------------------------------------------
  324.   def refresh
  325.     if self.contents != nil
  326.       self.contents.dispose
  327.       self.contents = nil
  328.     end
  329.     @data = []
  330.     # 添加报务

  331.     if @actor==nil   
  332.       for i in 1...$data_items.size
  333.         if $game_party.item_number(i) > 0
  334.           for pushtimes in 0...$game_party.item_number(i)
  335.             @data.push($data_items[i])
  336.           end
  337.         end
  338.       end
  339.       for i in 1...$data_weapons.size
  340.         if $game_party.weapon_number(i) > 0
  341.           for pushtimes in 0...$game_party.weapon_number(i)
  342.             @data.push($data_weapons[i])
  343.           end
  344.         end
  345.       end
  346.       for i in 1...$data_armors.size
  347.         if $game_party.armor_number(i) > 0
  348.           for pushtimes in 0...$game_party.armor_number(i)
  349.             @data.push($data_armors[i])
  350.           end
  351.         end
  352.       end
  353.     else
  354.       for i in [email]0...@actor.items.size[/email]
  355.         if @actor.items[i].is_a?(RPG::Item)
  356.           @data.push(@actor.items[i])
  357.         else         
  358.           if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor)
  359.             if @actor.items[i].name==$data_items[@actor.items[i].id].name
  360.               @data.push($data_items[@actor.items[i].id])
  361.               next
  362.             else
  363.               @data.push(@actor.items[i])
  364.               next
  365.             end
  366.           end
  367.         end
  368.       end
  369.     end
  370.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  371.     @item_max = @data.size
  372.     if @item_max > 0
  373.       self.contents = Bitmap.new(width - 32, row_max * 32)
  374.       self.contents.font.size = 20
  375.       for i in 0...@item_max
  376.         draw_item(i)
  377.       end
  378.     end
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 描绘项目
  382.   #     index : 项目编号
  383.   #--------------------------------------------------------------------------
  384.   def draw_item(index)
  385.     if @actor==nil
  386.       item = @data[index]
  387.       x = 4
  388.       y = index * 32
  389.       rect = Rect.new(x, y, self.width - 32, 32)
  390.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  391.       bitmap = RPG::Cache.icon(item.icon_name)
  392.       opacity = self.contents.font.color == normal_color ? 255 : 128
  393.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  394.       self.contents.font.size = 20
  395.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  396.       self.contents.font.size = 14
  397.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 0)
  398.     else
  399.       item = @data[index]
  400.       #if item.is_a?(RPG::Item) and
  401.         #$game_party.item_can_use?(item.id)
  402.         #self.contents.font.color = normal_color
  403.       #else
  404.         #self.contents.font.color = disabled_color
  405.       #end
  406.       x = 4
  407.       y = index * 32
  408.       rect = Rect.new(x, y, self.width - 32, 32)
  409.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  410.       bitmap = RPG::Cache.icon(item.icon_name)
  411.       opacity = self.contents.font.color == normal_color ? 255 : 128
  412.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  413.       self.contents.font.size = 20
  414.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  415.       self.contents.font.size = 14
  416.       self.contents.draw_text(x + 150, y, 400, 42, ":"+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s, 0)
  417.     end
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 刷新帮助文本
  421.   #--------------------------------------------------------------------------
  422.   def update_help
  423.     @help_window.set_text(item)
  424.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  425.     #@help_window.contents.font.size = 18
  426.     #if @actor==nil
  427.     #  @help_window.set_text(self.item == nil ? ""+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s : self.item.description+"    ★队伍目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s )
  428.     #else
  429.     #  @help_window.set_text(@actor.name+"    物品数量:"+@actor.item_amount.to_s+"    最大负重:"+@actor.max_size.to_s)
  430.     #end
  431.   end
  432.   def dispose
  433.     super
  434.     @actor.judge_equip if @actor != nil
  435.   end
  436. end

  437. #==============================================================================
  438. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  439. # ■ 使用方法写在发布页
  440. #============================================================================
  441. # ■ Window_EquipItem
  442. #------------------------------------------------------------------------------
  443. #  装备画面、显示浏览变更装备的候补物品的窗口。
  444. #==============================================================================

  445. class Window_EquipItem < Window_Selectable
  446.   #--------------------------------------------------------------------------
  447.   # ● 刷新
  448.   #--------------------------------------------------------------------------
  449.   def refresh
  450.     if self.contents != nil
  451.       self.contents.dispose
  452.       self.contents = nil
  453.     end
  454.     @data = []

  455.     # 添加可以装备的武器
  456.     if @equip_type == 0
  457.       weapon_set = $data_classes[@actor.class_id].weapon_set
  458.       for item in @actor.items
  459.         if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id)
  460.           @data.push(item)
  461.         end
  462.       end
  463.     end
  464.     # 添加可以装备的防具
  465.     if @equip_type != 0
  466.       armor_set = $data_classes[@actor.class_id].armor_set
  467.       for item in @actor.items
  468.         if item.is_a?(RPG::Armor) and armor_set.include?(item.id)
  469.           if item.kind == @equip_type-1
  470.             @data.push(item)
  471.           end
  472.         end
  473.       end
  474.     end
  475.     # 添加空白
  476.     @data.push(nil)
  477.     # 生成位图、描绘全部项目
  478.     @item_max = @data.size
  479.     self.contents = Bitmap.new(width - 32, row_max * 32)
  480.     for i in 0...@item_max-1
  481.       draw_item(i)
  482.     end
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 项目的描绘
  486.   #     index : 项目符号
  487.   #--------------------------------------------------------------------------
  488.   def draw_item(index)
  489.     item = @data[index]
  490.     x = 4 + index % 2 * (288 + 32)
  491.     y = index / 2 * 32
  492.     bitmap = RPG::Cache.icon(item.icon_name)
  493.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  494.     self.contents.font.color = normal_color
  495.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  496.   end
  497. end

  498. #==============================================================================
  499. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  500. # ■ 使用方法写在发布页
  501. #==============================================================================
  502. # ■ Window_ShopStatus_New
  503. #------------------------------------------------------------------------------
  504. #  商店画面、显示物品所持数与角色装备的窗口。
  505. #==============================================================================

  506. class Window_ShopStatus_New < Window_Selectable
  507.   #--------------------------------------------------------------------------
  508.   # ● 初始化对像
  509.   #--------------------------------------------------------------------------
  510.   def initialize
  511.     super(368, 128, 272, 352)
  512.     self.contents = Bitmap.new(width - 32, height - 32)
  513.     self.contents.font.size = 18
  514.     @item = nil
  515.     @item_max = $game_party.actors.size + 1
  516.     refresh
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● 刷新
  520.   #--------------------------------------------------------------------------
  521.   def refresh
  522.     self.contents.clear

  523.     if @item == nil
  524.       return
  525.     end
  526.     case @item
  527.     when RPG::Item
  528.       number = $game_party.item_number(@item.id)
  529.     when RPG::Weapon
  530.       number = $game_party.weapon_number(@item.id)
  531.     when RPG::Armor
  532.       number = $game_party.armor_number(@item.id)
  533.     end
  534.     self.contents.font.color = system_color
  535.     self.contents.draw_text(4, 0, 200, 32, "队伍中本物品数:")
  536.     self.contents.font.color = normal_color
  537.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  538.     self.contents.font.color = system_color
  539.     self.contents.draw_text(4, 32, 200, 32, "队伍目前物品数:")
  540.     self.contents.font.color = normal_color
  541.     self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2)
  542.     #if @item.is_a?(RPG::Item)
  543.       #return
  544.     #end
  545.     # 添加装备品信息
  546.     for i in 0...$game_party.actors.size
  547.       actor = $game_party.actors[i]
  548.       self.contents.font.color = Color.new(255,255,0)
  549.       self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ")
  550.       self.contents.font.color = normal_color
  551.       self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2)
  552.       # 获取当前的装备品
  553.       unless @item == nil or @item.is_a?(RPG::Item)
  554.         if @item.is_a?(RPG::Weapon)
  555.           item1 = $data_weapons[actor.weapon_id]
  556.         elsif @item.kind == 0
  557.           item1 = $data_armors[actor.armor1_id]
  558.         elsif @item.kind == 1
  559.           item1 = $data_armors[actor.armor2_id]
  560.         elsif @item.kind == 2
  561.           item1 = $data_armors[actor.armor3_id]
  562.         else
  563.           item1 = $data_armors[actor.armor4_id]
  564.         end
  565.         # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  566.         if actor.equippable?(@item)
  567.           self.contents.font.color = normal_color
  568.         else
  569.           self.contents.font.color = disabled_color
  570.         end        
  571.         # 描绘角色名字
  572.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  573.         # 可以装备的情况
  574.         if actor.equippable?(@item)
  575.           # 武器的情况
  576.           if @item.is_a?(RPG::Weapon)
  577.             atk1 = item1 != nil ? item1.atk : 0
  578.             atk2 = @item != nil ? @item.atk : 0
  579.             change = atk2 - atk1
  580.           end
  581.           # 防具的情况
  582.           if @item.is_a?(RPG::Armor)
  583.             pdef1 = item1 != nil ? item1.pdef : 0
  584.             mdef1 = item1 != nil ? item1.mdef : 0
  585.             pdef2 = @item != nil ? @item.pdef : 0
  586.             mdef2 = @item != nil ? @item.mdef : 0
  587.             change = pdef2 - pdef1 + mdef2 - mdef1
  588.           end
  589.           # 描绘能力值变化
  590.           self.contents.draw_text(124, 96 + 64 * i, 112, 32,
  591.             sprintf("%+d", change), 2)
  592.         end
  593.         # 描绘物品
  594.         if item1 != nil
  595.           x = 4
  596.           y = 64 + 64 * i + 32
  597.           bitmap = RPG::Cache.icon(item1.icon_name)
  598.           opacity = self.contents.font.color == normal_color ? 255 : 128
  599.           self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  600.           self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  601.         end
  602.       else
  603.         self.contents.font.color = normal_color
  604.         # 描绘角色名字
  605.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  606.       end
  607.     end
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 设置物品
  611.   #     item : 新的物品
  612.   #--------------------------------------------------------------------------
  613.   def item=(item)
  614.     if @item != item
  615.       @item = item
  616.       refresh
  617.     end
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 刷新光标矩形
  621.   #--------------------------------------------------------------------------
  622.   def update_cursor_rect
  623.     if @index < 0
  624.       self.cursor_rect.empty
  625.     else
  626.       self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
  627.     end
  628.   end
  629. end

  630. #==============================================================================
  631. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  632. # ■ 使用方法写在发布页
  633. #==============================================================================
  634. # ■ Scene_Menu
  635. #------------------------------------------------------------------------------
  636. #  处理菜单画面的类。
  637. #==============================================================================

  638. class Scene_Menu
  639.   #--------------------------------------------------------------------------
  640.   # ● 初始化对像
  641.   #     menu_index : 命令光标的初期位置
  642.   #--------------------------------------------------------------------------
  643.   def initialize(menu_index = 0)
  644.     @menu_index = menu_index

  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ● 主处理
  648.   #--------------------------------------------------------------------------
  649.   def main
  650.         @menu_com = Sprite.new
  651.     @menu_com.bitmap = RPG::Cache.picture("自己做背景.png")  
  652.     @menu_com.opacity = 100
  653.     # 生成命令窗口
  654.     s1 = $data_system.words.item
  655.     s2 = $data_system.words.skill
  656.     s3 = $data_system.words.equip
  657.     s4 = "状态"
  658.     s5 = "存档"
  659.     s6 = "CG"
  660.     s7 = "结束游戏"
  661.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
  662.     @command_window.index = @menu_index
  663.     @item_command_window = Window_Command.new(160,["队伍物品","个人物品"])
  664.     @item_command_window.x = 120
  665.     @item_command_window.visible = false
  666.     @item_command_window.active = false
  667.     @item_command_window.z = 999
  668.      @command_window.opacity = 0
  669.       # 同伴人数为 0 的情况下
  670.     if $game_party.actors.size == 0
  671.       # 物品、特技、装备、状态无效化
  672.       @command_window.disable_item(0)
  673.       @command_window.disable_item(1)
  674.       @command_window.disable_item(2)
  675.       @command_window.disable_item(3)
  676.     end
  677.     # 禁止存档的情况下
  678.     if $game_system.save_disabled
  679.       # 存档无效
  680.       @command_window.disable_item(4)
  681.     end
  682.     # 生成游戏时间窗口
  683.     @playtime_window = Window_PlayTime.new
  684.     @playtime_window.x = 0
  685.     @playtime_window.y = 224
  686.    
  687.    
  688.    
  689.         # 生成犯罪窗口
  690.     @fanzui_window = Window_Fanzui.new
  691.     @fanzui_window.x = 0
  692.     @fanzui_window.y = 200

  693.    
  694.    
  695.     # 生成步数窗口
  696.     @steps_window = Window_Steps.new
  697.     @steps_window.x = 0
  698.     @steps_window.y = 320
  699.     # 生成金钱窗口
  700.     @gold_window = Window_Gold.new
  701.     @gold_window.x = 0
  702.     @gold_window.y = 416
  703.     # 生成状态窗口
  704.     @status_window = Window_MenuStatus.new
  705.     @status_window.x = 160
  706.     @status_window.y = 0
  707.     # 执行过渡
  708.     Graphics.transition
  709.     # 主循环
  710.     loop do
  711.       # 刷新游戏画面
  712.       Graphics.update
  713.       # 刷新输入信息
  714.       Input.update
  715.       # 刷新画面
  716.       update
  717.       # 如果切换画面就中断循环
  718.       if $scene != self
  719.         break
  720.       end
  721.     end
  722.     # 准备过渡
  723.     Graphics.freeze
  724.     # 释放窗口
  725.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  726.     @menu_com.dispose
  727.    
  728.    
  729.     @fanzui_window.dispose
  730.    
  731.    
  732.     @command_window.dispose
  733.     @playtime_window.dispose
  734.     @steps_window.dispose
  735.     @gold_window.dispose
  736.     @status_window.dispose
  737.     @item_command_window.dispose
  738.   end
  739.   #--------------------------------------------------------------------------
  740.   # ● 刷新画面
  741.   #--------------------------------------------------------------------------
  742.   def update
  743.     # 刷新窗口
  744.     @command_window.update
  745.     @playtime_window.update
  746.     @steps_window.update
  747.     @gold_window.update
  748.     @status_window.update
  749.     @item_command_window.update
  750.     # 命令窗口被激活的情况下: 调用 update_command
  751.     if @command_window.active
  752.       update_command
  753.       return
  754.     end
  755.     # 状态窗口被激活的情况下: 调用 update_status
  756.     if @status_window.active
  757.       update_status
  758.       return
  759.     end
  760.     if @item_command_window.active
  761.       update_item_command
  762.       return
  763.     end
  764.   end
  765.   def update_item_command
  766.     if Input.trigger?(Input::B)
  767.       $game_system.se_play($data_system.cancel_se)
  768.       @item_command_window.active = false
  769.       @item_command_window.visible = false
  770.       @command_window.active = true
  771.     end
  772.     if Input.trigger?(Input::C)
  773.       case @item_command_window.index
  774.       when 0
  775.         $game_system.se_play($data_system.decision_se)
  776.         $scene = Scene_Item.new
  777.       when 1
  778.         # 演奏确定 SE
  779.         $game_system.se_play($data_system.decision_se)
  780.         # 激活状态窗口
  781.         @item_command_window.active = false
  782.         @item_command_window.visible = false
  783.         @status_window.active = true
  784.         @status_window.index = 0
  785.       end
  786.     end
  787.   end
  788.   #--------------------------------------------------------------------------
  789.   # ● 刷新画面 (命令窗口被激活的情况下)
  790.   #--------------------------------------------------------------------------
  791.   def update_command
  792.     # 按下 B 键的情况下
  793.     if Input.trigger?(Input::B)
  794.       # 演奏取消 SE
  795.       $game_system.se_play($data_system.cancel_se)
  796.       # 切换的地图画面
  797.       $scene = Scene_Map.new
  798.       return
  799.     end
  800.     # 按下 C 键的情况下
  801.     if Input.trigger?(Input::C)
  802.       # 同伴人数为 0、存档、游戏结束以外的场合
  803.       if $game_party.actors.size == 0 and @command_window.index < 4
  804.         # 演奏冻结 SE
  805.         $game_system.se_play($data_system.buzzer_se)
  806.         return
  807.       end
  808.       # 命令窗口的光标位置分支
  809.       case @command_window.index
  810.       when 0  # 物品
  811.         # 演奏确定 SE
  812.         $game_system.se_play($data_system.decision_se)
  813.         # 激活状态窗口
  814.         @command_window.active = false
  815.         @item_command_window.active = true
  816.         @item_command_window.index = 0
  817.         @item_command_window.visible = true
  818.       when 1  # 特技
  819.         # 演奏确定 SE
  820.         $game_system.se_play($data_system.decision_se)
  821.         # 激活状态窗口
  822.         @command_window.active = false
  823.         @status_window.active = true
  824.         @status_window.index = 0
  825.       when 2  # 装备
  826.         # 演奏确定 SE
  827.         $game_system.se_play($data_system.decision_se)
  828.         # 激活状态窗口
  829.         @command_window.active = false
  830.         @status_window.active = true
  831.         @status_window.index = 0
  832.       when 3  # 状态
  833.         # 演奏确定 SE
  834.         $game_system.se_play($data_system.decision_se)
  835.         # 激活状态窗口
  836.         @command_window.active = false
  837.         @status_window.active = true
  838.         @status_window.index = 0
  839.       when 4  # 存档
  840.         # 禁止存档的情况下
  841.         if $game_system.save_disabled
  842.           # 演奏冻结 SE
  843.           $game_system.se_play($data_system.buzzer_se)
  844.           return
  845.         end
  846.         # 演奏确定 SE
  847.         $game_system.se_play($data_system.decision_se)
  848.         # 切换到存档画面
  849.         $scene = Scene_Save.new
  850.         ##########################
  851.            when 5  # CG
  852.            $scene = Scene_Picture_Gallery.new
  853.            ############################
  854.       when 6  # 游戏结束
  855.         # 演奏确定 SE
  856.         $game_system.se_play($data_system.decision_se)
  857.         # 切换到游戏结束画面
  858.         $scene = Scene_End.new
  859.       end
  860.       return
  861.     end
  862.   end
  863.   #--------------------------------------------------------------------------
  864.   # ● 刷新画面 (状态窗口被激活的情况下)
  865.   #--------------------------------------------------------------------------
  866.   def update_status
  867.     # 按下 B 键的情况下
  868.     if Input.trigger?(Input::B)
  869.       # 演奏取消 SE
  870.       $game_system.se_play($data_system.cancel_se)
  871.       # 激活命令窗口
  872.       @command_window.active = true
  873.       @status_window.active = false
  874.       @status_window.index = -1
  875.       return
  876.     end
  877.     # 按下 C 键的情况下
  878.     if Input.trigger?(Input::C)
  879.       # 命令窗口的光标位置分支
  880.       case @command_window.index
  881.       when 0  # 物品        
  882.         $game_system.se_play($data_system.decision_se)
  883.         $scene = Scene_Item.new($game_party.actors[@status_window.index])
  884.       when 1  # 特技
  885.         # 本角色的行动限制在 2 以上的情况下
  886.         if $game_party.actors[@status_window.index].restriction >= 2
  887.           # 演奏冻结 SE
  888.           $game_system.se_play($data_system.buzzer_se)
  889.           return
  890.         end
  891.         # 演奏确定 SE
  892.         $game_system.se_play($data_system.decision_se)
  893.         # 切换到特技画面
  894.         $scene = Scene_Skill.new(@status_window.index)
  895.       when 2  # 装备
  896.         # 演奏确定 SE
  897.         $game_system.se_play($data_system.decision_se)
  898.         # 切换的装备画面
  899.         $scene = Scene_Equip.new(@status_window.index)
  900.       when 3  # 状态
  901.         # 演奏确定 SE
  902.         $game_system.se_play($data_system.decision_se)
  903.         # 切换到状态画面
  904.         $scene = Scene_Status.new(@status_window.index)
  905.       end
  906.       return
  907.     end
  908.   end
  909. end

  910. #==============================================================================
  911. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  912. # ■ 使用方法写在发布页
  913. #==============================================================================
  914. # ■ Scene_Item
  915. #------------------------------------------------------------------------------
  916. #  处理物品画面的类。
  917. #==============================================================================

  918. class Scene_Item

  919.   #★——添加定义
  920.   def initialize(actor = nil)
  921.     @actor = actor
  922.   end

  923.   #--------------------------------------------------------------------------
  924.   # ● 主处理
  925.   #--------------------------------------------------------------------------
  926.   def main
  927.         @menu_com = Sprite.new
  928.     @menu_com.bitmap = RPG::Cache.picture("技能窗口.png")  

  929.     # 生成帮助窗口、物品窗口
  930.     @help_window = Window_Help.new
  931.     @item_window = Window_Item.new(@actor)
  932.     # 关联帮助窗口
  933.     @item_window.help_window = @help_window
  934.     # 生成目标窗口 (设置为不可见・不活动)
  935.     @target_window = Window_Target.new
  936.     @target_window.visible = false
  937.     @target_window.active = false
  938.     if @actor==nil
  939.       @command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"])
  940.     else
  941.       @command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回队伍"])
  942.     end
  943.     @command_window.x = 240
  944.     @command_window.y = 180
  945.     @command_window.visible = false
  946.     @command_window.active = false
  947.     @command_window.z = 999
  948.     @target_window.z = 10000
  949.     # 执行过度
  950.     Graphics.transition
  951.     # 主循环
  952.     loop do
  953.       # 刷新游戏画面
  954.       Graphics.update
  955.       # 刷新输入信息
  956.       Input.update
  957.       # 刷新画面
  958.       update
  959.       # 如果画面切换就中断循环
  960.       if $scene != self
  961.         break
  962.       end
  963.     end
  964.     # 装备过渡
  965.     Graphics.freeze
  966.     # 释放窗口
  967.         @menu_com.bitmap.dispose if @menu_com.bitmap  
  968.     @menu_com.dispose

  969.     @help_window.dispose
  970.     @item_window.dispose
  971.     @target_window.dispose
  972.     @command_window.dispose
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # ● 刷新画面
  976.   #--------------------------------------------------------------------------
  977.   def update
  978.     # 刷新窗口
  979.     @help_window.update
  980.     @item_window.update
  981.     @target_window.update
  982.     @command_window.update
  983.     # 物品窗口被激活的情况下: 调用 update_item
  984.     if @item_window.active
  985.       update_item
  986.       return
  987.     end
  988.     # 目标窗口被激活的情况下: 调用 update_target
  989.     if @target_window.active
  990.       update_target
  991.       return
  992.     end
  993.     if @command_window.active
  994.       update_command
  995.       return
  996.     end
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # ● 刷新画面
  1000.   #--------------------------------------------------------------------------
  1001.   def update_command
  1002.     # 按下 B 键的情况下
  1003.     if Input.trigger?(Input::B)
  1004.       # 演奏取消 SE
  1005.       $game_system.se_play($data_system.cancel_se)
  1006.       # 切换到菜单画面
  1007.       @command_window.visible = false
  1008.       @command_window.active = false
  1009.       @item_window.active = true
  1010.       return
  1011.     end
  1012.     # 按下 C 键的情况下
  1013.     if Input.trigger?(Input::C)
  1014.       case @command_window.index
  1015.       when 0
  1016.         # 获取物品窗口当前选中的物品数据
  1017.         @item = @item_window.item
  1018.         # 不使用物品的情况下
  1019.         if @actor == nil
  1020.           $game_system.se_play($data_system.buzzer_se)
  1021.           return
  1022.         end
  1023.         unless @item.is_a?(RPG::Item)
  1024.           # 演奏冻结 SE
  1025.           $game_system.se_play($data_system.buzzer_se)
  1026.           return
  1027.         end
  1028.         # 不能使用的情况下
  1029.         unless $game_party.item_can_use?(@item.id)
  1030.           # 演奏冻结 SE
  1031.           $game_system.se_play($data_system.buzzer_se)
  1032.           return
  1033.         end
  1034.         # 演奏确定 SE
  1035.         $game_system.se_play($data_system.decision_se)
  1036.         # 效果范围是我方的情况下
  1037.         if @item.scope >= 3
  1038.           # 激活目标窗口
  1039.           @command_window.active = false
  1040.           @target_window.x = (@item_window.index + 1) % 2 * 304
  1041.           @target_window.visible = true
  1042.           @target_window.active = true
  1043.           # 设置效果范围 (单体/全体) 的对应光标位置
  1044.           if @item.scope == 4 || @item.scope == 6
  1045.             @target_window.index = -1
  1046.           else
  1047.             @target_window.index = 0
  1048.           end
  1049.         # 效果在我方以外的情况下
  1050.         else
  1051.           # 公共事件 ID 有效的情况下
  1052.           if @item.common_event_id > 0
  1053.             # 预约调用公共事件
  1054.             $game_temp.common_event_id = @item.common_event_id
  1055.             # 演奏物品使用时的 SE
  1056.             $game_system.se_play(@item.menu_se)
  1057.             # 消耗品的情况下
  1058.             if @item.consumable
  1059.               # 使用的物品数减 1
  1060.               if @actor==nil
  1061.                 $game_party.lose_item(@item.id, 1)
  1062.               else
  1063.                 @actor.items.delete_at(@item_window.index)
  1064.               end
  1065.               # 再描绘物品窗口的项目
  1066.               @item_window.draw_item(@item_window.index)
  1067.             end
  1068.             # 切换到地图画面
  1069.             $scene = Scene_Map.new
  1070.             return
  1071.           end
  1072.         end
  1073.         return
  1074.       when 1
  1075.         $game_system.se_play($data_system.decision_se)
  1076.         @command_window.active = false
  1077.         @target_window.visible = true
  1078.         @target_window.index = 0
  1079.         @target_window.active = true
  1080.       when 2
  1081.         $game_system.se_play($data_system.load_se)
  1082.         if @actor != nil
  1083.           @actor.items.delete_at(@item_window.index)
  1084.           @actor.judge_equip
  1085.         else
  1086.           if @item_window.item.is_a?(RPG::Item)
  1087.             $game_party.gain_item(@item_window.item.id,-1)
  1088.           end
  1089.           if @item_window.item.is_a?(RPG::Weapon)
  1090.             $game_party.gain_weapon(@item_window.item.id,-1)
  1091.           end
  1092.           if @item_window.item.is_a?(RPG::Armor)
  1093.             $game_party.gain_armor(@item_window.item.id,-1)
  1094.           end
  1095.         end
  1096.         # 切换到菜单画面
  1097.         @command_window.visible = false
  1098.         @command_window.active = false
  1099.         @item_window.refresh
  1100.         @item_window.active = true
  1101.       when 3
  1102.         if $game_party.item_full?
  1103.           $game_system.se_play($data_system.cancel_se)
  1104.           return
  1105.         end
  1106.         $game_system.se_play($data_system.decision_se)
  1107.         if @item_window.item.is_a?(RPG::Item)
  1108.           $game_party.gain_item(@item_window.item.id,1)
  1109.         end
  1110.         if @item_window.item.is_a?(RPG::Weapon)
  1111.           $game_party.gain_weapon(@item_window.item.id,1)
  1112.         end
  1113.         if @item_window.item.is_a?(RPG::Armor)
  1114.           $game_party.gain_armor(@item_window.item.id,1)
  1115.         end
  1116.         @actor.items.delete_at(@item_window.index)
  1117.         # 切换到菜单画面
  1118.         @command_window.visible = false
  1119.         @command_window.active = false
  1120.         @item_window.refresh
  1121.         @item_window.active = true
  1122.       end
  1123.     end
  1124.   end  
  1125.   #--------------------------------------------------------------------------
  1126.   # ● 刷新画面 (物品窗口被激活的情况下)
  1127.   #--------------------------------------------------------------------------
  1128.   def update_item
  1129.     # 按下 B 键的情况下
  1130.     if Input.trigger?(Input::B)
  1131.       # 演奏取消 SE
  1132.       $game_system.se_play($data_system.cancel_se)
  1133.       # 切换到菜单画面
  1134.       $scene = Scene_Menu.new(0)
  1135.       return
  1136.     end
  1137.     # 按下 C 键的情况下
  1138.     if Input.trigger?(Input::C)
  1139.       # 获取物品窗口当前选中的物品数据
  1140.       @item = @item_window.item
  1141.       $game_system.se_play($data_system.decision_se)
  1142.       if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil
  1143.         @command_window.enable_item(0)
  1144.       else
  1145.         @command_window.disable_item(0)
  1146.       end
  1147.       @command_window.index = 0
  1148.       @command_window.visible = true
  1149.       @command_window.active = true
  1150.       @item_window.active = false
  1151.       return
  1152.     end
  1153.     # 按下 R 键的情况下
  1154.     if Input.trigger?(Input::R)
  1155.       $game_system.se_play($data_system.cursor_se)
  1156.       actor_index = 0
  1157.       for i in 0...$game_party.actors.size
  1158.         if @actor==$game_party.actors[i]
  1159.           actor_index = i
  1160.           break
  1161.         end
  1162.       end
  1163.       actor_index += 1
  1164.       actor_index %= $game_party.actors.size
  1165.       # 切换到别的特技画面
  1166.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1167.       return
  1168.     end
  1169.     # 按下 L 键的情况下
  1170.     if Input.trigger?(Input::L)
  1171.       # 演奏光标 SE
  1172.       $game_system.se_play($data_system.cursor_se)      
  1173.       actor_index = 0
  1174.       for i in 0...$game_party.actors.size
  1175.         if @actor==$game_party.actors[i]
  1176.           actor_index = i
  1177.           break
  1178.         end
  1179.       end
  1180.       actor_index -= 1
  1181.       actor_index %= $game_party.actors.size
  1182.       # 切换到别的特技画面
  1183.       $scene = Scene_Item.new($game_party.actors[actor_index])
  1184.       return
  1185.     end
  1186.   end
  1187.   #--------------------------------------------------------------------------
  1188.   # ● 刷新画面 (目标窗口被激活的情况下)
  1189.   #--------------------------------------------------------------------------
  1190.   def update_target
  1191.     # 按下 B 键的情况下
  1192.     if Input.trigger?(Input::B)
  1193.       # 演奏取消 SE
  1194.       $game_system.se_play($data_system.cancel_se)
  1195.       # 由于物品用完而不能使用的场合
  1196.       unless $game_party.item_can_use?(@item.id)
  1197.         # 再次生成物品窗口的内容
  1198.         @item_window.refresh
  1199.       end
  1200.       # 删除目标窗口
  1201.       @command_window.active = true
  1202.       @target_window.visible = false
  1203.       @target_window.active = false
  1204.       return
  1205.     end
  1206.     # 按下 C 键的情况下
  1207.     if Input.trigger?(Input::C)
  1208.       if @command_window.index==0
  1209.         # 目标是全体的情况下
  1210.         if @target_window.index == -1
  1211.           # 对同伴全体应用物品使用效果
  1212.           used = false
  1213.           for i in $game_party.actors
  1214.             used |= i.item_effect(@item)
  1215.           end
  1216.         end
  1217.         # 目标是单体的情况下
  1218.         if @target_window.index >= 0
  1219.           # 对目标角色应用物品的使用效果
  1220.           target = $game_party.actors[@target_window.index]
  1221.           used = target.item_effect(@item)
  1222.         end
  1223.         # 使用物品的情况下
  1224.         if used
  1225.           # 演奏物品使用时的 SE
  1226.           $game_system.se_play(@item.menu_se)
  1227.           # 消耗品的情况下
  1228.           if @item.consumable

  1229.             if @actor == nil
  1230.               # 使用的物品数减 1
  1231.               $game_party.lose_item(@item.id, 1)
  1232.             else
  1233.               @actor.items.delete_at(@item_window.index)
  1234.             end

  1235.             # 再描绘物品窗口的项目
  1236.             @item_window.draw_item(@item_window.index)
  1237.           end
  1238.           # 再生成目标窗口的内容
  1239.           @target_window.refresh
  1240.           # 全灭的情况下
  1241.           if $game_party.all_dead?
  1242.             # 切换到游戏结束画面
  1243.             $scene = Scene_Gameover.new
  1244.             return
  1245.           end
  1246.           # 公共事件 ID 有效的情况下
  1247.           if @item.common_event_id > 0
  1248.             # 预约调用公共事件
  1249.             $game_temp.common_event_id = @item.common_event_id
  1250.             # 切换到地图画面
  1251.             $scene = Scene_Map.new
  1252.             return
  1253.           end
  1254.           @item_window.refresh
  1255.           @item_window.index -= 1 if @item_window.index >0
  1256.         end
  1257.         # 无法使用物品的情况下
  1258.         unless used
  1259.           # 演奏冻结 SE
  1260.           $game_system.se_play($data_system.buzzer_se)
  1261.         end
  1262.         return
  1263.       end
  1264.       if @command_window.index==1
  1265.         if $game_party.actors[@target_window.index].item_full?
  1266.           $game_system.se_play($data_system.buzzer_se)
  1267.           return
  1268.         end
  1269.         if @actor != nil
  1270.           @actor.items.delete_at(@item_window.index)
  1271.         else
  1272.           if @item_window.item.is_a?(RPG::Item)
  1273.             $game_party.lose_item(@item_window.item.id, 1)
  1274.           elsif @item_window.item.is_a?(RPG::Weapon)
  1275.             $game_party.lose_weapon(@item_window.item.id, 1)
  1276.           elsif @item_window.item.is_a?(RPG::Armor)
  1277.             $game_party.lose_armor(@item_window.item.id, 1)
  1278.           end
  1279.         end
  1280.         $game_system.se_play($data_system.decision_se)
  1281.         $game_party.actors[@target_window.index].items.push(@item_window.item)
  1282.         @item_window.refresh
  1283.         @item_window.index -= 1 if @item_window.index>0
  1284.         @item_window.active = true
  1285.         @command_window.visible = false
  1286.         @command_window.active = false
  1287.         @command_window.index = 0
  1288.         @target_window.visible = false
  1289.         @target_window.active = false
  1290.       end
  1291.     end
  1292.   end
  1293. end

  1294. #==============================================================================
  1295. # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
  1296. # ■ 使用方法写在发布页
  1297. #==============================================================================
  1298. # ■ Scene_Battle (分割定义 3)
  1299. #------------------------------------------------------------------------------
  1300. #  处理战斗画面的类。
  1301. #==============================================================================

  1302. class Scene_Battle
  1303.   #--------------------------------------------------------------------------
  1304.   # ● 开始选择物品
  1305.   #--------------------------------------------------------------------------
  1306.   def start_item_select
  1307.     # 无效化角色指令窗口
  1308.     @actor_command_window.active = false
  1309.     @actor_command_window.visible = false
  1310.     # 生成物品窗口
  1311.     @item_window = Window_Item.new($game_party.actors[@actor_index])
  1312.     # 关联帮助窗口
  1313.     #@item_window.help_window = @help_window
  1314.     @item_window.help_window =  Window_Help.new#★★★★★★★★★★★★
  1315.     # 无效化角色指令窗口
  1316.     @actor_command_window.active = false
  1317.     @actor_command_window.visible = false
  1318.   end
  1319.   #--------------------------------------------------------------------------
  1320.   # ● 刷新画面 (角色命令回合 : 选择物品)
  1321.   #--------------------------------------------------------------------------
  1322.   def update_phase3_item_select
  1323.     # 设置物品窗口为可视状态
  1324.     @item_window.visible = true
  1325.     # 刷新物品窗口
  1326.     @item_window.update
  1327.     # 按下 B 键的情况下
  1328.     if Input.trigger?(Input::B)
  1329.       # 演奏取消 SE
  1330.       $game_system.se_play($data_system.cancel_se)
  1331.       # 选择物品结束
  1332.       end_item_select
  1333.       return
  1334.     end
  1335.     # 按下 C 键的情况下
  1336.     if Input.trigger?(Input::C)
  1337.       # 获取物品窗口现在选择的物品资料
  1338.       @item = @item_window.item
  1339.       unless @item.is_a?(RPG::Item)
  1340.         # 演奏冻结 SE
  1341.         $game_system.se_play($data_system.buzzer_se)
  1342.         return
  1343.       end
  1344.       # 无法使用的情况下
  1345.       unless $game_party.item_can_use?(@item.id)
  1346.         # 演奏冻结 SE
  1347.         $game_system.se_play($data_system.buzzer_se)
  1348.         return
  1349.       end
  1350.       # 演奏确定 SE
  1351.       $game_system.se_play($data_system.decision_se)

  1352.       # 设置行动
  1353.       @active_battler.current_action.item_id = @item.id
  1354.       
  1355.                         # 消耗品的情况下
  1356.             if @item.consumable
  1357.               # 使用的物品数减 1
  1358.               $game_party.actors[@actor_index].gain_item(@item.id, 1, n=false)
  1359.               $game_party.gain_item(@item.id, 1)
  1360.               end

  1361.       # 设置物品窗口为不可见状态
  1362.       @item_window.visible = false
  1363.           # 效果范围是敌单体的情况下
  1364.       if @item.scope == 1
  1365.         # 开始选择敌人
  1366.         start_enemy_select
  1367.       # 效果范围是我方单体的情况下
  1368.       elsif @item.scope == 3 or @item.scope == 5
  1369.         # 开始选择角色
  1370.         start_actor_select
  1371.       # 效果范围不是单体的情况下
  1372.       else
  1373.         # 物品选择结束
  1374.         end_item_select
  1375.         # 转到下一位角色的指令输入
  1376.         phase3_next_actor
  1377.       end
  1378.       return
  1379.     end
  1380.   end
  1381. end





  1382. #==============================================================================
  1383. # 本脚本来自[url]www.66rpg.com[/url],转载和使用请保留此信息  
  1384. # 脚本名:真实商店,脚本作者:柳柳  
  1385. #==============================================================================
  1386. #  
  1387. # 功能:  
  1388. #  
  1389. # 买进卖出的物品在商店有所体现,卖出后会在商店可买物品中出现,物品有数量限制  
  1390. # 商店可进货出货————总之就是模拟真实商店。  
  1391. #   
  1392. # 这个脚本和原装商店并不冲突,两个商店可以并存。  
  1393. #  
  1394. # 使用方法:  
  1395. #  
  1396. # 1、在下面被井号框起来的中间部分,设置初期物品。格式如下:  
  1397. #    @goods[商店编号] = [ [种类,ID,可卖数量] ,  [种类,ID,可卖数量]......]  
  1398. #    其中种类,0为道具,1为武器,2为防具;ID是数据库编号  
  1399. #  
  1400. # 2、调用:$scene = Scene_Shop_Va.new(商店编号)   
  1401. #    比如你可以直接测试$scene = Scene_Shop_Va.new(1),已经设置好了。  
  1402. #  
  1403. # 3、商店出货:$game_system.shop_change(商店编号,种类,ID,数量)  
  1404. #    如果是进货,把数量设置为负数即可  
  1405. #  
  1406. #==============================================================================
  1407. # ■ Scene_Shop  
  1408. #------------------------------------------------------------------------------  
  1409. #  处理商店画面的类。  
  1410. #==============================================================================
  1411. class Game_System  
  1412. attr_accessor :goods   
  1413. alias vaule_shop_66RPG_initialize initialize  
  1414. def initialize  
  1415.    vaule_shop_66RPG_initialize  
  1416.    @goods = []  
  1417. ###########################################################################  
  1418.    # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量  
  1419.    @goods[1] = [[0,1,15],[0,2,10],[1,2,3]]   
  1420.    @goods[2] = [[0,3,8],[1,4,1],[1,2,1],[1,3,1],[1,4,1]]   
  1421.    @goods[3] = [[0,5,2],[1,3,1],[1,2,3]]   
  1422. ###########################################################################  
  1423. end  
  1424. def shop_change(shop,kind,id,delnumber)  
  1425.    dl = delnumber  
  1426.    for dt in $game_system.goods[shop]  
  1427.      if (dt[0]==kind) and (dt[1]==id)  
  1428.        dt[2] -= dl  
  1429.        dt[2] = [dt[2],99].min  
  1430.        if dt[2] == 0  
  1431.          $game_system.goods[shop].delete(dt)  
  1432.        end  
  1433.        return  
  1434.      end  
  1435.    end  
  1436.    $game_system.goods[shop].push([kind,id,-delnumber])  
  1437. end  
  1438. end
  1439. class Scene_Shop_Va  
  1440. def initialize(shop_number)  
  1441.    # 当前商店编号  
  1442.    @shop_now = shop_number      
  1443. end   
  1444. #--------------------------------------------------------------------------  
  1445. # ● 主处理  
  1446. #--------------------------------------------------------------------------  
  1447. def main  
  1448.        @type = 0   

  1449.    # 生成帮助窗口  
  1450.    @help_window = Window_Help.new  
  1451.    # 生成指令窗口  
  1452.    @command_window = Window_ShopCommand.new  
  1453.    # 生成金钱窗口  
  1454.    @gold_window = Window_Gold.new  
  1455.    @gold_window.x = 480  
  1456.    @gold_window.y = 64  
  1457.    # 生成时间窗口  
  1458.    @dummy_window = Window_Base.new(0, 128, 640, 352)  
  1459.    # 生成购买窗口  
  1460.    @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])  
  1461.    @buy_window.active = false  
  1462.    @buy_window.visible = false  
  1463.    @buy_window.help_window = @help_window  
  1464.    # 生成卖出窗口  
  1465.    @sell_window = Window_ShopSell.new  
  1466.    @sell_window.active = false  
  1467.    @sell_window.visible = false  
  1468.    @sell_window.help_window = @help_window  
  1469.    # 生成状态窗口  
  1470.     @status_window = Window_ShopStatus_New.new
  1471.     @status_window.visible = false
  1472.   @status_window.index = -1
  1473.    # 执行过渡  
  1474.    Graphics.transition  
  1475.    # 主循环  
  1476.    loop do  
  1477.      # 刷新游戏画面  
  1478.      Graphics.update  
  1479.      # 刷新输入信息  
  1480.      Input.update  
  1481.      # 刷新画面  
  1482.      update  
  1483.      # 如果画面切换的话就中断循环  
  1484.      if $scene != self  
  1485.        break  
  1486.      end  
  1487.    end  
  1488.    # 准备过渡  
  1489.    Graphics.freeze  
  1490.    # 释放窗口  
  1491.    @help_window.dispose  
  1492.    @command_window.dispose  
  1493.    @gold_window.dispose  
  1494.    @dummy_window.dispose  
  1495.    @buy_window.dispose  
  1496.    @sell_window.dispose  
  1497.    @status_window.dispose  
  1498.    

  1499. end  

  1500.   
  1501. #--------------------------------------------------------------------------  
  1502. # ● 刷新画面  
  1503. #--------------------------------------------------------------------------  
  1504. def update  
  1505.    # 刷新窗口  
  1506.    @help_window.update  
  1507.    @command_window.update  
  1508.    @gold_window.update  
  1509.    @dummy_window.update  
  1510.    @buy_window.update  
  1511.    @sell_window.update  
  1512.    @status_window.update  

  1513.    # 指令窗口激活的情况下: 调用 update_command  
  1514.    if @command_window.active  
  1515.            @help_window.visible=false
  1516.      update_command  
  1517.      return  
  1518.    end  
  1519.    # 购买窗口激活的情况下: 调用 update_buy  
  1520.    if @buy_window.active  
  1521.      update_buy  
  1522.          @help_window.visible=true#★★★★★★★★★★★★★★★★
  1523.       if @buy_window.item==nil#★★★★★★★★★★★★★★★★
  1524.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1525.       end #★★★★★★★★★★★★★★★★     
  1526.       update_buy
  1527.       return
  1528.     end

  1529.    # 卖出窗口激活的情况下: 调用 update_sell  
  1530.    if @sell_window.active  
  1531.            @help_window.visible=true#★★★★★★★★★★★★★★★★
  1532.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1533.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1534.       end #★★★★★★★★★★★★★★★★
  1535.       update_sell
  1536.       return
  1537.     end   
  1538.        if @type==1
  1539. # 修改開始
  1540.       @help_window.visible=true#★★★★★★★★★★★★★★★★
  1541.       if @sell_window.item==nil#★★★★★★★★★★★★★★★★
  1542.         @help_window.visible=false#★★★★★★★★★★★★★★★★
  1543.       end #★★★★★★★★★★★★★★★★
  1544. # 修改終了
  1545.       update_st1
  1546.       return
  1547.     end
  1548.   end

  1549. def update_st1
  1550.     if Input.trigger?(Input::B)
  1551.       $game_system.se_play($data_system.cancel_se)
  1552.       @buy_window.active = true
  1553.       @type = 0
  1554.       @status_window.index = -1
  1555.       @status_window.active = false
  1556.       return
  1557.     end
  1558.     if Input.trigger?(Input::C)
  1559.       if @status_window.index == 0        
  1560.         if $game_party.item_full?
  1561.           $game_system.se_play($data_system.cancel_se)
  1562.           return
  1563.         end        
  1564.         # 演奏商店 SE
  1565.         $game_system.se_play($data_system.shop_se)
  1566.         $game_party.lose_gold(@item.price)
  1567.                case @item  
  1568.        when RPG::Item  
  1569.                    $game_party.gain_item(@item.id, 1)
  1570.               temp = 0  
  1571.        when RPG::Weapon  
  1572.                    $game_party.gain_weapon(@item.id, 1)
  1573.          temp = 1  
  1574.        when RPG::Armor  
  1575.                    $game_party.gain_armor(@item.id, 1)

  1576.          temp = 2  
  1577.        end  
  1578.                goods_del(temp,@item.id,1)  
  1579.         # 刷新各窗口
  1580.         @gold_window.refresh
  1581.         @buy_window.refresh
  1582.         @status_window.refresh
  1583.         # 窗口状态转向购买模式
  1584.         @buy_window.active = true
  1585.         @buy_window.visible = true
  1586.         @status_window.active = false
  1587.         @status_window.index = -1
  1588.         @type = 0
  1589.       else
  1590.         if $game_party.actors[@status_window.index-1].item_full?
  1591.           $game_system.se_play($data_system.cancel_se)
  1592.           return
  1593.         end        
  1594.         # 演奏商店 SE
  1595.         $game_system.se_play($data_system.shop_se)
  1596.         $game_party.lose_gold(@item.price)
  1597.         case @item
  1598.         when RPG::Item
  1599.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 1)
  1600.                         temp = 0  
  1601.         when RPG::Weapon
  1602.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 2)
  1603.                         temp = 1  
  1604.         when RPG::Armor
  1605.           $game_party.actors[@status_window.index-1].gain_item(@item.id, 3)
  1606.                         temp = 2  
  1607.         end
  1608.         goods_del(temp,@item.id,1)
  1609.         # 刷新各窗口
  1610.         @gold_window.refresh
  1611.         @buy_window.refresh
  1612.         @status_window.refresh
  1613.         # 窗口状态转向购买模式
  1614.         @buy_window.active = true
  1615.         @status_window.active = false
  1616.         @type = 0
  1617.         @status_window.index = -1
  1618.       end
  1619.     end
  1620.   end
  1621.   
  1622. #--------------------------------------------------------------------------  
  1623. # ● 刷新画面 (指令窗口激活的情况下)  
  1624. #--------------------------------------------------------------------------  
  1625. def update_command  
  1626.    # 按下 B 键的情况下  
  1627.    if Input.trigger?(Input::B)  
  1628.      # 演奏取消 SE  
  1629.      $game_system.se_play($data_system.cancel_se)  
  1630.      # 切换到地图画面  
  1631.      $scene = Scene_Map.new  
  1632.      return  
  1633.    end  

  1634.    # 按下 C 键的情况下  
  1635.    if Input.trigger?(Input::C)  
  1636.      # 命令窗口光标位置分支  
  1637.      case @command_window.index  
  1638.      when 0  # 购买  
  1639.        # 演奏确定 SE  
  1640.        $game_system.se_play($data_system.decision_se)  
  1641.        # 窗口状态转向购买模式  
  1642.        @command_window.active = false  
  1643.        @dummy_window.visible = false  
  1644.        @buy_window.active = true  
  1645.        @buy_window.visible = true  
  1646.        @buy_window.refresh  
  1647.        @status_window.visible = true  
  1648.      when 1  # 卖出  
  1649.        # 演奏确定 SE  
  1650.        $game_system.se_play($data_system.decision_se)  
  1651.        # 窗口状态转向卖出模式  
  1652.        @command_window.active = false  
  1653.        @dummy_window.visible = false  
  1654.        @sell_window.active = true  
  1655.        @sell_window.visible = true  
  1656.        @sell_window.refresh  
  1657.       
  1658.      when 2  # 取消  
  1659.        # 演奏确定 SE  
  1660.        $game_system.se_play($data_system.decision_se)  
  1661.        # 切换到地图画面  
  1662.        $scene = Scene_Map.new  
  1663.      end  
  1664.      return  
  1665.    end  
  1666. end  

  1667.   
  1668.   
  1669. #--------------------------------------------------------------------------  
  1670. # ● 刷新画面 (购买窗口激活的情况下)  
  1671. #--------------------------------------------------------------------------  
  1672. def update_buy  
  1673.    # 设置状态窗口的物品  
  1674.    @status_window.item = @buy_window.item  
  1675.    # 按下 B 键的情况下  
  1676.    if Input.trigger?(Input::B)  
  1677.      # 演奏取消 SE  
  1678.      $game_system.se_play($data_system.cancel_se)  
  1679.      # 窗口状态转向初期模式  
  1680.      @command_window.active = true  
  1681.      @dummy_window.visible = true  
  1682.      @buy_window.active = false  
  1683.      @buy_window.visible = false  
  1684.      @status_window.visible = false  
  1685.      @status_window.item = nil  
  1686.      # 删除帮助文本  
  1687.      @help_window.set_text("")  
  1688.      return  
  1689.    end  
  1690.    
  1691.    # 按下 C 键的情况下  
  1692.    if Input.trigger?(Input::C)  
  1693.      # 获取物品  
  1694.      @item = @buy_window.item  
  1695.      # 物品无效的情况下、或者价格在所持金以上的情况下  
  1696.      if @item == nil or @item.price > $game_party.gold  
  1697.        # 演奏冻结 SE  
  1698.        $game_system.se_play($data_system.buzzer_se)  
  1699.        return  
  1700.      end  

  1701.      # 演奏确定 SE  
  1702.      $game_system.se_play($data_system.decision_se)  
  1703.      # 窗口状态转向数值输入模式  
  1704.      @buy_window.active = false
  1705.       @status_window.index = 0
  1706.       @type = 1
  1707.       @status_window.active = true

  1708.    end  
  1709. end  
  1710.   

  1711.   
  1712. #--------------------------------------------------------------------------  
  1713. # ● 画面更新 (卖出窗口激活的情况下)  
  1714. #--------------------------------------------------------------------------  
  1715. def update_sell  
  1716.    # 按下 B 键的情况下  
  1717.    if Input.trigger?(Input::B)  
  1718.      # 演奏取消 SE  
  1719.      $game_system.se_play($data_system.cancel_se)  
  1720.      # 窗口状态转向初期模式  
  1721.      @command_window.active = true  
  1722.      @dummy_window.visible = true  
  1723.      @sell_window.active = false  
  1724.      @sell_window.visible = false  
  1725.      @status_window.item = nil  
  1726.      # 删除帮助文本  
  1727.      @help_window.set_text("")  
  1728.      return  
  1729.    end  
  1730.    
  1731.    # 按下 C 键的情况下  
  1732.    if Input.trigger?(Input::C)  
  1733.      # 获取物品  
  1734.      @item = @sell_window.item  
  1735.      # 设置状态窗口的物品  
  1736.      @status_window.item = @item  
  1737.      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下  
  1738.      if @item == nil or @item.price == 0  
  1739.        # 演奏冻结 SE  
  1740.        $game_system.se_play($data_system.buzzer_se)  
  1741.        return  
  1742.      end  
  1743.      # 演奏确定 SE  
  1744.      $game_system.se_play($data_system.decision_se)  
  1745.             # 卖出处理
  1746.          $game_party.gain_gold(@item.price / 2)
  1747.       case @item
  1748.       when RPG::Item
  1749.         $game_party.lose_item(@item.id, 1)
  1750.         temp = 0  
  1751.       when RPG::Weapon
  1752.         $game_party.lose_weapon(@item.id, 1)
  1753.                  temp = 1  
  1754.       when RPG::Armor
  1755.         $game_party.lose_armor(@item.id, 1)
  1756.                  temp = 2  
  1757.                end
  1758.        goods_del(temp,@item.id,-1)  
  1759.       # 刷新各窗口
  1760.       @gold_window.refresh
  1761.       @sell_window.refresh
  1762.       @status_window.refresh
  1763.     end
  1764.   end


  1765. # 删除可出售商品内容  
  1766. def goods_del(kind,id,delnumber)  
  1767.    dl = delnumber  
  1768.    for dt in $game_system.goods[@shop_now]  
  1769.      if (dt[0]==kind) and (dt[1]==id)  
  1770.        dt[2] -= dl  
  1771.        dt[2] = [dt[2],99].min  
  1772.        if dt[2] == 0  
  1773.          $game_system.goods[@shop_now].delete(dt)  
  1774.        end  
  1775.        return  
  1776.      end  
  1777.    end  
  1778.    $game_system.goods[@shop_now].push([kind,id,-delnumber])  
  1779. end  
  1780. #==============================================================================
  1781. # ■ Window_ShopBuy_Va  
  1782. #------------------------------------------------------------------------------  
  1783. #  商店画面、浏览显示可以购买的商品的窗口。  
  1784. #==============================================================================
  1785. class Window_ShopBuy_Va < Window_Selectable  
  1786. attr_accessor :shop_goods  
  1787. #--------------------------------------------------------------------------  
  1788. # ● 初始化对像  
  1789. #     shop_goods : 商品  
  1790. #--------------------------------------------------------------------------  
  1791. def initialize(shop_goods)  
  1792.    super(0, 128, 368, 352)  
  1793.    @shop_goods = shop_goods  
  1794.    refresh  
  1795.    self.index = 0  
  1796. end  
  1797. #--------------------------------------------------------------------------  
  1798. # ● 获取物品  
  1799. #--------------------------------------------------------------------------  
  1800. def item  
  1801.    return @data[self.index]  
  1802. end  
  1803. #--------------------------------------------------------------------------  
  1804. # ● 获取物品  
  1805. #--------------------------------------------------------------------------  
  1806. def item_number  
  1807.    return @data_number[self.index]  
  1808. end  
  1809. #--------------------------------------------------------------------------  
  1810. # ● 刷新  
  1811. #--------------------------------------------------------------------------  
  1812. def refresh  
  1813.    if self.contents != nil  
  1814.      self.contents.dispose  
  1815.      self.contents = nil  
  1816.    end  
  1817.    @data = []  
  1818.    @data_number = []  
  1819.    for goods_item in @shop_goods  
  1820.      case goods_item[0]  
  1821.      when 0  
  1822.        item = $data_items[goods_item[1]]  
  1823.      when 1  
  1824.        item = $data_weapons[goods_item[1]]  
  1825.      when 2  
  1826.        item = $data_armors[goods_item[1]]  
  1827.      end  
  1828.      if (item != nil) and (goods_item[2] != 0)  
  1829.        @data.push(item)  
  1830.        @data_number.push(goods_item[2])  
  1831.      else  
  1832.        @data.delete(item)  
  1833.      end  
  1834.    end  
  1835.    # 如果项目数不是 0 就生成位图、描绘全部项目  
  1836.    @item_max = @data.size  
  1837.    if @item_max > 0  
  1838.      self.contents = Bitmap.new(width - 32, row_max * 32)  
  1839.      for i in 0...@item_max  
  1840.        draw_item(i)  
  1841.      end  
  1842.    end  
  1843. end  
  1844. #--------------------------------------------------------------------------  
  1845. # ● 描绘羡慕  
  1846. #     index : 项目编号  
  1847. #--------------------------------------------------------------------------  
  1848. def draw_item(index)  
  1849.    item = @data[index]  
  1850.    # 获取物品所持数  
  1851.    case item  
  1852.    when RPG::Item  
  1853.      number = $game_party.item_number(item.id)  
  1854.    when RPG::Weapon  
  1855.      number = $game_party.weapon_number(item.id)  
  1856.    when RPG::Armor  
  1857.      number = $game_party.armor_number(item.id)  
  1858.    end  
  1859.    # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色  
  1860.    # 除此之外的情况设置为无效文字色  
  1861.    if item.price <= $game_party.gold
  1862.      self.contents.font.color = normal_color  
  1863.    else  
  1864.      self.contents.font.color = disabled_color  
  1865.    end  
  1866.    x = 4  
  1867.    y = index * 32  
  1868.    rect = Rect.new(x, y, self.width - 32, 32)  
  1869.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))  
  1870.    bitmap = RPG::Cache.icon(item.icon_name)  
  1871.    opacity = self.contents.font.color == normal_color ? 255 : 128  
  1872.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)  
  1873.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)  
  1874.    self.contents.draw_text(x + 240, y, 88, 32, "剩  ", 2)  
  1875.    self.contents.draw_text(x + 240, y, 88, 32, @data_number[index].to_s, 2)  
  1876.    self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)  
  1877. end  
  1878. #--------------------------------------------------------------------------  
  1879. # ● 刷新帮助文本  
  1880. #--------------------------------------------------------------------------  
  1881. def update_help  
  1882.    @help_window.set_text(self.item == nil ? "" : self.item.description)  
  1883. end  
  1884. end
  1885. end
  1886. #==============================================================================
  1887. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  1888. #==============================================================================
复制代码
回复

使用道具 举报

梦石
0
星屑
80
在线时间
61 小时
注册时间
2016-7-9
回帖
29
发表于 2016-8-16 10:11:07 | 显示全部楼层
你这种商店怎么做的?是XP还是VX

点评

XP 这个是柳柳写的,我只是修改。里面有注解,很好使用的  发表于 2016-8-16 13:28
回复

使用道具 举报

梦石
0
星屑
80
在线时间
61 小时
注册时间
2016-7-9
回帖
29
发表于 2016-8-16 13:35:18 | 显示全部楼层
有没有示范发一个535555178@qq.com

点评

没有范例,是主站找的,只有脚本。  发表于 2016-8-16 14:19
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部