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

Project1

 找回密码
 注册会员
搜索

状态的各种用法请教!

查看数: 4173 | 评论数: 11 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-8-5 00:51

正文摘要:

忙了一天,有几个问题解决不了,所以来请教一番! 问题汇总: 1.如何让状态的增减属性改为额定的值,比如力量增加10,防御减少20等。 2.如何让状态改变属性有效度。(如果能实现,会方便一点,但关系不大) 关于问 ...

回复

芯☆淡茹水 发表于 2018-8-5 23:12:12
本帖最后由 芯☆淡茹水 于 2018-8-6 00:22 编辑

其实,相对于实时的侦测状态变化计算,也可以这样把 base_xx 一项一项的逐个改过来。

但有时候又不想改太多的默认函数,但最终弄好才发现也改了好多默认函数。

  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. # 1,状态关联公共事件。
  7. #    状态名后面加上 ☆ ,接着写上公共事件ID。
  8. #
  9. # 2,对应公共事件的编辑。
  10. #    公共事件编辑 注释 ,然后写上以下的对应备注项。
  11. #    注意:两项之间不要接连备注,用随意字符或空格隔开以及换行都行。
  12. #    备注格式:<maxhp:num>      最大HP
  13. #              <maxsp:num>      最大SP
  14. #              <str:num>        力量
  15. #              <dex:num>        敏捷
  16. #              <agi:num>        速度
  17. #              <int:num>        魔力
  18. #              <atk:num>        攻击力
  19. #              <pdef:num>       防御力
  20. #              <mdef:num>       魔法防御力
  21. #
  22. #    里面的 num 为增/减的值,正加负减,不要留空格。例: <maxhp:200> , <str:-20>
  23. #
  24. #==============================================================================
  25. module RPG
  26.   class State
  27.     #--------------------------------------------------------------------------
  28.     def name;    return @name.split("☆")[0] || "";     end
  29.     #--------------------------------------------------------------------------
  30.     def spce_id; return @name.split("☆")[1].to_i || 0; end
  31.   end
  32. end
  33. #==============================================================================
  34. module XdRs_Sp
  35.   #--------------------------------------------------------------------------
  36.   def self.state_has_spce?(state_id)
  37.     event = self.spce_event(state_id)
  38.     return event && event.list.any?{|l| l.code == 108 }
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   def self.spce_event(state_id)
  42.     return $data_common_events[$data_states[state_id].spce_id]
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   def self.state_add(state_id, sym)
  46.     return 0 unless self.state_has_spce?(state_id)
  47.     note = self.event_note(self.spce_event(state_id))
  48.     return $1.to_i  if note.match(Regexp.new("<#{sym}:(\\d+)>"))
  49.     return -$1.to_i if note.match(Regexp.new("<#{sym}:-(\\d+)>"))
  50.     return 0
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   def self.event_note(event)
  54.     note = event.list.find_all{|l| [108,408].include?(l.code)}.map{|l| l.parameters[0]}
  55.     return note.join(";")
  56.   end
  57. end
  58. #==============================================================================
  59. class Game_Battler
  60.   #--------------------------------------------------------------------------
  61.   def state_add(sym)
  62.     return 0 if @states.empty?
  63.     return eval(@states.map{|id| XdRs_Sp.state_add(id, sym)}.join("+"))
  64.   end
  65. end
  66. #==============================================================================
  67. class Game_Actor < Game_Battler
  68.   #--------------------------------------------------------------------------
  69.   alias xr_state_property_base_maxhp base_maxhp
  70.   def base_maxhp; return xr_state_property_base_maxhp + state_add("maxhp"); end
  71.   #--------------------------------------------------------------------------
  72.   alias xr_state_property_base_maxsp base_maxsp
  73.   def base_maxsp; return xr_state_property_base_maxsp + state_add("maxsp"); end
  74.   #--------------------------------------------------------------------------
  75.   alias xr_state_property_base_str base_str
  76.   def base_str;   return xr_state_property_base_str + state_add("str");     end
  77.   #--------------------------------------------------------------------------
  78.   alias xr_state_property_base_dex base_dex
  79.   def base_dex;   return xr_state_property_base_dex + state_add("dex");     end
  80.   #--------------------------------------------------------------------------
  81.   alias xr_state_property_base_agi base_agi
  82.   def base_agi;   return xr_state_property_base_agi + state_add("agi");     end
  83.   #--------------------------------------------------------------------------
  84.   alias xr_state_property_base_int base_int
  85.   def base_int;   return xr_state_property_base_int + state_add("int");     end
  86.   #--------------------------------------------------------------------------
  87.   alias xr_state_property_base_atk base_atk
  88.   def base_atk;   return xr_state_property_base_atk + state_add("atk");     end
  89.   #--------------------------------------------------------------------------
  90.   alias xr_state_property_base_pdef base_pdef
  91.   def base_pdef;  return xr_state_property_base_pdef + state_add("pdef");   end
  92.   #--------------------------------------------------------------------------
  93.   alias xr_state_property_base_mdef base_mdef
  94.   def base_mdef;  return xr_state_property_base_mdef + state_add("mdef");   end
  95. end
  96. #==============================================================================
  97. class Game_Enemy < Game_Battler
  98.   #--------------------------------------------------------------------------
  99.   alias xr_state_property_base_maxhp base_maxhp
  100.   def base_maxhp; return xr_state_property_base_maxhp + state_add("maxhp"); end
  101.   #--------------------------------------------------------------------------
  102.   alias xr_state_property_base_maxsp base_maxsp
  103.   def base_maxsp; return xr_state_property_base_maxsp + state_add("maxsp"); end
  104.   #--------------------------------------------------------------------------
  105.   alias xr_state_property_base_str base_str
  106.   def base_str;   return xr_state_property_base_str + state_add("str");     end
  107.   #--------------------------------------------------------------------------
  108.   alias xr_state_property_base_dex base_dex
  109.   def base_dex;   return xr_state_property_base_dex + state_add("dex");     end
  110.   #--------------------------------------------------------------------------
  111.   alias xr_state_property_base_agi base_agi
  112.   def base_agi;   return xr_state_property_base_agi + state_add("agi");     end
  113.   #--------------------------------------------------------------------------
  114.   alias xr_state_property_base_int base_int
  115.   def base_int;   return xr_state_property_base_int + state_add("int");     end
  116.   #--------------------------------------------------------------------------
  117.   alias xr_state_property_base_atk base_atk
  118.   def base_atk;   return xr_state_property_base_atk + state_add("atk");     end
  119.   #--------------------------------------------------------------------------
  120.   alias xr_state_property_base_pdef base_pdef
  121.   def base_pdef;  return xr_state_property_base_pdef + state_add("pdef");   end
  122.   #--------------------------------------------------------------------------
  123.   alias xr_state_property_base_mdef base_mdef
  124.   def base_mdef;  return xr_state_property_base_mdef + state_add("mdef");   end
  125. end
  126. #==============================================================================
  127. #==============================================================================
