查看: 2314|回复: 4

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

[复制链接]
梦石
0
星屑
453
在线时间
33 小时
注册时间
2017-10-4
回帖
24
发表于 2019-1-9 22:44:31 | 显示全部楼层 |阅读模式

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

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

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


  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. # ■ Window_tree
  272. #------------------------------------------------------------------------------
  273. #  メイン部分のウインドウです。
  274. #==============================================================================
  275. class Window_tree< Window_Command
  276.   include Hi_ru_Skilltree
  277.   attr_accessor :info_window
  278.   #--------------------------------------------------------------------------
  279.   # ● オブジェクト初期化
  280.   #--------------------------------------------------------------------------
  281.   def initialize(x,y,height)
  282.     @window_height = 292
  283.     super(x,y)
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 桁数の取得
  287.   #--------------------------------------------------------------------------
  288.   def col_max
  289.     return 9
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 横に項目が並ぶときの空白の幅を取得
  293.   #--------------------------------------------------------------------------
  294.   def spacing
  295.     return 28
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 項目の幅を取得
  299.   #--------------------------------------------------------------------------
  300.   def item_width
  301.     26
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ● 項目の高さを取得
  305.   #--------------------------------------------------------------------------
  306.   def item_height
  307.     26
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● ウィンドウ幅の取得
  311.   #--------------------------------------------------------------------------
  312.   def window_width
  313.     Graphics.width
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● ウィンドウ高さの取得
  317.   #--------------------------------------------------------------------------
  318.   def window_height
  319.     Graphics.height - 144
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● カーソルの更新
  323.   #--------------------------------------------------------------------------
  324.   def update_cursor
  325.     #カーソル描画フラグ
  326.     @flag_cursor = 1
  327.    
  328.     if @cursor_all
  329.       cursor_rect.set(0, 0, contents.width, row_max * item_height)
  330.       self.top_row = 0
  331.     elsif @index < 0
  332.       cursor_rect.empty
  333.     else
  334.       ensure_cursor_visible
  335.       cursor_rect.set(item_rect(@index))
  336.     end
  337.     #カーソル描画フラグ
  338.     @flag_cursor = 0
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ● 項目を描画する矩形の取得
  342.   #--------------------------------------------------------------------------
  343.   def item_rect(index)
  344.     if @flag_cursor == 1
  345.       draw_x = 0
  346.     else  
  347.       draw_x = 40
  348.     end  
  349.     rect = Rect.new
  350.     rect.width = item_width - draw_x
  351.     rect.height = item_height
  352.     rect.x = index % col_max * (item_width + spacing) + draw_x + 48
  353.     rect.y = index / col_max * (item_height + spacing/2 +1)
  354.     rect
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ● 項目の描画
  358.   #--------------------------------------------------------------------------
  359.   def draw_item(index)
  360.     change_color(normal_color, command_enabled?(index))
  361.     draw_text(item_rect_for_text(index), command_name(index), alignment)
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● コマンドリストの作成
  365.   #--------------------------------------------------------------------------
  366.   def make_command_list
  367.     a     = $game_variables[VARIABLES]
  368.    loopx = TREE[a].size - 1
  369.    check = []
  370.    exts  = []
  371.     for j in (0..loopx)
  372.       next if TREE[a][j][0] != $game_variables[TREE_ID]
  373.       branch   = TREE[a][j][1]
  374.       order    = TREE[a][j][2]
  375.       before   = TREE[a][j][3]
  376.       ext      = [TREE[a][j][4],TREE[a][j][5],branch,order,before,TREE[a][j][6]]
  377.       calculate = 9 * order + branch + 1
  378.       check[calculate] = true if branch <= 8
  379.       exts[calculate]  = ext
  380.     end
  381.     for i in (1..54)
  382.       add_command("", :ok, check[i],exts[i])
  383.     end
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # ● 決定やキャンセルなどのハンドリング処理
  387.   #--------------------------------------------------------------------------
  388.   def process_handling
  389.     return unless open? && active
  390.     return process_ok       if ok_enabled?        && Input.trigger?(:C)
  391.     return process_cancel   if cancel_enabled?    && Input.trigger?(:B)
  392.     return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
  393.     return process_pageup   if handle?(:pageup)   && Input.trigger?(:L)
  394.     return process_treeup   if Input.trigger?(:Y)
  395.     return process_treedown if Input.trigger?(:Z)
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● カーソル位置の設定
  399.   #--------------------------------------------------------------------------
  400.   def index=(index)
  401.     @index = index
  402.     update_cursor
  403.     call_update_help
  404.     @info_window.current_ext = current_ext if @info_window
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # ● カーソルを下に移動
  408.   #--------------------------------------------------------------------------
  409.   def cursor_down(wrap = false)
  410.     if index < item_max - col_max || (wrap && col_max == 1)
  411.       select((index + col_max) % item_max)
  412.      for c in 1..100
  413.       if current_item_enabled?
  414.         break
  415.       end
  416.         select((index + col_max) % item_max)
  417.       end
  418.     end
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● カーソルを上に移動
  422.   #--------------------------------------------------------------------------
  423.   def cursor_up(wrap = false)
  424.     if index >= col_max || (wrap && col_max == 1)
  425.       select((index - col_max + item_max) % item_max)
  426.      for c in 1..100
  427.       if current_item_enabled?
  428.         break
  429.       end
  430.         select((index - col_max + item_max) % item_max)
  431.       end
  432.     end
  433.   end
  434.   #--------------------------------------------------------------------------
  435.   # ● カーソルを右に移動
  436.   #--------------------------------------------------------------------------
  437.   def cursor_right(wrap = false)
  438.     if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
  439.       select((index + 1) % item_max)
  440.       for c in 1..100
  441.       if current_item_enabled?
  442.         break
  443.       end
  444.         select((index + 1) % item_max)
  445.       end
  446.     end
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   # ● カーソルを左に移動
  450.   #--------------------------------------------------------------------------
  451.   def cursor_left(wrap = false)
  452.     if col_max >= 2 && (index > 0 || (wrap && horizontal?))
  453.       select((index - 1 + item_max) % item_max)
  454.       for c in 1..100
  455.       if current_item_enabled?
  456.         break
  457.       end
  458.         select((index - 1 + item_max) % item_max)
  459.       end
  460.     end
  461.   end
  462.   #--------------------------------------------------------------------------
  463.   # ● L ボタン(PageUp)が押されたときの処理
  464.   #--------------------------------------------------------------------------
  465.   def process_pageup
  466.     Sound.play_cursor
  467.     Input.update
  468.     call_handler(:pageup)
  469.   end
  470.   #--------------------------------------------------------------------------
  471.   # ● R ボタン(PageDown)が押されたときの処理
  472.   #--------------------------------------------------------------------------
  473.   def process_pagedown
  474.     Sound.play_cursor
  475.     Input.update
  476.     call_handler(:pagedown)
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● Y ボタン(TreeUp)が押されたときの処理
  480.   #--------------------------------------------------------------------------
  481.   def process_treeup
  482.     a     = $game_variables[VARIABLES]
  483.     loopx = TREE[a].size - 1
  484.     tree_next = 0
  485.     for i in (0..loopx)
  486.       tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
  487.     end
  488.     unless $game_variables[TREE_ID] == 0
  489.       $game_variables[TREE_ID] -= 1
  490.     else
  491.       $game_variables[TREE_ID] = tree_next
  492.     end
  493.     Sound.play_cursor
  494.     Input.update
  495.     call_handler(:treeup)
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # ● Z ボタン(TreeDown)が押されたときの処理
  499.   #--------------------------------------------------------------------------
  500.   def process_treedown
  501.     a     = $game_variables[VARIABLES]
  502.     loopx = TREE[a].size - 1
  503.     tree_next = 0
  504.     for i in (0..loopx)
  505.       tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
  506.     end
  507.     unless $game_variables[TREE_ID] == tree_next
  508.       $game_variables[TREE_ID] += 1
  509.     else
  510.       $game_variables[TREE_ID] = 0
  511.     end
  512.     Sound.play_cursor
  513.     Input.update
  514.     call_handler(:treedown)
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ● リフレッシュ
  518.   #--------------------------------------------------------------------------
  519.   def refresh
  520.     clear_command_list
  521.     make_command_list
  522.     create_contents
  523.     super
  524.     draw_icon_bar
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # ● 各種描画
  528.   #--------------------------------------------------------------------------
  529.   def draw_icon_bar
  530.     a     = $game_variables[VARIABLES]
  531.     loopx = TREE[a].size - 1
  532.     d     = $game_actors[a].level
  533.     self.contents.font.size = 16
  534.    
  535.     for i in (0..loopx)
  536.       next if TREE[a][i][0] != $game_variables[TREE_ID]
  537.       branch   = TREE[a][i][1] * 54
  538.       order    = TREE[a][i][2] * 41
  539.       skill_id = TREE[a][i][4]
  540.       icon_index = $data_skills[skill_id].icon_index
  541.       if $game_actors[a].skill_learn?($data_skills[skill_id])
  542.         learn = true
  543.       else
  544.         learn = false
  545.       end
  546.       change_color(text_color(LEVEL_COLOR))
  547.       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
  548.       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
  549.       draw_text(branch+28,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 100
  550.       draw_icon(icon_index,48+branch,order,learn)
  551.     end
  552.     change_color(normal_color)
  553.    
  554.     for i in (0..loopx)
  555.       next if TREE[a][i][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  556.       branch   = TREE[a][i][1]
  557.       order    = TREE[a][i][2]
  558.       before   = TREE[a][i][3]
  559.       if before == 2 || before == 8
  560.        for j in (0..loopx)
  561.          next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  562.          next if branch  != TREE[a][j][1]
  563.          next if order   != (TREE[a][j][2] - 1) && before == 2
  564.          next if order   != (TREE[a][j][2] + 1) && before == 8
  565.          skill_id = TREE[a][j][4]
  566.          if $game_actors[a].skill_learn?($data_skills[skill_id])
  567.            colors = hp_gauge_color1
  568.          else
  569.            colors = text_color(8)
  570.          end
  571.          contents.fill_rect(58+branch*54,27+(order-1)*41,3,12,colors) if before == 8
  572.          contents.fill_rect(58+branch*54,27+order*41,3,12,colors) if before == 2
  573.         end
  574.       elsif before == 4 || before == 6
  575.         for j in (0..loopx)
  576.           next if TREE[a][j][0] != $game_variables[TREE_ID]
  577.           next if branch  != (TREE[a][j][1] - 1) && before == 6
  578.           next if branch  != (TREE[a][j][1] + 1) && before == 4
  579.           next if order   != TREE[a][j][2]
  580.           skill_id = TREE[a][j][4]
  581.           if $game_actors[a].skill_learn?($data_skills[skill_id])
  582.             colors = hp_gauge_color1
  583.           else
  584.             colors = text_color(8)
  585.           end
  586.         contents.fill_rect(22+branch*54,15+order*41,24,3,colors) if before == 4
  587.         contents.fill_rect(22+(branch+1)*54,15+order*41,24,3,colors) if before == 6
  588.         end
  589.       end
  590.     end
  591.    
  592.     chr = $game_actors[a]
  593.     draw_character(chr.character_name, chr.character_index, 16, 32)
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● ヘルプウィンドウ更新メソッドの呼び出し
  597.   #--------------------------------------------------------------------------
  598.   def call_update_help
  599.     update_help if active && @help_window
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # ● ヘルプウィンドウの更新
  603.   #--------------------------------------------------------------------------
  604.   def update_help
  605.     @help_window.clear
  606.       @help_window.set_item($data_skills[current_ext[0]]) unless current_ext == nil
  607.   end
  608. end

  609. #==============================================================================
  610. # ■ Window_info
  611. #==============================================================================
  612. class Window_info < Window_Base
  613.   include Hi_ru_Skilltree
  614.   attr_accessor :current_ext
  615.   #--------------------------------------------------------------------------
  616.   # ● 現在情報の設定
  617.   #--------------------------------------------------------------------------
  618.   def current_ext=(current_ext)
  619.     return if @current_ext == current_ext
  620.     @current_ext = current_ext
  621.     refresh
  622.   end

  623.   #--------------------------------------------------------------------------
  624.   # ● リフレッシュ
  625.   #--------------------------------------------------------------------------
  626.   def refresh
  627.     contents.clear
  628.     unless current_ext == nil
  629.     change_color(normal_color)
  630.      @stype_id = $data_skills[current_ext[0]].stype_id
  631.     draw_text(0,0, 54, 24," #{$data_system.skill_types[@stype_id]}:")
  632.     draw_text(54,0, 180, 24, $data_skills[current_ext[0]].name)
  633.     $game_variables[CURRENT] = []
  634.     $game_variables[CURRENT] = [current_ext[0],current_ext[1],current_ext[2],current_ext[3],current_ext[4],current_ext[5]]
  635.    
  636.     change_color(mp_cost_color)
  637.     draw_text(260,0, Graphics.width, 24, $data_skills[current_ext[0]].mp_cost)
  638.     change_color(normal_color)
  639.     draw_text(288,0, Graphics.width, 24, "/")
  640.     change_color(tp_cost_color)
  641.     draw_text(300,0, Graphics.width, 24, $data_skills[current_ext[0]].tp_cost)
  642.     change_color(normal_color)
  643.    
  644.     draw_text(348,0,Graphics.width, 24,"SP:")
  645.     self.contents.font.size = 24
  646.     sizex = 27
  647.     sizex = 18 if current_ext[1] >= 10
  648.     sizex = 9 if current_ext[1] >= 100
  649.     sizex = 0  if current_ext[1] >= 1000
  650.     draw_text(390+sizex,0,48, 24, current_ext[1])
  651.     self.contents.font.size = 28
  652.     draw_text(430,0,Graphics.width, 24, "/")
  653.     draw_text(440,0,Graphics.width, 24, $game_actors[$game_variables[VARIABLES]].skill_point)
  654.     self.contents.font.size = 24
  655.     draw_text(0,24,Graphics.width,24," Q,W键:切换角色  S,D键:切换技能树")
  656.    
  657.     end
  658.   end
  659. end

  660. #==============================================================================
  661. # ■ Window_Skillpoint_Task
  662. #------------------------------------------------------------------------------
  663. #  スキルの習得に関する選択肢を表示するウィンドウです。
  664. #==============================================================================
  665. class Window_Skillpoint_Task < Window_Command
  666.   include Hi_ru_Skilltree
  667.   #--------------------------------------------------------------------------
  668.   # ● オブジェクト初期化
  669.   #--------------------------------------------------------------------------
  670.   def initialize(x, y)
  671.     super(x, y)
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # ● ウィンドウ幅の取得
  675.   #--------------------------------------------------------------------------
  676.   def window_width
  677.     return 240
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # ● 決定ボタンが押されたときの処理
  681.   #--------------------------------------------------------------------------
  682.   def process_ok
  683.     if current_item_enabled?
  684.       Input.update
  685.       deactivate
  686.       call_ok_handler
  687.     else
  688.       Sound.play_buzzer
  689.     end
  690.   end
  691.   #--------------------------------------------------------------------------
  692.   # ● コマンドリストの作成
  693.   #--------------------------------------------------------------------------
  694.   def make_command_list
  695.     a     = $game_variables[VARIABLES]
  696.     loopx = TREE[a].size - 1
  697.     can   = false
  698.     branch   = $game_variables[CURRENT][2]
  699.     order    = $game_variables[CURRENT][3]
  700.     before   = $game_variables[CURRENT][4]
  701.    
  702.     if before == 2 || before == 8
  703.       for j in (0..loopx)
  704.         next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  705.         next if branch  != TREE[a][j][1]
  706.         next if order   != (TREE[a][j][2] - 1) && before == 2
  707.         next if order   != (TREE[a][j][2] + 1) && before == 8
  708.         skill_id = TREE[a][j][4]
  709.         if $game_actors[a].skill_learn?($data_skills[skill_id])
  710.           can = true
  711.         end
  712.       end
  713.     end
  714.     if before == 4 || before == 6
  715.       for j in (0..loopx)
  716.         next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
  717.         next if branch  != (TREE[a][j][1] - 1) && before == 6
  718.         next if branch  != (TREE[a][j][1] + 1) && before == 4
  719.         next if order   != TREE[a][j][2]
  720.         skill_id = TREE[a][j][4]
  721.         if $game_actors[a].skill_learn?($data_skills[skill_id])
  722.           can = true
  723.         end
  724.       end
  725.     end
  726.     can = true if before == 0
  727.    
  728.     if can == true
  729.       unless $game_actors[$game_variables[VARIABLES]].skill_learn?($data_skills[$game_variables[CURRENT][0]])
  730.         if $game_variables[CURRENT][5] > $game_actors[a].level
  731.           add_command("等级不足", :ok, false, 1)
  732.         elsif $game_actors[$game_variables[VARIABLES]].skill_point >= $game_variables[CURRENT][1]
  733.           add_command("学习该技能!", :ok, true, 1)
  734.         else
  735.           add_command("技能点不足", :ok, false, 1)
  736.         end
  737.       else
  738.         add_command("已经学会该技能了", :ok, false, 1)
  739.       end
  740.     else
  741.       add_command("需要前提技能", :ok, false, 1)
  742.     end
  743.     add_command("取消", :ok, true, 2)
  744.   end
  745.   #--------------------------------------------------------------------------
  746.   # ● リフレッシュ
  747.   #--------------------------------------------------------------------------
  748.   def refresh
  749.     clear_command_list
  750.     make_command_list
  751.     create_contents
  752.     self.height = window_height
  753.     select(0)
  754.     super
  755.   end
  756. end

  757. class Window_Skill_learn < Window_Command
  758.   include Hi_ru_Skilltree
  759.   #--------------------------------------------------------------------------
  760.   # ● オブジェクト初期化
  761.   #--------------------------------------------------------------------------
  762.   def initialize(x, y)
  763.     super(x, y)
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● ウィンドウ幅の取得
  767.   #--------------------------------------------------------------------------
  768.   def window_width
  769.     360
  770.   end
  771.   #--------------------------------------------------------------------------
  772.   # ● ウィンドウ高さの取得
  773.   #--------------------------------------------------------------------------
  774.   def window_height
  775.     72
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 項目の幅を取得
  779.   #--------------------------------------------------------------------------
  780.   def item_width
  781.     1
  782.   end
  783.   #--------------------------------------------------------------------------
  784.   # ● 項目の高さを取得
  785.   #--------------------------------------------------------------------------
  786.   def item_height
  787.     1
  788.   end
  789.   #--------------------------------------------------------------------------
  790.   # ● コマンドリストの作成
  791.   #--------------------------------------------------------------------------
  792.   def make_command_list
  793.      add_command("", :ok, true, 1) #エラー回避
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # ● リフレッシュ
  797.   #--------------------------------------------------------------------------
  798.   def refresh
  799.     clear_command_list
  800.     make_command_list
  801.     create_contents
  802.     self.height = window_height
  803.     select(0)
  804.     super
  805.     draw_learn
  806.     Audio.me_stop
  807.     Audio.me_play(SKILL_LEARN_ME, SKILL_LEARN_VOLUME, SKILL_LEARN_PITCH)
  808.   end
  809.   #--------------------------------------------------------------------------
  810.   # ● 各種描画
  811.   #--------------------------------------------------------------------------
  812.   def draw_learn
  813.     icon_index = $data_skills[$game_variables[CURRENT][0]].icon_index
  814.     draw_icon(icon_index,0,0,true)
  815.     draw_text(32,0,320,24,$data_skills[$game_variables[CURRENT][0]].name + " 已被学会!")
  816.     draw_text(80,24,200,24,"SP")
  817.     draw_text(120,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point + $game_variables[CURRENT][1])
  818.     draw_text(160,24,24,24,"→")
  819.     draw_text(190,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point)
  820.   end
  821. end

  822. #==============================================================================
  823. # ■ Scene_Menu
  824. #------------------------------------------------------------------------------
  825. #  メニュー画面の処理を行うクラスです。
  826. #==============================================================================
  827. class Scene_Menu < Scene_MenuBase
  828.   #--------------------------------------------------------------------------
  829.   # ● コマンドウィンドウの作成
  830.   #--------------------------------------------------------------------------
  831.   alias skilltree_create_command_window create_command_window
  832.   def create_command_window
  833.     skilltree_create_command_window
  834.     @command_window.set_handler(:skill_tree_go,    method(:command_skill_tree))
  835.   end
  836.   #--------------------------------------------------------------------------
  837.   # ○ コマンド[スキルツリー]
  838.   #--------------------------------------------------------------------------
  839.   def command_skill_tree
  840.     SceneManager.call(Scene_Skilltree)
  841.   end
  842. end
  843. #==============================================================================
  844. # ■ Window_MenuCommand
  845. #------------------------------------------------------------------------------
  846. #  メニュー画面で表示するコマンドウィンドウです。
  847. #==============================================================================
  848. class Window_MenuCommand
  849.   #--------------------------------------------------------------------------
  850.   # ● 独自コマンドの追加用
  851.   #--------------------------------------------------------------------------
  852.   alias skilltree_add_original_commands add_original_commands
  853.   def add_original_commands
  854.     skilltree_add_original_commands
  855.     if $game_switches[Hi_ru_Skilltree::MENU_SWITCH]
  856.       add_command(Hi_ru_Skilltree::MENU_COMMAND, :skill_tree_go, true)
  857.     end
  858.   end
  859. end
复制代码


设定了10号角色没有技能树
QQ截图20190109224100.png
然后进游戏加入10号角色后打开技能树会显示
QQ截图20190109224150.png

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


梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

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

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

评分

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

查看全部评分

用头画头像,用脚写脚本
回复

使用道具 举报

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

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

使用道具 举报

梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-1-10 00:22:14 | 显示全部楼层
本帖最后由 KB.Driver 于 2019-1-10 00:27 编辑
melatin 发表于 2019-1-10 00:05
谢谢帮助,改成[]就不会报错了。


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


在这个脚本中这样修改后也能运行,但是毕竟有潜在的隐患。
可以输出一段文字到控制台提醒编程者。

  1. class NilClass
  2.   def size
  3.     puts "调用了NilClass#size -> 0,此方法存在隐患。如果其他脚本功能异常请检查此处。"
  4.     0
  5.   end
  6. end
复制代码
用头画头像,用脚写脚本
回复

使用道具 举报

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

好的,多谢大神点拨~~
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部