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

Project1

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

[已经过期] 请问如何在加点脚本上新增用道具增加点数

[复制链接]

Lv2.观梦者

梦石
0
星屑
582
在线时间
310 小时
注册时间
2016-2-29
帖子
210
跳转到指定楼层
1
发表于 2016-9-4 09:13:41 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
除了升级外,通过道具或事件增加点数,请问要如何实现?
  1. #encoding:utf-8
  2. #=============================================================================
  3. #-----------RMVA加点系统正常向-v1.03---By:救世小树--------转载请注明出处-------
  4. #=============================================================================

  5. module Point_Tree
  6.   
  7.   POINT_KIND     = 6       #设定加点种类
  8.   LEVEL_UP_POINT = 1.1      #每升一级自由属性点增加数
  9.   RESET_ITEM     = 26       #洗点水编号
  10.   
  11.   STR_POINT        = ["体力","韧性","力量","智慧","抗性","灵巧"]
  12.   
  13.   #分别对应增加       [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
  14.   POINT_ADD_PARAM = [[12 ,  0,   0,  0,   0,   0,   0,   0],     #体力
  15.                      [5  , 0,   0,  1,   0,   0,   0,   1],     #韧性
  16.                      [5  ,  0,   1,  0,   0,   0,   0,   0],     #力量
  17.                      [5  ,  0,   0,  0,   1,   1,   0,   0],     #智慧
  18.                      [5  ,  0,   0,  0,   0,   1,   0,   1],     #抗性
  19.                      [5  ,  0,   0,  0,   0,   0,   1,   0],     #灵巧
  20.                      
  21.                     ]
  22.                                           
  23.                      #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
  24.   
  25.   #分别对应增加       [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
  26.   POINT_ADD_XPARAM = [[0 , 0, 0, 0, 0, 0, 0, 25, 0, 0],     #体力
  27.                       [0 , 0, 0, 0, 0, 0, 25, 0, 0, 0],     #韧性
  28.                       [5 , 0, 2.5, 0, 0, 0, 0, 0, 0, 0],     #力量
  29.                       [0 , 0, 10, 0, 0, 0, 0, 0, 25, 0],     #智慧
  30.                       [0 , 0, 0, 0, 0, 25, 0, 0, 0, 0],     #抗性
  31.                       [8 , 10, 5, 0, 10, 0, 0, 0, 0, 0],     #灵巧
  32.                       ]

  33.                                                            
  34.                      #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
  35.   
  36.   #各种名称
  37.   
  38.   ADDPOINT       = "潜能"     #菜单中选项
  39.   POINT_NAME     = "潜能点"   #未分配点数
  40.   
  41.   XARAM_NAME     = ["命中","闪避","暴击","暴击闪避","远程闪避","远程反射","格挡","HP再生","Mp再生","Tp再生"]

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

  59. $temp_point = []
  60. for i in 0 .. Point_Tree::POINT_KIND-1
  61.   $temp_point.push(0)
  62. end

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

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

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

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

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

  189.   def update_help
  190.     @help_window.set_text(self.index+1) if @help_window
  191.     @status_window.index = self.index if @status_window
  192.   end
  193. end

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


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

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

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

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

  426. class Window_MenuCommand < Window_Command
  427.   alias add_original_commands_old add_original_commands
  428.   def add_original_commands
  429.     add_original_commands_old
  430.     add_command(Point_Tree::ADDPOINT,    :addpoint)
  431.   end
  432. end

  433. class Scene_Menu < Scene_MenuBase
  434.   alias create_command_window_old create_command_window
  435.   def create_command_window
  436.     create_command_window_old
  437.     @command_window.set_handler(:addpoint,method(:add_point))
  438.   end
  439.   def add_point
  440.     @status_window.select_last
  441.     @status_window.activate
  442.     @status_window.set_handler(:ok,     method(:on_ok))
  443.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  444.   end
  445.   def on_ok
  446.     SceneManager.call(Scene_Point)
  447.     Window_Point_Command::init_command_position
  448.   end
  449. end



  450. class Scene_ItemBase < Scene_MenuBase
  451.   def item_usable?
  452.     if item.id == Point_Tree::RESET_ITEM and item.is_a?(RPG::Item)
  453.       return true
  454.     end
  455.     user.usable?(item) && item_effects_valid?
  456.   end
  457. end






  458. class Window_Status < Window_Selectable
  459.   include Point_Tree
  460.   alias draw_parameters_old draw_parameters
  461.   def draw_parameters(x, y)
  462.     draw_parameters_old(x,y)
  463.     draw_point(x,y)
  464.   end
  465.   def draw_point(x,y)
  466.     for i in 0..5
  467.       change_color(system_color)
  468.       draw_text(x+100, y+ line_height * i, 80, line_height, STR_POINT[i])
  469.       change_color(normal_color)
  470.       draw_text(x+180, y+ line_height * i, 36, line_height,@actor.point[i+1].to_s, 2)
  471.     end
  472.   end
  473.   
  474. end

  475. class Window_Base < Window
  476.   def draw_actor_param(actor, x, y, param_id)
  477.     change_color(system_color)
  478.     draw_text(x-30, y, 80, line_height, Vocab::param(param_id))
  479.     change_color(normal_color)
  480.     draw_text(x+ 50, y, 36, line_height, actor.param(param_id), 2)
  481.   end
  482. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-7-18 11:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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