Project1

标题: 为什么不能使用技能 [打印本页]

作者: j296196585    时间: 2016-10-30 14:03
标题: 为什么不能使用技能
本帖最后由 j296196585 于 2016-10-30 14:04 编辑

RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4.  
  5. #等级可无限提升
  6. #パラメータの算出が適当すぎるので、各自修正が必要かと。
  7.  
  8.   BASE_FINAL_LEVEL = 9999   #上限レベル(あんまり大きな値を設定するとハングします)
  9.   MAXHP_LIMIT = 99999999    #HP限界値
  10.   MAXSP_LIMIT = 99999999    #SP限界値
  11.   STR_LIMIT   = 999999      #STR限界値
  12.   DEX_LIMIT   = 999999      #DEX限界値
  13.   AGI_LIMIT   = 999999      #AGI限界値
  14.   INT_LIMIT   = 999999      #INT限界値
  15.  
  16. class Game_Actor < Game_Battler
  17.   def new_final_level
  18.     lv = BASE_FINAL_LEVEL
  19.     #以下上限LV個別指定用
  20.     #case self.id
  21.     #when 1
  22.     #  lv = 255
  23.     #when 2
  24.     #  lv = 999
  25.     #when 8
  26.     #  lv = 15600
  27.     #end
  28.     return lv
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● EXP 計算
  32.   #--------------------------------------------------------------------------
  33.   def make_exp_list
  34.     actor = $data_actors[@actor_id]
  35.     @exp_list = Array.new(new_final_level + 2)
  36.     @exp_list[1] = 0
  37.     pow_i = 2.4 + actor.exp_inflation / 100.0
  38.     for i in 2..new_final_level + 1
  39.       if i > new_final_level
  40.         @exp_list[i] = 0
  41.       else
  42.         n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)
  43.         @exp_list[i] = @exp_list[i-1] + Integer(n)
  44.       end
  45.     end
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● MaxSP の取得
  49.   #--------------------------------------------------------------------------
  50.   def maxsp
  51.     n = [[base_maxsp + @maxsp_plus, 0].max, MAXSP_LIMIT].min
  52.     for i in @states
  53.       n *= $data_states[i].maxsp_rate / 100.0
  54.     end
  55.     n = [[Integer(n), 0].max, MAXSP_LIMIT].min
  56.     return n  
  57.   end
  58.   # ● MaxHP の取得
  59.   #--------------------------------------------------------------------------
  60.   def maxhp
  61.     n = [[base_maxhp + @maxhp_plus, 1].max, MAXHP_LIMIT].min
  62.     for i in @states
  63.       n *= $data_states[i].maxhp_rate / 100.0
  64.     end
  65.     n = [[Integer(n), 1].max, MAXHP_LIMIT].min
  66.     return n
  67.   end
  68.   #--------------------------------------------------------------------------
  69.    # ● 基本 根骨 の取得
  70.   #--------------------------------------------------------------------------
  71.   def geigu
  72.     gu1= 1
  73.     gu2 = 1
  74.     n = @level*gu1  +  gu2
  75.     return n
  76.   end
  77.   #--------------------------------------------------------------------------
  78.    # ● 基本 minjie の取得
  79.   #--------------------------------------------------------------------------
  80.   def minjie
  81.     m1= 1
  82.     m2 = 1
  83.     n = @level*m1  +  m2
  84.     return n
  85.   end
  86.   # ● 基本 MaxHP の取得
  87.   #--------------------------------------------------------------------------
  88.   def base_maxhp
  89.     gj = 0
  90.     hp1= $data_actors[@actor_id].parameters[0, 1]
  91.     hp2 = $data_actors[@actor_id].parameters[0, 2]
  92.     n = @level*hp1  +  hp2
  93.        if  @actor_id == $game_party.actors[0].id
  94.     gj=$game_variables[30][1]
  95.     end
  96. if  $game_party.actors[1] != nil
  97.     if  @actor_id == $game_party.actors[1].id and $cong_zan != nil and $cong_zan != 0
  98.     gj=$game_variables[29][$cong_zan][1]
  99.     end
  100. end   
  101.     return n + gj
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 基本 MaxSP の取得
  105.   #--------------------------------------------------------------------------
  106.   def base_maxsp
  107.     gj = 0
  108.     mp1 = $data_actors[@actor_id].parameters[1, 1]
  109.     mp2 = $data_actors[@actor_id].parameters[1, 2]
  110.     n = @level*mp1  +  mp2
  111.      if  @actor_id == $game_party.actors[0].id
  112.     gj=$game_variables[30][2]
  113.     end
  114. if  $game_party.actors[1] != nil and $cong_zan != nil and $cong_zan != 0
  115.     if  @actor_id == $game_party.actors[1].id
  116.     gj=$game_variables[29][$cong_zan][2]
  117.     end
  118. end   
  119.     return n + gj
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 基本腕力の取得
  123.   #--------------------------------------------------------------------------
  124.   def base_str
  125.     str1 = $data_actors[@actor_id].parameters[2, 1]
  126.     str2 = $data_actors[@actor_id].parameters[2, 2]
  127.      n = @level*str1  +  str2
  128.     weapon = $data_weapons[@weapon_id]
  129.     armor1 = $data_armors[@armor1_id]
  130.     armor2 = $data_armors[@armor2_id]
  131.     armor3 = $data_armors[@armor3_id]
  132.     armor4 = $data_armors[@armor4_id]
  133.     n += weapon != nil ? weapon.str_plus : 0
  134.     n += armor1 != nil ? armor1.str_plus : 0
  135.     n += armor2 != nil ? armor2.str_plus : 0
  136.     n += armor3 != nil ? armor3.str_plus : 0
  137.     n += armor4 != nil ? armor4.str_plus : 0
  138.     return [[n, 1].max, STR_LIMIT].min
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 基本器用さの取得
  142.   #--------------------------------------------------------------------------
  143.   def base_dex
  144.     dex1 = $data_actors[@actor_id].parameters[3, 1]
  145.     dex2 = $data_actors[@actor_id].parameters[3, 2]
  146.     n = @level*dex1  +  dex2
  147.  
  148.     weapon = $data_weapons[@weapon_id]
  149.     armor1 = $data_armors[@armor1_id]
  150.     armor2 = $data_armors[@armor2_id]
  151.     armor3 = $data_armors[@armor3_id]
  152.     armor4 = $data_armors[@armor4_id]
  153.     n += weapon != nil ? weapon.dex_plus : 0
  154.     n += armor1 != nil ? armor1.dex_plus : 0
  155.     n += armor2 != nil ? armor2.dex_plus : 0
  156.     n += armor3 != nil ? armor3.dex_plus : 0
  157.     n += armor4 != nil ? armor4.dex_plus : 0
  158.     return [[n, 1].max, DEX_LIMIT].min
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 基本速度さの取得
  162.   #--------------------------------------------------------------------------
  163.   def base_agi
  164.     agi1 = $data_actors[@actor_id].parameters[4,1]
  165.     agi2 = $data_actors[@actor_id].parameters[4,2]
  166.     n = @level*agi1  +  agi2
  167.  
  168.     weapon = $data_weapons[@weapon_id]
  169.     armor1 = $data_armors[@armor1_id]
  170.     armor2 = $data_armors[@armor2_id]
  171.     armor3 = $data_armors[@armor3_id]
  172.     armor4 = $data_armors[@armor4_id]
  173.     n += weapon != nil ? weapon.agi_plus : 0
  174.     n += armor1 != nil ? armor1.agi_plus : 0
  175.     n += armor2 != nil ? armor2.agi_plus : 0
  176.     n += armor3 != nil ? armor3.agi_plus : 0
  177.     n += armor4 != nil ? armor4.agi_plus : 0
  178.      if  @actor_id == $game_party.actors[0].id
  179.     gj=$game_variables[30][4]
  180.     end
  181. if  $game_party.actors[1] != nil and $cong_zan != nil and $cong_zan != 0
  182.     if  @actor_id == $game_party.actors[1].id
  183.     gj=$game_variables[29][$cong_zan][4]
  184.     end
  185. end   
  186.     return [[n, 1].max, AGI_LIMIT].min  + gj
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 基本魔力の取得
  190.   #--------------------------------------------------------------------------
  191.   def base_int
  192.     int1 = $data_actors[@actor_id].parameters[5,1]
  193.     int2 = $data_actors[@actor_id].parameters[5,2]
  194.     n = @level*int1  +  int2
  195.  
  196.     weapon = $data_weapons[@weapon_id]
  197.     armor1 = $data_armors[@armor1_id]
  198.     armor2 = $data_armors[@armor2_id]
  199.     armor3 = $data_armors[@armor3_id]
  200.     armor4 = $data_armors[@armor4_id]
  201.     n += weapon != nil ? weapon.int_plus : 0
  202.     n += armor1 != nil ? armor1.int_plus : 0
  203.     n += armor2 != nil ? armor2.int_plus : 0
  204.     n += armor3 != nil ? armor3.int_plus : 0
  205.     n += armor4 != nil ? armor4.int_plus : 0
  206.     return [[n, 1].max, INT_LIMIT].min
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● EXP の変更
  210.   #     exp : 新しい EXP
  211.   #--------------------------------------------------------------------------
  212.   def exp=(exp)
  213.     # ★EXPの上限チェックを解除
  214.     @exp = [exp, 0].max
  215.     # レベルアップ
  216.     while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
  217.       @level += 1
  218.       @hp = maxhp  #补血法
  219.       @sp = maxsp  #血法
  220.      # スキル習得
  221.       for j in $data_classes[@class_id].learnings
  222.         if j.level == @level
  223.           learn_skill(j.skill_id)
  224.         end
  225.       end
  226.     end
  227.     # レベルダウン
  228.     while @exp < @exp_list[@level]
  229.       @level -= 1
  230.     end
  231.     # 現在の HP と SP が最大値を超えていたら修正
  232.     @hp = [@hp, self.maxhp].min
  233.     @sp = [@sp, self.maxsp].min
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● レベルの変更
  237.   #     level : 新しいレベル
  238.   #--------------------------------------------------------------------------
  239.   def level=(level)
  240.     # 上下限チェック
  241.     # ★LV上限をnew_final_levelでチェックするように変更
  242.     level = [[level, new_final_level].min, 1].max
  243.  
  244.     # EXP を変更
  245.     self.exp = @exp_list[level]
  246.   end
  247. end
  248.  
  249.  
  250. class Game_Battler
  251.   #--------------------------------------------------------------------------
  252.   # ● MaxSP の取得
  253.   #--------------------------------------------------------------------------
  254.   def maxsp
  255.     n = [[base_maxsp + @maxsp_plus, 0].max, MAXSP_LIMIT].min
  256.     for i in @states
  257.       n *= $data_states[i].maxsp_rate / 100.0
  258.     end
  259.     n = [[Integer(n), 0].max, MAXSP_LIMIT].min
  260.     return n
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 腕力の取得
  264.   #--------------------------------------------------------------------------
  265.   def str
  266.     n = [[base_str + @str_plus, 1].max, STR_LIMIT].min
  267.     for i in @states
  268.       n *= $data_states[i].str_rate / 100.0
  269.     end
  270.     n = [[Integer(n), 1].max, STR_LIMIT].min
  271.     return n
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # ● 器用さの取得
  275.   #--------------------------------------------------------------------------
  276.   def dex
  277.     n = [[base_dex + @dex_plus, 1].max, DEX_LIMIT].min
  278.     for i in @states
  279.       n *= $data_states[i].dex_rate / 100.0
  280.     end
  281.     n = [[Integer(n), 1].max, DEX_LIMIT].min
  282.     return n
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 素早さの取得
  286.   #--------------------------------------------------------------------------
  287.   def agi
  288.     n = [[base_agi + @agi_plus, 1].max, AGI_LIMIT].min
  289.     for i in @states
  290.       n *= $data_states[i].agi_rate / 100.0
  291.     end
  292.     n = [[Integer(n), 1].max, AGI_LIMIT].min
  293.     return n
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 魔力の取得
  297.   #--------------------------------------------------------------------------
  298.   def int
  299.     n = [[base_int + @int_plus, 1].max, INT_LIMIT].min
  300.     for i in @states
  301.       n *= $data_states[i].int_rate / 100.0
  302.     end
  303.     n = [[Integer(n), 1].max, INT_LIMIT].min
  304.     return n
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● MaxHP の設定
  308.   #     maxhp : 新しい MaxHP
  309.   #--------------------------------------------------------------------------
  310.   def maxhp=(maxhp)
  311.     @maxhp_plus += maxhp - self.maxhp
  312.     @maxhp_plus = [[@maxhp_plus, -MAXHP_LIMIT].max, MAXHP_LIMIT].min
  313.     @hp = [@hp, self.maxhp].min
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● MaxSP の設定
  317.   #     maxsp : 新しい MaxSP
  318.   #--------------------------------------------------------------------------
  319.   def maxsp=(maxsp)
  320.     @maxsp_plus += maxsp - self.maxsp
  321.     @maxsp_plus = [[@maxsp_plus, -MAXSP_LIMIT].max, MAXSP_LIMIT].min
  322.     @sp = [@sp, self.maxsp].min
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # ● 腕力の設定
  326.   #     str : 新しい腕力
  327.   #--------------------------------------------------------------------------
  328.   def str=(str)
  329.     @str_plus += str - self.str
  330.     @str_plus = [[@str_plus, -STR_LIMIT].max, STR_LIMIT].min
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● 器用さの設定
  334.   #     dex : 新しい器用さ
  335.   #--------------------------------------------------------------------------
  336.   def dex=(dex)
  337.     @dex_plus += dex - self.dex
  338.     @dex_plus = [[@dex_plus, -DEX_LIMIT].max, DEX_LIMIT].min
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ● 素早さの設定
  342.   #     agi : 新しい素早さ
  343.   #--------------------------------------------------------------------------
  344.   def agi=(agi)
  345.     @agi_plus += agi - self.agi
  346.     @agi_plus = [[@agi_plus, -AGI_LIMIT].max, AGI_LIMIT].min
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● 魔力の設定
  350.   #     int : 新しい魔力
  351.   #--------------------------------------------------------------------------
  352.   def int=(int)
  353.     @int_plus += int - self.int
  354.     @int_plus = [[@int_plus, -INT_LIMIT].max, INT_LIMIT].min
  355.   end
  356. end
  357.  
  358. #==============================================================================
  359. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  360. #==============================================================================

360截图20161030140407366.jpg (22.02 KB, 下载次数: 0)

360截图20161030140407366.jpg

作者: cinderelmini    时间: 2016-10-30 14:12
看起来像是局部变量gj被赋了无效值………………
可以试试看在186行上面插入一行nil判定。。。。
不过这么做最好在166行下面初始化一下gj的值以免被识别成方法……
比如…………
  1. n = @level*agi1  +  agi2
  2. gj = nil # 初始化
  3. # 分割线
  4. gj = 0 if gj.nil? # 判定nil
  5. return [[n, 1].max, AGI_LIMIT].min  + gj
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1