本帖最后由 guoxiaomi 于 2023-6-6 02:21 编辑
第一种写法我也是第一次见到,似乎是为了避免使用alias,改用类继承类自身的clone。这个写法属实逆天,你这个脚本是完整的吗?如果是完整的我可以修改一下。下面那个调用了外部32位的tktk_bitmap.dll,而且还是操作Bitmap的dll,RGM是不兼容的。如果想实现那些效果,可以用RGM自带的Bitmap的功能,也可以等后续我有空了写一个类似的。
对比一下两者的区别:
1. 不需要进行对自身的clone和继承;
2. 对于函数skills中出现的super,改用alias来代替。首先alias此函数(24行)创建一个别名,然后把super换成此函数别名(27行)。
#=============================================================================== # ● 【简易坑爹系列】武器、装备与状态的附加特技 #=============================================================================== class Game_Actor WEAPON_SKILLS = {} ARMOR_SKILLS = {} STATE_SKILLS = {} #----------------------------------------------------# # 设置区域 # # 设置方法:STATE_SKILLS[状态id] = [特技id] # WEAPON_SKILLS 与 ARMOR_SKILLS 同理 # 当特技id为负值时则删减该技能 # 不论顺序,删减技能一并落后处理 #----------------------------------------------------# WEAPON_SKILLS[5] = [5] # 匕首 致命一击 ARMOR_SKILLS[63] = [4] # 软木盾 盾防 # STATE_SKILLS[74] = [23]#鱼人仿息 悬浮水膜 #----------------------------------------------------# alias _origin_skills skills def skills output = _origin_skills | (WEAPON_SKILLS[@weapon_id] || []) [@armor1_id, @armor2_id, @armor3_id, @armor4_id].each { |a| output |= ARMOR_SKILLS[a] || [] } @states.each { |s| output |= STATE_SKILLS[s] || [] } output.each do |s| if s < 0 output.delete(s.abs) output.delete(s) end end output.sort end def skill_learn?(skill_id) skills.include?(skill_id) end end
#===============================================================================
# ● 【简易坑爹系列】武器、装备与状态的附加特技
#===============================================================================
class Game_Actor
WEAPON_SKILLS = {}
ARMOR_SKILLS = {}
STATE_SKILLS = {}
#----------------------------------------------------#
# 设置区域
#
# 设置方法:STATE_SKILLS[状态id] = [特技id]
# WEAPON_SKILLS 与 ARMOR_SKILLS 同理
# 当特技id为负值时则删减该技能
# 不论顺序,删减技能一并落后处理
#----------------------------------------------------#
WEAPON_SKILLS[5] = [5] # 匕首 致命一击
ARMOR_SKILLS[63] = [4] # 软木盾 盾防
# STATE_SKILLS[74] = [23]#鱼人仿息 悬浮水膜
#----------------------------------------------------#
alias _origin_skills skills
def skills
output = _origin_skills | (WEAPON_SKILLS[@weapon_id] || [])
[@armor1_id, @armor2_id, @armor3_id, @armor4_id].each { |a| output |= ARMOR_SKILLS[a] || [] }
@states.each { |s| output |= STATE_SKILLS[s] || [] }
output.each do |s|
if s < 0
output.delete(s.abs)
output.delete(s)
end
end
output.sort
end
def skill_learn?(skill_id)
skills.include?(skill_id)
end
end
|