复制代码


上面 ↑ 状态增加的属性受状态百分比增幅的影响; 下面 ↓ 状态增加的属性不受状态百分比增幅的影响,但是如果有 属性破限 脚本可能会失效。


RUBY 代码复制
  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. # 1,状态关联公共事件。
  7. #    状态名后面加上 ☆ ,接着写上公共事件ID。
  8. #
  9. # 2,对应公共事件的编辑。
  10. #    公共事件编辑 注释 ,然后写上以下的对应备注项。
  11. #    注意:两项之间不要接连备注,用随意字符或空格隔开以及换行都行。
  12. #    备注格式:<maxhp:num>      最大HP
  13. #              <maxsp:num>      最大SP
  14. #              <str:num>        力量
  15. #              <dex:num>        敏捷
  16. #              <agi:num>        速度
  17. #              <int:num>        魔力
  18. #              <atk:num>        攻击力
  19. #              <pdef:num>       防御力
  20. #              <mdef:num>       魔法防御力
  21. #
  22. #    里面的 num 为增/减的值,正加负减,不要留空格。例: <maxhp:200> , <str:-20>
  23. #
  24. #==============================================================================
  25. module RPG
  26.   class State
  27.     #--------------------------------------------------------------------------
  28.     def name;    return @name.split("☆")[0] || "";     end
  29.     #--------------------------------------------------------------------------
  30.     def spce_id; return @name.split("☆")[1].to_i || 0; end
  31.   end
  32. end
  33. #==============================================================================
  34. module XdRs_Sp
  35.   #--------------------------------------------------------------------------
  36.   def self.state_has_spce?(state_id)
  37.     event = self.spce_event(state_id)
  38.     return event && event.list.any?{|l| l.code == 108 }
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   def self.spce_event(state_id)
  42.     return $data_common_events[$data_states[state_id].spce_id]
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   def self.state_add(state_id, sym)
  46.     return 0 unless self.state_has_spce?(state_id)
  47.     note = self.event_note(self.spce_event(state_id))
  48.     return $1.to_i  if note.match(Regexp.new("<#{sym}:(\\d+)>"))
  49.     return -$1.to_i if note.match(Regexp.new("<#{sym}:-(\\d+)>"))
  50.     return 0
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   def self.event_note(event)
  54.     note = event.list.find_all{|l| [108,408].include?(l.code)}.map{|l| l.parameters[0]}
  55.     return note.join(";")
  56.   end
  57. end
  58. #==============================================================================
  59. class Game_Battler
  60.   #--------------------------------------------------------------------------
  61.   def state_add(sym)
  62.     return 0 if @states.empty?
  63.     return eval(@states.map{|id| XdRs_Sp.state_add(id, sym)}.join("+"))
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   alias xr_state_property_maxhp maxhp
  67.   def maxhp
  68.     n = xr_state_property_maxhp + state_add("maxhp")
  69.     return [[n, 1].max, 999999].min
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   alias xr_state_property_maxsp maxsp
  73.   def maxsp
  74.     n = xr_state_property_maxsp + state_add("maxsp")
  75.     return [[n, 0].max, 9999].min
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   alias xr_state_property_str str
  79.   def str
  80.     n = xr_state_property_str + state_add("str")
  81.     return [[n, 0].max, 999].min
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   alias xr_state_property_dex dex
  85.   def dex
  86.     n = xr_state_property_dex + state_add("dex")
  87.     return [[n, 0].max, 999].min
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   alias xr_state_property_agi agi
  91.   def agi
  92.     n = xr_state_property_agi + state_add("agi")
  93.     return [[n, 0].max, 999].min
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   alias xr_state_property_int int
  97.   def int
  98.     n = xr_state_property_int + state_add("int")
  99.     return [[n, 0].max, 999].min
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   alias xr_state_property_atk atk
  103.   def atk;  return xr_state_property_atk + state_add("atk");   end
  104.   #--------------------------------------------------------------------------
  105.   alias xr_state_property_pdef pdef
  106.   def pdef; return xr_state_property_pdef + state_add("pdef"); end
  107.   #--------------------------------------------------------------------------
  108.   alias xr_state_property_mdef mdef
  109.   def mdef; return xr_state_property_mdef + state_add("mdef"); end
  110. end
  111. #==============================================================================
  112. class Game_Actor < Game_Battler
  113.   #--------------------------------------------------------------------------
  114.   alias xr_state_property_maxhp maxhp
  115.   def maxhp
  116.     n = xr_state_property_maxhp + state_add("maxhp")
  117.     return [[n, 1].max, 9999].min
  118.   end
  119. end
  120. #==============================================================================
  121. #==============================================================================




