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

Project1

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

[已经过期] 请问有没有类似这个物品分类的技能分类脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2014-11-1
帖子
10
跳转到指定楼层
1
发表于 2015-2-22 23:38:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. module RPG
  5.   class Weapon
  6.     def description
  7.       description = @description.split(/@/)[0]
  8.       return description != nil ? description : ''
  9.     end
  10.     def desc
  11.       desc = @description.split(/@/)[1]
  12.       return desc != nil ? desc : "普通物品"
  13.     end
  14.   end
  15.   class Item
  16.     def description
  17.       description = @description.split(/@/)[0]
  18.       return description != nil ? description : ''
  19.     end
  20.     def desc
  21.       desc = @description.split(/@/)[1]
  22.       return desc != nil ? desc : "普通物品"
  23.     end
  24.   end
  25.   class Armor
  26.     def description
  27.       description = @description.split(/@/)[0]
  28.       return description != nil ? description : ''
  29.     end
  30.     def desc
  31.       desc = @description.split(/@/)[1]
  32.       return desc != nil ? desc : "普通物品"
  33.     end
  34.   end
  35. end

  36. class Harts_Window_ItemTitle < Window_Base
  37.   def initialize
  38.     super(0, 0, 160, 64)
  39.     self.contents = Bitmap.new(width - 32, height - 32)
  40.     self.contents.clear
  41.     self.contents.font.color = normal_color
  42.     self.contents.draw_text(4, 0, 120, 32, Vocab::item, 1)
  43.   end
  44. end

  45. class Harts_Window_ItemCommand < Window_Selectable
  46.   attr_accessor :commands
  47.   def initialize
  48.     super(0, 64, 160, 296)
  49.     self.index = 0
  50.     refresh
  51.   end
  52.   
  53. def addcommand
  54.    @commands = []
  55.    for i in 1...$data_items.size
  56.      if $game_party.item_number($data_items[i]) > 0
  57.        push = true
  58.        for com in @commands
  59.          if com == $data_items[i].desc
  60.            push = false
  61.          end
  62.        end
  63.        if push == true
  64.          @commands.push($data_items[i].desc)
  65.        end
  66.      end
  67.    end
  68.    for i in 1...$data_weapons.size
  69.      if $game_party.item_number($data_weapons[i]) > 0
  70.        push = true
  71.        for com in @commands
  72.          if com == $data_weapons[i].desc
  73.            push = false
  74.            end
  75.          end
  76.          if push == true
  77.            @commands.push($data_weapons[i].desc)
  78.          end
  79.        end
  80.      end
  81.      for i in 1...$data_armors.size
  82.        if $game_party.item_number($data_armors[i]) > 0
  83.          push = true
  84.          for com in @commands
  85.            if com == $data_armors[i].desc
  86.              push = false
  87.            end
  88.          end
  89.          if push == true
  90.            @commands.push($data_armors[i].desc)
  91.          end
  92.        end
  93.      end
  94.      if @commands == []
  95.        @commands.push("普通物品")
  96.      end      
  97.      @item_max = @commands.size
  98.   end
  99.   
  100. def refresh
  101.     addcommand
  102.     create_contents
  103.     for i in 0...@item_max
  104.       draw_item(i, normal_color)
  105.     end
  106.   end
  107.   
  108.   def draw_item(index, color)
  109.     y = index * WLH
  110.     self.contents.font.color = color
  111.     if @commands[index] != nil
  112.       self.contents.draw_text(4,y, 172, WLH, @commands[index])
  113.     end
  114.   end

  115.   def update_help
  116.     @help_window.set_text(@commands[self.index])
  117.   end
  118. end

  119. class Harts_Window_ItemList < Window_Selectable
  120.   
  121.   def initialize
  122.     super(160, 0, 384, 360)
  123.     self.index = 0
  124.     refresh
  125.   end
  126.   
  127.   def item
  128.     return @data[self.index]
  129.   end
  130.   
  131.   def refresh
  132.     @data = []
  133.   end
  134.   
  135.   def set_item(command)
  136.     refresh
  137.     for i in 1...$data_items.size
  138.       if $game_party.item_number($data_items[i]) > 0  and $data_items[i].desc == command
  139.         @data.push($data_items[i])
  140.       end
  141.     end
  142.     for i in 1...$data_weapons.size
  143.       if $game_party.item_number($data_weapons[i]) > 0  and $data_weapons[i].desc == command
  144.         @data.push($data_weapons[i])
  145.       end
  146.     end
  147.     for i in 1...$data_armors.size
  148.       if $game_party.item_number($data_armors[i]) > 0  and $data_armors[i].desc == command
  149.         @data.push($data_armors[i])
  150.       end
  151.     end
  152.     @item_max = @data.size
  153.     if @item_max > 0
  154.       self.contents = Bitmap.new(width - 32, row_max * 32)
  155.       self.contents.clear
  156.       for i in 0...@item_max
  157.         draw_item(i)
  158.       end
  159.     end
  160.   end
  161.   
  162.   def item_number
  163.     return @item_max
  164.   end
  165.   
  166.   def draw_item(index)
  167.     rect = item_rect(index)
  168.     self.contents.clear_rect(rect)
  169.     item = @data[index]
  170.     if item != nil
  171.       number = $game_party.item_number(item)
  172.       enabled = $game_party.item_can_use?(item)
  173.       rect.width -= 4
  174.       draw_item_name(item, rect.x, rect.y, enabled)
  175.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  176.     end
  177.   end
  178.   
  179.   def update_help
  180.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  181.   end
  182. end
  183. class Harts_Window_Help < Window_Base
  184.   
  185.   def initialize
  186.     super(0, 360, 544, WLH + 32)
  187.   end

  188.   def set_text(text, align = 0)
  189.     if text != @text or align != @align
  190.       self.contents.clear
  191.       self.contents.font.color = normal_color
  192.       self.contents.draw_text(4, 0, self.width - 40, WLH , text, align)
  193.       @text = text
  194.       @align = align
  195.     end
  196.   end
  197. end

  198. class Harts_Window_MenuStatus < Window_Selectable

  199.   def initialize(x, y)
  200.     super(x, y, 288, 416)
  201.     refresh
  202.     self.active = false
  203.     self.index = -1
  204.   end

  205.   def refresh
  206.     self.contents.clear
  207.     @item_max = $game_party.members.size
  208.     for actor in $game_party.members
  209.       x = 8
  210.       y = actor.index * 96 + WLH / 2
  211.       draw_actor_name(actor, x, y)
  212.       draw_actor_class(actor, x + 120, y)
  213.       draw_actor_level(actor, x, y + WLH * 1)
  214.       draw_actor_state(actor, x, y + WLH * 2)
  215.       draw_actor_hp(actor, x + 120, y + WLH * 1)
  216.       draw_actor_mp(actor, x + 120, y + WLH * 2)
  217.     end
  218.   end

  219.   def update_cursor
  220.     if @index < 0               
  221.       self.cursor_rect.empty
  222.     elsif @index < @item_max  
  223.       self.cursor_rect.set(0, @index * 96, contents.width, 96)
  224.     elsif @index >= 100        
  225.       self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
  226.     else                       
  227.       self.cursor_rect.set(0, 0, contents.width, @item_max * 96)
  228.     end
  229.   end
  230. end

  231. class Scene_Item < Scene_Base
  232.   def start
  233.     super
  234.     create_menu_background
  235.     @viewport = Viewport.new(0, 0, 544, 416)
  236.     @itemtitle_window = Harts_Window_ItemTitle.new
  237.     @itemcommand_window = Harts_Window_ItemCommand.new
  238.     @command_index = @itemcommand_window.index
  239.     @itemcommand_window.refresh
  240.     @itemlist_window = Harts_Window_ItemList.new
  241.     @itemlist_window.active = false
  242.     @help_window = Harts_Window_Help.new
  243.     @help_window.viewport = @viewport
  244.     @target_window = Harts_Window_MenuStatus.new(96, 0)
  245.     @itemcommand_window.help_window = @help_window
  246.     @itemlist_window.help_window = @help_window
  247.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  248.     hide_target_window
  249.   end

  250.   def terminate
  251.     super
  252.     dispose_menu_background
  253.     @viewport.dispose
  254.     @itemtitle_window.dispose
  255.     @itemcommand_window.dispose
  256.     @itemlist_window.dispose
  257.     @help_window.dispose
  258.     @target_window.dispose
  259.   end

  260.   def return_scene
  261.     $scene = Scene_Menu.new(0)
  262.   end

  263.   def update
  264.     super
  265.     update_menu_background
  266.     @help_window.update
  267.     @itemlist_window.update
  268.     @itemcommand_window.update
  269.     @target_window.update
  270.     @itemcommand_window.refresh
  271.     if @command_index != @itemcommand_window.index
  272.       @itemlist_window.index = 0
  273.       @command_index = @itemcommand_window.index
  274.       @itemcommand_window.update_help
  275.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  276.     end
  277.     if @itemcommand_window.active
  278.       @itemcommand_window.update_help
  279.       update_itemcommand
  280.     elsif @itemlist_window.active
  281.       update_itemlist
  282.     elsif @target_window.active
  283.       update_target_selection
  284.     end
  285.   end

  286.   def update_itemcommand
  287.     if Input.trigger?(Input::B)
  288.       Sound.play_cancel
  289.       return_scene
  290.       return
  291.     end
  292.     if Input.trigger?(Input::C)
  293.       if @itemlist_window.item_number == 0
  294.         Sound.play_buzzer
  295.         return
  296.       end
  297.       Sound.play_decision
  298.       @itemcommand_window.active = false
  299.       @itemlist_window.index = 0
  300.       @itemlist_window.active = true
  301.       return
  302.     end
  303.   end

  304.   def update_itemlist
  305.     if Input.trigger?(Input::B)
  306.       Sound.play_cancel
  307.       @itemcommand_window.active = true
  308.       @itemlist_window.active = false
  309.       @itemcommand_window.index = @command_index
  310.     elsif Input.trigger?(Input::C)
  311.       @item = @itemlist_window.item
  312.       if @item != nil
  313.         $game_party.last_item_id = @item.id
  314.       end
  315.       if $game_party.item_can_use?(@item)
  316.         Sound.play_decision
  317.         determine_item
  318.       else
  319.         Sound.play_buzzer
  320.       end
  321.     end
  322.   end

  323.   def determine_item
  324.     if @item.for_friend?
  325.       show_target_window(@itemlist_window.index % 2 == 0)
  326.       if @item.for_all?
  327.         @target_window.index = 99
  328.       else
  329.         if $game_party.last_target_index < @target_window.item_max
  330.           @target_window.index = $game_party.last_target_index
  331.         else
  332.           @target_window.index = 0
  333.         end
  334.       end
  335.     else
  336.       use_item_nontarget
  337.     end
  338.   end

  339.   def update_target_selection
  340.     if Input.trigger?(Input::B)
  341.       Sound.play_cancel
  342.       if $game_party.item_number(@item) == 0
  343.         @itemlist_window.refresh                 
  344.       end
  345.       @itemlist_window.active = true
  346.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  347.       hide_target_window
  348.       @itemlist_window.active = true
  349.     elsif Input.trigger?(Input::C)
  350.       if not $game_party.item_can_use?(@item)
  351.         Sound.play_buzzer
  352.       else
  353.         determine_target
  354.       end
  355.     end
  356.   end

  357.   def determine_target
  358.     used = false
  359.     if @item.for_all?
  360.       for target in $game_party.members
  361.         target.item_effect(target, @item)
  362.         used = true unless target.skipped
  363.       end
  364.     else
  365.       $game_party.last_target_index = @target_window.index
  366.       target = $game_party.members[@target_window.index]
  367.       target.item_effect(target, @item)
  368.       used = true unless target.skipped
  369.     end
  370.     if used
  371.       use_item_nontarget
  372.     else
  373.       Sound.play_buzzer
  374.     end
  375.   end

  376.   def show_target_window(right)
  377.     @itemlist_window.active = false
  378.     width_remain = 544 - @target_window.width
  379.     @target_window.x = right ? width_remain : 0
  380.     @target_window.visible = true
  381.     @target_window.active = true
  382.     if right
  383.       @viewport.rect.set(0, 0, width_remain, 416)
  384.       @viewport.ox = 0
  385.     else
  386.       @viewport.rect.set(@target_window.width, 0, width_remain, 416)
  387.       @viewport.ox = @target_window.width
  388.     end
  389.   end

  390.   def hide_target_window
  391.     @target_window.visible = false
  392.     @target_window.active = false
  393.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  394.     @viewport.rect.set(0, 0, 544, 416)
  395.     @viewport.ox = 0
  396.   end

  397.   def use_item_nontarget
  398.     Sound.play_use_item
  399.     $game_party.consume_item(@item)
  400.     @itemlist_window.draw_item(@itemlist_window.index)
  401.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  402.     @target_window.refresh
  403.     if $game_party.all_dead?
  404.       $scene = Scene_Gameover.new
  405.     elsif @item.common_event_id > 0
  406.       $game_temp.common_event_id = @item.common_event_id
  407.       $scene = Scene_Map.new
  408.     end
  409.   end
  410. end

  411. #==============================================================================
  412. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  413. #==============================================================================
复制代码
ヾ(´ε`ヾ)

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2014-11-1
帖子
10
2
 楼主| 发表于 2015-2-23 15:31:50 | 只看该作者
゚(つд`゚)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 02:13

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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