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

Project1

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

[已经过期] 新人第一次写脚本求改正

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2035
在线时间
22 小时
注册时间
2015-2-18
帖子
4
跳转到指定楼层
1
发表于 2015-2-24 21:41:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
自己写了一个脚本,是技能最大个数的,超过技能最大个数后,会要求遗忘技能来学习新的技能,新人第一次写,求帮我改一下脚本,什么渐变之类我都看不懂,求改一下脚本让他有提示,好看一点
RUBY 代码复制
  1. #职业备注栏填写 <skill_max: 4> 最多可学习4个技能,第五个以后需要遗忘技能
  2.  
  3. #正则表达式
  4. class RPG::Actor < RPG::BaseItem
  5.   #--------------------------------------------------------------------------
  6.   # ● 获取技能最大数
  7.   #--------------------------------------------------------------------------
  8.   def skill_max
  9.     classes = $data_classes[@class_id]
  10.     classes.note  =~ /<skill_max\s*:(.*)>/i
  11.     return $1.to_i if $1!= nil
  12.   end
  13. end
  14.  
  15. #使用时的情况
  16. class Game_Actor
  17.   #--------------------------------------------------------------------------
  18.   # ● 领悟技能
  19.   #--------------------------------------------------------------------------
  20.   def learn_skill(skill_id)
  21.     unless skill_learn?($data_skills[skill_id])
  22.       @skills.push(skill_id)
  23.       @skills.sort!
  24.       skill_learn_max(@skills)
  25.     end
  26.   end
  27.   def skill_learn_max(new_skill)
  28.     if actor.skill_max != nil then
  29.     if new_skill.size > actor.skill_max then#超过
  30.        SceneManager.call(Scene_skill_learn)
  31.     end
  32.     end
  33.   end
  34. end
  35.  
  36. #窗口
  37.  
  38. #场景
  39. class Scene_skill_learn < Scene_MenuBase
  40.   #--------------------------------------------------------------------------
  41.   # ● 开始处理
  42.   #--------------------------------------------------------------------------
  43.   def start
  44.     super
  45.     create_skill_learn_window
  46.     create_skill_forget_command
  47.     @skill_window.activate
  48.     @have_learn = false
  49.     @forget_skill_id = 0
  50.   end
  51.   def create_skill_learn_window
  52.       Window_skill_command.init_command_position
  53.       @skill_window = Window_skill_command.new(@actor)
  54.       @skill_window.set_handler(:skill_name0,      method(:on_skill_ok))
  55.       @skill_window.set_handler(:skill_name1,      method(:on_skill_ok))
  56.       @skill_window.set_handler(:skill_name2,      method(:on_skill_ok))
  57.       @skill_window.set_handler(:skill_name3,      method(:on_skill_ok))
  58.       @skill_window.set_handler(:skill_name4,      method(:on_skill_ok))
  59.       @skill_window.x = (Graphics.width - @skill_window.width)/2
  60.       @skill_window.y = (Graphics.height- @skill_window.height)/2
  61.   end
  62.   def create_skill_forget_command
  63. #      @skill_select_window.init_command_position
  64.       @skill_select_window = Window_skill_forget_command.new
  65.       @skill_select_window.set_handler(:forget_skill,      method(:forget_skill))
  66.       @skill_select_window.set_handler(:cancel,      method(:skill_select_cancel))
  67.       @skill_select_window.x = @skill_window.x + @skill_window.width
  68.       @skill_select_window.y = @skill_window.y
  69.   end
  70.   #更新
  71.   def forget_skill
  72.     msgbox @actor.skills
  73.     @actor.forget_skill(@forget_skill_id)
  74.     msgbox @actor.skills
  75. #    @actor.skills.sort!
  76.     @have_learn = true
  77.     return_scene1
  78.   end
  79.   def return_scene1
  80.     if @have_learn then
  81.       SceneManager.return
  82.     end
  83.   end
  84.   def skill_select_cancel
  85.     @skill_select_window.hide
  86.     @skill_select_window.deactivate
  87.     @skill_window.activate
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ● 个人指令“确定”
  91.   #--------------------------------------------------------------------------
  92.   def on_skill_ok
  93.     case @skill_window.current_symbol
  94.     when :skill_name0
  95.       @forget_skill_id = @actor.skills[0].id
  96.     when :skill_name1
  97.       @forget_skill_id = @actor.skills[1].id
  98.     when :skill_name2
  99.       @forget_skill_id = @actor.skills[2].id
  100.     when :skill_name3
  101.       @forget_skill_id = @actor.skills[3].id
  102.     when :skill_name4
  103.       @forget_skill_id = @actor.skills[4].id
  104.     end
  105.     @skill_window.deactivate
  106.     @skill_select_window.show
  107.     @skill_select_window.activate
  108.   end
  109.   def update
  110.     super
  111.     @skill_select_window.y = @skill_window.y + @skill_window.index * 24
  112.   end
  113. end
  114. #==============================================================================
  115. # ■ Window_MenuCommand
  116. #------------------------------------------------------------------------------
  117. #  技能遗忘选择列表
  118. #==============================================================================
  119.  
  120. class Window_skill_command < Window_Command
  121.   #--------------------------------------------------------------------------
  122.   # ● 初始化指令选择位置(类方法)
  123.   #--------------------------------------------------------------------------
  124.   def self.init_command_position
  125.     @@last_command_symbol = nil
  126.  
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 初始化对象
  130.   #--------------------------------------------------------------------------
  131.   def initialize(actor)
  132.     @skill_name = []
  133.     @skill_name[0] = actor.skills[0].name
  134.     @skill_name[1] = actor.skills[1].name
  135.     @skill_name[2] = actor.skills[2].name
  136.     @skill_name[3] = actor.skills[3].name
  137.     @skill_name[4] = actor.skills[4].name
  138.     super(0, 0)
  139.     select_last
  140.   end
  141.  
  142.   #--------------------------------------------------------------------------
  143.   # ● 获取窗口的宽度
  144.   #--------------------------------------------------------------------------
  145.   def window_width
  146.     return 160
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 获取显示行数
  150.   #--------------------------------------------------------------------------
  151.   def visible_line_number
  152.     item_max
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 生成指令列表
  156.   #--------------------------------------------------------------------------
  157.   def make_command_list
  158.     add_commands
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 向指令列表添加主要的指令
  162.   #--------------------------------------------------------------------------
  163.   def add_commands
  164.      add_command(@skill_name[0], :skill_name0)
  165.      add_command(@skill_name[1], :skill_name1)
  166.      add_command(@skill_name[2], :skill_name2)
  167.      add_command(@skill_name[3], :skill_name3)
  168.      add_command(@skill_name[4], :skill_name4)
  169.   end
  170.  
  171.   #--------------------------------------------------------------------------
  172.   # ● 按下确定键时的处理
  173.   #--------------------------------------------------------------------------
  174.   def process_ok
  175.     @@last_command_symbol = current_symbol
  176.     super
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 返回最后一个选项的位置
  180.   #--------------------------------------------------------------------------
  181.   def select_last
  182.     select_symbol(@@last_command_symbol)
  183.   end
  184. end
  185.  
  186. #==============================================================================
  187. # ■ Window_MenuCommand
  188. #------------------------------------------------------------------------------
  189. #  技能是否遗忘
  190. #==============================================================================
  191. class Window_skill_forget_command < Window_Command
  192.   def initialize
  193.     super(100,120)
  194.     self.visible = false
  195.     self.active = false
  196.     @index = 0
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 生成指令列表
  200.   #--------------------------------------------------------------------------
  201.   def make_command_list
  202.     add_command("遗忘",:forget_skill)
  203.     add_command("取消",:cancel)
  204.   end
  205. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-15 21:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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