Project1

标题: 如何让武器和防具能增加血和魔法 [打印本页]

作者: zxs060929    时间: 2012-6-15 21:26
标题: 如何让武器和防具能增加血和魔法
本帖最后由 zxs060929 于 2012-6-15 21:41 编辑

我给武器添加2个变量  脚本如下 参照F1写的
module RPG
  class Weapon
    alias zxs_initialize initialize
    def initialize
      @zxs_maxhp_plus = 0
      @zxs_maxsp_plus = 0
      zxs_initialize
    end
    attr_accessor :zxs_maxhp_plus
    attr_accessor :zxs_maxsp_plus
  end
end
然后再game_actor里取maxsp的时候,把武器里的变量也加给maxsp 脚本如下
def base_maxsp
    n = $data_actors[@actor_id].parameters[1, @level]
    weapon = $data_weapons[@weapon_id]
    n += weapon != nil ? weapon.zxs_maxsp_plus : 0
    return [[n, 1].max, 9999].min
  end
进入游戏一得到 武器就弹出 说 nil  can't be coerced into Fixnum
请问我这个脚本要怎么修改
dsu_plus_rewardpost_czw
作者: chd114    时间: 2012-6-15 21:28
你给武器加变量做神马···


‘‘──chd114于2012-6-15 21:28补充以下内容:

你给武器加变量做神马···
’’
作者: zxs060929    时间: 2012-6-15 21:42
chd114 发表于 2012-6-15 21:28
你给武器加变量做神马···

标题改了  为了让武器和防具能给角色加最大血 和魔法
作者: chd114    时间: 2012-6-15 21:43
zxs060929 发表于 2012-6-15 21:42
标题改了  为了让武器和防具能给角色加最大血 和魔法

什么时候加?
作者: zxs060929    时间: 2012-6-15 21:48
chd114 发表于 2012-6-15 21:43
什么时候加?

装上那件装备 就加 卸下来  就不加
作者: hys111111    时间: 2012-6-15 21:58
  1. def base_maxsp
  2.     n = $data_actors[@actor_id].parameters[1, @level]
  3.     weapon = $data_weapons[@weapon_id]
  4.     n += weapon.zxs_maxsp_plus.to_i
  5.     return [[n, 1].max, 9999].min
  6.   end
复制代码
这样子试试
作者: chd114    时间: 2012-6-15 22:01
zxs060929 发表于 2012-6-15 21:48
装上那件装备 就加 卸下来  就不加

并行事件里面加条件分歧
条件分歧:角色为[你的装备]装备中
   HP+1
    等待20针
除此以外的场合
   
分期结束


‘‘──chd114于2012-6-15 22:02补充以下内容:

这样是用在事件里面,好处是可以在你想要的地图里用这个效果,坏处是一定要准备一个并行处理事件在地图上执行这个指令,影响游戏速度
’’
作者: zxs060929    时间: 2012-6-15 22:03
hys111111 发表于 2012-6-15 21:58
这样子试试

。。按照那样 就弹出错误说 我没定义 zxs_maxsp_plus


‘‘──zxs060929于2012-6-15 22:12补充以下内容:

我是用站上的一个打造装备的脚本
那脚本只用装备上数据库里原来的属性加成
我想弄个能加血和魔法的
最好是脚本 我想用那个打造装备的脚本
’’
作者: 乱糟糟    时间: 2012-6-15 22:20
module RPG
   class Weapon
     alias zxs_initialize initialize
     def initialize
      
       zxs_initialize
       @zxs_maxhp_plus = 0
       @zxs_maxsp_plus = 0
     end
     attr_accessor :zxs_maxhp_plus
     attr_accessor :zxs_maxsp_plus
     def zxs_maxsp_plus
       return 0
     end  
   end
end
不过武器的其他数据LZ要怎么加进去呢?



‘‘──乱糟糟于2012-6-15 23:47补充以下内容:

比如可以用说明描述。。
class Weapon
    def zxs_maxsp_plus
      zxs_maxsp_plus = @description.split(/@/)[1]
      return zxs_maxsp_plus != nil ? zxs_maxsp_plus.to_i : 0
    end
def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
’’
作者: zxs060929    时间: 2012-6-15 23:54
乱糟糟 发表于 2012-6-15 22:20
module RPG
   class Weapon
     alias zxs_initialize initialize

def zxs_maxsp_plus
     return [@zxs_maxsp_plus.to_i,0].max
end
自己搞定了
不过你的没报错 就给你认可了 虽然你的那个脚本 返回的永远都是0




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