查看: 2681|回复: 3

[已经解决] 人物属性加点与技能加点冲突

[复制链接]
梦石
0
星屑
1225
在线时间
564 小时
注册时间
2014-11-30
回帖
126
发表于 2015-6-6 15:41:40 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 309988769 于 2015-6-6 15:48 编辑
  1. #encoding:utf-8
  2. #=============================================================================
  3. #-----------RMVA加点系统正常向-v1.01---By:救世小树--------转载请注明出处-------
  4. #=============================================================================

  5. module Point_Tree
  6.   
  7.   POINT_VARIABLE = 34
  8.   POINT_KIND     = 4             #设定加点种类
  9.   #储存属性点的变量编号是34+角色id*(6+1),
  10.   #即41号变量为一号角色自由点;42号起6个变量为1号角色6个种类的已加点值
  11.   
  12.   LEVEL_UP_POINT = 1
  13.   #每升一级属性点增加数
  14.   
  15.   RESET_ITEM     = 20   #洗点水编号
  16.   
  17.   STR_POINT        = ["武力","谋略","政治","兵法"]#,"韧性","灵活","???"]
  18.   #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  19.   POINT_ADD_PARAM = [[0 ,  0,   12,  0,   0,   0,   0,   0],     #体力
  20.                      [0  , 0,   0,  0,   12,   0,   0,   0],     #精神
  21.                      [0  ,  0,   0,  9,   0,   9,   0,   0],     #力量
  22.                      [0  ,  0,   0,  0,   0,   0,   15,   0],     #魔力
  23. #~                      [0  ,  0,   0,  0,   0,   0,   0,   0],     #韧性
  24. #~                      [0  ,  0,   0,  0,   0,   0,   0,   0],     #灵活
  25.                      
  26. #~                      [0,0,0,0,0,0,0,0]
  27.                     ]
  28.                      #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
  29.   
  30.   #分别对应增加       [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  31.   POINT_ADD_XPARAM = [[0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  32.                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  33.                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  34.                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  35. #~                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  36. #~                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  37. #~                     
  38. #~                       [0,0,0,0,0,0,0,0,0,0]
  39.                      ]
  40.                      #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
  41.   
  42.   #各种名称
  43.   ADDPOINT       = "加点"   #菜单中选项
  44.   
  45.   POINT_NAME     = "属性点" #未分配点数
  46.   
  47.   XARAM_NAME     = ["物理命中","物理闪避","暴击几率","暴击闪避","魔法闪避","魔法反射","物理反击","兵力回复率","气力回复率","怒气上升率"]
  48.   def reset(actor_id)       #洗点
  49.     for i in 1..6
  50.       $game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE]+=$game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE+i]
  51.       $game_variables[actor_id*(POINT_KIND+1) + POINT_VARIABLE+i]=0
  52.     end
  53.   end
  54.   
  55.   def temp_all
  56.     r = 0
  57.     for i in 0 .. POINT_KIND-1
  58.       r+=$temp_point[i]
  59.     end
  60.     return r
  61.   end
  62.   
  63.   def point_add_param(actor_id)
  64.     case actor_id
  65.     when 1
  66.       #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  67.       return [[0 ,  0,   12,  0,   0,   0,   0,   0],     #体力
  68.               [0  , 0,   0,  0,   12,   0,   0,   0],     #精神
  69.               [0  ,  0,   0,  9,   0,   9,   0,   0],     #力量
  70.               [0  ,  0,   0,  0,   0,   0,   15,   0],     #魔力
  71.              ]
  72.     else
  73.       return POINT_ADD_PARAM
  74.     end
  75.   end
  76.   
  77.   def point_add_xparam(actor_id)
  78.     case actor_id
  79.     when 1
  80.       #分别对应增加 [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  81.       return [[0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  82.               [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  83.               [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  84.               [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  85.              ]
  86.     else
  87.       return POINT_ADD_XPARAM
  88.     end
  89.   end
  90. end
  91. $temp_point = []
  92. for i in 0 .. Point_Tree::POINT_KIND-1
  93.   $temp_point.push(0)
  94. end

  95. class Game_Actor < Game_Battler
  96.   include Point_Tree
  97.   alias level_up_tre level_up
  98.   def level_up
  99.     level_up_tre
  100.     @hp += mhp
  101.     @mp += mmp
  102.     $game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE] += LEVEL_UP_POINT
  103.   end
  104.   def point_plus(param_id)
  105.     r=0
  106.     for i in 0 .. POINT_KIND-1
  107.       r+=$game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE+i+1]*point_add_param(@actor_id)[i][param_id]
  108.     end
  109.     return r
  110.   end

  111.   alias point_base_param param
  112.   
  113.   def param(param_id)
  114.     value = param_base(param_id) + param_plus(param_id) + point_plus(param_id)
  115.     value *= param_rate(param_id) * param_buff_rate(param_id)
  116.     [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  117.   end
  118.   def xparam(xparam_id)
  119.     xp = super(xparam_id)
  120.     for i in 0 .. POINT_KIND-1
  121.       xp+=($game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE+i+1]*point_add_xparam(@actor_id)[i][xparam_id]/10000.0)
  122.     end
  123.     return xp
  124.   end
  125.   def item_apply(user, item)
  126.     super(user, item)
  127.     if item.id == RESET_ITEM and item.is_a?(RPG::Item)
  128.       reset(@actor_id)
  129.       self.hp = [self.hp,self.mhp].min
  130.       self.mp = [self.mp,self.mmp].min
  131.     end
  132.   end
  133. end

  134. class Window_Point_Command < Window_Command
  135.   
  136.   include Point_Tree
  137.   #--------------------------------------------------------------------------
  138.   # ● 初始化指令选择位置(类方法)
  139.   #--------------------------------------------------------------------------
  140.   def self.init_command_position
  141.     @@last_command_symbol = nil
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 初始化对象
  145.   #--------------------------------------------------------------------------
  146.   def initialize(actor)
  147.     @status_window = nil
  148.     @actor = actor
  149.     super(0,0)
  150.     select_last
  151.   end
  152.   def actor=(actor)
  153.     return if @actor == actor
  154.     @actor = actor
  155.     refresh
  156.   end
  157.   def status_window=(status_window)
  158.     return if @status_window == status_window
  159.     @status_window = status_window
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ● 获取窗口的宽度
  163.   #--------------------------------------------------------------------------
  164.   def window_width
  165.     return 160
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 获取显示行数
  169.   #--------------------------------------------------------------------------
  170.   def visible_line_number
  171.     item_max
  172.   end
  173.   def get_actor_point(id)
  174.     s = $game_variables[@actor.id*(POINT_KIND+1)+POINT_VARIABLE+id+1].to_s
  175.     return "("+s+")+"+$temp_point[id].to_s
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 生成指令列表
  179.   #--------------------------------------------------------------------------
  180.   def make_command_list
  181.     for i in 0 .. POINT_KIND-1
  182.       add_command(STR_POINT[i]   + get_actor_point(i)  , :point_add  ,add_enabled)
  183.     end
  184.     add_command("确定",  :point_ok)
  185.     add_command("取消",  :point_cancle)
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 按下确定键时的处理
  189.   #--------------------------------------------------------------------------
  190.   def process_ok
  191.     @@last_command_symbol = current_symbol
  192.     super
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 返回最后一个选项的位置
  196.   #--------------------------------------------------------------------------
  197.   def select_last
  198.     select_symbol(@@last_command_symbol)
  199.   end
  200.   
  201.   def add_enabled
  202.     temp_all < $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE]
  203.   end

  204.   def update_help
  205.     @help_window.set_text(self.index+1) if @help_window
  206.     @status_window.index = self.index if @status_window
  207.   end
  208.   
  209.   #--------------------------------------------------------------------------
  210.   # ● 光标向左移动
  211.   #--------------------------------------------------------------------------
  212.   def cursor_left(param)
  213.     call_handler(:LEFT)
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 光标向右移动
  217.   #--------------------------------------------------------------------------
  218.   def cursor_right(param)
  219.     call_handler(:RIGHT)
  220.   end
  221. end

  222. if !ADJUST_X
  223. #帮助窗口
  224. class Window_Point_Help < Window_Base
  225.   include Point_Tree
  226.   def initialize(x,y,w,h)
  227.     super(x, y, w, h)
  228.   end
  229.   
  230.   def set_text(id)
  231.     contents.clear
  232.     if id <= POINT_KIND
  233.       text = "\\}提升一点该属性"
  234.     elsif id == POINT_KIND+1
  235.       text = "\\}确认此次加点分配"
  236.     elsif  id == POINT_KIND+2
  237.       text = "\\}取消此次加点分配"
  238.     end
  239.     draw_text_ex(8, 8, text)
  240.   end
  241. end
  242. end


  243. #角色状态窗口
  244. class Window_Point_Actor < Window_Base
  245.   include Point_Tree
  246.   
  247.   
  248.   def initialize(actor)
  249.     super(160, 0, Graphics.width - 160, Graphics.height)
  250.     @actor = actor
  251.     @index = 0
  252.     refresh
  253.   end
  254.   def actor=(actor)
  255.     return if @actor == actor
  256.     @actor = actor
  257.     refresh
  258.   end
  259.   def index=(index)
  260.     return if @index == index
  261.     @index = index
  262.     refresh
  263.   end
  264.   def line_height
  265.     return 24
  266.   end
  267.   def refresh
  268.     contents.clear
  269.     contents.font.size = 32
  270.     draw_actor_name(@actor, 100, 0)
  271.     draw_actor_class(@actor, 240, 0)
  272.     draw_actor_face(@actor, 2, 0)
  273.     contents.font.size = 20
  274.     draw_actor_level(@actor, 102,  24)
  275.     draw_actor_point(100,48)
  276.     contents.font.size = 16
  277.     draw_actor_param_point(8,16 * 6)
  278.     draw_actor_xparam_point(8,16 * 14)
  279.     draw_text(8,100,172,24,"←→:切换角色")
  280.   end
  281.   def draw_actor_point(x,y)
  282.     draw_text(x,y,200,line_height,"  未分配"+POINT_NAME + ":" + $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE].to_s)
  283.     draw_text(x,y+line_height,200,line_height,"此次分配"+POINT_NAME + ":" + temp_all.to_s)
  284.   end
  285.   def draw_actor_param_point(x,y)
  286.     8.times {|i| draw_actor_param_to_s(x,y,i)}
  287.   end
  288.   def draw_actor_xparam_point(x,y)
  289.     10.times {|i| draw_actor_xparam_to_s(x,y,i)}
  290.   end
  291.   
  292.   def draw_actor_param_to_s(x,y,param_id)
  293.     a=0
  294.     for i in 0 .. POINT_KIND-1
  295.       a+=$temp_point[i]*point_add_param(@actor.id)[i][param_id]
  296.     end
  297.     s1 = Vocab::param(param_id)
  298.     s2 = @actor.param(param_id).to_s
  299.     s3 = (@actor.param(param_id) + a).to_s
  300.     if @index < POINT_KIND
  301.       if point_add_param(@actor.id)[@index][param_id]==0
  302.         s4 = ""
  303.       else
  304.         s4 = "+" + point_add_param(@actor.id)[@index][param_id].to_s
  305.       end
  306.     else
  307.       s4 = ""
  308.     end
  309.    
  310.     change_color(system_color)
  311.     draw_text(x,y+16*param_id,100,line_height,s1)
  312.     change_color(normal_color)
  313.     s2+= " →"
  314.     draw_text(x+82,y+16*param_id,120,line_height,s2,2)
  315.     contents.font.color = Color.new(0,255,0)
  316.     draw_text(x+150,y+16*param_id,100,line_height,s3,2)
  317.     contents.font.color = Color.new(0,255,0)
  318.     contents.font.size = 14
  319.     draw_text(x+266,y+16*param_id,100,line_height,s4,2)
  320.     contents.font.size = 16
  321.   end
  322.   
  323.   def draw_actor_xparam_to_s(x,y,xparam_id)
  324.     a=0.00
  325.     for i in 0 .. POINT_KIND-1
  326.       a+=($temp_point[i]*point_add_xparam(@actor.id)[i][xparam_id]/10000.0)
  327.     end
  328.     s1 = XARAM_NAME[xparam_id]
  329.     s2 = sprintf("%03.2f%%",@actor.xparam(xparam_id)*100)
  330.     s3 = sprintf("%03.2f%%",(@actor.xparam(xparam_id) + a)*100)

  331.     if @index < POINT_KIND
  332.       if point_add_xparam(@actor.id)[@index][xparam_id]==0
  333.         s4=""
  334.       else
  335.         s4 = sprintf("+%03.2f%%",point_add_xparam(@actor.id)[@index][xparam_id]/100.0)
  336.       end
  337.     else
  338.       s4 = ""
  339.     end
  340.    
  341.     change_color(system_color)
  342.     draw_text(x,y+16*xparam_id,100,line_height,s1)
  343.     change_color(normal_color)
  344.     s2+= " →"
  345.     draw_text(x+82,y+16*xparam_id,150,line_height,s2,2)
  346.     change_color(system_color)
  347.     draw_text(x+150,y+16*xparam_id,120,line_height,s3,2)
  348.     change_color(normal_color)
  349.     contents.font.size = 14
  350.     draw_text(x+266,y+16*xparam_id,100,line_height,s4)
  351.     contents.font.size = 16
  352.    
  353.   end
  354. end

  355. class Scene_Point < Scene_MenuBase
  356.   include Point_Tree
  357.   def start
  358.     super
  359.     Window_Point_Command::init_command_position
  360.     create_background
  361.     @actor = $game_party.menu_actor
  362.     create_command_window
  363.     create_status_window
  364.     create_help_window
  365.     @command_window.activate
  366.   end
  367.   def terminate
  368.     super
  369.     dispose_background
  370.   end
  371.   
  372.   def create_command_window
  373.     @command_window = Window_Point_Command.new(@actor)
  374.     @command_window.set_handler(:cancel,      method(:return_scene))
  375.     @command_window.set_handler(:RIGHT,    method(:next_actor))
  376.     @command_window.set_handler(:LEFT,      method(:prev_actor))
  377.     @command_window.set_handler(:point_add,   method(:add_point))
  378.     @command_window.set_handler(:point_ok,    method(:add_ok))
  379.     @command_window.set_handler(:point_cancle,method(:add_cancle))
  380.    
  381.   end
  382.   def return_scene
  383.     add_cancle
  384.     SceneManager.return
  385.   end
  386.   def create_status_window
  387.     @status_window = Window_Point_Actor.new(@actor)
  388.     @command_window.status_window = @status_window
  389.   end
  390.   def create_help_window
  391.     @help_window = Window_Point_Help.new(0,@command_window.height,160,[email]Graphics.height-@command_window.height[/email])
  392.     @help_window.viewport = @viewport
  393.     @command_window.help_window = @help_window
  394.   end
  395.   
  396.   def add_point
  397.     if temp_all >= $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE]
  398.       @command_window.activate
  399.       return
  400.     end
  401.     $temp_point[@command_window.index] += 1
  402.     @status_window.refresh
  403.     @command_window.refresh
  404.     @command_window.activate
  405.   end
  406.   

  407.   def add_ok
  408.     for i in 0 .. POINT_KIND-1
  409.       $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE+i+1] += $temp_point[i]
  410.     end
  411.     $game_variables[@actor.id*(POINT_KIND+1) + POINT_VARIABLE] -= temp_all
  412.     add_cancle
  413.   end
  414.   
  415.   def add_cancle
  416.     for i in 0 .. POINT_KIND-1
  417.       $temp_point[i]=0
  418.     end
  419.     @status_window.refresh
  420.     @command_window.refresh
  421.     @command_window.activate
  422.   end
  423.   
  424.   
  425.   def next_actor
  426.     @actor = $game_party.menu_actor_next
  427.     on_actor_change
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 切换到上一个角色
  431.   #--------------------------------------------------------------------------
  432.   def prev_actor
  433.     @actor = $game_party.menu_actor_prev
  434.     on_actor_change
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ● 切换角色
  438.   #--------------------------------------------------------------------------
  439.   def on_actor_change
  440.     add_cancle
  441.     @status_window.actor = @actor
  442.     @command_window.actor = @actor
  443.     @command_window.activate
  444.   end
  445.   
  446.   
  447. end

  448. class Window_MenuCommand < Window_Command
  449.   alias add_original_commands_old add_original_commands
  450.   def add_original_commands
  451.     add_original_commands_old
  452.     add_command(Point_Tree::ADDPOINT,    :addpoint)
  453.   end
  454. end

  455. class Scene_Menu < Scene_MenuBase
  456.   alias create_command_window_old create_command_window
  457.   def create_command_window
  458.     create_command_window_old
  459.     @command_window.set_handler(:addpoint,method(:on_ok))
  460.   end
  461.   def on_ok
  462.     SceneManager.call(Scene_Point)
  463.   end
  464. end



  465. class Scene_ItemBase < Scene_MenuBase
  466.   def item_usable?
  467.     if item.id == Point_Tree::RESET_ITEM
  468.       return true
  469.     end
  470.     user.usable?(item) && item_effects_valid?
  471.   end
  472. end

  473. #==============================================================================
  474. #
  475. # ▼ 以下为我的修改,主要为了适应1024*576分辨率。By风宥雪
  476. #
  477. #==============================================================================
  478. if ADJUST_X
  479. #帮助窗口
  480. class Window_Point_Help < Window_Help
  481.   include Point_Tree
  482.   def set_text(id)
  483.     contents.clear
  484.     if id <= POINT_KIND
  485.       text = "提升一点该属性"
  486.     elsif id == POINT_KIND+1
  487.       text = "确认此次加点分配"
  488.     elsif  id == POINT_KIND+2
  489.       text = "取消此次加点分配"
  490.     end
  491.     draw_text_ex(8, 8, text)
  492.   end
  493. end
  494. #加点命令窗口
  495. class Window_Point_Command < Window_Command
  496.   #--------------------------------------------------------------------------
  497.   # ● 初始化对象
  498.   #--------------------------------------------------------------------------
  499.   def initialize(actor)
  500.     @status_window = nil
  501.     @actor = actor
  502.     super(ADJUST_X,ADJUST_Y)
  503.     select_last
  504.   end
  505.   #--------------------------------------------------------------------------
  506.   # ● 获取窗口的高度
  507.   #--------------------------------------------------------------------------
  508.   def window_height
  509.     ADJUST_CY
  510.   end
  511. end
  512. #角色状态窗口
  513. class Window_Point_Actor < Window_Base
  514.   def initialize(actor)
  515.     super(160+ADJUST_X, ADJUST_Y, ADJUST_CX - 160, ADJUST_CY)
  516.     @actor = actor
  517.     @index = 0
  518.     refresh
  519.   end
  520.   #基础属性
  521.    def draw_actor_param_to_s(x,y,param_id)
  522.     #坐标下调一点
  523.     y += 25
  524.     a=0
  525.     for i in 0 .. POINT_KIND-1
  526.       a+=$temp_point[i]*point_add_param(@actor.id)[i][param_id]
  527.     end
  528.     #属性名称
  529.     s1 = Vocab::param(param_id)
  530.     #当前值
  531.     s2 = @actor.param(param_id).to_s
  532.     #新值
  533.     s3 = (@actor.param(param_id) + a).to_s
  534.     #加点效果
  535.     if @index < POINT_KIND
  536.       if point_add_param(@actor.id)[@index][param_id]==0
  537.         s4 = ""
  538.       else
  539.         s4 = "+" + point_add_param(@actor.id)[@index][param_id].to_s
  540.       end
  541.     else
  542.       s4 = ""
  543.     end
  544.     #特殊属性
  545.     change_color(system_color)
  546.     draw_text(x,y+16*param_id,100,line_height,s1)
  547.     change_color(normal_color)
  548.     s2+= " →"
  549.     draw_text(x+52,y+16*param_id,150,line_height,s2,2)
  550.     contents.font.color = Color.new(0,255,0) if a > 0
  551.     contents.font.bold = true
  552.     draw_text(x+150,y+16*param_id,120,line_height,s3,2)
  553.     #contents.font.color = Color.new(0,255,0)
  554.     #contents.font.bold = true
  555.     draw_text(250,y+16*param_id,100,line_height,s4,2)
  556.     contents.font.bold = false
  557.   end
  558.   
  559.   def draw_actor_xparam_to_s(x,y,xparam_id)
  560.     #坐标下调一点
  561.     y += 25
  562.     a=0.00
  563.     for i in 0 .. POINT_KIND-1
  564.       a+=($temp_point[i]*point_add_xparam(@actor.id)[i][xparam_id]/10000.0)
  565.     end
  566.     s1 = XARAM_NAME[xparam_id]
  567.     s2 = sprintf("%03.2f%%",@actor.xparam(xparam_id)*100)
  568.     s3 = sprintf("%03.2f%%",(@actor.xparam(xparam_id) + a)*100)

  569.     if @index < POINT_KIND
  570.       if point_add_xparam(@actor.id)[@index][xparam_id]==0
  571.         s4=""
  572.       else
  573.         s4 = sprintf("+%03.2f%%",point_add_xparam(@actor.id)[@index][xparam_id]/100.0)
  574.       end
  575.     else
  576.       s4 = ""
  577.     end
  578.     change_color(system_color)
  579.     draw_text(x,y+16*xparam_id,100,line_height,s1)
  580.     change_color(normal_color)
  581.     s2+= " →"
  582.     draw_text(x+52,y+16*xparam_id,150,line_height,s2,2)
  583.     contents.font.color = Color.new(0,255,0)  if a > 0
  584.     contents.font.bold = true
  585.     draw_text(x+150,y+16*xparam_id,120,line_height,s3,2)
  586.     #contents.font.color = Color.new(0,255,0)
  587.     #contents.font.bold = true
  588.     draw_text(250,y+16*xparam_id,100,line_height,s4,2)
  589.     contents.font.bold = false
  590.   end
  591. end

  592. class Scene_Point < Scene_MenuBase
  593.   def create_help_window
  594.     @help_window = Window_Point_Help.new()
  595.     @help_window.viewport = @viewport
  596.     @command_window.help_window = @help_window
  597.   end
  598. end

  599. end