至于属性有效度 element_ranks , 可以直接修改, 也可以修改后并储存。
但是,element_ranks 相当于公共数据,比如你把它的某项属性有效度改为 C ,
如果是角色, 所有是这个修改过属性有效度的职业的角色,他的那项属性有效度都变成了 C。
敌人相同,所有ID相同的敌人的属性有效度都跟着改变。

点评

↓ 坐月子要注意身体,真的要少碰电脑,况且也这么晚了。睡眠不足未休息好皮肤容易衰老。  发表于 2018-8-6 00:26
这个改base_xxxx是有点太过了,状态决定基础值的设定太诡异。  发表于 2018-8-5 23:39
但是不是人人都要做 dota2 的。 加在 base_xx 会受到状态百分比的增幅。总之嘛,各人有各人的想法和需求。  发表于 2018-8-5 23:39
个人觉得改base_xxx或者直接改xxx取决于游戏战斗计算式的设定,其实像dota2里面基础攻击力和攻击力都是定义好了的,  发表于 2018-8-5 23:28
芯☆淡茹水 发表于 2018-8-5 17:01:18
本帖最后由 芯☆淡茹水 于 2018-8-5 17:56 编辑

看了一下,公共事件的增减属性值只有六项,所以改用 公共事件 的 注释 来 备注
这个在状态名关联公共事件,如果有其它的脚本在状态里使用同样方法关联东西,可能会使状态名字变得奇怪或相关功能失效。

  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. # 1,状态关联公共事件。
  7. #    状态名后面加上 ☆ ,接着写上公共事件ID。
  8. #
  9. # 2,对应公共事件的编辑。
  10. #    公共事件编辑 注释 ,然后写上以下的对应备注项。
  11. #    注意:两项之间不要接连备注,用随意字符或空格隔开以及换行都行。
  12. #    备注格式:<maxhp:num>      最大HP
  13. #              <maxsp:num>      最大SP
  14. #              <str:num>        力量
  15. #              <dex:num>        敏捷
  16. #              <agi:num>        速度
  17. #              <int:num>        魔力
  18. #              <atk:num>        攻击力
  19. #              <pdef:num>       防御力
  20. #              <mdef:num>       魔法防御力
  21. #
  22. #    里面的 num 为增/减的值,正加负减,中间不要留空格。例: <maxhp:200> , <str:-20>
  23. #
  24. #==============================================================================
  25. module RPG
  26.   class State
  27.     #--------------------------------------------------------------------------
  28.     def name;    return @name.split("☆")[0] || "";     end
  29.     #--------------------------------------------------------------------------
  30.     def spce_id; return @name.split("☆")[1].to_i || 0; end
  31.   end
  32. end
  33. #==============================================================================
  34. module XdRs_Sp
  35.   #--------------------------------------------------------------------------
  36.   def self.attribute_names
  37.     return ["maxhp","maxsp","str","dex","agi","int","atk","pdef","mdef"]
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   def self.state_has_spce?(state_id)
  41.     event = self.spce_event(state_id)
  42.     return event && event.list.any?{|l| l.code == 108 }
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   def self.spce_event(state_id)
  46.     return $data_common_events[$data_states[state_id].spce_id]
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   def self.state_add(state_id, sym)
  50.     note = self.event_note(self.spce_event(state_id))
  51.     return $1.to_i  if note.match(Regexp.new("<#{sym}:(\\d+)>"))
  52.     return -$1.to_i if note.match(Regexp.new("<#{sym}:-(\\d+)>"))
  53.     return 0
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   def self.event_note(event)
  57.     note = event.list.find_all{|l| [108,408].include?(l.code)}.map{|l| l.parameters[0]}
  58.     return note.join(";")
  59.   end
  60. end
  61. #==============================================================================
  62. class Game_Battler
  63.   #--------------------------------------------------------------------------
  64.   alias xr_state_property_initialize initialize
  65.   def initialize
  66.     xr_state_property_initialize
  67.     @atk_plus  = @pdef_plus = @mdef_plus = 0
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   def refresh_state_changed(states_data, type)
  71.     return unless ["add", "remove"].include?(type)
  72.     data = (states_data - @states) | (@states - states_data)
  73.     data = data.find_all{|id| XdRs_Sp.state_has_spce?(id) }
  74.     unless data.empty?
  75.       data.each{|id| attribute_count(id, type)}
  76.       @hp = [@hp, self.maxhp].min
  77.       @sp = [@sp, self.maxsp].min
  78.     end
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   def attribute_count(state_id, type)
  82.     XdRs_Sp.attribute_names.each do |sym|
  83.       num = XdRs_Sp.state_add(state_id, sym)
  84.       next if num == 0
  85.       num = type == "add" ? num : -num
  86.       value = instance_variable_get("@#{sym}_plus") + num
  87.       instance_variable_set("@#{sym}_plus", value)
  88.     end
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   alias xr_state_property_add_state add_state
  92.   def add_state(state_id, force=false)
  93.     last_states = @states.clone
  94.     xr_state_property_add_state(state_id, force)
  95.     last_states != @states && refresh_state_changed(last_states, "add")
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   alias xr_state_property_remove_state remove_state
  99.   def remove_state(state_id, force=false)
  100.     last_states = @states.clone
  101.     xr_state_property_remove_state(state_id, force)
  102.     last_states != @states && refresh_state_changed(last_states, "remove")
  103.   end
  104. end
  105. #==============================================================================
  106. class Game_Actor < Game_Battler
  107.   #--------------------------------------------------------------------------
  108.   alias xr_state_property_base_atk base_atk
  109.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  110.   #--------------------------------------------------------------------------
  111.   alias xr_state_property_base_pdef base_pdef
  112.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  113.   #--------------------------------------------------------------------------
  114.   alias xr_state_property_base_mdef base_mdef
  115.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  116. end
  117. #==============================================================================
  118. class Game_Enemy < Game_Battler
  119.   #--------------------------------------------------------------------------
  120.   alias xr_state_property_base_atk base_atk
  121.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  122.   #--------------------------------------------------------------------------
  123.   alias xr_state_property_base_pdef base_pdef
  124.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  125.   #--------------------------------------------------------------------------
  126.   alias xr_state_property_base_mdef base_mdef
  127.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  128. end
  129. #==============================================================================
  130. #==============================================================================
