查看: 2164|回复: 8

[已经过期] 【求助】如何在小树的加点脚本中用事件增加可分配点数

[复制链接]
梦石
2
星屑
3034
在线时间
398 小时
注册时间
2016-8-16
回帖
92

开拓者

发表于 2016-11-11 20:15:07 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 RaidenInfinity 于 2016-11-11 20:46 编辑

如题,我用的是无需变量的版本,现在我要设置达成成就的话就可以获取自由分配的点数,那么该怎么办?求助。另外,附上脚本。


  1. #encoding:utf-8
  2. #=============================================================================
  3. #-----------RMVA加点系统正常向-v1.03---By:救世小树--------转载请注明出处-------
  4. #=============================================================================

  5. module Point_Tree
  6.   
  7.   POINT_KIND     = 5       #设定加点种类
  8.   LEVEL_UP_POINT = 5       #每升一级自由属性点增加数
  9.   RESET_ITEM     = 20      #洗点水编号
  10.   
  11.   STR_POINT        = ["增加体质","增加力量","增加魔力","增加灵巧","增加敏捷","     "]
  12.   
  13.   #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  14.   POINT_ADD_PARAM = [[25 ,  20,   0,  0,   0,   0,   0,   0],     #体力
  15.                      [0  ,  0,   10,  0,   0,   0,   0,   0],     #力量
  16.                      [2  ,  15,   0,  0,   3,   1,   0,   0],     #魔力
  17.                      [2  ,  2,   0,  0,   0,   0,   0,   3],     #灵巧
  18.                      [0  ,  0,   0,  0,   0,   0,   2,   0],     #敏捷
  19.                      
  20.                      [0,0,0,0,0,0,0,0]]
  21.                      #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
  22.   
  23.   #分别对应增加       [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  24.   POINT_ADD_XPARAM = [[0 , 0, 0, 0, 0, 0, 0, 5, 5, 0],
  25.                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  26.                       [0 , 0, 0, 0, 0, 0, 0, 0, 0, 0],
  27.                       [5 , 0, 5, 0, 0, 0, 5, 0, 0, 0],
  28.                       [0 , 5, 0, 5, 5, 0, 0, 0, 0, 0],
  29.                      
  30.                       [0,0,0,0,0,0,0,0,0,0]]
  31.                      #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
  32.   
  33.   #各种名称
  34.   
  35.   ADDPOINT       = "加点"     #菜单中选项
  36.   POINT_NAME     = "属性点"   #未分配点数
  37.   
  38.   XARAM_NAME     = ["物理命中","物理闪避","暴击","暴击闪避","魔术闪避","魔术反射","物理反击","体力再生","魔力再生","怒气再生"]

  39.   
  40.   def temp_all
  41.     r = 0
  42.     for i in 0 .. POINT_KIND-1
  43.       r+=$temp_point[i]
  44.     end
  45.     return r
  46.   end
  47.   
  48.   def reset(actor_id)
  49.     for i in 1..6
  50.       $game_actors[actor_id].point[0] += $game_actors[actor_id].point[i]
  51.       $game_actors[actor_id].point[i] =0
  52.     end
  53.   end
  54.   
  55. end

  56. $temp_point = []
  57. for i in 0 .. Point_Tree::POINT_KIND-1
  58.   $temp_point.push(0)
  59. end

  60. class Game_Actor < Game_Battler
  61.   include Point_Tree
  62.   attr_accessor :point
  63.   
  64.   alias setup_tre setup
  65.   def setup(actor_id)
  66.     @point = []
  67.     for i in 0 .. POINT_KIND
  68.       @point.push(0)
  69.     end
  70.     setup_tre(actor_id)
  71.   end
  72.   
  73.   
  74.   
  75.   
  76.   alias level_up_tre level_up
  77.   def level_up
  78.     level_up_tre
  79.     @hp += mhp
  80.     @mp += mmp
  81.     @point[0] += LEVEL_UP_POINT
  82.   end
  83.   

  84.   
  85.   def point_plus(param_id)
  86.     r=0
  87.     for i in 1 .. POINT_KIND
  88.       r+=@point[i]*POINT_ADD_PARAM[i-1][param_id]
  89.     end
  90.     return r
  91.   end

  92.   alias point_base_param param
  93.   
  94.   def param(param_id)
  95.     value = param_base(param_id) + param_plus(param_id) + point_plus(param_id)
  96.     value *= param_rate(param_id) * param_buff_rate(param_id)
  97.     [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  98.   end
  99.   def xparam(xparam_id,extra_add = 0)
  100.     xp = super(xparam_id)
  101.     for i in 0 .. POINT_KIND-1
  102.       xp+=(@point[i+1]*POINT_ADD_XPARAM[i][xparam_id]/10000.0)
  103.     end
  104.     return xp
  105.   end

  106.   def item_apply(user, item)
  107.     super(user, item)
  108.     if item.id == RESET_ITEM and item.is_a?(RPG::Item)
  109.       reset(@actor_id)
  110.       self.hp = [self.hp,self.mhp].min
  111.       self.mp = [self.mp,self.mmp].min
  112.     end
  113.   end
  114.   
  115. end

  116. class Window_Point_Command < Window_Command
  117.   
  118.   include Point_Tree
  119.   #--------------------------------------------------------------------------
  120.   # ● 初始化指令选择位置(类方法)
  121.   #--------------------------------------------------------------------------
  122.   def self.init_command_position
  123.     @@last_command_symbol = nil
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 初始化对象
  127.   #--------------------------------------------------------------------------
  128.   def initialize(actor)
  129.     @status_window = nil
  130.     @actor = actor
  131.     super(0,0)
  132.     select_last
  133.   end
  134.   def actor=(actor)
  135.     return if @actor == actor
  136.     @actor = actor
  137.     refresh
  138.   end
  139.   def status_window=(status_window)
  140.     return if @status_window == status_window
  141.     @status_window = status_window
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 获取窗口的宽度
  145.   #--------------------------------------------------------------------------
  146.   def window_width
  147.     return 160
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 获取显示行数
  151.   #--------------------------------------------------------------------------
  152.   def visible_line_number
  153.     item_max
  154.   end
  155.   def get_actor_point(index)
  156.     s = @actor.point[index+1].to_s
  157.     return "("+s+")+"+$temp_point[index].to_s
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 生成指令列表
  161.   #--------------------------------------------------------------------------
  162.   def make_command_list
  163.     for i in 0 .. POINT_KIND-1
  164.       add_command(STR_POINT[i]   + get_actor_point(i)  , :point_add  ,add_enabled)
  165.     end
  166.     add_command("确认加点",  :point_ok)
  167.     add_command("取消加点",  :point_cancle)
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● 按下确定键时的处理
  171.   #--------------------------------------------------------------------------
  172.   def process_ok
  173.     @@last_command_symbol = current_symbol
  174.     super
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ● 返回最后一个选项的位置
  178.   #--------------------------------------------------------------------------
  179.   def select_last
  180.     select_symbol(@@last_command_symbol)
  181.   end
  182.   
  183.   def add_enabled
  184.     temp_all < @actor.point[0]
  185.   end

  186.   def update_help
  187.     @help_window.set_text(self.index+1) if @help_window
  188.     @status_window.index = self.index if @status_window
  189.   end
  190. end

  191. #帮助窗口
  192. class Window_Point_Help < Window_Base
  193.   include Point_Tree
  194.   def initialize(x,y,w,h)
  195.     super(x, y, w, h)
  196.    
  197.    
  198.   end
  199.   def set_text(id)
  200.     contents.clear
  201.     if id <= POINT_KIND
  202.       text = "\\}提升一点该属性,每增加一次
  203. 此项点数,可以提升能力值。"
  204.     elsif id == POINT_KIND+1
  205.       text = "\\}确认此次加点分配"
  206.     elsif  id == POINT_KIND+2
  207.       text = "\\}取消此次加点分配"
  208.     end
  209.     draw_text_ex(8, 8, text)
  210.   end
  211. end


  212. #角色状态窗口
  213. class Window_Point_Actor < Window_Base
  214.   include Point_Tree
  215.   
  216.   
  217.   def initialize(actor)
  218.     super(160, 0, Graphics.width - 160, Graphics.height)
  219.     @actor = actor
  220.     @index = 0
  221.     refresh
  222.   end
  223.   def actor=(actor)
  224.     return if @actor == actor
  225.     @actor = actor
  226.     refresh
  227.   end
  228.   def index=(index)
  229.     return if @index == index
  230.     @index = index
  231.     refresh
  232.   end
  233.   def line_height
  234.     return 24
  235.   end
  236.   def refresh
  237.     contents.clear
  238.     contents.font.size = 24
  239.     draw_actor_name(@actor, 100, 0)
  240.     draw_actor_class(@actor, 240, 0)
  241.     draw_actor_face(@actor, 2, 0)
  242.     contents.font.size = 20
  243.     draw_actor_level(@actor, 102,  24)
  244.     draw_actor_point(100,48)
  245.     contents.font.size = 16
  246.     draw_actor_param_point(8,16 * 6)
  247.     draw_actor_xparam_point(8,16 * 14)
  248.   end
  249.   def draw_actor_point(x,y)
  250.     draw_text(x,y,200,line_height,"  剩余点数"+POINT_NAME + ":" + @actor.point[0].to_s)
  251.     draw_text(x,y+line_height,200,line_height,"此次分配"+POINT_NAME + ":" + temp_all.to_s)
  252.   end
  253.   def draw_actor_param_point(x,y)
  254.     8.times {|i| draw_actor_param_to_s(x,y,i)}
  255.   end
  256.   def draw_actor_xparam_point(x,y)
  257.     10.times {|i| draw_actor_xparam_to_s(x,y,i)}
  258.   end
  259.   
  260.   def draw_actor_param_to_s(x,y,param_id)
  261.     a=0
  262.     for i in 0 .. POINT_KIND-1
  263.       a+=$temp_point[i]*POINT_ADD_PARAM[i][param_id]
  264.     end
  265.     s1 = Vocab::param(param_id)
  266.     s2 = @actor.param(param_id).to_s
  267.     s3 = (@actor.param(param_id)+a).to_s
  268.     if @index < POINT_KIND
  269.       if POINT_ADD_PARAM[@index][param_id]==0
  270.         s4 = ""
  271.       else
  272.         s4 = "+" + POINT_ADD_PARAM[@index][param_id].to_s
  273.       end
  274.     else
  275.       s4 = ""
  276.     end
  277.    
  278.     change_color(system_color)
  279.     draw_text(x,y+16*param_id,100,line_height,s1)
  280.     change_color(normal_color)
  281.     s2+= " →"
  282.     draw_text(x+82,y+16*param_id,120,line_height,s2,2)
  283.     change_color(system_color)
  284.     draw_text(x+150,y+16*param_id,100,line_height,s3,2)
  285.     change_color(normal_color)
  286.     contents.font.size = 14
  287.     draw_text(x+266,y+16*param_id,100,line_height,s4)
  288.     contents.font.size = 16
  289.   end
  290.   def draw_actor_xparam_to_s(x,y,xparam_id)
  291.     a=0.00
  292.     for i in 0 .. POINT_KIND-1
  293.       a+=($temp_point[i]*POINT_ADD_XPARAM[i][xparam_id]/10000.0)
  294.     end
  295.     s1 = XARAM_NAME[xparam_id]
  296.     s2 = sprintf("%02.2f%%",@actor.xparam(xparam_id)*100)
  297.     s3 = sprintf("%02.2f%%",(@actor.xparam(xparam_id) + a)*100)

  298.     if @index < POINT_KIND
  299.       if POINT_ADD_XPARAM[@index][xparam_id]==0
  300.         s4=""
  301.       else
  302.         s4 = sprintf("+%02.2f%%",POINT_ADD_XPARAM[@index][xparam_id]/100.0)
  303.       end
  304.     else
  305.       s4 = ""
  306.     end
  307.    
  308.     change_color(system_color)
  309.     draw_text(x,y+16*xparam_id,100,line_height,s1)
  310.     change_color(normal_color)
  311.     s2+= " →"
  312.     draw_text(x+82,y+16*xparam_id,120,line_height,s2,2)
  313.     change_color(system_color)
  314.     draw_text(x+150,y+16*xparam_id,100,line_height,s3,2)
  315.     change_color(normal_color)
  316.     contents.font.size = 14
  317.     draw_text(x+266,y+16*xparam_id,100,line_height,s4)
  318.     contents.font.size = 16
  319.    
  320.    
  321.   end
  322. end

  323. class Scene_Point < Scene_Base
  324.   include Point_Tree
  325.   def start
  326.     super
  327.     create_background
  328.     @actor = $game_party.menu_actor
  329.     create_command_window
  330.     create_status_window
  331.     create_help_window
  332.     @command_window.activate
  333.   end
  334.   def terminate
  335.     super
  336.     dispose_background
  337.   end
  338.   def create_background
  339.     @background_sprite = Sprite.new
  340.     @background_sprite.bitmap = SceneManager.background_bitmap
  341.     @background_sprite.color.set(16, 16, 16, 128)
  342.   end
  343.   def dispose_background
  344.     @background_sprite.dispose
  345.   end
  346.   
  347.   def create_command_window
  348.     @command_window = Window_Point_Command.new(@actor)
  349.     @command_window.set_handler(:cancel,      method(:return_scene))
  350.     @command_window.set_handler(:pagedown,    method(:next_actor))
  351.     @command_window.set_handler(:pageup,      method(:prev_actor))
  352.     @command_window.set_handler(:point_add,   method(:add_point))
  353.     @command_window.set_handler(:point_ok,    method(:add_ok))
  354.     @command_window.set_handler(:point_cancle,method(:add_cancle))
  355.    
  356.   end
  357.   def return_scene
  358.     add_cancle
  359.     SceneManager.return
  360.   end
  361.   def create_status_window
  362.     @status_window = Window_Point_Actor.new(@actor)
  363.     @command_window.status_window = @status_window
  364.   end
  365.   def create_help_window
  366.     @help_window = Window_Point_Help.new(0,@command_window.height,160,[email]Graphics.height-@command_window.height[/email])
  367.     #(0, 216, 160, 200)
  368.     @help_window.viewport = @viewport
  369.     @command_window.help_window = @help_window
  370.   end
  371.   
  372.   def add_point
  373.     if temp_all >= @actor.point[0]
  374.       @command_window.activate
  375.       return
  376.     end
  377.     $temp_point[@command_window.index] += 1
  378.     @status_window.refresh
  379.     @command_window.refresh
  380.     @command_window.activate
  381.   end
  382.   

  383.   def add_ok
  384.     for i in 0 .. POINT_KIND-1
  385.       @actor.point[i+1] += $temp_point[i]
  386.     end
  387.     @actor.point[0]-= temp_all
  388.     add_cancle
  389.   end
  390.   
  391.   def add_cancle
  392.     for i in 0 .. POINT_KIND-1
  393.       $temp_point[i]=0
  394.     end
  395.     @status_window.refresh
  396.     @command_window.refresh
  397.     @command_window.activate
  398.   end
  399.   
  400.   
  401.   def next_actor
  402.     @actor = $game_party.menu_actor_next
  403.     on_actor_change
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 切换到上一个角色
  407.   #--------------------------------------------------------------------------
  408.   def prev_actor
  409.     @actor = $game_party.menu_actor_prev
  410.     on_actor_change
  411.   end
  412.   #--------------------------------------------------------------------------
  413.   # ● 切换角色
  414.   #--------------------------------------------------------------------------
  415.   def on_actor_change
  416.     add_cancle
  417.     @status_window.actor = @actor
  418.     @command_window.actor = @actor
  419.     @command_window.activate
  420.   end
  421.   
  422. end


  423. class Scene_Menu < Scene_MenuBase
  424.   alias create_command_window_old create_command_window
  425.   def create_command_window
  426.     create_command_window_old
  427.     @command_window.set_handler(:addpoint,method(:add_point))
  428.   end
  429.   def add_point
  430.     @status_window.select_last
  431.     @status_window.activate
  432.     @status_window.set_handler(:ok,     method(:on_ok))
  433.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  434.   end
  435.   def on_ok
  436.     SceneManager.call(Scene_Point)
  437.     Window_Point_Command::init_command_position
  438.   end
  439. end



  440. class Scene_ItemBase < Scene_MenuBase
  441.   def item_usable?
  442.     if item.id == Point_Tree::RESET_ITEM and item.is_a?(RPG::Item)
  443.       return true
  444.     end
  445.     user.usable?(item) && item_effects_valid?
  446.   end
  447. end






  448. class Window_Status < Window_Selectable
  449.   include Point_Tree
  450.   alias draw_parameters_old draw_parameters
  451.   def draw_parameters(x, y)
  452.     draw_parameters_old(x,y)
  453.     draw_point(x,y)
  454.   end
  455.   def draw_point(x,y)
  456.     for i in 0..5
  457.       change_color(system_color)
  458.       draw_text(x+300, y+ line_height * i, 80, line_height, STR_POINT[i])
  459.       change_color(normal_color)
  460.       draw_text(x+380, y+ line_height * i, 36, line_height,@actor.point[i+1].to_s, 2)
  461.     end
  462.   end
  463.   
  464. end

  465. class Window_Base < Window
  466.   def draw_actor_param(actor, x, y, param_id)
  467.     change_color(system_color)
  468.     draw_text(x-30, y, 80, line_height, Vocab::param(param_id))
  469.     change_color(normal_color)
  470.     draw_text(x+ 50, y, 36, line_height, actor.param(param_id), 2)
  471.   end
  472. end
复制代码


附上自己做的图标

4.PNG
1.PNG
3.PNG

点评

93行报错...  发表于 2016-11-11 20:34
梦石
2
星屑
3034
在线时间
398 小时
注册时间
2016-8-16
回帖
92

开拓者

 楼主| 发表于 2016-11-11 20:38:59 | 显示全部楼层
这个脚本我自己改了很多的!!
回复

使用道具 举报

漾夕☽星化残月☾

梦石
0
星屑
8611
在线时间
3858 小时
注册时间
2015-5-12
回帖
2022

剧作品鉴家

发表于 2016-11-11 20:45:19 | 显示全部楼层
本帖最后由 御曹司 于 2016-11-11 21:08 编辑

$game_actors[actor_id].point[0]
就是你要的变量的写法、把actor_id写上然后用脚本里面改变量写法改就行了。
我想吐槽为什么不用代码框?
另外注意转载声明

还有就是我用那个帖子里面的代码实验的...
l

点评

喝杯溫水冷靜一下  发表于 2016-11-11 20:59
回复

使用道具 举报

梦石
0
星屑
6891
在线时间
7027 小时
注册时间
2013-11-2
回帖
1263

开拓者剧作品鉴家

发表于 2016-11-11 20:59:44 | 显示全部楼层
本帖最后由 RaidenInfinity 于 2016-11-11 21:02 编辑

在第88行加入:


  1. def add_points(i)
  2.   @points[0] += i
  3. end
复制代码


然后在事件脚本指令里面调用:


  1. $game_actors[角色ID].add_points(可分配点数)
复制代码
回复

使用道具 举报

梦石
2
星屑
3034
在线时间
398 小时
注册时间
2016-8-16
回帖
92

开拓者

 楼主| 发表于 2016-11-11 21:13:03 | 显示全部楼层
本帖最后由 卫宫白 于 2016-11-11 21:21 编辑

谢谢了,但是为什么我的游戏总是报错?

点评

这非常难解决,因为我们完全不知道你报的是什么类型的错,还有报错的讯息。  发表于 2016-11-11 21:59
回复

使用道具 举报

梦石
2
星屑
3034
在线时间
398 小时
注册时间
2016-8-16
回帖
92

开拓者

 楼主| 发表于 2016-11-11 23:37:39 | 显示全部楼层

不是拉,就是脚本有冲突。每次调用脚本事件时总会跳错。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部