From 1be3f7ce3ef83f3edfc32ae87fceb8a9f336cf67 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Tue, 7 May 2019 20:01:07 +0800 Subject: [PATCH] fight check --- luafight/Modules/Battle/Logic/Base/Buff.lua | 13 +- luafight/Modules/Battle/Logic/Base/Effect.lua | 6 +- .../Modules/Battle/Logic/Base/Passivity.lua | 1003 +++++++++++++---- .../Modules/Battle/Logic/Base/RoleData.lua | 6 +- luafight/Modules/Battle/Logic/Base/Skill.lua | 29 +- luafight/Modules/Battle/Logic/Buff/Brand.lua | 7 +- luafight/Modules/Battle/Logic/Buff/HOT.lua | 5 +- .../Battle/Logic/Buff/PropertyChange.lua | 18 +- .../Battle/Logic/Misc/BattleDefine.lua | 12 + .../Modules/Battle/Logic/Misc/BattleUtil.lua | 103 +- luafight/Modules/Battle/Logic/RoleLogic.lua | 24 +- .../ljsd/jieling/config/SMonsterConfig.java | 52 +- .../jieling/handler/GetPlayerInfoHandler.java | 1 - .../jieling/handler/LoginRequestHandler.java | 2 + .../ljsd/jieling/handler/map/MapLogic.java | 71 +- .../jieling/logic/hero/HeroAttributeEnum.java | 6 +- .../ljsd/jieling/logic/hero/HeroLogic.java | 4 + .../com/ljsd/jieling/util/CBean2Proto.java | 15 +- .../com/ljsd/jieling/util/FightDataUtil.java | 28 +- .../java/com/ljsd/jieling/util/ItemUtil.java | 32 +- .../com/ljsd/jieling/util/StringUtil.java | 2 +- 21 files changed, 1083 insertions(+), 356 deletions(-) diff --git a/luafight/Modules/Battle/Logic/Base/Buff.lua b/luafight/Modules/Battle/Logic/Base/Buff.lua index dfd91a6dc..4a03f4df2 100644 --- a/luafight/Modules/Battle/Logic/Base/Buff.lua +++ b/luafight/Modules/Battle/Logic/Base/Buff.lua @@ -39,7 +39,6 @@ function Buff.Create(caster, type, duration, ...) buff.duration = duration --持续时间为0时buff永久存在 buff.interval = -1 --间隔帧为0时每帧触发,小于0不触发 默认不触发OnTrigger - buff.maxCount = 0 --限定效果最大数量 buff.framePass = 0 buff:SetData(...) @@ -146,7 +145,7 @@ function BuffManager:Update() local isCovered = false for i=1, buffList.size do local oldBuff = buffList.buffer[i] - if oldBuff.target == buff.target and oldBuff:OnCover(buff) then --判定该效果能否被覆盖 + if oldBuff.cover and oldBuff.target == buff.target and oldBuff:OnCover(buff) then --判定该效果能否被覆盖 oldBuff:OnEnd() oldBuff.target.Event:DispatchEvent(BattleEventName.BuffEnd, oldBuff) putBuff(oldBuff) @@ -158,17 +157,15 @@ function BuffManager:Update() break end end - if not isCovered and (buff.maxCount == 0 or buffList.size < buff.maxCount) then + if not isCovered then buffList:Add(buff) buff:OnStart() buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) end else - if buff.maxCount == 0 or buffList.size < buff.maxCount then --限制相同效果的数量,为0则不限制 - buffList:Add(buff) - buff:OnStart() - buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) - end + buffList:Add(buff) + buff:OnStart() + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) end end for i=1, self.buffList.size do diff --git a/luafight/Modules/Battle/Logic/Base/Effect.lua b/luafight/Modules/Battle/Logic/Base/Effect.lua index c2862dceb..45870df2e 100644 --- a/luafight/Modules/Battle/Logic/Base/Effect.lua +++ b/luafight/Modules/Battle/Logic/Base/Effect.lua @@ -76,7 +76,6 @@ local effectList = { local f1 = args[2] local f2 = args[3] BattleLogic.WaitForTrigger(interval, function () - target.Event:DispatchEvent(BattleEventName.RoleBeHealed, caster) target:AddBuff(Buff.Create(caster, BuffName.HOT, f2, 1, floor(caster:GetRoleData(propertyList[pro1]) * f1))) end) end, @@ -170,7 +169,7 @@ local effectList = { end BattleLogic.WaitForTrigger(interval, function () local dmg = BattleUtil.CalDamage(caster, target, dt, f1) - BattleUtil.ApplyTreat(caster, caster, floor(dmg * f2)) + BattleUtil.CalTreat(caster, caster, floor(dmg * f2)) end) end, --造成[a]%的[b]伤害,对[c]造成额外[d]%伤害 @@ -417,8 +416,7 @@ local effectList = { local f1 = args[2] BattleLogic.WaitForTrigger(interval, function () - target.Event:DispatchEvent(BattleEventName.RoleBeHealed, caster) - BattleUtil.ApplyTreat(caster, target, floor(caster:GetRoleData(propertyList[pro1]) * f1)) + BattleUtil.CalTreat(caster, target, floor(caster:GetRoleData(propertyList[pro1]) * f1)) end) end, --对[a]的伤害[b]%,持续[c]秒 diff --git a/luafight/Modules/Battle/Logic/Base/Passivity.lua b/luafight/Modules/Battle/Logic/Base/Passivity.lua index 099434f12..792925ab5 100644 --- a/luafight/Modules/Battle/Logic/Base/Passivity.lua +++ b/luafight/Modules/Battle/Logic/Base/Passivity.lua @@ -6,278 +6,837 @@ local max = math.max --local BattleEventName = BattleEventName --local BuffName = BuffName -local function queryAllies(role) return function (r) return r.camp == role.camp end end -local function queryEnemy(role) return function (r) return r.camp ~= role.camp end end +--属性编号 +local propertyList = { + RoleDataName.Attack, + RoleDataName.PhysicalDefence, + RoleDataName.MagicDefence, + RoleDataName.Speed, + RoleDataName.DamageBocusFactor, + RoleDataName.DamageReduceFactor, + RoleDataName.Hit, + RoleDataName.Dodge, + RoleDataName.Crit, + RoleDataName.CritDamageFactor, + RoleDataName.TreatFacter, + RoleDataName.MaxHp, + RoleDataName.MaxHp, +} + +local function chooseTarget(role, chooseId) + local chooseType = floor(chooseId / 10000) % 10 + local chooseWeight = floor(chooseId / 100) % 10 + local sort = floor(chooseId / 10) % 10 + local num = chooseId % 10 + local arr + if chooseType == 1 then + arr = BattleLogic.Query(function (r) return r.camp == role.camp end) + elseif chooseType == 2 then + if role.lockTarget and num == 1 then --嘲讽时对单个敌军生效 + return {role.lockTarget} + end + arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end) + elseif chooseType == 3 then + if role.ctrl_blind then --致盲时自身变随机友军 + arr = BattleLogic.Query(function (r) return r.camp == role.camp end) + BattleUtil.RandomList(arr) + return {arr[1]} + end + return {role} + elseif chooseType == 4 then + if role.lockTarget then --嘲讽时对仇恨目标生效 + return {role.lockTarget} + end + if role.ctrl_blind then --致盲时仇恨目标变随机 + arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end) + BattleUtil.RandomList(arr) + return {arr[1]} + end + return {BattleLogic.GetAggro(role.camp)} + else + arr = BattleLogic.Query() + end + + if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效 + BattleUtil.RandomList(arr) + elseif chooseWeight == 1 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.Hp) + local r2 = b:GetRoleData(RoleDataName.Hp) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 2 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp) + local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 3 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.Attack) + local r2 = b:GetRoleData(RoleDataName.Attack) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 4 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.PhysicalDefence) + local r2 = b:GetRoleData(RoleDataName.PhysicalDefence) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 5 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.PhysicalDefence) + local r2 = b:GetRoleData(RoleDataName.PhysicalDefence) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 6 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.MagicDefence) + local r2 = b:GetRoleData(RoleDataName.MagicDefence) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + elseif chooseWeight == 7 then + BattleUtil.Sort(arr, function(a, b) + local r1 = a:GetRoleData(RoleDataName.MagicDefence) + local r2 = b:GetRoleData(RoleDataName.MagicDefence) + if sort == 1 then return r1 > r2 else return r1 < r2 end + end) + end + return arr +end + --被动技能表 local passivityList = { - --受到暴击伤害时,有(a%)的概率发动一次反击,对敌人造成【b*c+d】的【e】伤害 - [201011] = function(role, args) - local f1 = args[1]/100 + --发动技能时,[a]的概率将[b]*[c]算作[d]计算 + --a[float],b[属性],c[float],d[属性] + [1] = function(role, args) + local f1 = args[1] + local pro1 = args[2] + local f2 = args[3] + local pro2 = args[4] + + local OnSkillCast = function(skill) + BattleUtil.RandomAction(f1, function () + local duration = 0 + for i=1, skill.effectList.size do + duration = max(duration, skill.effectList.buffer[i].duration) + end + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], duration) + end) + end + role.Event:AddEvent(BattleEventName.SkillCast, OnSkillCast) + end, + + --发动技能后,[a]的概率对敌方随机1名施加攻击*[c]的[d]伤害。 + --a[float],c[float],d[伤害类型] + [2] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local dt = args[3] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 20001) + if arr[1] then + BattleUtil.CalDamage(role, arr[1], dt, f2) + end + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,使仇恨目标受到治疗效果降低[a],持续[b] + --a[float],b[int] + [3] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + local OnSkillCastEnd = function(skill) + local arr = chooseTarget(role, 40000) + if arr[1] then + BattleUtil.CalDamage(role, arr[1], dt, f2) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,[d]改变自身[a]属性[b],持续[c]秒 + --a[属性],b[float],c[int],d[改变类型] + [4] = function(role, args) + local pro = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + local OnSkillCastEnd = function(skill) + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct)) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,[a]的概率回复攻击最高的1人的[b]*[c]血量,持续[d]秒。 + --a[float],b[属性],c[float],d[int] + [5] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + local f3 = args[4] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 10111) + if arr[1] then + arr[1]:AddBuff(Buff.Create(role, BuffName.HOT, f3, 1, floor(role:GetRoleData(propertyList[pro]) * f2))) + end + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,[a]的概率提升随机角色的[b]*[c]的[d],持续[e]秒。 + --a[float],b[属性],c[float],d[属性],e[int] + [6] = function(role, args) + local f1 = args[1] + local pro1 = args[2] + local f2 = args[3] + local pro2 = args[4] + local f3 = args[5] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 10001) + if arr[1] then + arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro1], floor(role:GetRoleData(propertyList[pro2]) * f2), 1)) + end + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --使用回复技能时,[a]的概率提高恢复效果[b]。 + --a[float],b[float] + [7] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + local OnPassiveTreating = function(treatingFunc) + BattleUtil.RandomAction(f1, function () + treatingFunc(f2) + end) + end + role.Event:AddEvent(BattleEventName.PassiveTreating, OnPassiveTreating) + end, + + --受击后,[a]的概率,回复自身的[b]*[c]的血量 + --a[float],b[属性],c[float] + [8] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + + local OnRoleBeDamaged = function(treatingFunc) + BattleUtil.RandomAction(f1, function () + BattleUtil.CalTreat(role, role, floor(role:GetRoleData(propertyList[pro]) * f2)) + end) + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnRoleBeDamaged) + end, + + --受击后,[a]对攻击者造成的攻击*[c]的持续伤害,持续[d]秒。 + --a[float],c[float],d[int] + [9] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local f3 = args[3] + + local triggerUid = {} + local OnRoleBeDamaged = function(atkRole) + if atkRole.isTeam then + return + end + if triggerUid[atkRole.uid] then --加入限定避免循环触发 + return + end + BattleUtil.RandomAction(f1, function () + atkRole:AddBuff(Buff.Create(role, BuffName.DOT, f3, 1, 0, 1, f2)) + triggerUid[atkRole.uid] = atkRole.uid + BattleLogic.WaitForTrigger(f3+1, function () + triggerUid[atkRole.uid] = nil + end) + end) + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnRoleBeDamaged) + end, + + --受击时[e],[a]的概率将[b]*[c]算作[d]计算 + --a[float],b[属性],c[float],d[属性],e[伤害类型] + [10] = function(role, args) + local f1 = args[1] local pro1 = args[2] local f2 = args[3] local pro2 = args[4] local dt = args[5] - local OnCrit = function(atkRole) - BattleUtil.RandomAction(f1, function () - local value = role:GetRoleData(BattleUtil.GetPropertyName(pro1)) * f2 + role:GetRoleData(BattleUtil.GetPropertyName(pro2)) - BattleUtil.CalDamage(role, atkRole, value, 1, dt) - end) + local OnRoleBeDamagedBefore = function(atkRole, func, damageType) + if damageType == dt then + BattleUtil.RandomAction(f1, function () + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], BattleLogic.GameDeltaTime) + end) + end end - role.Event:AddEvent(BattleEventName.RoleBeCrit, OnCrit) + role.Event:AddEvent(BattleEventName.RoleBeDamagedBefore, OnRoleBeDamagedBefore) end, - --生命低于(a%)的时候,提升自身减伤率(b%),持续(c)秒。每场战斗只能触发一次。 - [201021] = function(role, args) + --受击时,有[a]的概率抵消[b]*[c]的攻击。 + --a[float],b[属性],c[float] + [11] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + + local OnPassiveDamaging = function(damagingFunc) + BattleUtil.RandomAction(f1, function () + damagingFunc(floor(role:GetRoleData(propertyList[pro]) * f2)) + end) + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) + end, + + --受击后,有[a]的概率对敌方全体造成攻击*[c]的[d]伤害 + --a[float],c[float],d[伤害类型] + [12] = function(role, args) local f1 = args[1] local f2 = args[2] - local f3 = args[3] + local dt = args[3] - local buffId1 = BattleUtil.CreateBuffId(role, 1) + local lastTrigger = 0 + local OnRoleBeDamaged = function(atkRole) + if atkRole.isTeam then + return + end + lastTrigger = lastTrigger + 1 + if lastTrigger > 1 then --加入限定避免循环触发 + return + end + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 20000) + for i=1, #arr do + BattleUtil.CalDamage(role, arr[i], dt, f2) + end + end) + lastTrigger = 0 + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnRoleBeDamaged) + end, + + --受击后,有[a]的概率对随机1人造成[b]*[c]的真实伤害。 + --a[float],b[属性],c[float] + [13] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + + local lastTrigger = 0 + local OnRoleBeDamaged = function(atkRole) + if atkRole.isTeam then + return + end + lastTrigger = lastTrigger + 1 + if lastTrigger > 1 then --加入限定避免循环触发 + return + end + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 20001) + if arr[1] then + BattleUtil.ApplyDamage(role, atkRole, floor(role:GetRoleData(propertyList[pro]) * f2)) + end + end) + lastTrigger = 0 + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnRoleBeDamaged) + end, + + --受击后[f],[a]的概率将[b]*[c]算作[d]计算,持续[e]秒。 + --a[float],b[属性],c[float],d[属性],e[int],f[伤害类型] + [14] = function(role, args) + local f1 = args[1] + local pro1 = args[2] + local f2 = args[3] + local pro2 = args[4] + local f3 = args[5] + local dt = args[6] + + local OnRoleBeDamaged = function(atkRole, damage, bCrit, finalDmg, damageType) + if damageType == dt then + BattleUtil.RandomAction(f1, function () + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], f3) + end) + end + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnRoleBeDamaged) + end, + + --免疫[a]属性伤害。 + --a[属性类型] + [15] = function(role, args) + local pt = args[1] + local elementDamageReduceFactor + if pt == 1 then + elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor + elseif pt == 2 then + elementDamageReduceFactor = RoleDataName.WindDamageReduceFactor + elseif pt == 3 then + elementDamageReduceFactor = RoleDataName.IceDamageReduceFactor + elseif pt == 4 then + elementDamageReduceFactor = RoleDataName.LandDamageReduceFactor + elseif pt == 5 then + elementDamageReduceFactor = RoleDataName.LightDamageReduceFactor + elseif pt == 6 then + elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor + end + role.data:AddValue(elementDamageReduceFactor, 10000) + end, + + --发动技能后,[a]的概率将[b]*[c]算作[d]计算,持续[e]秒。 + --a[float],b[属性],c[float],d[属性],e[int] + [16] = function(role, args) + local f1 = args[1] + local pro1 = args[2] + local f2 = args[3] + local pro2 = args[4] + local f3 = args[5] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + role:AddPropertyTransfer(propertyList[pro1], f2, propertyList[pro2], f3) + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,[d]改变自身[a]属性[b],持续[c]秒 + --a[属性],b[int],c[int],d[改变类型] + [17] = function(role, args) + local pro1 = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct)) + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,[d]改变己方全体[a]属性[b],持续[c]秒 + --a[属性],b[int],c[int],d[改变类型] + [18] = function(role, args) + local pro1 = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + local OnSkillCastEnd = function(skill) + local arr = chooseTarget(role, 10000) + for i=1, #arr do + arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct)) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --受到治疗效果提高[a]。 + --a[float] + [19] = function(role, args) + local f1 = args[1] + end, + + --[b]造成的持续伤害时间延长[a]。 + --a[int],b[改变类型] + [20] = function(role, args) + local f1 = args[1] + local ct = args[2] + + local OnBuffCaster = function(buff) + if buff.type == BuffName.DOT then + if ct == 1 then --加算 + buff.duration = buff.duration + f1 + elseif ct == 2 then --乘加算(百分比属性加算) + buff.duration = buff.duration * (1 + f1) + elseif ct == 3 then --减算 + buff.duration = buff.duration - f1 + elseif ct == 4 then --乘减算(百分比属性减算) + buff.duration = buff.duration * (1 - f1) + end + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) + end, + + --自身增益效果超过[a]时,技能伤害提升[b]。 + --a[int],b[float] + [21] = function(role, args) + local i1 = args[1] + local f1 = args[2] + + local count = 0 + local targetBuff + local active = count > i1 + local OnBuffStart = function(buff) + if buff.isBuff then + count = count + 1 + if count > i1 and not active then + active = true + targetBuff = Buff.Create(role, BuffName.PropertyChange, 0, RoleDataName.DamageBocusFactor, f1, 1) + targetBuff.isBuff = false --自身不算增益 + role:AddBuff(targetBuff) + end + end + end + local OnBuffEnd = function(buff) + if buff.isBuff then + count = count - 1 + if count <= i1 and active then + active = false + if targetBuff then + targetBuff.disperse = true + end + end + end + end + role.Event:AddEvent(BattleEventName.BuffStart, OnBuffStart) + role.Event:AddEvent(BattleEventName.BuffEnd, OnBuffEnd) + end, + + --血量低于[a]时,[b]概率触发控制免疫,持续[c]秒。每场战斗只能触发1次。 + --a[float],b[float],c[int] + [22] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local f3 = args[2] local triggerCount = 0 local OnDamaged = function(atkRole) if BattleUtil.GetHPPencent(role) < f1 then if triggerCount < 1 then - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, f3, RoleDataName.DamageReduceFactor, f2, 1) - role:AddBuff(buff) - triggerCount = triggerCount + 1 + BattleUtil.RandomAction(f2, function () + role:AddBuff(Buff.Create(role, BuffName.Immune, f3, 1)) + triggerCount = triggerCount + 1 + end) end end end - role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) end, - --开场降低敌方全体(a%)的【c】,持续(bs)。 - [202011] = function(role, args) - local f1 = args[1]/100 + --死亡时,立即回复己方全体[a]*[b]的血量。 + --a[属性],b[float] + [23] = function(role, args) + local pro = args[1] + local f1 = args[2] + + local OnDead = function(atkRole) + local arr = chooseTarget(role, 10000) + for i=1, #arr do + BattleUtil.CalTreat(role, arr[i], floor(role:GetRoleData(propertyList[pro]) * f1)) + end + end + role.Event:AddEvent(BattleEventName.RoleDead, OnDead) + end, + + --控制效果命中后,[a]的概率施加[c]的[d]伤害 + --a[float],c[float],d[伤害类型] + [24] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local dt = args[3] + + local OnBuffCaster = function(buff) + if buff.type == BuffName.Control then + BattleUtil.RandomAction(f1, function () + BattleUtil.CalDamage(role, buff.target, dt, f2) + end) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) + end, + + --控制效果命中后,[a]对全体造成[c]的[d]伤害。 + --a[float],c[float],d[伤害类型] + [25] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local dt = args[3] + + local OnBuffCaster = function(buff) + if buff.type == BuffName.Control then + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(buff.target, 10000) + for i=1, #arr do + BattleUtil.CalDamage(role, arr[i], dt, f2) + end + end) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) + end, + + --造成的伤害暴击后,[a]施加攻击*[c]的[d]持续伤害,持续[e]秒。 + --a[float],c[float],d[伤害类型],e[int] + [26] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local dt = args[3] + local f3 = args[4] + + local triggerUid = {} + local OnRoleCrit = function(defRole) + if triggerUid[defRole.uid] then --加入限定避免循环触发 + return + end + BattleUtil.RandomAction(f1, function () + defRole:AddBuff(Buff.Create(role, BuffName.DOT, f3, 1, 0, dt, f2)) + triggerUid[defRole.uid] = defRole.uid + BattleLogic.WaitForTrigger(f3+1, function () + triggerUid[defRole.uid] = nil + end) + end) + end + role.Event:AddEvent(BattleEventName.RoleCrit, OnRoleCrit) + end, + + --造成的伤害暴击后,[a]的概率回复自身[b]*[c]的血量 + --a[float],b[属性],c[float] + [27] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + + local OnRoleCrit = function(defRole) + BattleUtil.RandomAction(f1, function () + BattleUtil.CalTreat(role, role, floor(role:GetRoleData(propertyList[pro]) * f2)) + end) + end + role.Event:AddEvent(BattleEventName.RoleCrit, OnRoleCrit) + end, + + --对血量高于[a]的敌人伤害提高[b]。 + --a[float],b[float] + [28] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + local OnRoleDamageBefore = function(defRole, factorFunc) + if BattleUtil.GetHPPencent(defRole) > f1 then + factorFunc(f2) + end + end + role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) + end, + + --对血量低于[a]的敌人伤害提高[b]。 + --a[float],b[float] + [29] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + local OnRoleDamageBefore = function(defRole, factorFunc) + if BattleUtil.GetHPPencent(defRole) < f1 then + factorFunc(f2) + end + end + role.Event:AddEvent(BattleEventName.RoleDamageBefore, OnRoleDamageBefore) + end, + + --发动技能后,[d]改变己方全体[a]属性[b],持续[c]秒 + --a[属性],b[float],c[int],d[改变类型] + [30] = function(role, args) + local pro = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + local OnSkillCastEnd = function(skill) + local arr = chooseTarget(role, 10000) + for i=1, #arr do + arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct)) + end + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --发动技能后,有[a]的概率眩晕敌方其中1人,持续[b]秒。 + --a[float],b[int] + [31] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + local OnSkillCastEnd = function(skill) + BattleUtil.RandomAction(f1, function () + local arr = chooseTarget(role, 20001) + if arr[1] then + arr[1]:AddBuff(Buff.Create(role, BuffName.Control, f2, 1)) + end + end) + end + role.Event:AddEvent(BattleEventName.SkillCastEnd, OnSkillCastEnd) + end, + + --持续伤害效果命中后,[d]改变自身[a]属性[b],持续[c]秒 + --a[属性],b[float],c[int],d[改变类型] + [32] = function(role, args) + local pro = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + local OnBuffCaster = function(buff) + if buff.type == BuffName.DOT then + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct)) + end + end + role.Event:AddEvent(BattleEventName.BuffCaster, OnBuffCaster) + end, + + --[d]改变自身[a]属性[b],持续[c]秒 + --a[属性],b[float],c[int],d[改变类型] + [33] = function(role, args) + local pro = args[1] + local f1 = args[2] + local f2 = args[3] + local ct = args[4] + + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct)) + end, + + --造成伤害时,额外增加[a]点伤害。 + --a[int] + [34] = function(role, args) + local f1 = args[1] + + local OnPassiveDamaging = function(damagingFunc) + damagingFunc(-f1) + end + role.Event:AddEvent(BattleEventName.PassiveDamaging, OnPassiveDamaging) + end, + + --进入战斗[a]秒后,造成的伤害提升[b],持续[c]秒 + --a[int],b[float],c[int] + [35] = function(role, args) + local f1 = args[1] + local f2 = args[2] + local f3 = args[3] + + BattleLogic.WaitForTrigger(f1, function () + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, RoleDataName.DamageBocusFactor, f2, 1)) + end) + end, + + --进入战斗[a]秒后,[d]改变[b]属性[c],持续[e]秒 + --a[int],b[属性],c[int],d[改变类型],e[int] + [36] = function(role, args) + local f1 = args[1] + local pro = args[2] + local f2 = args[3] + local ct = args[4] + local f3 = args[5] + + BattleLogic.WaitForTrigger(f1, function () + role:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro], f2, ct)) + end) + end, + + --进入战斗[a]秒后,免疫控制效果,持续[b]秒 + --a[int],b[int] + [37] = function(role, args) + local f1 = args[1] + local f2 = args[2] + + BattleLogic.WaitForTrigger(f1, function () + role:AddBuff(Buff.Create(role, BuffName.Immune, f2, 1)) + end) + end, + + --每[a]秒,[d]改变[b]的[c],[g改变[e]的[f],最高叠加[h]层 (举例:每5秒,扣除10%的生命,提高5%的速度, 最高叠加5层) + --a[int],b[float],c[属性],d[改变类型],e[float],f[属性],g[改变类型],h[int] + [38] = function(role, args) + local f1 = args[1] local f2 = args[2] local pro1 = args[3] + local ct1 = args[4] + local f3 = args[5] + local pro2 = args[6] + local ct2 = args[7] + local i1 = args[8] - local buffId1 = BattleUtil.CreateBuffId(role, 1) + local auraBuff = Buff.Create(role, BuffName.Aura, 0, function (role) + local changeBuff1 = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro1], f2, ct1) + changeBuff1.cover = true + changeBuff1.maxLayer = i1 - local arr = BattleLogic.Query(queryEnemy(role)) - local v - for i=1, #arr do - v = arr[i] - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, f2, BattleUtil.GetPropertyName(pro1), f1, 2) - v:AddBuff(buff) - end + local changeBuff2 = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro2], f3, ct2) + changeBuff2.cover = true + changeBuff2.maxLayer = i1 + + role:AddBuff(changeBuff1) + role:AddBuff(changeBuff2) + end) + auraBuff.interval = f1 + role:AddBuff(auraBuff) end, - --开场增加增加全队暴击率(a%),持续(b)秒。 - [202021] = function(role, args) - local f1 = args[1]/100 - local f2 = args[2] - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - - local arr = BattleLogic.Query(queryAllies(role)) - local v - for i=1, #arr do - v = arr[i] - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, f2, RoleDataName.Crit, f1, 2) - v:AddBuff(buff) - end - end, - - --场上每有1个流血目标,GCD降低(a)秒。最高降低(b)秒。 - [203011] = function(role, args) + --进入战斗后,每[a]秒回复[b]生命 + --a[int],b[int] + [39] = function(role, args) local f1 = args[1] local f2 = args[2] - local buffId1 = BattleUtil.CreateBuffId(role, 1) - - local originGcd = role:GetRoleData(RoleDataName.GCD) - local aurabuff = Buff.Create(role, BuffName.Aura, buffId1, 0, function (role) - local arr = BattleLogic.Query(queryEnemy(role)) - local count = 0 - local v - for i=1, #arr do - v = arr[i] - if v.BuffMgr:HasBuff(BuffName.Bleed) then - count = count + 1 - end - end - role.data:SetValue(RoleDataName.GCD, max(originGcd - count * f1, f2)) + local auraBuff = Buff.Create(role, BuffName.Aura, 0, function (role) + BattleUtil.CalTreat(role, role, f2) end) - aurabuff.interval = 0 - role:AddBuff(aurabuff) + auraBuff.interval = f1 + role:AddBuff(auraBuff) end, - --每次受到伤害,额外提升伤害(a%)(最多b%)。 - [203021] = function(role, args) - local f1 = args[1]/100 - local f2 = args[2]/100 - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local totalFactor = 0 + --被指定[a]造成伤害时,回复[b]生命 + --a[职业],b[int] + [40] = function(role, args) + local i1 = args[1] + local f1 = args[2] local OnDamaged = function(atkRole) - if totalFactor <= f2 then - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, 0, RoleDataName.DamageBocusFactor, f2, 1) - role:AddBuff(buff) - totalFactor = totalFactor + f1 + if atkRole.professionId == i1 then + BattleUtil.CalTreat(role, role, f1) end end role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) end, - --开场额外增加暴击率(a%)。 - [204011] = function(role, args) - local f1 = args[1]/100 + --造成伤害时,将伤害的[a]%转化为自身生命 + --a[float] + [41] = function(role, args) + local f1 = args[1] - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, 0, RoleDataName.Crit, f1, 1) - role:AddBuff(buff) + local OnDamaged = function(atkRole, damage, bCrit, finalDmg) + BattleUtil.CalTreat(role, role, floor(f1 * finalDmg)) + end + role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) end, - --受到攻击时,攻击者有(a%)的概率被附加1个印记。 - [204021] = function(role, args) - local f1 = args[1]/100 + --造成暴击伤害时,有[a]的概率造成[b]的暴击伤害。 + --a[float],b[float] + [42] = function(role, args) + local f1 = args[1] + local f2 = args[2] - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local OnDamaged = function(atkRole) + local OnPassiveCriting = function(crit) BattleUtil.RandomAction(f1, function () - local buff = Buff.Create(role, BuffName.Brand, buffId1, 0, "咒术师印记") - atkRole:AddBuff(buff) + crit(f2) end) end - - role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) - end, - - --生命低于(a%),治疗量增加(b%),持续(c)秒。每场战斗只能触发一次。 - [205011] = function(role, args) - local f1 = args[1] - local f2 = args[2]/100 - local f3 = args[3] - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - - local triggerCount = 0 - local OnDamaged = function(atkRole) - if BattleUtil.GetHPPencent(role) < f1 then - if triggerCount < 1 then - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, f3, RoleDataName.TreatFacter, f2, 1) - role:AddBuff(buff) - triggerCount = triggerCount + 1 - end - end - end - - role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) - end, - - --生命低于(a%),提升友军(b%)的【e】,并且(d%)概率眩晕对方全体(c)秒,每场战斗只能触发一次。 - [205021] = function(role, args) - local f1 = args[1] - local f2 = args[2]/100 - local f3 = args[3] - local f4 = args[4]/100 - local pro1 = args[5] - local f5 = args[6] - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local buffId2 = BattleUtil.CreateBuffId(role, 2) - - local triggerCount = 0 - local OnDamaged = function(atkRole) - if BattleUtil.GetHPPencent(role) < f1 then - if triggerCount < 1 then - local arr = BattleLogic.Query(queryAllies(role)) - local v - for i=1, #arr do - v = arr[i] - local buff = Buff.Create(role, BuffName.PropertyChange, buffId1, f5, BattleUtil.GetPropertyName(pro1), f2, 1) - v:AddBuff(buff) - end - - BattleUtil.RandomAction(f4, function () - local arr = BattleLogic.Query(queryEnemy(role)) - local v - for i=1, #arr do - v = arr[i] - local stun = Buff.Create(role, BuffName.Stun, buffId2, f3) - v:AddBuff(stun) - end - end) - triggerCount = triggerCount + 1 - end - end - end - role.Event:AddEvent(BattleEventName.RoleBeDamaged, OnDamaged) - end, - - --每(a)秒恢复(b)魂能 - [206021] = function(role, args) - local f1 = args[1] - local i1 = args[2] - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local aurabuff = Buff.Create(role, BuffName.Aura, buffId1, 0, function (role) - BattleLogic.AddMP(role.camp, i1) - end) - aurabuff.interval = f1 - role:AddBuff(aurabuff) - end, - - --自身生命高于(a%),暴击率提高(b%) - [207011] = function(role, args) - local f1 = args[1] - local f2 = args[2]/100 - - local buffId1 = BattleUtil.CreateBuffId(role, 1) - local buffId2 = BattleUtil.CreateBuffId(role, 2) - - local buff = Buff.Create(role, BuffName.PropertyChange, buffId2, 0, RoleDataName.Crit, f2, 1) - local active = BattleUtil.GetHPPencent(role) > f1 - if active then - role:AddBuff(buff) - end - - local aurabuff = Buff.Create(role, BuffName.Aura, buffId1, 0, function (role) - local curActive = BattleUtil.GetHPPencent(role) > f1 - if active ~= curActive then - active = curActive - if active then - buff.disperse = false - role:AddBuff(buff) - else - buff.disperse = true - end - end - end) - aurabuff.interval = 0 - role:AddBuff(aurabuff) - end, - - --召唤物存在期间,场上伙伴阵亡超过2名时,冰雪皇后会牺牲并复活所有已阵亡的队友,保留其(a%)的生命,全场只可触发1次 - [208011] = function(role, args) - local f1 = args[1]/100 - - local deadCount = 0 - local triggerCount = 0 - - local OnDead = function(role) - if role.camp == role.camp and role.roleType ~= 3 then - deadCount = deadCount + 1 - if deadCount > 2 and role.summon and triggerCount < 1 then - BattleLogic.RemoveSummon(role.summon) - local arr = BattleLogic.Query(function (r) return r.camp == role.camp and r.roleType ~= 3 end, true) - local v - for i=1, #arr do - v = arr[i] - local hp = v:GetRoleData(RoleDataName.MaxHp) - v.data:AddValue(RoleDataName.Hp, floor(hp*f1)) - v.Event:DispatchEvent(BattleEventName.RoleRevive) - end - triggerCount = triggerCount + 1 - end - end - end - BattleLogic.Event:AddEvent(BattleEventName.BattleRoleDead, OnDead) + role.Event:AddEvent(BattleEventName.PassiveCriting, OnPassiveCriting) end, } return passivityList \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Base/RoleData.lua b/luafight/Modules/Battle/Logic/Base/RoleData.lua index 190ac7eb3..ab8a992c7 100644 --- a/luafight/Modules/Battle/Logic/Base/RoleData.lua +++ b/luafight/Modules/Battle/Logic/Base/RoleData.lua @@ -3,7 +3,11 @@ RoleData.__index = RoleData local max = math.max local floor = math.floor function RoleData.New() - local instance = {role=0, data={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} + local instance = {role=0, data={0,0,0,0,0, + 0,0,0,0,0, + 0,0,0,0,0, + 0,0,0,0,0, + 0,0,0,0,0}} setmetatable(instance, RoleData) return instance end diff --git a/luafight/Modules/Battle/Logic/Base/Skill.lua b/luafight/Modules/Battle/Logic/Base/Skill.lua index 7faae8754..e96b5dcaa 100644 --- a/luafight/Modules/Battle/Logic/Base/Skill.lua +++ b/luafight/Modules/Battle/Logic/Base/Skill.lua @@ -76,43 +76,43 @@ local function chooseTarget(role, chooseId, exceptList) BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.Hp) local r2 = b:GetRoleData(RoleDataName.Hp) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 2 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.Hp) / a:GetRoleData(RoleDataName.MaxHp) local r2 = b:GetRoleData(RoleDataName.Hp) / b:GetRoleData(RoleDataName.MaxHp) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 3 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.Attack) local r2 = b:GetRoleData(RoleDataName.Attack) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 4 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.PhysicalDefence) local r2 = b:GetRoleData(RoleDataName.PhysicalDefence) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 5 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.PhysicalDefence) local r2 = b:GetRoleData(RoleDataName.PhysicalDefence) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 6 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.MagicDefence) local r2 = b:GetRoleData(RoleDataName.MagicDefence) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) elseif chooseWeight == 7 then BattleUtil.Sort(arr, function(a, b) local r1 = a:GetRoleData(RoleDataName.MagicDefence) local r2 = b:GetRoleData(RoleDataName.MagicDefence) - return sort == 1 and r1 < r2 or r1 > r2 + if sort == 1 then return r1 > r2 else return r1 < r2 end end) end @@ -209,6 +209,10 @@ function Skill:Cast() local duration = effectGroup.duration local effects = effectGroup.effects local nn = floor(chooseId / 10000) % 10 + local count = chooseId % 10 + if count == 0 then + count = #arr + end if self.owner.camp == 0 and nn == 2 then --我方释放效果开始切镜头 BattleLogic.Event:DispatchEvent(BattleEventName.ZoomIn, 0.3) BattleLogic.WaitForTrigger(duration, function() @@ -218,15 +222,14 @@ function Skill:Cast() if chooseId == 10000 or chooseId == 20000 then --10000 我方aoe 20000 敌方aoe local camp = chooseId == 10000 and self.owner.camp or 1 - self.owner.camp self.owner.Event:DispatchEvent(BattleEventName.AOE, camp) - for j=1, #arr do + for j=1, count do takeEffect(self.owner, arr[j], effects, duration) end elseif nn == 1 or nn == 3 then - for j=1, #arr do + for j=1, count do takeEffect(self.owner, arr[j], effects, duration) end else - local count = chooseId % 10 local d = duration / (count + 1) --分割多人目标施加效果的时间,按照(1+1+..+2)的时间权重占比分配 for j=1, count do local index = j @@ -280,6 +283,7 @@ function Skill:Cast() BattleLogic.Event:DispatchEvent(BattleEventName.SkillCast, self.cd) --队伍技能结构和其他相同,只是cd项为对应异妖类型 end + --技能的施法时间计算,根据当前目标id关联的持续时间,取其中时间最长的一个 local duration = 0 for i=1, self.effectList.size do duration = max(duration, self.effectList.buffer[i].duration) @@ -289,6 +293,11 @@ function Skill:Cast() BattleLogic.WaitForTrigger(duration, function() self.choosedList:Clear() BattleLogic.SetSkillUsable(self.owner.camp, true) + if not self.isTeamSkill then + self.owner.Event:DispatchEvent(BattleEventName.SkillCastEnd, self) + else + BattleLogic.Event:DispatchEvent(BattleEventName.SkillCastEnd, self.cd) + end end) end --表现层调用 diff --git a/luafight/Modules/Battle/Logic/Buff/Brand.lua b/luafight/Modules/Battle/Logic/Buff/Brand.lua index f5a981812..17ba16659 100644 --- a/luafight/Modules/Battle/Logic/Buff/Brand.lua +++ b/luafight/Modules/Battle/Logic/Buff/Brand.lua @@ -7,6 +7,7 @@ function Brand:SetData(...) self.flag, self.endFunc = ... --标记,结束回调 self.cover = true self.layer = 1 + self.maxLayer = 0 end --初始化后调用一次 @@ -33,7 +34,11 @@ function Brand:OnCover(newBuff) --log("Brand:OnCover") local b = newBuff.flag == self.flag if b then - newBuff.layer = self.layer + 1 + if newBuff.maxLayer == 0 then + newBuff.layer = self.layer + 1 + else + newBuff.layer = math.min(self.layer + 1, newBuff.maxLayer) + end end return b end diff --git a/luafight/Modules/Battle/Logic/Buff/HOT.lua b/luafight/Modules/Battle/Logic/Buff/HOT.lua index d9aeb1c8c..d3dd32c35 100644 --- a/luafight/Modules/Battle/Logic/Buff/HOT.lua +++ b/luafight/Modules/Battle/Logic/Buff/HOT.lua @@ -12,12 +12,15 @@ end --初始化后调用一次 function HOT:OnStart() --log("HOT:OnStart") + self.target.Event:DispatchEvent(BattleEventName.RoleBeHealed, self.caster) end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd function HOT:OnTrigger() --log("HOT:OnTrigger") - BattleUtil.ApplyTreat(self.caster, self.target, self.healValue) + if not self.target.ctrl_noheal then --禁疗无法加血 + BattleUtil.ApplyTreat(self.caster, self.target, self.healValue) + end return true end diff --git a/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua b/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua index 941092081..dc2bf0601 100644 --- a/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua +++ b/luafight/Modules/Battle/Logic/Buff/PropertyChange.lua @@ -7,6 +7,9 @@ function PropertyChange:SetData(...) self.propertyName, self.Value, self.changeType = ... + self.cover = false --默认不可叠加 + self.layer = 1 + self.maxLayer = 0 end --初始化后调用一次 @@ -46,14 +49,21 @@ end --只有当Cover字段为true时触发,返回true则被新效果覆盖 function PropertyChange:OnCover(newBuff) --log("PropertyChange:OnCover") - if self.layer then - if self.maxCount == 0 then + local b = self.propertyName == newBuff.propertyName and self.changeType == newBuff.changeType + if b then + if newBuff.maxLayer == 0 then newBuff.layer = self.layer + 1 + newBuff.Value = newBuff.Value + self.Value else - newBuff.layer = math.min(self.layer + 1, self.maxCount) + if self.layer < newBuff.maxLayer then + newBuff.Value = newBuff.Value + self.Value + else + newBuff.Value = self.Value + end + newBuff.layer = math.min(self.layer + 1, newBuff.maxLayer) end end - return true + return b end return PropertyChange \ No newline at end of file diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 5b020ad56..eecd3f590 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -17,6 +17,8 @@ BattleEventName = { RoleBeDamaged = indexAdd(), RoleDamage = indexAdd(), + RoleDamageBefore = indexAdd(), + RoleBeDamagedBefore = indexAdd(), RoleBeTreated = indexAdd(), RoleTreat = indexAdd(), RoleBeHealed = indexAdd(), @@ -30,6 +32,11 @@ BattleEventName = { RoleCDChanged = indexAdd(), SkillCast = indexAdd(), + SkillCastEnd = indexAdd(), + + PassiveTreating = indexAdd(), + PassiveDamaging = indexAdd(), + PassiveCriting = indexAdd(), ZoomIn = indexAdd(), ZoomChange = indexAdd(), @@ -39,6 +46,7 @@ BattleEventName = { RoleViewBullet = indexAdd(), --弹道飞行击中表现 + BuffCaster = indexAdd(), BuffStart = indexAdd(), BuffTrigger = indexAdd(), BuffEnd = indexAdd(), @@ -61,7 +69,11 @@ RoleDataName = { Dodge = indexAdd(), --闪避率(%) Crit = indexAdd(), --暴击率(%) CritDamageFactor = indexAdd(), --暴击伤害系数(%) + Tenacity = indexAdd(), --抗暴率(%) TreatFacter = indexAdd(),--治疗加成系数(%) + CureFacter = indexAdd(),--受到治疗加成系数(%) + TeamDamageBocusFactor = indexAdd(),--队伍伤害加成系数(%) + TeamDamageReduceFactor = indexAdd(),--队伍伤害减免系数(%) FireDamageReduceFactor = indexAdd(), --火系伤害减免系数(%) WindDamageReduceFactor = indexAdd(), --风系伤害减免系数(%) IceDamageReduceFactor = indexAdd(), --冰系伤害减免系数(%) diff --git a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua index 1346a8f3e..36c2305b0 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -42,15 +42,6 @@ function BattleUtil.CalHit(atkRole, defRole) return bHit end -function BattleUtil.CalCrit(atkRole, defRole) - local bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit), 0, 1) - if bCrit then - atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole) - defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole) - end - return bCrit -end - function BattleUtil.CalShield(atkRole, defRole, damage) for i=1, defRole.shield.size do local buff = defRole.shield.buffer[i] @@ -68,41 +59,59 @@ function BattleUtil.CalShield(atkRole, defRole, damage) return damage end -function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit) - if not bCrit then bCrit = false end +function BattleUtil.ApplyDamage(atkRole, defRole, damage, bCrit, damageType) + bCrit = bCrit or false + damageType = damageType or 0 damage = floor(damage + 0.5) - local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) - if finalDmg > 0 then - if atkRole then - atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit) - end - defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit) - if defRole:GetRoleData(RoleDataName.Hp) <= 0 then - defRole.isDead = true - BattleLogic.BuffMgr:ClearBuff(defRole) - defRole.Event:DispatchEvent(BattleEventName.RoleDead) - BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole) - if defRole.camp == 1 then - BattleLogic.WaitForTrigger(1, function () - BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 1) - end) + --加入被动效果 + local damagingFunc = function(dmgDeduction) damage = damage - dmgDeduction end + defRole.Event:DispatchEvent(BattleEventName.PassiveDamaging, damagingFunc) + + if damage > 0 then + local finalDmg = defRole.data:SubValue(RoleDataName.Hp, damage) + if finalDmg > 0 then + if atkRole then + atkRole.Event:DispatchEvent(BattleEventName.RoleDamage, defRole, damage, bCrit, finalDmg, damageType) + end + defRole.Event:DispatchEvent(BattleEventName.RoleBeDamaged, atkRole, damage, bCrit, finalDmg, damageType) + if bCrit then + atkRole.Event:DispatchEvent(BattleEventName.RoleCrit, defRole) + defRole.Event:DispatchEvent(BattleEventName.RoleBeCrit, atkRole) + end + + if defRole:GetRoleData(RoleDataName.Hp) <= 0 then + defRole.isDead = true + BattleLogic.BuffMgr:ClearBuff(defRole) + defRole.Event:DispatchEvent(BattleEventName.RoleDead) + BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, defRole) + if defRole.camp == 1 then + BattleLogic.WaitForTrigger(1, function () + BattleLogic.Event:DispatchEvent(BattleEventName.ZoomChange, BattleLogic.GetAggro(0), 1) + end) + end end end + return finalDmg + else + return damage end - return finalDmg end --执行完整的命中,伤害,暴击计算,返回命中,暴击 function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDef) - if atkRole.isTeam and not defRole.isDead then + if atkRole.isTeam and not defRole.isDead then --如果计算真实伤害,则damageType为伤害值 return BattleUtil.ApplyDamage(atkRole, defRole, damageType), false end + baseFactor = baseFactor or 1 + local factorFunc = function(exFactor) baseFactor = baseFactor + exFactor end + atkRole.Event:DispatchEvent(BattleEventName.RoleDamageBefore, defRole, factorFunc, damageType) + defRole.Event:DispatchEvent(BattleEventName.RoleBeDamagedBefore, atkRole, factorFunc, damageType) + local bCrit = false local baseDamage - baseFactor = baseFactor or 1 ignoreDef = 1 - (ignoreDef or 0) - bCrit = BattleUtil.CalCrit(atkRole, defRole) + bCrit = Random.Range01() <= clamp(atkRole:GetRoleData(RoleDataName.Crit), 0, 1) local defence = 0 if damageType == 1 then --1 物理 2 魔法 defence = defRole:GetRoleData(RoleDataName.PhysicalDefence) @@ -118,13 +127,14 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe --计算暴击 if bCrit or defRole.isFlagCrit then local critDamageFactor = atkRole:GetRoleData(RoleDataName.CritDamageFactor) + --加入被动效果 + local critFunc = function(critEx) critDamageFactor = critEx end + atkRole.Event:DispatchEvent(BattleEventName.PassiveCriting, critFunc) baseDamage = max(attack * critDamageFactor - 0.5 * defence * ignoreDef, 0) else baseDamage = max(attack - 0.5 * defence * ignoreDef, 0) end - local atkData, defData = atkRole.data, defRole.data --伤害 =(基础伤害*(1+己伤害加成-目标伤害减免)*(1+己方属性伤害加成-目标属性伤害减免),10%*己攻) - local element = 1 local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor if atkRole.element == 1 then @@ -140,7 +150,7 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe elseif atkRole.element == 6 then elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor end - element = (1 + atkData:GetData(RoleDataName.ElementDamageBocusFactor)) * (1 - defData:GetData(elementDamageReduceFactor)) + element = (1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor)) * max(1 - defRole:GetRoleData(elementDamageReduceFactor), 0) baseDamage = baseDamage * baseFactor * element baseDamage = floor(max(baseDamage, 0.1 * attack)) @@ -154,23 +164,36 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe baseDamage = BattleUtil.CalShield(atkRole, defRole, baseDamage) local finalDmg = 0 --计算实际造成的扣血 if not defRole.isDead then - finalDmg = BattleUtil.ApplyDamage(atkRole, defRole, baseDamage, bCrit) + finalDmg = BattleUtil.ApplyDamage(atkRole, defRole, baseDamage, bCrit, damageType) end return finalDmg, bCrit end -function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) +function BattleUtil.CalTreat(castRole, targetRole, value, baseFactor) if targetRole.ctrl_noheal then --禁疗无法加血 return end + targetRole.Event:DispatchEvent(BattleEventName.RoleBeHealed, castRole) + BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) +end + +function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor) baseFactor = baseFactor or 1 local maxHp = targetRole:GetRoleData(RoleDataName.MaxHp) local hp = targetRole:GetRoleData(RoleDataName.Hp) local factor = castRole:GetRoleData(RoleDataName.TreatFacter) - local treat = min(floor(value * baseFactor * (factor + 1) + 0.5), maxHp - hp) - targetRole.data:AddValue(RoleDataName.Hp, treat) - castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat) - targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat) + local baseTreat = floor(value * baseFactor * (factor + 1) + 0.5) + + --加入被动效果 + local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end + castRole.Event:DispatchEvent(BattleEventName.PassiveTreating, treatingFunc) + + local treat = min(baseTreat, maxHp - hp) + if treat > 0 then + targetRole.data:AddValue(RoleDataName.Hp, treat) + castRole.Event:DispatchEvent(BattleEventName.RoleTreat, targetRole, treat) + targetRole.Event:DispatchEvent(BattleEventName.RoleBeTreated, castRole, treat) + end end function BattleUtil.RandomAction(rand, action) @@ -223,7 +246,7 @@ function BattleUtil.GetPropertyName(type) end function BattleUtil.GetHPPencent(role) - return role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp) * 100 + return role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp) end diff --git a/luafight/Modules/Battle/Logic/RoleLogic.lua b/luafight/Modules/Battle/Logic/RoleLogic.lua index 5144afe37..73f7ed2a2 100644 --- a/luafight/Modules/Battle/Logic/RoleLogic.lua +++ b/luafight/Modules/Battle/Logic/RoleLogic.lua @@ -16,6 +16,7 @@ function RoleLogic.New() local instance = {uid=0,roleData=0,data=RoleData.New(),camp=0,name=0,roleType=0, shield=BattleList.New(), exCalDmgList=BattleList.New(), + proTranList=BattleList.New(), buffFilter=BattleList.New(), Event=BattleEvent:New(),passiveList=0,isDead=false,Auto=false,IsDebug=false,enable=false} setmetatable(instance, RoleLogic) @@ -35,6 +36,7 @@ function RoleLogic:Init(uid, data) self.shield:Clear() --护盾列表 self.exCalDmgList:Clear() --额外计算伤害列表 self.buffFilter:Clear() --buff屏蔽列表 + self.proTranList:Clear() --属性转换列表 self.Event:ClearEvent() @@ -116,7 +118,26 @@ function RoleLogic:CanCastSkill() end function RoleLogic:GetRoleData(property) - return self.data:GetData(property) + local tarPro = self.data:GetData(property) + local item + for i=1, self.proTranList.size do + item = self.proTranList.buffer[i] + if item.proName == property then + tarPro = tarPro + self.data:GetData(item.tranProName) * item.tranFactor + end + end + return tarPro +end + +--proA替换的属性,factor系数,proB被替换的属性, duration持续时间 +--读取proB属性时,得到的值为proB + proA * factor +function RoleLogic:AddPropertyTransfer(proA, factor, proB, duration) + local proTran = {proName = proB, tranProName = proA, tranFactor = factor} + self.proTranList:Add(proTran) + local index = self.proTranList.size + BattleLogic.WaitForTrigger(duration, function () + self.proTranList:Remove(index) + end) end function RoleLogic:AddBuff(buff) @@ -128,6 +149,7 @@ function RoleLogic:AddBuff(buff) return end end + buff.caster.Event:DispatchEvent(BattleEventName.BuffCaster, buff) BattleLogic.BuffMgr:AddBuff(self, buff) end diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java index e39663a63..81380c9b8 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SMonsterConfig.java @@ -3,7 +3,6 @@ package com.ljsd.jieling.config; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; import com.ljsd.jieling.protocols.CommonProto; -import com.ljsd.jieling.protocols.FightInfoProto; import com.ljsd.jieling.util.CBean2Proto; import java.util.Map; @@ -46,9 +45,20 @@ public class SMonsterConfig implements BaseConfig { private float critDamageFactor; - private float damageBonusFactor; + private float elementDamageBonusFactor; - private float[] damageReduceFactor; + private float damageBocusFactor; + + private float damageReduceFactor; + + private float cureFacter; + private float treatFacter; + private float differDemonsReduceFactor; + private float antiCritDamageFactor; + private float differDemonsBocusFactor; + + + private float[] elementDamageReduceFactor; private int[] skillList; @@ -136,12 +146,12 @@ public class SMonsterConfig implements BaseConfig { return critDamageFactor; } - public float getDamageBonusFactor() { - return damageBonusFactor; + public float getElementDamageBonusFactor() { + return elementDamageBonusFactor; } - public float[] getDamageReduceFactor() { - return damageReduceFactor; + public float[] getElementDamageReduceFactor() { + return elementDamageReduceFactor; } public int[] getSkillList() { @@ -155,4 +165,32 @@ public class SMonsterConfig implements BaseConfig { public int getPropertyName() { return propertyName; } + + public float getDamageBocusFactor() { + return damageBocusFactor; + } + + public float getDamageReduceFactor() { + return damageReduceFactor; + } + + public float getCureFacter() { + return cureFacter; + } + + public float getTreatFacter() { + return treatFacter; + } + + public float getDifferDemonsReduceFactor() { + return differDemonsReduceFactor; + } + + public float getAntiCritDamageFactor() { + return antiCritDamageFactor; + } + + public float getDifferDemonsBocusFactor() { + return differDemonsBocusFactor; + } } \ No newline at end of file diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index b227b7225..7aa668cd5 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -52,7 +52,6 @@ public class GetPlayerInfoHandler extends BaseHandler{ ActivityLogic.getInstance().flushEveryDay(user); } user.getPlayerInfoManager().setLoginTime(TimeUtils.now()); - MapLogic.getInstance().checkIsInMap(user); Map guidePoints = user.getPlayerInfoManager().getGuidePoints(); List list = new ArrayList<>(); for(Map.Entry guideItem : guidePoints.entrySet()){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java index 60b9ff90e..e939ee513 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/LoginRequestHandler.java @@ -1,5 +1,6 @@ package com.ljsd.jieling.handler; +import com.ljsd.jieling.handler.map.MapLogic; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.netty.cocdex.PacketNetData; @@ -60,6 +61,7 @@ public class LoginRequestHandler extends BaseHandler { try { MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.LOGIN_RESPONSE_VALUE, loginResponse, true); + MapLogic.getInstance().whenLogin(user); LOGGER.info("back to client!"); } catch (Exception e) { e.printStackTrace(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index 5f1e61fbe..51b44206d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -76,7 +76,6 @@ public class MapLogic { MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); return; } - checkIsInMap(user); // 初始序章地图 if (user.getPlayerInfoManager().getMapId() == 0) { String error = initTeamInfo(teamId, uid, user, mapManager); @@ -150,7 +149,7 @@ public class MapLogic { cellToProto(cells, entry); } MapInfoProto.MapEnterResponse.Builder mapEnterResponse = MapInfoProto.MapEnterResponse.newBuilder(); - mapEnterResponse.setLeftTime(getLeftTime(user)); + mapEnterResponse.setLeftTime(getLeftTime(user,true)); for (Map.Entry buffEntry : mapManager.getFoodBufferMap().entrySet()) { if (buffEntry.getValue() <= 0) { continue; @@ -296,7 +295,7 @@ public class MapLogic { mapManager.addWalkCells(new HashSet<>(cells)); mapManager.setCurXY(curXY); MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder() - .setLeftTime(getLeftTime(user)) + .setLeftTime(getLeftTime(user,true)) .build(); MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true); return true; @@ -338,8 +337,8 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "未开始探索"); return; } - if (getLeftTime(user) <= 0) { - LOGGER.info("updateMap() uid=>{}, no step=>{}", uid, getLeftTime(user)); + if (getLeftTime(user,true) <= 0) { + LOGGER.info("updateMap() uid=>{}, no step=>{}", uid, getLeftTime(user,true)); MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } @@ -362,7 +361,7 @@ public class MapLogic { mapManager.setCurXY(curXY); MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder() .setEventId(cell.getEventId()) - .setLeftTime(getLeftTime(user)) + .setLeftTime(getLeftTime(user,true)) .build(); LOGGER.info("updateMap() uid=>{} mapId =>{} eventId=>{}", uid, mapManager.getCurMapId(), cell.getEventId()); mapManager.updateFoodBufferByStep(cells.size()); @@ -446,8 +445,8 @@ public class MapLogic { MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } - if (getLeftTime(user) <= 0) { - LOGGER.info("mapManager.getLeftTime() <= 0 =>{}", getLeftTime(user)); + if (getLeftTime(user,true) <= 0) { + LOGGER.info("mapManager.getLeftTime() <= 0 =>{}", getLeftTime(user,true)); MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); return; } @@ -502,7 +501,7 @@ public class MapLogic { .build(); eventUpdateResponse.setEventBehaviorCommon(eventBehaviorCommon); eventUpdateResponse.setEventId(nextEventId); - eventUpdateResponse.setLeftTime(getLeftTime(user)); + eventUpdateResponse.setLeftTime(getLeftTime(user,true)); if (dropBuilder != null) { eventUpdateResponse.setDrop(dropBuilder); } @@ -707,11 +706,27 @@ public class MapLogic { public void outMap(ISession session,int mapId,MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); User user = UserManager.getUser(uid); + boolean result = onlyLevelMap(user,true); + if(!result){ + MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); + return; + } + MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); + } + + public void whenLogin(User user) throws Exception { + int leftTime = getLeftTime(user,true); + if(leftTime == 0){ + onlyLevelMap(user,false); + } + } + + + private boolean onlyLevelMap(User user,boolean needTemporaryItem) throws Exception { MapManager mapManager = user.getMapManager(); if (mapManager.getMapInfo() == null) { LOGGER.info("mapManager.getMapInfo() == null"); - MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); - return; + return false; } CrossInfo crossInfo = mapManager.getCrossInfoMap().get(mapManager.getCurMapId()); if (mapManager.getStars() != null && crossInfo != null) { @@ -721,10 +736,11 @@ public class MapLogic { mapManager.updateCrossInfoMap(mapManager.getCurMapId(), crossInfo); } } - resetMapInfo(user, true); - MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true); + resetMapInfo(user, needTemporaryItem); + return true; } + public void resetMapInfo(User user, boolean needTemporaryItem) throws Exception { MapManager mapManager = user.getMapManager(); mapManager.setFoodBufferMap(new HashMap<>()); @@ -828,7 +844,7 @@ public class MapLogic { int[] reviveTime = sChallengeConfig.getReviveTime(); long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000); user.getMapManager().setCanMoveTime(TimeUtils.now() + time); - int leftTime = getLeftTime(user); + int leftTime = getLeftTime(user,true); remainHp.clear(); if (leftTime <= (int) (time / 1000)) { resetMapInfo(user, false); @@ -1007,7 +1023,7 @@ public class MapLogic { int[] reviveTime = sChallengeConfig.getReviveTime(); long time = (long) (MathUtils.calABX(dieCount, reviveTime) * 1000); user.getMapManager().setCanMoveTime(TimeUtils.now() + time); - int leftTime = getLeftTime(user); + int leftTime = getLeftTime(user,true); remainHp.clear(); if (leftTime <= (int) (time / 1000)) { resetMapInfo(user, false); @@ -1218,14 +1234,18 @@ public class MapLogic { return mapMission.getTotalWeight(); } - public int getLeftTime(User user) throws Exception { - SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId()); + public int getLeftTime(User user,boolean needResetMap) throws Exception { + int curMapId = user.getMapManager().getCurMapId(); + if(curMapId == 0){ + return -1; + } + SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(curMapId); long startExporeTime = user.getMapManager().getStartExporeTime(); if (startExporeTime == 0) { return -1; } int useTime = (int) ((TimeUtils.now() - startExporeTime) / 1000); - if (useTime >= sChallengeConfig.getMapTime()) { + if (needResetMap && useTime >= sChallengeConfig.getMapTime()) { resetMapInfo(user, false); return 0; } else { @@ -1378,7 +1398,7 @@ public class MapLogic { } mapManager.setStartExporeTime(TimeUtils.now()); MapInfoProto.MapStartExploreResponse mapStartExploreResponse = MapInfoProto.MapStartExploreResponse.newBuilder() - .setLeftTime(getLeftTime(user)) + .setLeftTime(getLeftTime(user,true)) .build(); MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapStartExploreResponse, true); } @@ -1796,19 +1816,6 @@ public class MapLogic { } } - public void checkIsInMap(User user) throws Exception { - if (user.getMapManager().getCurMapId() == 0) { - return; - } - int leftTime = getLeftTime(user); - if (leftTime >= 0) { - return; - } - // TODO 发邮件 - - resetMapInfo(user, true); - } - public void minuteCheckAndRemoveMapRank(){ Map> sCMap = SCMap.sCMap; for(Integer mapId : sCMap.keySet()){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroAttributeEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroAttributeEnum.java index 935c21b84..179700b16 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroAttributeEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroAttributeEnum.java @@ -13,7 +13,11 @@ public enum HeroAttributeEnum { Dodge(54), CritFactor(55), CritDamageFactor(56), - TreatFacter(57), + CureFacter(57), + TreatFacter(58), + DifferDemonsReduceFactor(59), + AntiCritDamageFactor(60), + DifferDemonsBocusFactor(66), FireDamageBonusFactor(101), WindDamageBonusFactor(102), WaterDamageBonusFactor(103), diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 49f27cb7a..c23140c9b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -39,7 +39,11 @@ public class HeroLogic { transTemplate.add(HeroAttributeEnum.Dodge.getPropertyId()); // 闪避率 transTemplate.add(HeroAttributeEnum.CritFactor.getPropertyId()); // 暴击率 transTemplate.add(HeroAttributeEnum.CritDamageFactor.getPropertyId()); // 暴击伤害系数 + transTemplate.add(HeroAttributeEnum.AntiCritDamageFactor.getPropertyId()); // 抗暴率 transTemplate.add(HeroAttributeEnum.TreatFacter.getPropertyId()); // 治疗加成系数 + transTemplate.add(HeroAttributeEnum.CureFacter.getPropertyId()); // 受治疗 + transTemplate.add(HeroAttributeEnum.DifferDemonsBocusFactor.getPropertyId()); // 增加受到的异妖伤害 + transTemplate.add(HeroAttributeEnum.DifferDemonsReduceFactor.getPropertyId()); // 异妖减伤率 // transTemplate.add(HeroAttributeEnum.FireDamageBonusFactor.getPropertyId()); // 火系伤害加成系数 transTemplate.add(HeroAttributeEnum.FireDamageReduceFactor.getPropertyId()); // 火系伤害减免系数 // transTemplate.add(HeroAttributeEnum.WindDamageBonusFactor.getPropertyId()); // 风系伤害加成系数 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java index 62f3bfec8..5e9be4cce 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java @@ -2,7 +2,6 @@ package com.ljsd.jieling.util; import com.ljsd.jieling.config.SMonsterConfig; import com.ljsd.jieling.handler.map.MapManager; -import com.ljsd.jieling.handler.map.MapMission; import com.ljsd.jieling.handler.map.TemporaryItems; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.protocols.CommonProto; @@ -152,7 +151,7 @@ public class CBean2Proto { public static CommonProto.FightUnitInfo getMonster(SMonsterConfig sMonsterConfig) { StringBuilder monsterPropertyList = new StringBuilder(); StringBuilder monsterSkillList = new StringBuilder(); //火风水地光暗 - float[] damageReduceFactor = sMonsterConfig.getDamageReduceFactor(); + float[] damageReduceFactor = sMonsterConfig.getElementDamageReduceFactor(); monsterPropertyList.append(sMonsterConfig.getLevel()).append("#"); //等级 monsterPropertyList.append(sMonsterConfig.getHp()).append("#"); //生命 monsterPropertyList.append(sMonsterConfig.getHp()).append("#"); //最大生命 @@ -160,20 +159,24 @@ public class CBean2Proto { monsterPropertyList.append(sMonsterConfig.getPhysicalDefence()).append("#"); //护甲 monsterPropertyList.append(sMonsterConfig.getMagicDefence()).append("#"); //魔抗 monsterPropertyList.append(sMonsterConfig.getSpeed()).append("#"); //速度 - monsterPropertyList.append(0).append("#"); //伤害加成系数 - monsterPropertyList.append(0).append("#"); //伤害减免系数 + monsterPropertyList.append(sMonsterConfig.getDamageBocusFactor()).append("#"); //伤害加成系数 + monsterPropertyList.append(sMonsterConfig.getDamageReduceFactor()).append("#"); //伤害减免系数 monsterPropertyList.append(sMonsterConfig.getHit()).append("#"); //命中率 monsterPropertyList.append(sMonsterConfig.getDodge()).append("#"); //闪避率 monsterPropertyList.append(sMonsterConfig.getCritFactor()).append("#"); //暴击率 monsterPropertyList.append(sMonsterConfig.getCritDamageFactor()).append("#"); //暴击伤害系数 - monsterPropertyList.append(0).append("#"); //治疗加成系数 + monsterPropertyList.append(sMonsterConfig.getAntiCritDamageFactor()).append("#"); //抗暴率系数 + monsterPropertyList.append(sMonsterConfig.getTreatFacter()).append("#"); //治疗加成系数 + monsterPropertyList.append(sMonsterConfig.getCureFacter()).append("#"); //受到治疗加成系数 + monsterPropertyList.append(sMonsterConfig.getDifferDemonsBocusFactor()).append("#"); //异妖伤害加成系数 + monsterPropertyList.append(sMonsterConfig.getDifferDemonsReduceFactor()).append("#"); //异妖伤害减免系数 monsterPropertyList.append(damageReduceFactor[0]).append("#"); //火系伤害减免系数 monsterPropertyList.append(damageReduceFactor[1]).append("#"); //冰系伤害减免系数 monsterPropertyList.append(damageReduceFactor[2]).append("#"); //雷系伤害减免系数 monsterPropertyList.append(damageReduceFactor[3]).append("#"); //风系伤害减免系数 monsterPropertyList.append(damageReduceFactor[4]).append("#"); //地系伤害减免系数 monsterPropertyList.append(damageReduceFactor[5]).append("#"); //暗系伤害减免系数 - monsterPropertyList.append(sMonsterConfig.getDamageBonusFactor()); //属性值加成 + monsterPropertyList.append(sMonsterConfig.getElementDamageBonusFactor()); //属性值加成 if (sMonsterConfig.getSkillList()!=null){ for (Integer i : sMonsterConfig.getSkillList()){ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java index d58215746..c24b87413 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/FightDataUtil.java @@ -1,16 +1,12 @@ package com.ljsd.jieling.util; import com.ljsd.jieling.config.*; -import com.ljsd.jieling.db.redis.RedisKey; -import com.ljsd.jieling.db.redis.RedisUtil; -import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.protocols.CommonProto; import org.luaj.vm2.LuaTable; import org.luaj.vm2.LuaValue; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class FightDataUtil { @@ -110,20 +106,24 @@ public class FightDataUtil { property.rawset(5, LuaValue.valueOf(sMonster.getPhysicalDefence())); property.rawset(6, LuaValue.valueOf(sMonster.getMagicDefence())); property.rawset(7, LuaValue.valueOf(sMonster.getSpeed())); - property.rawset(8, LuaValue.valueOf(0)); - property.rawset(9, LuaValue.valueOf(0)); + property.rawset(8, LuaValue.valueOf(sMonster.getDamageBocusFactor())); + property.rawset(9, LuaValue.valueOf(sMonster.getDamageReduceFactor())); property.rawset(10, LuaValue.valueOf(sMonster.getHit())); property.rawset(11, LuaValue.valueOf(sMonster.getDodge())); property.rawset(12, LuaValue.valueOf(sMonster.getCritFactor())); property.rawset(13, LuaValue.valueOf(sMonster.getCritDamageFactor())); - property.rawset(14, LuaValue.valueOf(0)); - property.rawset(15, LuaValue.valueOf(sMonster.getDamageReduceFactor()[0])); - property.rawset(16, LuaValue.valueOf(sMonster.getDamageReduceFactor()[1])); - property.rawset(17, LuaValue.valueOf(sMonster.getDamageReduceFactor()[2])); - property.rawset(18, LuaValue.valueOf(sMonster.getDamageReduceFactor()[3])); - property.rawset(19, LuaValue.valueOf(sMonster.getDamageReduceFactor()[4])); - property.rawset(20, LuaValue.valueOf(sMonster.getDamageReduceFactor()[5])); - property.rawset(21, String.valueOf(sMonster.getDamageBonusFactor())); + property.rawset(14, LuaValue.valueOf(sMonster.getAntiCritDamageFactor())); + property.rawset(15, LuaValue.valueOf(sMonster.getTreatFacter())); + property.rawset(16, LuaValue.valueOf(sMonster.getCureFacter())); + property.rawset(17, LuaValue.valueOf(sMonster.getDifferDemonsBocusFactor())); + property.rawset(18, LuaValue.valueOf(sMonster.getDifferDemonsReduceFactor())); + property.rawset(19, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[0])); + property.rawset(20, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[1])); + property.rawset(21, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[2])); + property.rawset(22, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[3])); + property.rawset(23, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[4])); + property.rawset(24, LuaValue.valueOf(sMonster.getElementDamageReduceFactor()[5])); + property.rawset(25, String.valueOf(sMonster.getElementDamageBonusFactor())); return property; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index cd53fb9a6..ee814d6c2 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -341,12 +341,24 @@ public class ItemUtil { return; } Map itemMap = user.getItemManager().getItemMap(); + StringBuilder rewardStr = new StringBuilder(); + boolean isFirst = true; for (Map.Entry entry : items.entrySet()) { SItem sItem = SItem.getsItemMap().get (entry.getKey()); if (sItem == null){ continue; } - if (!isVictory && sItem.getIsSave() != 1) { + if (sItem.getIsSave() != 1) { + continue; + } + if(!isVictory){ + if(isFirst){ + rewardStr.append(entry.getKey()).append("#").append(entry.getValue().getItemNum()); + isFirst = false; + }else{ + rewardStr.append("|").append(entry.getKey()).append("#").append(entry.getValue().getItemNum()); + } + continue; } Item item = itemMap.get(entry.getKey()); @@ -364,12 +376,28 @@ public class ItemUtil { if (sItem == null){ continue; } - if (!isVictory && sItem.getIsSave() != 1) { + if (sItem.getIsSave() != 1) { + continue; + } + if(!isVictory){ + if(isFirst){ + rewardStr.append(equip.getEquipId()).append("#").append("1"); + isFirst = false; + }else{ + rewardStr.append("|").append(equip.getEquipId()).append("#").append("1"); + } continue; } user.getEquipManager().addEquip(equip); } user.getMapManager().setTemporaryItems(null); + if(!isVictory){ + String title = SErrorCodeEerverConfig.getI18NMessage("equip_bag_limit_title"); + String content = SErrorCodeEerverConfig.getI18NMessage("equip_bag_limit_txt"); + int nowTime =(int) (TimeUtils.now()/1000); + MailLogic.getInstance().sendMail(Integer.parseInt(user.getId()),title,content,rewardStr.toString(),nowTime,Global.MAIL_EFFECTIVE_TIME); + } + } private static void useItem(User user,Map useItemMap) throws Exception{ diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/StringUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/StringUtil.java index 60ca8df89..e10c82b44 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/StringUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/StringUtil.java @@ -13,7 +13,7 @@ import java.util.List; public class StringUtil { public static int[] parseFiledInt(String value) { - if ("null".equals(value) || value == null) { + if ("null".equals(value) || StringUtil.isEmpty(value)) { return new int[0]; } String[] param = value.split("#");