复制代码


上面一共发了 3 个版本的,总有一款适合的。

评分

参与人数 2星屑 +350 +1 收起 理由
RyanBern + 300 + 1 认可答案
SailCat + 50 认可答案

查看全部评分

阮声悠悠 发表于 2018-8-5 15:09:11
灯笼菜刀王 发表于 2018-8-5 13:24
其实, 如果是要"状态加成的数值全部为增加固定数值而不是百分比" 那改下公式就好了

  #-------- ...

想问个问题
  1.   #--------------------------------------------------------------------------
  2.   # ● 获取力量
  3.   #--------------------------------------------------------------------------
  4.   def str
  5.     n = [[base_str + @str_plus, 1].max, 999].min
  6.     for i in @states
  7.       n *= $data_states[i].str_rate / 100.0
  8.      [color=Red] #这里调用方法(self,n,0,0,0,0),把n和self代入进去,在方法内进行计算,然后返回一个值[/color]
  9.      n += #上面返回的值
  10.     end
  11.     n = [[Integer(n), 1].max, 999].min
  12.     return n
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 获取灵巧
  16.   #--------------------------------------------------------------------------
  17.   def dex
  18.     n = [[base_dex + @dex_plus, 1].max, 999].min
  19.     for i in @states
  20.       n *= $data_states[i].dex_rate / 100.0
  21.      [color=Red] #这里也调用同一个方法(self,0,n,0,0,0),把n和self代入进去,在方法内进行计算,然后返回一个值[/color]
  22.      n += #上面返回的值
  23.     end
  24.     n = [[Integer(n), 1].max, 999].min
  25.     return n
  26.   end
复制代码


然后呢,这个方法的逻辑是这样
RUBY 代码复制
  1. (self,LiLiang,LingQiao,MoLi,MoFaFangYu,SuDu)
  2. if self.state?(32)
  3.   LiLiang += 123
  4.   LingQiao += 22
  5. end


我不知道该怎么写

点评

你这个就和芯大的方法一致了,不会引用常数的话,还是芯大那招直接在数据库设置更方便。  发表于 2018-8-6 09:55
芯☆淡茹水 发表于 2018-8-5 15:04:15
嘛~,想要每个状态都多个属性增减那就更简单了,既然数据库状态里没有地方写,
那也只有编辑在脚本里。
建一个哈希随便编辑就行了, 想多少个状态就照格式写多少个,每个状态想增减多少属性就写多少,
不说四五个,每个状态9项属性你全都增减也是可以的。
  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. #==============================================================================
  7. module XdRs_Sp
  8.   Add_Data = {
  9.   #对应格式(正加负减):
  10.   #状态ID   HP  SP 力量 敏捷 速度 魔力 攻击 物防 魔防
  11.       8 => [200, 0,  0,  0,   0,   0,   0,   0,   0],
  12.      12 => [0,-200,0,0,0,0,0,0,0],
  13.      13 => [200,0,100,0,0,0,0,0,0]
  14.   }
  15.   #--------------------------------------------------------------------------
  16.   def self.attribute_names
  17.     return ["maxhp","maxsp","str","dex","agi","int","atk","pdef","mdef"]
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   def self.state_add(state_id, param_index)
  21.     return Add_Data[state_id] ?  Add_Data[state_id][param_index] || 0 : 0
  22.   end
  23. end
  24. #==============================================================================
  25. class Game_Battler
  26.   #--------------------------------------------------------------------------
  27.   alias xr_state_property_initialize initialize
  28.   def initialize
  29.     xr_state_property_initialize
  30.     @atk_plus  = @pdef_plus = @mdef_plus = 0
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   def refresh_state_changed(states_data, type)
  34.     return unless ["add", "remove"].include?(type)
  35.     data = (states_data - @states) | (@states - states_data)
  36.     data.each{|id| attribute_count(id, type)}
  37.     @hp = [@hp, self.maxhp].min
  38.     @sp = [@sp, self.maxsp].min
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   def attribute_count(state_id, type)
  42.     XdRs_Sp.attribute_names.each_with_index do |sym, index|
  43.       num = XdRs_Sp.state_add(state_id, index)
  44.       next if num == 0
  45.       num = type == "add" ? num : -num
  46.       value = instance_variable_get("@#{sym}_plus") + num
  47.       instance_variable_set("@#{sym}_plus", value)
  48.     end
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   alias xr_state_property_add_state add_state
  52.   def add_state(state_id, force=false)
  53.     last_states = @states.clone
  54.     xr_state_property_add_state(state_id, force)
  55.     last_states != @states && refresh_state_changed(last_states, "add")
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   alias xr_state_property_remove_state remove_state
  59.   def remove_state(state_id, force=false)
  60.     last_states = @states.clone
  61.     xr_state_property_remove_state(state_id, force)
  62.     last_states != @states && refresh_state_changed(last_states, "remove")
  63.   end
  64. end
  65. #==============================================================================
  66. class Game_Actor < Game_Battler
  67.   #--------------------------------------------------------------------------
  68.   alias xr_state_property_base_atk base_atk
  69.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  70.   #--------------------------------------------------------------------------
  71.   alias xr_state_property_base_pdef base_pdef
  72.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  73.   #--------------------------------------------------------------------------
  74.   alias xr_state_property_base_mdef base_mdef
  75.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  76. end
  77. #==============================================================================
  78. class Game_Enemy < Game_Battler
  79.   #--------------------------------------------------------------------------
  80.   alias xr_state_property_base_atk base_atk
  81.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  82.   #--------------------------------------------------------------------------
  83.   alias xr_state_property_base_pdef base_pdef
  84.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  85.   #--------------------------------------------------------------------------
  86.   alias xr_state_property_base_mdef base_mdef
  87.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  88. end
  89. #==============================================================================
  90. #==============================================================================
