NoDead = Buff:New() --初始化Buff,通过传入一些自定义参数控制成长相关的数值 function NoDead:SetData(...) self.damageFactor, self.factorCT, self.isCanRelive = ... -- buff期间的增伤系数 self.cover = true --控制效果可被覆盖 -- 刷新排序等级 self.sort = 4 self.recordDamage=0 end -- 伤害降低 function NoDead:onPassiveDamaging(func, target, damage, skill) if skill and skill.type == BattleSkillType.Special then local dd = BattleUtil.CountValue(damage, self.damageFactor, self.factorCT) - damage if func then func(-math.floor(BattleUtil.ErrorCorrection(dd))-self.recordDamage) end end end -- 记录承受伤害 function NoDead:OnRoleBeHit(atkRole, damage, bCrit, finalDmg, damageType, skill,isDirect) if skill and (skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra or skill.type==BattleSkillType.DeadSkill ) and atkRole.camp~=self.target.camp then self.recordDamage=self.recordDamage+math.floor(damage*0.1) end end function NoDead:OnSkillCastEnd(skill) if skill and (skill.type == BattleSkillType.Special or skill.type==BattleSkillType.Extra ) then self.recordDamage=0 end end --初始化后调用一次 function NoDead:OnStart() -- self.target.Event:AddEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self) self.target.Event:AddEvent(BattleEventName.SkillCastEnd,self.OnSkillCastEnd,self) if self.target.star>=11 then self.target.Event:AddEvent(BattleEventName.RoleBeHit,self.OnRoleBeHit,self) end self.target:SetDeadFilter(false) self.target:SetReliveFilter(self.isCanRelive) self.target:SetIsCanAddSkill(false) end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd function NoDead:OnTrigger() return true end --效果结束时调用一次 function NoDead:OnEnd() self.target.Event:RemoveEvent(BattleEventName.PassiveDamaging, self.onPassiveDamaging, self) self.target.Event:RemoveEvent(BattleEventName.SkillCastEnd,self.OnSkillCastEnd,self) if self.target.star>=11 then self.target.Event:RemoveEvent(BattleEventName.RoleBeHit,self.OnRoleBeHit,self) end --self.target.Event self.target:SetDeadFilter(true) -- self.target:SetIsCanAddSkill(false) end --只有当cover字段为true时触发,返回true则被新效果覆盖 function NoDead:OnCover(newBuff) return true end -- 比较buff function NoDead:OnCompare(buff) return true end return NoDead