复制代码




===============================================================================================================





  1. #encoding:utf-8
  2. #===========================================================================
  3. #          RMVA 豪华型技能加点|技能被动效果:        v1.05
  4. #                       By希忆 66rpg.com
  5. #                                                 转载或修改请保留此类信息
  6. #===========================================================================
  7. # 在游戏系统类的实现
  8. #
  9. # 完工了,大概
  10. #===========================================================================
  11. #角色类,新增一堆方法。
  12. class Game_Actor < Game_Battler
  13.   
  14.   #初始化角色
  15.   #@skill_level:存放技能等级数据的哈希表,技能id=>技能等级
  16.   #@sp:剩余技能点
  17.   alias setup_201410131453 setup
  18.   def setup(actor_id)
  19.     @skill_level=Hash.new(0)
  20.     setup_201410131453(actor_id)
  21.     @sp = (@level-1) * SkillLevel::LEVELUPSP + SkillLevel::INITIALSP
  22.     auto_skill_levelup if self.class.auto_sp
  23.   end
  24.   
  25.   #读取技能点的方法,如果是自动升级技能的职业,则没必要有技能点
  26.   def sp
  27.     return 0 if self.class.auto_sp
  28.     @sp
  29.   end
  30.   
  31.   #读取技能基础等级,
  32.   #锁定技能等级优先度最高,
  33.   #链接技能等级次之,这个我好像在计算技能最终等级的方法里面又来了一遍。
  34.   #主要是技能基础等级是升级技能的窗口看到的等级,最终等级是使用技能的窗口。
  35.   def skill_basic_level(skill_id)
  36.     return 0 if skill_id == 0
  37.     lock = $data_skills[skill_id].lock_level
  38.     return lock if lock != 0
  39.     lnk = $data_skills[skill_id].link_skill
  40.     return skill_basic_level(lnk) if lnk != 0
  41.     @skill_level[skill_id]
  42.   end
  43.   
  44.   #获取装备增加技能的等级之和
  45.   def skill_plus_level(skill_id)
  46.     self.equips.compact.inject(0){|skl,eqp| skl+eqp.add_skill(skill_id)}
  47.   end
  48.   
  49.   #读取技能最终等级,如果技能基础等级为零,则不加装备提升直接等于零。
  50.   #最后返回基础等级+装备附加与技能最大等级中的小值
  51.   def skill_level(skill_id)
  52.     return 0 if skill_id == 0
  53.     lock = $data_skills[skill_id].lock_level
  54.     return lock if lock != 0
  55.     lnk = $data_skills[skill_id].link_skill
  56.     return skill_level(lnk) if lnk != 0
  57.     return 0 unless @skills.include?(skill_id)
  58.     return 0 if skill_basic_level(skill_id) == 0
  59.     [skill_basic_level(skill_id) + skill_plus_level(skill_id) ,\
  60.     $data_skills[skill_id].max_level].min
  61.   end
  62.   
  63.   #升一级技能技能能升级就升级,返回成功,否则返回失败
  64.   def level_up_skill(skill_id)
  65.     skl = $data_skills[skill_id]
  66.     if skill_can_levelup?(skl)
  67.       @sp -= skl.sp_cost
  68.       @skill_level[skill_id] += 1
  69.       return true
  70.     else
  71.       return false
  72.     end
  73.   end
  74.   
  75.   #初始化角色时初始化技能的方法,
  76.   #这里是不管默认的技能设定直接加载能学到的所有技能,也就是职业列表下的那些。
  77.   def init_skills
  78.     @skills = []
  79.     self.class.learnings.each do |learning|
  80.       @skills.push(learning.skill_id)
  81.     end
  82.     @skills.sort!
  83.   end
  84.   
  85.   #主要用在技能列表的窗口里的。确保只有技能等级为1级及以上的技能才能显示。
  86.   def has_skill?(skill)
  87.     skills.include?(skill) && skill_basic_level(skill.id) > 0
  88.   end
  89.   
  90.   #判断是否学习了技能,同样要确保只有技能等级为1级及以上的技能才能显示。
  91.   #和上面的区别是上面的可以有装备附带,状态附带的技能等级不为0的技能
  92.   #这里只能是职业列表下“领悟”的技能,装备状态附带的都不算
  93.   def skill_learn?(skill)
  94.     skill.is_a?(RPG::Skill) && @skills.include?(skill.id) && skill_basic_level(skill.id) > 0
  95.   end
  96.   
  97.   #判断前置技能是否都满足
  98.   def skill_former_match?(skill)
  99.     skill.former.each do |former|
  100.       return false unless skill_basic_level(former[0]) >= former[1]
  101.     end
  102.     true
  103.   end
  104.   
  105.   #判断技能是否已经学到精通了、
  106.   def skill_max_learn?(skill)
  107.     skill_basic_level(skill.id) == skill.max_learn
  108.   end
  109.   
  110.   #计算学习下一等级的技能所需要的人物等级
  111.   #如果精通了return false【感觉好像有点奇葩。。。】
  112.   def skill_next_level(skill)
  113.     return false if skill_max_learn?(skill)
  114.     skill.learn_level[0] + skill_basic_level(skill.id) * skill.learn_level[1]
  115.   end
  116.   
  117.   #技能能否升级?首先看是否锁定,是否链接,是否精通,
  118.   #再看等级是否符合学习下一级,sp是否足够,前置技能是否满足要求。
  119.   def skill_can_levelup?(skill)
  120.     return false if skill.lock_level != 0
  121.     return false if skill.link_skill != 0
  122.     return false if skill_max_learn?(skill)
  123.     @level >= skill_next_level(skill) && @sp >= skill.sp_cost && skill_former_match?(skill)
  124.   end
  125.   
  126.   #好像没什么用处。。。当初修改的用意是直接设置技能等级,后来觉得不好控制。。。
  127.   #反正就放着吧,不去管它好了
  128.   def learn_skill(skill_id,sk_level=0)
  129.     unless skill_learn?($data_skills[skill_id])
  130.       @skills.push(skill_id)
  131.       @skills.sort!
  132.       @skill_level[skill_id]=sk_level unless @skill_level.has_key?(skill_id)
  133.     end
  134.   end
  135.   
  136.   #自动升级技能。
  137.   def auto_skill_levelup
  138.     @skills.each do |skill|
  139.       skl=$data_skills[skill]
  140.       if self.class.auto_sp
  141.         while skill_next_level(skl) && skill_next_level(skl) <= @level do
  142.           @skill_level[skill] += 1
  143.         end
  144.       elsif skl.auto_levelup
  145.         while level_up_skill(skill) do
  146.         end
  147.       end
  148.     end
  149.   end
  150.   
  151.   #升级时发生的事情,等级+1,sp增加,如果是自动升级技能的职业则自动升级技能
  152. #  alias skill_system_levelup level_up
  153.   def level_up
  154. #    skill_system_levelup
  155.     @level += 1
  156.     @sp += SkillLevel::LEVELUPSP
  157.     auto_skill_levelup
  158.   end
  159.   
  160.   #被动技能提升的基础属性(加法叠加的部分)
  161.   #SkillLevel.formula:带入公式计算。
  162.   def skill_plus(param_id)
  163.     skills.inject(0) do |plu,skl|
  164.       plu + SkillLevel.formula(self.skill_level(skl.id),skl.param_add(param_id))
  165.     end
  166.   end
  167.   
  168.   #被动技能提升的基础属性倍率(乘法叠加)
  169.   def skill_rate(param_id)
  170.     skills.inject(1.00) do |plu,skl|
  171.       plu * SkillLevel.formula(self.skill_level(skl.id),skl.param_rate(param_id))
  172.     end
  173.   end
  174.   
  175.   #被动技能影响的属性抗性(乘法叠加)
  176.   def skill_element_rate(element_id)
  177.     skills.inject(1.00) do |plu,skl|
  178.       plu * SkillLevel.formula(self.skill_level(skl.id),skl.element_rate(element_id))
  179.     end
  180.   end
  181.   
  182.   #状态提升的基础属性(加法叠加的部分)
  183.   def state_param_plus(param_id)
  184.     states.inject(0) do |plu,sta|
  185.       plu + SkillLevel.formula(@state_level[sta.id],sta.param_add(param_id))
  186.     end
  187.   end
  188.   #状态提升的基础属性倍率(乘法叠加)
  189.   def state_param_rate(param_id)
  190.     states.inject(1.00) do |plu,sta|
  191.       plu * SkillLevel.formula(@state_level[sta.id],sta.param_rate(param_id))
  192.     end
  193.   end
  194.   #状态额外影响的属性抗性(乘法叠加)
  195.   def state_element_rate(element_id)
  196.     states.inject(1.00) do |plu,sta|
  197.       plu * SkillLevel.formula(@state_level[sta.id],sta.element_rate(element_id))
  198.     end
  199.   end
  200.   
  201.   #基础属性的计算,添加了被动技能的提升,按默认的先加后乘
  202.   def param(param_id)
  203.     value = param_base(param_id) + param_plus(param_id) +
  204.             skill_plus(param_id) + state_param_plus(param_id)
  205.     value *= param_rate(param_id) * param_buff_rate(param_id) *
  206.              skill_rate(param_id) * state_param_rate(param_id)
  207.     [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  208.   end
  209.   
  210.   #状态影响的附加属性xparam
  211.   def state_xparam(xparam_id)
  212.     states.inject(0.0) do |plu,sta|
  213.       plu + SkillLevel.formula(@state_level[sta.id],sta.xparam(xparam_id))
  214.     end
  215.   end
  216.   #附加属性xparam的计算,命中暴击什么的,迭代加算。
  217.   def xparam(xparam_id)
  218.     state_xparam(xparam_id) + @skills.inject(super(xparam_id)) do |plu,skl|
  219.       plu + SkillLevel.formula(self.skill_level(skl),$data_skills[skl].xparam(xparam_id))
  220.     end
  221.   end
  222.   
  223.   #状态影响特殊属性sparam的计算
  224.   def state_sparam(sparam_id)
  225.     states.inject(1.0) do |plu,sta|
  226.       plu * SkillLevel.formula(@state_level[sta.id],sta.sparam(sparam_id))
  227.     end
  228.   end
  229.   #特殊属性sparam的计算,经验值比率什么的,迭代连乘计算。
  230.   def sparam(sparam_id)
  231.     state_sparam(sparam_id)*skills.inject(super(sparam_id)) do |plu,skl|
  232.       plu * SkillLevel.formula(self.skill_level(skl.id),skl.sparam(sparam_id))
  233.     end
  234.   end
  235.   
  236.   #技能消耗mp由于技能等级修正的倍率,
  237.   #反正就是到SkillLevel.formula找对应编号的公式。
  238.   def skill_mp_rate(skill)
  239.     SkillLevel.formula(skill_level(skill.id),skill.mp_type)
  240.   end
  241.   
  242.   #计算最终技能消耗mp的量
  243.   def skill_mp_cost(skill)
  244.     (skill.mp_cost * mcr * skill_mp_rate(skill)).to_i
  245.   end
  246.   
  247.   #计算暴击伤害倍率super:Game_Battler中的critical_rate,返回1.5
  248.   #人物提升,职业提升,被动技能修正和装备提升
  249.   def critical_rate
  250.     v = super
  251.     v *= (1.0 + self.actor.critical_rate/100.0)
  252.     v *= (1.0 + self.class.critical_rate/100.0)
  253.     v *= skills.inject(1.00) do |plu,skl|
  254.       plu * SkillLevel.formula(self.skill_level(skl.id),skl.critical_rate)
  255.     end
  256.     v*equips.compact.inject(1.00){ |rat,equip| rat*(1.00+equip.critical_rate/100.0) }
  257.   end
  258.   
  259.   #属性伤害修正。
  260.   def element_rate(element_id)
  261.     super(element_id) * skill_element_rate(element_id) * state_element_rate(element_id)
  262.   end
  263.   
  264.   #被动技能影响的属性强化效果。
  265.   def skill_element_damage(element_id)
  266.     skills.inject(1.00) do |plu,skl|
  267.       plu * SkillLevel.formula(self.skill_level(skl.id),skl.element_damage(element_id))
  268.     end
  269.   end
  270.   
  271.   def state_element_damage(element_id)
  272.     states.inject(1.00) do |plu,sta|
  273.       plu * SkillLevel.formula(@state_level[sta.id],sta.element_damage(element_id))
  274.     end
  275.   end
  276.   
  277.   #基础属性强化,角色备注和职业备注修正。
  278.   def basic_element_damage(element_id)
  279.     (1.0 + self.actor.element_damage(element_id)/100.0) *
  280.     (1.0 + self.class.element_damage(element_id)/100.0)
  281.   end
  282.   
  283.   #计算最终属性强化基础技能装备迭代连乘
  284.   def element_damage(element_id)
  285.     basic_element_damage(element_id) *
  286.     equips.compact.inject(skill_element_damage(element_id)) do |rat,equip|
  287.       rat*(1.00+equip.element_damage(element_id)/100.0)
  288.     end
  289.   end

  290.   #受到hp伤害转移给mp的比例,遍历计算并返回最大值
  291.   def damage_convert
  292.     skl = skills.collect{|sk| sk = SkillLevel.formula(self.skill_level(sk.id),sk.damage_convert)}
  293.     sta = states.collect{|st| st = SkillLevel.formula(@state_level[st.id],st.damage_convert)}
  294.     (skl+sta).max
  295.   end
  296.   
  297.   #洗技能了,
  298.   alias item_apply_201411181846 item_apply
  299.   def item_apply(user, item)
  300.     item_apply_201411181846(user, item)
  301.     if item.is_a?(RPG::Item) and item.id == SkillLevel::RESETITEM
  302.       if self.reset_skill
  303.         self.hp = [self.hp,self.mhp].min
  304.         self.mp = [self.mp,self.mmp].min
  305.       end
  306.     end
  307.   end
  308.   
  309.   #洗技能的方法
  310.   def reset_skill
  311.     return false if self.class.auto_sp
  312.     @sp = (@level-1) * SkillLevel::LEVELUPSP + SkillLevel::INITIALSP
  313.     @skills.each  { |skill| @skill_level[skill]=0 }
  314.     return true
  315.   end
  316.   
  317. end

  318. #有关洗点水的使用判断,想和上面洗点放在一起。于是没有放进场景相关。
  319. class Scene_ItemBase < Scene_MenuBase
  320.   def item_usable?
  321.     if item.id == SkillLevel::RESETITEM
  322.       return false if item_target_actors[0].class.auto_sp
  323.       return true
  324.     end
  325.     user.usable?(item) && item_effects_valid?
  326.   end
  327. end

  328. class Game_Enemy
  329.   #敌人属性强化
  330.   def element_damage(id)
  331.     1.0 + self.enemy.element_damage(id)/100.0
  332.   end
  333.   #敌人暴击倍率 super:Game_Battler定义的critical_rate,返回1.5
  334.   def critical_rate
  335.     super * (1+self.enemy.element_damage/100.0)
  336.   end
  337.   #敌人的技能等级,要么锁定,要么1
  338.   def skill_level(skill_id)
  339.     lock = $data_skills[skill_id].lock_level if $data_skills[skill_id]
  340.     return lock if lock != 0
  341.     return 1
  342.   end
  343.     #状态提升的基础属性(加法叠加的部分)
  344.   def state_param_plus(param_id)
  345.     states.inject(0) do |plu,sta|
  346.       plu + SkillLevel.formula(@state_level[sta.id],sta.param_add(param_id))
  347.     end
  348.   end
  349.   #状态提升的基础属性倍率(乘法叠加)
  350.   def state_param_rate(param_id)
  351.     states.inject(1.00) do |plu,sta|
  352.       plu * SkillLevel.formula(@state_level[sta.id],sta.param_rate(param_id))
  353.     end
  354.   end
  355.   #状态额外影响的属性抗性(乘法叠加)
  356.   def state_element_rate(element_id)
  357.     states.inject(1.00) do |plu,sta|
  358.       plu * SkillLevel.formula(@state_level[sta.id],sta.element_rate(element_id))
  359.     end
  360.   end
  361.   
  362.   #基础属性的计算,添加了被动技能的提升,按默认的先加后乘
  363.   def param(param_id)
  364.     value = param_base(param_id) + param_plus(param_id) +
  365.             state_param_plus(param_id)
  366.     value *= param_rate(param_id) * param_buff_rate(param_id) *
  367.              state_param_rate(param_id)
  368.     [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  369.   end
  370.   
  371.   #状态影响的附加属性xparam
  372.   def state_xparam(xparam_id)
  373.     states.inject(0.0) do |plu,sta|
  374.       plu + SkillLevel.formula(@state_level[sta.id],sta.xparam(xparam_id))
  375.     end
  376.   end
  377.   #附加属性xparam的计算,命中暴击什么的,迭代加算。
  378.   def xparam(xparam_id)
  379.     state_xparam(xparam_id) + super(xparam_id)
  380.   end
  381.   
  382.   #状态影响特殊属性sparam的计算
  383.   def state_sparam(sparam_id)
  384.     states.inject(1.0) do |plu,sta|
  385.       plu * SkillLevel.formula(@state_level[sta.id],sta.sparam(sparam_id))
  386.     end
  387.   end
  388.   #特殊属性sparam的计算,经验值比率什么的,迭代连乘计算。
  389.   def sparam(sparam_id)
  390.     super(sparam_id)*state_sparam(sparam_id)
  391.   end
  392.   def state_element_damage(element_id)
  393.     states.inject(1.00) do |plu,sta|
  394.       plu * SkillLevel.formula(@state_level[sta.id],sta.element_damage(element_id))
  395.     end
  396.   end
  397.   def element_rate(element_id)
  398.     super(element_id) * state_element_rate(element_id)
  399.   end
  400. end



  401. class Game_Battler < Game_BattlerBase
  402.   
  403.   #attr_reader :state_level
  404.   #@state_level 保存状态等级的数组
  405.   alias initialize_201410131453 initialize
  406.   def initialize
  407.     initialize_201410131453
  408.     @state_level = Hash.new(0)
  409.   end
  410.   
  411.   #属性修正的计算,将使用者属性强化也计算在内的
  412.   def item_element_rate(user, item)
  413.     if item.damage.element_id < 0
  414.       user.atk_elements.empty? ? 1.0 : elements_max_rate(user)
  415.     else
  416.       element_rate(item.damage.element_id)*user.element_damage(item.damage.element_id)
  417.     end
  418.   end
  419.   
  420.   #将使用者属性强化也计算在内的最有效属性。
  421.   def elements_max_rate(user)
  422.     user.atk_elements.inject([0.0]) {|r, i| r.push(element_rate(i)*user.element_damage(i)) }.max
  423.   end
  424.   
  425.   def damage_convert #受到hp伤害转移给mp的比例
  426.     0
  427.   end
  428.   
  429.   #计算伤害,SkillLevel.formula找公式算修正。
  430.   def make_damage_value(user, item)
  431.     value = item.damage.eval(user, self, $game_variables)
  432.     if item.is_a?(RPG::Skill)
  433.       value *= SkillLevel.formula(user.skill_level(item.id),item.damage_increase_type)
  434.     end
  435.    
  436.     value *= item_element_rate(user, item)
  437.     value *= pdr if item.physical?
  438.     value *= mdr if item.magical?
  439.     value *= rec if item.damage.recover?
  440.     value = apply_critical(value,user) if @result.critical
  441.     value = apply_variance(value, item.damage.variance)
  442.     value = apply_guard(value)
  443.    
  444.     if value > 0 && damage_convert > 0
  445.       valmp = [(value*damage_convert).to_i,self.mp].min
  446.       self.mp -= valmp
  447.       value -= valmp
  448.     end
  449.     @result.make_damage(value.to_i, item)
  450.   end
  451.   
  452.   #计算暴击修正,添加了参数user
  453.   def apply_critical(value,user)
  454.     value * user.critical_rate
  455.   end
  456.   
  457.   #基础暴击修正
  458.   def critical_rate
  459.     1.5
  460.   end
  461.   
  462.   #状态附加,添加参数user,写的有点奇怪。如果有明确的user,
  463.   #就提取技能等级user.skill_level($data_states[state_id].link_skill)
  464.   #然后按SkillLevel.formula公式算得到附加概率,如果随机数比概率大(算是失败)
  465.   #就直接返回,再下去按部就班如果没有状态就附加新状态,如果有明确的user,
  466.   #状态的等级就等于之前提取的技能等级,否则为1。
  467.   def add_state(state_id,user = nil)
  468.     if state_addable?(state_id)
  469.       if user != nil
  470.         lv = user.skill_level($data_states[state_id].link_skill)
  471.       else
  472.         lv = 1
  473.       end
  474.       return if rand > SkillLevel.formula(lv,$data_states[state_id].chance)
  475.       add_new_state(state_id) unless state?(state_id)
  476.       if user != nil
  477.         @state_level[state_id] = lv
  478.       else
  479.         @state_level[state_id] = 1
  480.       end
  481.       reset_state_counts(state_id)
  482.       @result.added_states.push(state_id).uniq!
  483.     end
  484.   end
  485.   
  486.   def item_effect_add_state_attack(user, item, effect)
  487.     user.atk_states.each do |state_id|
  488.       chance = effect.value1
  489.       chance *= state_rate(state_id)
  490.       chance *= user.atk_states_rate(state_id)
  491.       chance *= luk_effect_rate(user)
  492.       if rand < chance
  493.         add_state(state_id,user)
  494.         @result.success = true
  495.       end
  496.     end
  497.   end

  498.   def item_effect_add_state_normal(user, item, effect)
  499.     chance = effect.value1
  500.     chance *= state_rate(effect.data_id) if opposite?(user)
  501.     chance *= luk_effect_rate(user)      if opposite?(user)
  502.     if rand < chance
  503.       add_state(effect.data_id,user)
  504.       @result.success = true
  505.     end
  506.   end
  507.   
  508. end
复制代码



就是升级没有人物加点的加点数,只有技能升级的技能点,搞了很久,找不到解决的办法,望高手帮我解决一下
梦石
0
星屑
62
在线时间
839 小时
注册时间
2010-6-26
回帖
652
发表于 2015-6-6 19:28:03 | 显示全部楼层
看了一眼,试过上下调换顺序么

点评

不行的,会导致其他冲突  发表于 2015-6-10 11:47

评分

参与人数 1星屑 +132 收起 理由
VIPArcher + 132 我很赞同

查看全部评分

新手们!不要被看扁了!我们也会用论坛搜索,我们也会自己找脚本,我们也会自己点击关闭按钮旁边的小问号!
回复

使用道具 举报

梦石
0
星屑
1881
在线时间
414 小时
注册时间
2012-7-30
回帖
68
发表于 2015-6-6 20:14:19 | 显示全部楼层
在游戏系统类的153行level_up函数里加上$game_variables[self.id*(POINT_KIND+1) + POINT_VARIABLE] += LEVEL_UP_POINT

点评

请问具体是怎么添加的,我试了一下,就报错了。是直接把@level += 1中的1去掉,然后复制。还是直接复制在后面了?  发表于 2015-7-3 20:37
回复

使用道具 举报

梦石
0
星屑
1187
在线时间
12 小时
注册时间
2015-7-22
回帖
4
发表于 2015-7-29 11:20:44 | 显示全部楼层
用那个非变量版然后把加属性点的放在下面
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部