复制代码

点评

-_-!!! , 好吧,反正已经做了,顺便再改一版出来。  发表于 2018-8-5 16:02
当然是你说的关联公共事件……占用公共事件位置那毕竟还是在数据库中,调整可以联动,也不用记忆一堆id……  发表于 2018-8-5 15:59
要不可以关联公共事件,反正里面有增加属性,读取其数据就可以了。但也要占用公共事件位置,  发表于 2018-8-5 15:57
那有什么办法! XP这尿性你又不是不知道,想要过多的数据,在数据库状态里根本无法下手。  发表于 2018-8-5 15:56
把数据批量写在脚本里……维护会是个极大的问题  发表于 2018-8-5 15:46

评分

参与人数 1+1 收起 理由
阮声悠悠 + 1 我很赞同

查看全部评分

阮声悠悠 发表于 2018-8-5 13:39:36
porlutia 发表于 2018-8-5 08:09
1. 这个的原理 就是 先获取基础攻击力,然后把它赋值给n
  这里是判断 如果在第32号状态下 n的数值增加20    ...

谢谢回复哈

问题1刚刚试了下,在main前插入,发现没有效果。。其实你说的意思我明白。不太明白的是这个脚本怎么使用。

2呢,我也看到灯笼菜刀王的原帖了。
但是和我想做的其实不是同一个效果
table = [0,1000,1000,1000,1000,1000,1000]     是把属性的A,B,C,D,E,F有效度都增加10倍

而我是想自定义element_rate的值
比如1号属性是A,2号属性是F,3号属性是E,4号。。5号。。
这样
灯笼菜刀王 发表于 2018-8-5 13:24:36
其实, 如果是要"状态加成的数值全部为增加固定数值而不是百分比" 那改下公式就好了

  #--------------------------------------------------------------------------
  # ● 获取力量
  #--------------------------------------------------------------------------
  def str
    n = [[base_str + @str_plus, 1].max, 999].min
    for j in @states
      n += $data_states[j].str_rate - 100
    end
    n = [[Integer(n), 1].max, 999].min
    return n
  end

