战斗同步
parent
5855a00391
commit
17f30d751a
|
@ -72,10 +72,7 @@ end
|
|||
function BuffManager:AddBuff(target, buff)
|
||||
buff.target = target
|
||||
self.buffQueue:Enqueue(buff)
|
||||
if not buff.exCtrlTime then
|
||||
buff.exCtrlTime = 0
|
||||
end
|
||||
buff.frameDuration = floor(buff.duration * (1 + buff.exCtrlTime) * BattleLogic.GameFrameRate)
|
||||
buff.frameDuration = floor(buff.duration * BattleLogic.GameFrameRate)
|
||||
--if buff.isBuff then --TODO:增益buff持续时间加成
|
||||
-- local buffBocus = buff.caster:GetRoleData(RoleDataName.BuffBocus)
|
||||
-- buff.frameDuration = floor(buff.duration * (1 + buffBocus + buff.exCtrlTime) * BattleLogic.GameFrameRate)
|
||||
|
|
|
@ -40,6 +40,11 @@ local function casterBulletEffect(caster, target, interval)
|
|||
end
|
||||
end
|
||||
|
||||
local function calBuffHit(caster, target, baseRandom)
|
||||
local hit = (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
return BattleUtil.ErrorCorrection(hit * baseRandom)
|
||||
end
|
||||
|
||||
--效果表
|
||||
local effectList = {
|
||||
--造成[a]%的[b]伤害
|
||||
|
@ -64,7 +69,7 @@ local effectList = {
|
|||
--[a]%概率[b],持续[c]秒
|
||||
--a[float],b[控制状态],c[float]
|
||||
[3] = function(caster, target, args, interval)
|
||||
local f1 = args[1] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f1 = calBuffHit(caster, target, args[1])
|
||||
local cb1 = args[2]
|
||||
local f2 = args[3]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
@ -136,7 +141,7 @@ local effectList = {
|
|||
--a[float],b[float],c[改变类型]
|
||||
[8] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[2])
|
||||
local ct = args[3]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
BattleUtil.RandomAction(f2, function ()
|
||||
|
@ -208,7 +213,7 @@ local effectList = {
|
|||
[14] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[3])
|
||||
local rid = args[4]
|
||||
local f3 = args[5]
|
||||
local i1 = args[6]
|
||||
|
@ -273,7 +278,7 @@ local effectList = {
|
|||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local i1 = args[3]
|
||||
local f2 = args[4] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[4])
|
||||
casterBulletEffect(caster, target, interval)
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
local dmg = floor(caster:GetRoleData(propertyList[dt]) * f1)
|
||||
|
@ -353,7 +358,7 @@ local effectList = {
|
|||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local dot = args[3]
|
||||
local f2 = args[4] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[4])
|
||||
local ct = args[5]
|
||||
local f3 = args[6]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
@ -507,7 +512,7 @@ local effectList = {
|
|||
--[a]%概率[b],持续[c]秒
|
||||
--a[float],b[免疫buff],c[int]
|
||||
[31] = function(caster, target, args, interval)
|
||||
local f1 = args[1] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f1 = calBuffHit(caster, target, args[1])
|
||||
local ib1 = args[2]
|
||||
local f2 = args[3]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
@ -518,7 +523,7 @@ local effectList = {
|
|||
--a[float],b[float],c[改变类型]
|
||||
[32] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local f2 = args[2] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[2])
|
||||
local ct = args[3]
|
||||
local d = args[4]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
@ -539,7 +544,7 @@ local effectList = {
|
|||
[33] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[3])
|
||||
local rid = args[4]
|
||||
local f3 = args[5]
|
||||
local i1 = args[6]
|
||||
|
@ -667,9 +672,9 @@ local effectList = {
|
|||
[41] = function(caster, target, args, interval)
|
||||
local f1 = args[1]
|
||||
local dt = args[2]
|
||||
local f2 = args[3] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f2 = calBuffHit(caster, target, args[3])
|
||||
local f3 = args[4]
|
||||
local f4 = args[5] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f4 = calBuffHit(caster, target, args[5])
|
||||
casterBulletEffect(caster, target, interval)
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
BattleUtil.RandomAction(f2, function ()
|
||||
|
@ -686,7 +691,7 @@ local effectList = {
|
|||
--进入虚弱状态,有[a]%的概率受到额外[b]%的伤害,状态持续[c]秒
|
||||
--a[folat],b[float],c[int]
|
||||
[42] = function(caster, target, args, interval)
|
||||
local f1 = args[1] * (1 + caster:GetRoleData(RoleDataName.Hit) / (1 + target:GetRoleData(RoleDataName.Dodge)))
|
||||
local f1 = calBuffHit(caster, target, args[1])
|
||||
local f2 = args[2]
|
||||
local f3 = args[3]
|
||||
BattleLogic.WaitForTrigger(interval, function ()
|
||||
|
|
|
@ -2,6 +2,10 @@ RoleData = {}
|
|||
RoleData.__index = RoleData
|
||||
local max = math.max
|
||||
local floor = math.floor
|
||||
local function isFactor(name)
|
||||
return name > 7
|
||||
end
|
||||
|
||||
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,0,0,0,0},
|
||||
orginData={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}}
|
||||
|
@ -12,21 +16,17 @@ end
|
|||
function RoleData:Init(role, data)
|
||||
self.role = role
|
||||
for i=1, #data do
|
||||
self.data[i] = floor(data[i] * 100000 + 0.5) / 100000 --进行精度处理,避免前后端计算不一致
|
||||
self.orginData[i] = floor(data[i] * 100000 + 0.5) / 100000 --进行精度处理,避免前后端计算不一致
|
||||
self.data[i] = BattleUtil.ErrorCorrection(data[i])
|
||||
self.orginData[i] = BattleUtil.ErrorCorrection(data[i])
|
||||
end
|
||||
end
|
||||
|
||||
function RoleData:GetData(name)
|
||||
if self.data[name] then
|
||||
return self.data[name]
|
||||
end
|
||||
return self.data[name]
|
||||
end
|
||||
|
||||
function RoleData:GetOrginData(name)
|
||||
if self.orginData[name] then
|
||||
return self.orginData[name]
|
||||
end
|
||||
return self.orginData[name]
|
||||
end
|
||||
|
||||
function RoleData:SetValue(name, value)
|
||||
|
@ -55,7 +55,13 @@ end
|
|||
|
||||
function RoleData:AddPencentValue(name, pencent)
|
||||
if self.data[name] then
|
||||
return self:AddValue(name, self.orginData[name] * pencent)
|
||||
local delta
|
||||
if isFactor(name) then
|
||||
delta = BattleUtil.ErrorCorrection(self.orginData[name] * pencent)
|
||||
else
|
||||
delta = floor(self.orginData[name] * pencent)
|
||||
end
|
||||
return self:AddValue(name, delta)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
@ -84,7 +90,13 @@ end
|
|||
|
||||
function RoleData:SubPencentValue(name, pencent)
|
||||
if self.data[name] then
|
||||
return self:SubValue(name, self.data[name] * pencent)
|
||||
local delta
|
||||
if isFactor(name) then
|
||||
delta = BattleUtil.ErrorCorrection(self.orginData[name] * pencent)
|
||||
else
|
||||
delta = floor(self.orginData[name] * pencent)
|
||||
end
|
||||
return self:SubValue(name, delta)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
|
|
@ -142,6 +142,7 @@ function Skill:Cast()
|
|||
BattleLogic.SetAggro(self.owner)
|
||||
if not self.isTeamSkill then
|
||||
local time = max(8-self.owner:GetRoleData(RoleDataName.Speed)/(8*(self.owner:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
time = BattleUtil.ErrorCorrection(time)
|
||||
if self.owner.superSkill == self then
|
||||
self.sp = 0
|
||||
self.spPass = floor(self.cd * BattleLogic.GameFrameRate)
|
||||
|
|
|
@ -265,7 +265,7 @@ function BattleLogic.GetSkillUsable(camp)
|
|||
end
|
||||
|
||||
function BattleLogic.WaitForTrigger(delayTime, action)
|
||||
delayTime = floor(delayTime * 100000 + 0.5) / 100000 --进行精度处理,避免前后端计算不一致
|
||||
delayTime = BattleUtil.ErrorCorrection(delayTime)
|
||||
local delayFrame = floor(delayTime * BattleLogic.GameFrameRate + 0.5)
|
||||
if delayFrame == 0 then --0延迟的回调直接调用
|
||||
action()
|
||||
|
@ -537,6 +537,15 @@ function BattleLogic.RecordRoleProperty(uid, camp, name, value, delta)
|
|||
table.insert(record, string.format("frame:%d, uid:%d, camp:%d, name:%s, value:%d, delta:%d", curFrame, uid, camp, name, value, delta))
|
||||
end
|
||||
|
||||
--Record专用
|
||||
function BattleLogic.RecordDamage(args)
|
||||
local str = ""
|
||||
for i=1, #args do
|
||||
str = str..tostring(args[i]) .. (i == #args and "" or "#")
|
||||
end
|
||||
table.insert(record, string.format("frame:%d, damageArgs:%s", curFrame, str))
|
||||
end
|
||||
|
||||
--Record专用
|
||||
function BattleLogic.RecordEffect(caster, target, type, args, interval)
|
||||
local cUid = tostring(caster.uid) or "cTeam"
|
||||
|
|
|
@ -17,6 +17,21 @@ local function clamp(v, minValue, maxValue)
|
|||
return v
|
||||
end
|
||||
|
||||
function BattleUtil.ErrorCorrection(f) --进行精度处理,避免前后端计算不一致
|
||||
return floor(f * 100000 + 0.5) / 100000
|
||||
end
|
||||
|
||||
function BattleUtil.FP_Mul(...)
|
||||
local f = 1
|
||||
for i, v in ipairs{...} do
|
||||
f = floor(f * v * 100000 + 0.5) / 100000
|
||||
end
|
||||
if BattleLogic.IsOpenBattleRecord then
|
||||
BattleLogic.RecordDamage({...})
|
||||
end
|
||||
return f
|
||||
end
|
||||
|
||||
function BattleUtil.ChooseTarget(role, chooseId)
|
||||
local chooseType = floor(chooseId / 10000) % 10
|
||||
local chooseWeight = floor(chooseId / 100) % 10
|
||||
|
@ -221,12 +236,11 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
--加入被动效果
|
||||
local critFunc = function(critEx) critDamageFactor = critEx end
|
||||
atkRole.Event:DispatchEvent(BattleEventName.PassiveCriting, critFunc)
|
||||
baseDamage = max(attack * critDamageFactor - 0.5 * defence * ignoreDef, 0)
|
||||
baseDamage = max(BattleUtil.FP_Mul(attack, critDamageFactor) - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
|
||||
else
|
||||
baseDamage = max(attack - 0.5 * defence * ignoreDef, 0)
|
||||
baseDamage = max(attack - BattleUtil.FP_Mul(0.5, defence, ignoreDef), 0)
|
||||
end
|
||||
--伤害 =(基础伤害*(1+己伤害加成-目标伤害减免)*(1+己方属性伤害加成-目标属性伤害减免),10%*己攻)
|
||||
local exFactor = 1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor)
|
||||
|
||||
local elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
|
||||
if atkRole.element == 1 then
|
||||
elementDamageReduceFactor = RoleDataName.FireDamageReduceFactor
|
||||
|
@ -241,9 +255,11 @@ function BattleUtil.CalDamage(atkRole, defRole, damageType, baseFactor, ignoreDe
|
|||
elseif atkRole.element == 6 then
|
||||
elementDamageReduceFactor = RoleDataName.DarkDamageReduceFactor
|
||||
end
|
||||
exFactor = exFactor * (1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor))
|
||||
|
||||
baseDamage = baseDamage * baseFactor * exFactor
|
||||
--伤害 =(基础伤害*(1+己伤害加成-目标伤害减免)*(1+己方属性伤害加成-目标属性伤害减免),10%*己攻)
|
||||
baseDamage = BattleUtil.FP_Mul(baseDamage, baseFactor,
|
||||
1 + atkRole:GetRoleData(RoleDataName.DamageBocusFactor) - defRole:GetRoleData(RoleDataName.DamageReduceFactor),
|
||||
(1 + atkRole:GetRoleData(RoleDataName.ElementDamageBocusFactor) - defRole:GetRoleData(elementDamageReduceFactor)))
|
||||
baseDamage = floor(max(baseDamage, 0.1 * attack))
|
||||
|
||||
local func
|
||||
|
@ -275,7 +291,7 @@ function BattleUtil.ApplyTreat(castRole, targetRole, value, baseFactor)
|
|||
|
||||
local factor = castRole.isTeam and 1 or castRole:GetRoleData(RoleDataName.TreatFacter) --释放者为team则不计算治疗加成属性
|
||||
local factor2 = targetRole:GetRoleData(RoleDataName.CureFacter)
|
||||
local baseTreat = floor(value * baseFactor * factor * factor2 + 0.5)
|
||||
local baseTreat = floor(BattleUtil.FP_Mul(value, baseFactor, factor, factor2) + 0.5)
|
||||
|
||||
--加入被动效果
|
||||
local treatingFunc = function(exFactor) baseTreat = floor(baseTreat * (exFactor + 1) + 0.5) end
|
||||
|
|
|
@ -68,8 +68,8 @@ function RoleLogic:Init(uid, data)
|
|||
self.skill = skillPool:Get()
|
||||
self.skill:Init(self, data.skill, false)
|
||||
self.skill.sp = 0
|
||||
local time = max(6-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.skill.spPass = floor( time * BattleLogic.GameFrameRate)
|
||||
local time = max(8-self:GetRoleData(RoleDataName.Speed)/(8*(self:GetRoleData(RoleDataName.Level)+10)), 1.5)
|
||||
self.skill.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
end
|
||||
if data.superSkill and #data.superSkill > 0 then
|
||||
self.superSkill = skillPool:Get()
|
||||
|
@ -235,7 +235,7 @@ function RoleLogic:GetRoleData(property)
|
|||
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
|
||||
tarPro = tarPro + BattleUtil.ErrorCorrection(self.data:GetData(item.tranProName) * item.tranFactor)
|
||||
end
|
||||
end
|
||||
return tarPro
|
||||
|
|
|
@ -121,9 +121,9 @@ public class MissionLoigc {
|
|||
}
|
||||
if(state!=2 && sTreasureTaskConfig.getTaskType() == MissionType.SENVER_HAPPY.getMissionTypeValue()){
|
||||
if(System.currentTimeMillis()>user.getActivityManager().getSenvenTime()){
|
||||
state=0;
|
||||
state=1;
|
||||
}else {
|
||||
state = 1;
|
||||
state =0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue