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

Project1

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

[已经解决] 关于技能树スキルツリ的报错求助

[复制链接]

Lv2.观梦者

梦石
0
星屑
453
在线时间
33 小时
注册时间
2017-10-4
帖子
38
跳转到指定楼层
1
发表于 2019-1-9 22:44:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
脚本如下:
RUBY 代码复制
  1. #===============================================================================
  2. #★ RGSS3 技能树(设定) Verα2.00(角色设定型)  by ヒール
  3. #-------------------------------------------------------------------------------
  4. # 一个技能树系统,可以链式学习新技能。
  5. # 通过消耗SP来学习新技能。
  6. #-------------------------------------------------------------------------------
  7. #以下为有关角色SP的脚本:
  8. #$game_variables[x] = $game_actors[角色ID].skill_point (设定x号变量用于存储某
  9. #                                                      角色的SP值)
  10. #$game_actors[角色ID].skill_point += 10(增加某角色10点SP)
  11. #
  12. #你也可以根据队伍id改变角色的SP值:
  13. #
  14. #$game_party.members[队伍id].skill_point
  15. #※队伍id=0 则为队长角色,id=1为队长后第一位角色,2为队长后第二位角色
  16. #
  17. # SceneManager.call(Scene_Skilltree)   
  18. # 显示技能树画面
  19. #-------------------------------------------------------------------------------
  20. #Ver1.01 同角色の別技能树の技能の習得が他の技能树の技能の習得を
  21. #可能にしていた不具合を修正しました。
  22. #-------------------------------------------------------------------------------
  23. #Ver2.00 大幅に改修し、自在な形の技能树の作成が可能になりました。
  24. #ただし、以前の设定は流用できません。
  25. #また、習得条件にレベルの设定が出来るようになりました。
  26. #===============================================================================
  27.  
  28. module Hi_ru_Skilltree
  29.   SKILL_LEARN_ME     = 'Audio/ME/Item'   #学习技能成功时的ME
  30.   SKILL_LEARN_VOLUME = 100               #ME的音量
  31.   SKILL_LEARN_PITCH  = 110               #ME的音调
  32.   LEVEL_COLOR        = 10                #需要等级的数字颜色
  33.   TREE =[]
  34.   TREE[10] = nil #0号角色无技能树
  35.  
  36.   #技能树指令的开关id
  37.   #开关开启时,会在菜单中显示"技能树"的指令
  38.   MENU_SWITCH = 10
  39.  
  40.   #技能树指令的文本。
  41.   MENU_COMMAND = "技能树"
  42.  
  43.   #有关技能树的变量。
  44.   #默认使用变量为10、11、12号变量。
  45.   VARIABLES = 10                #角色ID
  46.   CURRENT   = 11                #各种技能信息
  47.   TREE_ID   = 12                #技能树ID
  48.  
  49.   #默认的SP初始值
  50.   SP_DEFAULT = 1000
  51.  
  52.   #默认升级时获得的SP
  53.   SP_LEVELUP = 5
  54.  
  55.   #以下为每个角色的技能树设定。
  56.   #设定前请仔细阅读"技能树Ver2.00設定方法・注意.txt"和参考图片
  57.   #技能树的全部可用位置为:9行×6列,共54个.
  58.   #设定的行号必须小于或等于8,纵号小于或等于5。
  59.   #一个位置只能放置一个技能,否则无法成功运作。
  60.   #前提技能方向的设定:0 无条件, 2,4,6,8 为↓←→↑(小键盘的方向)
  61.   #当角色等级大于需要等级时,不会显示需要等级的数字。
  62.   #无需要等级时请设定为0。
  63.  
  64.    #TREE[角色ID] = [
  65.    #[技能树id,横号,纵号,前提技能方向,学会技能id,消耗SP,需要等级],
  66.    #]
  67.    #
  68.  
  69.    #1号角色的设定
  70.  
  71.    TREE[1] =[
  72.    [ 0, 0, 0, 0,  10,  5,  0],
  73.    [ 0, 1, 0, 4,  16, 10,  3],
  74.    [ 0, 2, 0, 4,  17, 12,  0],
  75.    [ 0, 3, 0, 4,  18, 14,  0],
  76.    [ 0, 4, 0, 4,  19, 16,  0],
  77.    [ 0, 5, 0, 4,  20, 18,  0],
  78.    [ 0, 6, 0, 4,  21, 20,  0],
  79.    [ 0, 7, 0, 4,  22, 24,  0],
  80.    [ 0, 8, 0, 4,  23, 28,  0],
  81.                                     #不一定非要空行,只是为了看起来更方便。
  82.    [ 0, 0, 1, 8,  11,  6,  2],
  83.    [ 0, 1, 1, 4,  24,  8,  0],
  84.    [ 0, 2, 1, 4,  25, 10,  0],
  85.    [ 0, 3, 1, 4,  26, 14,  0],
  86.    [ 0, 4, 1, 4,  27, 18,  0],
  87.    [ 0, 5, 1, 8,  61, 16,  0],
  88.    [ 0, 6, 1, 4,  62, 16,  0],
  89.    [ 0, 7, 1, 4,  54, 10,  0],
  90.    [ 0, 8, 1, 4,  48, 10,  0],
  91.  
  92.    [ 0, 0, 2, 8,  12,  7,  3],
  93.    [ 0, 1, 2, 4,  28, 10,  0],
  94.    [ 0, 2, 2, 4,  29, 13,  0],
  95.    [ 0, 3, 2, 4,  30, 16,  0],
  96.    [ 0, 4, 2, 8,  31, 20,  0],
  97.    [ 0, 5, 2, 8,  60, 16,  0],
  98.    [ 0, 6, 2, 4,  63, 16,  0],
  99.    [ 0, 7, 2, 4,  55, 13,  0],
  100.    [ 0, 8, 2, 4,  49, 13,  0],
  101.  
  102.    [ 0, 0, 3, 8,  13,  8,  6],
  103.    [ 0, 1, 3, 0,  32, 10,  0],
  104.    [ 0, 2, 3, 4,  33, 13,  0],
  105.    [ 0, 3, 3, 4,  34, 16,  0],
  106.    [ 0, 4, 3, 4,  35, 20,  0],
  107.    [ 0, 5, 3, 4,  58, 16,  0],
  108.    [ 0, 6, 3, 4,  59, 16,  0],
  109.    [ 0, 7, 3, 8,  56, 16,  0],
  110.    [ 0, 8, 3, 4,  50, 16,  0],
  111.  
  112.    [ 0, 0, 4, 8,  14,  9, 10],
  113.    [ 0, 1, 4, 4,  36, 10,  0],
  114.    [ 0, 2, 4, 4,  37, 13,  0],
  115.    [ 0, 3, 4, 4,  38, 16,  0],[ 0, 4, 4, 4,  39, 20,  0], #一行放两个也是ok的。
  116.    [ 0, 5, 4, 4,  52, 16,  0],
  117.    [ 0, 6, 4, 4,  53, 20,  0],
  118.    [ 0, 7, 4, 4,  57, 16,  0],
  119.    [ 0, 8, 4, 8,  51, 20,  0],
  120.  
  121.    [ 0, 0, 5, 6,  15, 15, 15],
  122.    [ 0, 1, 5, 6,  40, 10,  0],
  123.    [ 0, 2, 5, 6,  41, 13,  0],
  124.    [ 0, 3, 5, 6,  42, 16,  0],
  125.    [ 0, 4, 5, 8,  43, 20,  0],
  126.    [ 0, 5, 5, 4,  44, 25,  0],
  127.    [ 0, 6, 5, 4,  45, 30,  0],
  128.    [ 0, 7, 5, 4,  46, 35,  0],
  129.    [ 0, 8, 5, 4,  47, 40,135],
  130.  
  131.                                     #不一定非要空行,只是为了看起来更方便。
  132.    [ 1, 0, 0, 0,  64,  5,  0],          #下面为第二个技能树的设定。
  133.    [ 1, 1, 0, 4,  65,  6,  0],
  134.    [ 1, 2, 0, 4,  66,  7,  0],
  135.    [ 1, 3, 0, 4,  67,  8,  0],
  136.    [ 1, 4, 0, 4,  68,  9,  0],
  137.    [ 1, 5, 0, 4,  69, 15,  0],
  138.  
  139.    [ 2, 0, 0, 2,  63, 16,  0],
  140.    [ 2, 0, 1, 0, 126, 15,  0],
  141.    ]
  142.  
  143.    #2号角色的设定
  144.  
  145.    TREE[2] =[
  146.    [ 0, 0, 0, 0,  10,  5,  0],
  147.    [ 0, 1, 0, 4,  86, 10,  0],
  148.    [ 0, 2, 0, 4,  87, 12,  0],
  149.    [ 0, 3, 0, 4,  88, 14,  0],
  150.    [ 0, 4, 0, 4,  89, 16,  0],
  151.    [ 0, 5, 0, 4,  90, 18,  0],
  152.    [ 0, 6, 0, 4,  91, 20,  0],
  153.    [ 0, 7, 0, 4,  92, 24,  0],
  154.    [ 0, 8, 0, 4,  93, 28,  0],
  155.  
  156.    [ 0, 0, 1, 8,  81,  6,  0],
  157.    [ 0, 1, 1, 4,  94,  8,  0],
  158.    [ 0, 2, 1, 4,  95, 10,  0],
  159.    [ 0, 3, 1, 4,  96, 14,  0],
  160.    [ 0, 4, 1, 4,  97, 18,  0],
  161.    [ 0, 5, 1, 4,  82,  7,  0],
  162.    [ 0, 6, 1, 4,  83,  8,  0],
  163.    [ 0, 7, 1, 4,  84,  9,  0],
  164.    [ 0, 8, 1, 8,  85, 15,  0],
  165.  
  166.    [ 0, 0, 2, 8,  98, 10,  0],
  167.    [ 0, 1, 2, 4,  99, 13,  0],
  168.    [ 0, 2, 2, 4, 100, 16,  0],
  169.    [ 0, 3, 2, 4, 101, 20,  0],
  170.    [ 0, 4, 2, 4, 102, 10,  0],
  171.    [ 0, 5, 2, 4, 103, 13,  0],
  172.    [ 0, 6, 2, 4, 104, 16,  0],
  173.    [ 0, 7, 2, 4, 105, 20,  0],
  174.    [ 0, 8, 2, 8, 106, 10,  0],
  175.  
  176.    [ 0, 0, 3, 8, 107, 13,  0],
  177.    [ 0, 1, 3, 4, 108, 16,  0],
  178.    [ 0, 2, 3, 4, 109, 20,  0],
  179.    [ 0, 3, 3, 4, 110, 10,  0],
  180.    [ 0, 4, 3, 4, 111, 13,  0],
  181.    [ 0, 5, 3, 4, 112, 16,  0],
  182.    [ 0, 6, 3, 4, 113, 20,  0],
  183.    [ 0, 7, 3, 4, 114, 25,  0],
  184.    [ 0, 8, 3, 8, 115, 30,  0],
  185.  
  186.    [ 0, 0, 4, 8, 116, 35,  0],
  187.    [ 0, 1, 4, 4, 117, 40,  0],
  188.    [ 0, 2, 4, 4, 118, 10,  0],
  189.    [ 0, 3, 4, 4, 119, 13,  0],
  190.    [ 0, 4, 4, 4, 120, 16,  0],
  191.    [ 0, 5, 4, 4, 121, 20,  0],
  192.    [ 0, 6, 4, 4, 122, 16,  0],
  193.    [ 0, 7, 4, 4, 123, 20,  0],
  194.    [ 0, 8, 4, 4, 124, 10,  0],
  195.    ]
  196.  
  197.    #设定结束。
  198.  
  199. end



RUBY 代码复制
  1. #===============================================================================
  2. #★ RGSS3 技能树(本体) Verα2.00(角色設定型)  by ヒール
  3. #-------------------------------------------------------------------------------
  4. # 请将本脚本放在"技能树ーα2.00(设定)"之下。
  5. # 无需改变此脚本。(可以设定用语)
  6. #==============================================================================
  7. # ■ Game_Actor [class]
  8. #==============================================================================
  9. class Game_Actor < Game_Battler
  10.   #--------------------------------------------------------------------------
  11.   # ○ モジュールの設定
  12.   #--------------------------------------------------------------------------
  13.   include Hi_ru_Skilltree
  14.   #--------------------------------------------------------------------------
  15.   # ● 公開インスタンス変数
  16.   #--------------------------------------------------------------------------
  17.   attr_accessor :skill_point
  18.   #--------------------------------------------------------------------------
  19.   # ● セットアップ [エイリアス]
  20.   #     actor_id : アクター ID
  21.   #--------------------------------------------------------------------------
  22.   alias setup_skill_point setup
  23.   def setup(actor_id)
  24.     setup_skill_point(actor_id)
  25.     setup_skillpoint
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ○ SPのセットアップ
  29.   #--------------------------------------------------------------------------
  30.   def setup_skillpoint
  31.     @skill_point = SP_DEFAULT
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● レベルアップ
  35.   #--------------------------------------------------------------------------
  36.   alias level_up_skill_point level_up
  37.   def level_up
  38.     level_up_skill_point
  39.     @skill_point += SP_LEVELUP
  40.   end
  41. end
  42. #===============================================================================
  43. # ■ Scene_Skill_tree
  44. #===============================================================================
  45. class Scene_Skilltree < Scene_MenuBase
  46.   include Hi_ru_Skilltree
  47.   #--------------------------------------------------------------------------
  48.   # ● 開始処理
  49.   #--------------------------------------------------------------------------
  50.   def start
  51.     super
  52.     $game_variables[VARIABLES] = $game_party.members[0].actor.id #先頭のアクターで開始
  53.     $game_variables[TREE_ID]   = 0
  54.     create_help_window
  55.     create_task_window
  56.     #create_learn_window スキル習得ウインドウのみ直前で生成
  57.     create_info_window
  58.     create_tree_window
  59.     window_setting
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● ヘルプウィンドウの作成
  63.   #--------------------------------------------------------------------------
  64.   def create_help_window
  65.     @help_window = Window_Help.new
  66.     @help_window.viewport = @viewport
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● スキル習得ウインドウの作成
  70.   #--------------------------------------------------------------------------
  71.   def create_learn_window
  72.     wx = Graphics.width  / 2 - 180
  73.     wy = Graphics.height / 2 - 60
  74.     @learn_window = Window_Skill_learn.new(wx, wy)
  75.     @learn_window.unselect
  76.     @learn_window.deactivate
  77.     @learn_window.z  += 100
  78.     @learn_window.hide
  79.     @learn_window.set_handler(:ok,   method(:learn_ok))
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● タスクウィンドウの作成
  83.   #--------------------------------------------------------------------------
  84.   def create_task_window
  85.     wx = (Graphics.width - 180)/2
  86.     wy = 64
  87.     @task_window = Window_Skillpoint_Task.new(wx, wy)
  88.     @task_window.unselect
  89.     @task_window.deactivate
  90.     @task_window.z  += 100
  91.     @task_window.hide
  92.     @task_window.set_handler(:cancel,   method(:task_cancel))
  93.     @task_window.set_handler(:ok,   method(:task_ok))
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● インフォメーションウインドウの作成
  97.   #--------------------------------------------------------------------------
  98.   def create_info_window
  99.     @info_window = Window_info.new(0,Graphics.height-72,Graphics.width,72)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● ツリーウインドウの作成
  103.   #--------------------------------------------------------------------------
  104.   def create_tree_window
  105.     @tree_window = Window_tree.new(0,72,200)
  106.     @tree_window.set_handler(:cancel,   method(:tree_cancel))
  107.     @tree_window.set_handler(:ok,   method(:call_task))
  108.     @tree_window.set_handler(:pageup,   method(:treeq_downpage))
  109.     @tree_window.set_handler(:pagedown,   method(:treew_nextpage))
  110.     @tree_window.set_handler(:treeup,   method(:tree_up))
  111.     @tree_window.set_handler(:treedown,   method(:tree_down))
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● ウィンドウのセット
  115.   #--------------------------------------------------------------------------
  116.   def window_setting
  117.     @tree_window.help_window = @help_window
  118.     @tree_window.info_window = @info_window
  119.     @info_window.current_ext = @tree_window.current_ext
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● スキル選択ウインドウ[キャンセル]
  123.   #--------------------------------------------------------------------------
  124.   def tree_cancel
  125.     return_scene
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● タスクウィンドウ呼び出し
  129.   #--------------------------------------------------------------------------
  130.   def call_task
  131.     @tree_window.deactivate
  132.     @task_window.show
  133.     @task_window.activate
  134.     @task_window.refresh
  135.     @task_window.select(0)
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● アクターの切り替え
  139.   #--------------------------------------------------------------------------
  140.   def treeq_downpage
  141.     $game_variables[TREE_ID] = 0
  142.     chara_current = $game_variables[VARIABLES]
  143.     loopx = $game_party.members.size - 1
  144.     for i in 0..loopx
  145.       if chara_current == $game_party.members[i].actor.id
  146.         unless i == 0
  147.           chara_next = $game_party.members[i-1].actor.id
  148.         else
  149.           chara_next = $game_party.members[loopx].actor.id
  150.         end
  151.         break
  152.       end
  153.     end
  154.     $game_variables[VARIABLES] = chara_next
  155.     @help_window.refresh
  156.     @info_window.refresh
  157.     @tree_window.refresh
  158.     @tree_window.select(0)
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● アクターの切り替え
  162.   #--------------------------------------------------------------------------
  163.   def treew_nextpage
  164.     $game_variables[TREE_ID] = 0
  165.     chara_current = $game_variables[VARIABLES]
  166.     loopx = $game_party.members.size - 1
  167.     for i in 0..loopx
  168.       if chara_current == $game_party.members[i].actor.id
  169.         unless i == loopx
  170.           chara_next = $game_party.members[i+1].actor.id
  171.         else
  172.           chara_next = $game_party.members[0].actor.id
  173.         end
  174.         break
  175.       end
  176.     end
  177.     $game_variables[VARIABLES] = chara_next
  178.     @help_window.refresh
  179.     @info_window.refresh
  180.     @tree_window.refresh
  181.     @tree_window.select(0)
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● ツリーの切り替え
  185.   #--------------------------------------------------------------------------
  186.   def tree_up
  187.     @help_window.refresh
  188.     @info_window.refresh
  189.     @tree_window.refresh
  190.     @tree_window.select(0)
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● ツリーの切り替え
  194.   #--------------------------------------------------------------------------
  195.   def tree_down
  196.     @help_window.refresh
  197.     @info_window.refresh
  198.     @tree_window.refresh
  199.     @tree_window.select(0)
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ● タスクウィンドウの消去
  203.   #--------------------------------------------------------------------------
  204.   def close_task
  205.     @task_window.hide
  206.     @task_window.deactivate
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● スキル習得ウィンドウ呼び出し
  210.   #--------------------------------------------------------------------------
  211.   def call_learn
  212.     @learn_window.show
  213.     @learn_window.activate
  214.     @learn_window.refresh
  215.     @learn_window.select(0)
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● スキル習得ウィンドウの消去
  219.   #--------------------------------------------------------------------------
  220.   def close_learn
  221.     @learn_window.hide
  222.     @learn_window.deactivate
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● スキル習得ウィンドウ[決定]
  226.   #--------------------------------------------------------------------------
  227.   def learn_ok
  228.     case @learn_window.index
  229.     when 0
  230.       close_learn
  231.       @tree_window.activate
  232.       @help_window.refresh
  233.       @info_window.refresh
  234.       @tree_window.refresh
  235.     end
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● タスクウィンドウ[習得する]
  239.   #--------------------------------------------------------------------------
  240.   def task_ok
  241.     case @task_window.index
  242.     when 0
  243.       $game_actors[$game_variables[VARIABLES]].learn_skill($game_variables[CURRENT][0])
  244.       $game_actors[$game_variables[VARIABLES]].skill_point -= $game_variables[CURRENT][1]
  245.       close_task
  246.       @help_window.refresh
  247.       @info_window.refresh
  248.       @tree_window.refresh
  249.       create_learn_window
  250.       call_learn
  251.     when 1
  252.       close_task
  253.       @tree_window.activate
  254.       @help_window.refresh
  255.       @info_window.refresh
  256.       @tree_window.refresh
  257.     end
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● タスクウィンドウ[キャンセル]
  261.   #--------------------------------------------------------------------------
  262.   def task_cancel
  263.     close_task
  264.     @tree_window.activate
  265.     @help_window.refresh
  266.     @tree_window.refresh
  267.     @tree_window.refresh  
  268.   end
  269. end
  270.  
  271. #==============================================================================
  272. # ■ Window_tree
  273. #------------------------------------------------------------------------------
  274. #  メイン部分のウインドウです。
  275. #==============================================================================
  276. class Window_tree< Window_Command
  277.   include Hi_ru_Skilltree
  278.   attr_accessor :info_window
  279.   #--------------------------------------------------------------------------
  280.   # ● オブジェクト初期化
  281.   #--------------------------------------------------------------------------
  282.   def initialize(x,y,height)
  283.     @window_height = 292
  284.     super(x,y)
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ● 桁数の取得
  288.   #--------------------------------------------------------------------------
  289.   def col_max
  290.     return 9
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # ● 横に項目が並ぶときの空白の幅を取得
  294.   #--------------------------------------------------------------------------
  295.   def spacing
  296.     return 28
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ● 項目の幅を取得
  300.   #--------------------------------------------------------------------------
  301.   def item_width
  302.     26
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 項目の高さを取得
  306.   #--------------------------------------------------------------------------
  307.   def item_height
  308.     26
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● ウィンドウ幅の取得
  312.   #--------------------------------------------------------------------------
  313.   def window_width
  314.     Graphics.width
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● ウィンドウ高さの取得
  318.   #--------------------------------------------------------------------------
  319.   def window_height
  320.     Graphics.height - 144
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● カーソルの更新
  324.   #--------------------------------------------------------------------------
  325.   def update_cursor
  326.     #カーソル描画フラグ
  327.     @flag_cursor = 1
  328.  
  329.     if @cursor_all
  330.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  331.       self.top_row = 0
  332.     elsif @index < 0
  333.       cursor_rect.empty
  334.     else
  335.       ensure_cursor_visible
  336.       cursor_rect.set(item_rect(@index))
  337.     end
  338.     #カーソル描画フラグ
  339.     @flag_cursor = 0
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 項目を描画する矩形の取得
  343.   #--------------------------------------------------------------------------
  344.   def item_rect(index)
  345.     if @flag_cursor == 1
  346.       draw_x = 0
  347.     else  
  348.       draw_x = 40
  349.     end  
  350.     rect = Rect.new
  351.     rect.width = item_width - draw_x
  352.     rect.height = item_height
  353.     rect.x = index % col_max * (item_width + spacing) + draw_x + 48
  354.     rect.y = index / col_max * (item_height + spacing/2 +1)
  355.     rect
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 項目の描画
  359.   #--------------------------------------------------------------------------
  360.   def draw_item(index)
  361.     change_color(normal_color, command_enabled?(index))
  362.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● コマンドリストの作成
  366.   #--------------------------------------------------------------------------
  367.   def make_command_list
  368.     a     = $game_variables[VARIABLES]
  369.    loopx = TREE[a].size - 1
  370.    check = []
  371.    exts  = []
  372.     for j in (0..loopx)
  373.       next if TREE[a][j][0] != $game_variables[TREE_ID]
  374.       branch   = TREE[a][j][1]
  375.       order    = TREE[a][j][2]
  376.       before   = TREE[a][j][3]
  377.       ext      = [TREE[a][j][4],TREE[a][j][5],branch,order,before,TREE[a][j][6]]
  378.       calculate = 9 * order + branch + 1
  379.       check[calculate] = true if branch <= 8
  380.       exts[calculate]  = ext
  381.     end
  382.     for i in (1..54)
  383.       add_command("", :ok, check[i],exts[i])
  384.     end
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● 決定やキャンセルなどのハンドリング処理
  388.   #--------------------------------------------------------------------------
  389.   def process_handling
  390.     return unless open? && active
  391.     return process_ok       if ok_enabled?        && Input.trigger?(:C)
  392.     return process_cancel   if cancel_enabled?    && Input.trigger?(:B)
  393.     return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
  394.     return process_pageup   if handle?(:pageup)   && Input.trigger?(:L)
  395.     return process_treeup   if Input.trigger?(:Y)
  396.     return process_treedown if Input.trigger?(:Z)
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● カーソル位置の設定
  400.   #--------------------------------------------------------------------------
  401.   def index=(index)
  402.     @index = index
  403.     update_cursor
  404.     call_update_help
  405.     @info_window.current_ext = current_ext if @info_window
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● カーソルを下に移動
  409.   #--------------------------------------------------------------------------
  410.   def cursor_down(wrap = false)
  411.     if index < item_max - col_max || (wrap && col_max == 1)
  412.       select((index + col_max) % item_max)
  413.      for c in 1..100
  414.       if current_item_enabled?
  415.         break
  416.       end
  417.         select((index + col_max) % item_max)
  418.       end
  419.     end
  420.   end
  421.   #--------------------------------------------------------------------------
  422.   # ● カーソルを上に移動
  423.   #--------------------------------------------------------------------------
  424.   def cursor_up(wrap = false)
  425.     if index >= col_max || (wrap && col_max == 1)
  426.       select((index - col_max + item_max) % item_max)
  427.      for c in 1..100
  428.       if current_item_enabled?
  429.         break
  430.       end
  431.         select((index - col_max + item_max) % item_max)
  432.       end
  433.     end
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● カーソルを右に移動
  437.   #--------------------------------------------------------------------------
  438.   def cursor_right(wrap = false)
  439.     if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
  440.       select((index + 1) % item_max)
  441.       for c in 1..100
  442.       if current_item_enabled?
  443.         break
  444.       end
  445.         select((index + 1) % item_max)
  446.       end
  447.     end
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● カーソルを左に移動
  451.   #--------------------------------------------------------------------------
  452.   def cursor_left(wrap = false)
  453.     if col_max >= 2 && (index > 0 || (wrap && horizontal?))
  454.       select((index - 1 + item_max) % item_max)
  455.       for c in 1..100
  456.       if current_item_enabled?
  457.         break
  458.       end
  459.         select((index - 1 + item_max) % item_max)
  460.       end
  461.     end
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● L ボタン(PageUp)が押されたときの処理
  465.   #--------------------------------------------------------------------------
  466.   def process_pageup
  467.     Sound.play_cursor
  468.     Input.update
  469.     call_handler(:pageup)
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   # ● R ボタン(PageDown)が押されたときの処理
  473.   #--------------------------------------------------------------------------
  474.   def process_pagedown
  475.     Sound.play_cursor
  476.     Input.update
  477.     call_handler(:pagedown)
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● Y ボタン(TreeUp)が押されたときの処理
  481.   #--------------------------------------------------------------------------
  482.   def process_treeup
  483.     a     = $game_variables[VARIABLES]
  484.     loopx = TREE[a].size - 1
  485.     tree_next = 0
  486.     for i in (0..loopx)
  487.       tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
  488.     end
  489.     unless $game_variables[TREE_ID] == 0
  490.       $game_variables[TREE_ID] -= 1
  491.     else
  492.       $game_variables[TREE_ID] = tree_next
  493.     end
  494.     Sound.play_cursor
  495.     Input.update
  496.     call_handler(:treeup)
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ● Z ボタン(TreeDown)が押されたときの処理
  500.   #--------------------------------------------------------------------------
  501.   def process_treedown
  502.     a     = $game_variables[VARIABLES]
  503.     loopx = TREE[a].size - 1
  504.     tree_next = 0
  505.     for i in (0..loopx)
  506.       tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
  507.     end
  508.     unless $game_variables[TREE_ID] == tree_next
  509.       $game_variables[TREE_ID] += 1
  510.     else
  511.       $game_variables[TREE_ID] = 0
  512.     end
  513.     Sound.play_cursor
  514.     Input.update
  515.     call_handler(:treedown)
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● リフレッシュ
  519.   #--------------------------------------------------------------------------
  520.   def refresh
  521.     clear_command_list
  522.     make_command_list
  523.     create_contents
  524.     super
  525.     draw_icon_bar
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   # ● 各種描画
  529.   #--------------------------------------------------------------------------
  530.   def draw_icon_bar
  531.     a     = $game_variables[VARIABLES]
  532.     loopx = TREE[a].size - 1
  533.     d     = $game_actors[a].level
  534.     self.contents.font.size = 16
  535.  
  536.     for i in (0..loopx)
  537.       next if TREE[a][i][0] != $game_variables[TREE_ID]
  538.       branch   = TREE[a][i][1] * 54
  539.       order    = TREE[a][i][2] * 41
  540.       skill_id = TREE[a][i][4]
  541.       icon_index = $data_skills[skill_id].icon_index
  542.       if $game_actors[a].skill_learn?($data_skills[skill_id])
  543.         learn = true
  544.       else
  545.         learn = false
  546.       end
  547.       change_color(text_color(LEVEL_COLOR))
  548.       draw_text(branch+40,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 1  && TREE[a][i][6] <10
  549.       draw_text(branch+34,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 10 && TREE[a][i][6] <100
  550.       draw_text(branch+28,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 100
  551.       draw_icon(icon_index,48+branch,order,learn)
  552.     end
  553.     change_color(normal_color)
  554.  
  555.     for i in (0..loopx)
  556.       next if TREE[a][i][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  557.       branch   = TREE[a][i][1]
  558.       order    = TREE[a][i][2]
  559.       before   = TREE[a][i][3]
  560.       if before == 2 || before == 8
  561.        for j in (0..loopx)
  562.          next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  563.          next if branch  != TREE[a][j][1]
  564.          next if order   != (TREE[a][j][2] - 1) && before == 2
  565.          next if order   != (TREE[a][j][2] + 1) && before == 8
  566.          skill_id = TREE[a][j][4]
  567.          if $game_actors[a].skill_learn?($data_skills[skill_id])
  568.            colors = hp_gauge_color1
  569.          else
  570.            colors = text_color(8)
  571.          end
  572.          contents.fill_rect(58+branch*54,27+(order-1)*41,3,12,colors) if before == 8
  573.          contents.fill_rect(58+branch*54,27+order*41,3,12,colors) if before == 2
  574.         end
  575.       elsif before == 4 || before == 6
  576.         for j in (0..loopx)
  577.           next if TREE[a][j][0] != $game_variables[TREE_ID]
  578.           next if branch  != (TREE[a][j][1] - 1) && before == 6
  579.           next if branch  != (TREE[a][j][1] + 1) && before == 4
  580.           next if order   != TREE[a][j][2]
  581.           skill_id = TREE[a][j][4]
  582.           if $game_actors[a].skill_learn?($data_skills[skill_id])
  583.             colors = hp_gauge_color1
  584.           else
  585.             colors = text_color(8)
  586.           end
  587.         contents.fill_rect(22+branch*54,15+order*41,24,3,colors) if before == 4
  588.         contents.fill_rect(22+(branch+1)*54,15+order*41,24,3,colors) if before == 6
  589.         end
  590.       end
  591.     end
  592.  
  593.     chr = $game_actors[a]
  594.     draw_character(chr.character_name, chr.character_index, 16, 32)
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  598.   #--------------------------------------------------------------------------
  599.   def call_update_help
  600.     update_help if active && @help_window
  601.   end
  602.   #--------------------------------------------------------------------------
  603.   # ● ヘルプウィンドウの更新
  604.   #--------------------------------------------------------------------------
  605.   def update_help
  606.     @help_window.clear
  607.       @help_window.set_item($data_skills[current_ext[0]]) unless current_ext == nil
  608.   end
  609. end
  610.  
  611. #==============================================================================
  612. # ■ Window_info
  613. #==============================================================================
  614. class Window_info < Window_Base
  615.   include Hi_ru_Skilltree
  616.   attr_accessor :current_ext
  617.   #--------------------------------------------------------------------------
  618.   # ● 現在情報の設定
  619.   #--------------------------------------------------------------------------
  620.   def current_ext=(current_ext)
  621.     return if @current_ext == current_ext
  622.     @current_ext = current_ext
  623.     refresh
  624.   end
  625.  
  626.   #--------------------------------------------------------------------------
  627.   # ● リフレッシュ
  628.   #--------------------------------------------------------------------------
  629.   def refresh
  630.     contents.clear
  631.     unless current_ext == nil
  632.     change_color(normal_color)
  633.      @stype_id = $data_skills[current_ext[0]].stype_id
  634.     draw_text(0,0, 54, 24," #{$data_system.skill_types[@stype_id]}:")
  635.     draw_text(54,0, 180, 24, $data_skills[current_ext[0]].name)
  636.     $game_variables[CURRENT] = []
  637.     $game_variables[CURRENT] = [current_ext[0],current_ext[1],current_ext[2],current_ext[3],current_ext[4],current_ext[5]]
  638.  
  639.     change_color(mp_cost_color)
  640.     draw_text(260,0, Graphics.width, 24, $data_skills[current_ext[0]].mp_cost)
  641.     change_color(normal_color)
  642.     draw_text(288,0, Graphics.width, 24, "/")
  643.     change_color(tp_cost_color)
  644.     draw_text(300,0, Graphics.width, 24, $data_skills[current_ext[0]].tp_cost)
  645.     change_color(normal_color)
  646.  
  647.     draw_text(348,0,Graphics.width, 24,"SP:")
  648.     self.contents.font.size = 24
  649.     sizex = 27
  650.     sizex = 18 if current_ext[1] >= 10
  651.     sizex = 9 if current_ext[1] >= 100
  652.     sizex = 0  if current_ext[1] >= 1000
  653.     draw_text(390+sizex,0,48, 24, current_ext[1])
  654.     self.contents.font.size = 28
  655.     draw_text(430,0,Graphics.width, 24, "/")
  656.     draw_text(440,0,Graphics.width, 24, $game_actors[$game_variables[VARIABLES]].skill_point)
  657.     self.contents.font.size = 24
  658.     draw_text(0,24,Graphics.width,24," Q,W键:切换角色  S,D键:切换技能树")
  659.  
  660.     end
  661.   end
  662. end
  663.  
  664. #==============================================================================
  665. # ■ Window_Skillpoint_Task
  666. #------------------------------------------------------------------------------
  667. #  スキルの習得に関する選択肢を表示するウィンドウです。
  668. #==============================================================================
  669. class Window_Skillpoint_Task < Window_Command
  670.   include Hi_ru_Skilltree
  671.   #--------------------------------------------------------------------------
  672.   # ● オブジェクト初期化
  673.   #--------------------------------------------------------------------------
  674.   def initialize(x, y)
  675.     super(x, y)
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ● ウィンドウ幅の取得
  679.   #--------------------------------------------------------------------------
  680.   def window_width
  681.     return 240
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● 決定ボタンが押されたときの処理
  685.   #--------------------------------------------------------------------------
  686.   def process_ok
  687.     if current_item_enabled?
  688.       Input.update
  689.       deactivate
  690.       call_ok_handler
  691.     else
  692.       Sound.play_buzzer
  693.     end
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● コマンドリストの作成
  697.   #--------------------------------------------------------------------------
  698.   def make_command_list
  699.     a     = $game_variables[VARIABLES]
  700.     loopx = TREE[a].size - 1
  701.     can   = false
  702.     branch   = $game_variables[CURRENT][2]
  703.     order    = $game_variables[CURRENT][3]
  704.     before   = $game_variables[CURRENT][4]
  705.  
  706.     if before == 2 || before == 8
  707.       for j in (0..loopx)
  708.         next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  709.         next if branch  != TREE[a][j][1]
  710.         next if order   != (TREE[a][j][2] - 1) && before == 2
  711.         next if order   != (TREE[a][j][2] + 1) && before == 8
  712.         skill_id = TREE[a][j][4]
  713.         if $game_actors[a].skill_learn?($data_skills[skill_id])
  714.           can = true
  715.         end
  716.       end
  717.     end
  718.     if before == 4 || before == 6
  719.       for j in (0..loopx)
  720.         next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  721.         next if branch  != (TREE[a][j][1] - 1) && before == 6
  722.         next if branch  != (TREE[a][j][1] + 1) && before == 4
  723.         next if order   != TREE[a][j][2]
  724.         skill_id = TREE[a][j][4]
  725.         if $game_actors[a].skill_learn?($data_skills[skill_id])
  726.           can = true
  727.         end
  728.       end
  729.     end
  730.     can = true if before == 0
  731.  
  732.     if can == true
  733.       unless $game_actors[$game_variables[VARIABLES]].skill_learn?($data_skills[$game_variables[CURRENT][0]])
  734.         if $game_variables[CURRENT][5] > $game_actors[a].level
  735.           add_command("等级不足", :ok, false, 1)
  736.         elsif $game_actors[$game_variables[VARIABLES]].skill_point >= $game_variables[CURRENT][1]
  737.           add_command("学习该技能!", :ok, true, 1)
  738.         else
  739.           add_command("技能点不足", :ok, false, 1)
  740.         end
  741.       else
  742.         add_command("已经学会该技能了", :ok, false, 1)
  743.       end
  744.     else
  745.       add_command("需要前提技能", :ok, false, 1)
  746.     end
  747.     add_command("取消", :ok, true, 2)
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # ● リフレッシュ
  751.   #--------------------------------------------------------------------------
  752.   def refresh
  753.     clear_command_list
  754.     make_command_list
  755.     create_contents
  756.     self.height = window_height
  757.     select(0)
  758.     super
  759.   end
  760. end
  761.  
  762. class Window_Skill_learn < Window_Command
  763.   include Hi_ru_Skilltree
  764.   #--------------------------------------------------------------------------
  765.   # ● オブジェクト初期化
  766.   #--------------------------------------------------------------------------
  767.   def initialize(x, y)
  768.     super(x, y)
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● ウィンドウ幅の取得
  772.   #--------------------------------------------------------------------------
  773.   def window_width
  774.     360
  775.   end
  776.   #--------------------------------------------------------------------------
  777.   # ● ウィンドウ高さの取得
  778.   #--------------------------------------------------------------------------
  779.   def window_height
  780.     72
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 項目の幅を取得
  784.   #--------------------------------------------------------------------------
  785.   def item_width
  786.     1
  787.   end
  788.   #--------------------------------------------------------------------------
  789.   # ● 項目の高さを取得
  790.   #--------------------------------------------------------------------------
  791.   def item_height
  792.     1
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● コマンドリストの作成
  796.   #--------------------------------------------------------------------------
  797.   def make_command_list
  798.      add_command("", :ok, true, 1) #エラー回避
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # ● リフレッシュ
  802.   #--------------------------------------------------------------------------
  803.   def refresh
  804.     clear_command_list
  805.     make_command_list
  806.     create_contents
  807.     self.height = window_height
  808.     select(0)
  809.     super
  810.     draw_learn
  811.     Audio.me_stop
  812.     Audio.me_play(SKILL_LEARN_ME, SKILL_LEARN_VOLUME, SKILL_LEARN_PITCH)
  813.   end
  814.   #--------------------------------------------------------------------------
  815.   # ● 各種描画
  816.   #--------------------------------------------------------------------------
  817.   def draw_learn
  818.     icon_index = $data_skills[$game_variables[CURRENT][0]].icon_index
  819.     draw_icon(icon_index,0,0,true)
  820.     draw_text(32,0,320,24,$data_skills[$game_variables[CURRENT][0]].name + " 已被学会!")
  821.     draw_text(80,24,200,24,"SP")
  822.     draw_text(120,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point + $game_variables[CURRENT][1])
  823.     draw_text(160,24,24,24,"→")
  824.     draw_text(190,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point)
  825.   end
  826. end
  827.  
  828. #==============================================================================
  829. # ■ Scene_Menu
  830. #------------------------------------------------------------------------------
  831. #  メニュー画面の処理を行うクラスです。
  832. #==============================================================================
  833. class Scene_Menu < Scene_MenuBase
  834.   #--------------------------------------------------------------------------
  835.   # ● コマンドウィンドウの作成
  836.   #--------------------------------------------------------------------------
  837.   alias skilltree_create_command_window create_command_window
  838.   def create_command_window
  839.     skilltree_create_command_window
  840.     @command_window.set_handler(:skill_tree_go,    method(:command_skill_tree))
  841.   end
  842.   #--------------------------------------------------------------------------
  843.   # ○ コマンド[スキルツリー]
  844.   #--------------------------------------------------------------------------
  845.   def command_skill_tree
  846.     SceneManager.call(Scene_Skilltree)
  847.   end
  848. end
  849. #==============================================================================
  850. # ■ Window_MenuCommand
  851. #------------------------------------------------------------------------------
  852. #  メニュー画面で表示するコマンドウィンドウです。
  853. #==============================================================================
  854. class Window_MenuCommand
  855.   #--------------------------------------------------------------------------
  856.   # ● 独自コマンドの追加用
  857.   #--------------------------------------------------------------------------
  858.   alias skilltree_add_original_commands add_original_commands
  859.   def add_original_commands
  860.     skilltree_add_original_commands
  861.     if $game_switches[Hi_ru_Skilltree::MENU_SWITCH]
  862.       add_command(Hi_ru_Skilltree::MENU_COMMAND, :skill_tree_go, true)
  863.     end
  864.   end
  865. end


设定了10号角色没有技能树

然后进游戏加入10号角色后打开技能树会显示


求助这是因为什么问题……


Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

2
发表于 2019-1-9 23:49:55 | 只看该作者
脚本正常运行的话,技能树会是数组,数组是有size方法的。
但是你把他的技能树设置成了nil,nil没有size这个方法,就报错了。

你可以试试把nil改成[0]

评分

参与人数 1星屑 +20 收起 理由
VIPArcher + 20 认可答案

查看全部评分

用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
453
在线时间
33 小时
注册时间
2017-10-4
帖子
38
3
 楼主| 发表于 2019-1-10 00:05:38 | 只看该作者
KB.Driver 发表于 2019-1-9 23:49
脚本正常运行的话,技能树会是数组,数组是有size方法的。
但是你把他的技能树设置成了nil,nil没有size这个 ...

谢谢帮助,改成[]就不会报错了。
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

4
发表于 2019-1-10 00:22:14 | 只看该作者
本帖最后由 KB.Driver 于 2019-1-10 00:27 编辑
melatin 发表于 2019-1-10 00:05
谢谢帮助,改成[]就不会报错了。


当然,还有一个邪道方法,就是在NilClass中定义size方法
RUBY 代码复制
  1. class NilClass;def size;0;end;end


在这个脚本中这样修改后也能运行,但是毕竟有潜在的隐患。
可以输出一段文字到控制台提醒编程者。
RUBY 代码复制
  1. class NilClass
  2.   def size
  3.     puts "调用了NilClass#size -> 0,此方法存在隐患。如果其他脚本功能异常请检查此处。"
  4.     0
  5.   end
  6. end
用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
453
在线时间
33 小时
注册时间
2017-10-4
帖子
38
5
 楼主| 发表于 2019-1-10 11:31:49 | 只看该作者
KB.Driver 发表于 2019-1-10 00:22
当然,还有一个邪道方法,就是在NilClass中定义size方法
class NilClass;def size;0;end;end[/p ...

好的,多谢大神点拨~~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-24 03:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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