把乘改加就好了~  不过因为数据库只能填 0-200的数值, 不能用负数, 所以只能把 100当做 0;  填80就是相当于 -20

缺点, 只能用于 -100~+100 的变化. 需要超过这个数值的, 还是要用芯大的扩展脚本~

点评

=v=知道哦,猫姐的数据库备注接口非常好用,要增加一两个扩展很方便,但是如果11个都要狂野.... 外接备注的话,就和引用常量一样了~  发表于 2018-8-6 09:53
你知道有个东西叫做数据库备注狂野模式么……  发表于 2018-8-5 21:42
我觉得这个更适合你...不用写N个IF..  发表于 2018-8-5 15:34
谢谢!可以告诉我1楼的问题一怎么用吗?那个适合我。。。  发表于 2018-8-5 13:49
芯☆淡茹水 发表于 2018-8-5 11:52:49
本帖最后由 芯☆淡茹水 于 2018-8-5 17:57 编辑

唔~,根据楼上加了3个属性(攻击,防御,魔防)进去。
至于 回避 嘛,状态本身加的就是固定值。

  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. # 属性命名:<maxhp:num>      最大HP
  7. #           <maxsp:num>      最大SP
  8. #           <str:num>        力量
  9. #           <dex:num>        敏捷
  10. #           <agi:num>        速度
  11. #           <int:num>        魔力
  12. #           <atk:num>        攻击力
  13. #           <pdef:num>       防御力
  14. #           <mdef:num>       魔法防御力
  15. #
  16. # 里面的 num 为增/减的值,正加负减,不要留空格。例: <maxhp:200> ,  <str:-20>
  17. # 最后在对应状态里勾上这个属性即可(可多项)。
  18. #
  19. #==============================================================================
  20. #==============================================================================
  21. class Game_Battler
  22.   #--------------------------------------------------------------------------
  23.   alias xr_state_property_initialize initialize
  24.   def initialize
  25.     xr_state_property_initialize
  26.     @atk_plus  = @pdef_plus = @mdef_plus = 0
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   def refresh_state_changed(states_data, type)
  30.     return unless ["add", "remove"].include?(type)
  31.     data = (states_data - @states) | (@states - states_data)
  32.     data = data.find_all{|id| !$data_states[id].guard_element_set.empty?}
  33.     unless data.empty?
  34.       data.each{|id| attribute_count($data_states[id], type)}
  35.       @hp = [@hp, self.maxhp].min
  36.       @sp = [@sp, self.maxsp].min
  37.     end
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   def attribute_count(state, type)
  41.     syms = ["maxhp","maxsp","str","dex","agi","int","atk","pdef","mdef"]
  42.     state.guard_element_set.size.times do |i|
  43.       element = $data_system.elements[state.guard_element_set[i]]
  44.       9.times do |j|
  45.         num = nil
  46.         num = $1.to_i  if element.match(Regexp.new("<#{syms[j]}:(\\d+)>"))
  47.         num = -$1.to_i if element.match(Regexp.new("<#{syms[j]}:-(\\d+)>"))
  48.         next unless num
  49.         num = type == "add" ? num : -num
  50.         value = instance_variable_get("@#{syms[j]}_plus") + num
  51.         instance_variable_set("@#{syms[j]}_plus", value)
  52.       end
  53.     end
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   alias xr_state_property_add_state add_state
  57.   def add_state(state_id, force=false)
  58.     last_states = @states.clone
  59.     xr_state_property_add_state(state_id, force)
  60.     last_states != @states && refresh_state_changed(last_states, "add")
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   alias xr_state_property_remove_state remove_state
  64.   def remove_state(state_id, force=false)
  65.     last_states = @states.clone
  66.     xr_state_property_remove_state(state_id, force)
  67.     last_states != @states && refresh_state_changed(last_states, "remove")
  68.   end
  69. end
  70. #==============================================================================
  71. class Game_Actor < Game_Battler
  72.   #--------------------------------------------------------------------------
  73.   alias xr_state_property_base_atk base_atk
  74.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  75.   #--------------------------------------------------------------------------
  76.   alias xr_state_property_base_pdef base_pdef
  77.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  78.   #--------------------------------------------------------------------------
  79.   alias xr_state_property_base_mdef base_mdef
  80.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  81. end
  82. #==============================================================================
  83. class Game_Enemy < Game_Battler
  84.   #--------------------------------------------------------------------------
  85.   alias xr_state_property_base_atk base_atk
  86.   def base_atk;  return xr_state_property_base_atk + @atk_plus;   end
  87.   #--------------------------------------------------------------------------
  88.   alias xr_state_property_base_pdef base_pdef
  89.   def base_pdef; return xr_state_property_base_pdef + @pdef_plus; end
  90.   #--------------------------------------------------------------------------
  91.   alias xr_state_property_base_mdef base_mdef
  92.   def base_mdef; return xr_state_property_base_mdef + @mdef_plus; end
  93. end
  94. #==============================================================================
  95. #==============================================================================
复制代码
芯☆淡茹水 发表于 2018-8-5 10:42:09
本帖最后由 芯☆淡茹水 于 2018-8-5 11:10 编辑

1,以前做过这个功能,XP的各项东西没有备注,想加额外的东西有些蛋疼,
所以做的这个功能只好用属性开刀。

整个功能脚本剔出来就是这样,比较简单
  1. #==============================================================================
  2. # 状态增减固定属性              
  3. #==============================================================================
  4. # Author : 芯☆淡茹水
  5. #==============================================================================
  6. # 属性命名:<maxhp:num>      最大HP
  7. #           <maxsp:num>      最大SP
  8. #           <str:num>        力量
  9. #           <dex:num>        敏捷
  10. #           <agi:num>        速度
  11. #           <int:num>        魔力
  12. #
  13. # 里面的 num 为增/减的值,正加负减,不要留空格。例: <maxhp:200> ,  <str:-20>
  14. # 最后在对应状态里勾上这个属性即可(可多项)。
  15. #
  16. #==============================================================================
  17. #==============================================================================
  18. class Game_Battler
  19.   #--------------------------------------------------------------------------
  20.   def refresh_state_changed(states_data, type)
  21.     return unless ["add", "remove"].include?(type)
  22.     data = (states_data - @states) | (@states - states_data)
  23.     data = data.find_all{|id| !$data_states[id].guard_element_set.empty?}
  24.     unless data.empty?
  25.       data.each{|id| attribute_count($data_states[id], type)}
  26.       @hp = [@hp, self.maxhp].min
  27.       @sp = [@sp, self.maxsp].min
  28.     end
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   def attribute_count(state, type)
  32.     syms = ["maxhp","maxsp","str","dex","agi","int"]
  33.     state.guard_element_set.size.times do |i|
  34.       element = $data_system.elements[state.guard_element_set[i]]
  35.       6.times do |j|
  36.         num = nil
  37.         num = $1.to_i    if element.match(Regexp.new("<#{syms[j]}:(\\d+)>"))
  38.         num = -($1.to_i) if element.match(Regexp.new("<#{syms[j]}:-(\\d+)>"))
  39.         next unless num
  40.         num = type == "add" ? num : -num
  41.         value = instance_variable_get("@#{syms[j]}_plus") + num
  42.         instance_variable_set("@#{syms[j]}_plus", value)
  43.       end
  44.     end
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   alias xr_state_property_add_state add_state
  48.   def add_state(state_id, force=false)
  49.     last_states = @states.clone
  50.     xr_state_property_add_state(state_id, force)
  51.     last_states != @states && refresh_state_changed(last_states, "add")
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   alias xr_state_property_remove_state remove_state
  55.   def remove_state(state_id, force=false)
  56.     last_states = @states.clone
  57.     xr_state_property_remove_state(state_id, force)
  58.     last_states != @states && refresh_state_changed(last_states, "remove")
  59.   end
  60. end
  61. #==============================================================================
  62. #==============================================================================
复制代码


然后如果不知道怎么用的话,这儿有个简单范例

Project2.rar (187.92 KB, 下载次数: 102)

2,状态不是可以勾选属性防御吗?!

点评

属性上这么写:maxhp:1 maxhp:2 maxhp:4 maxhp:8 maxhp:16....你要300-400的加成值的话,也就是最多写到maxhp:256,通过勾选可以实现511以内的加成  发表于 2018-8-5 21:42
看到了,但可能不适合我。因为,一个状态有4项加成,可能每个值都不同,然后我想做300~400个左右,针对批量,需要用到的属性就有点多了  发表于 2018-8-5 13:31
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-5-21 21:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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