fight check

back_recharge
wangyuan 2019-05-07 20:01:07 +08:00
parent 954d3168a9
commit 1be3f7ce3e
21 changed files with 1083 additions and 356 deletions

View File

@ -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

View File

@ -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]秒

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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
--表现层调用

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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(), --冰系伤害减免系数(%

View File

@ -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

View File

@ -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

View File

@ -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;
}
}

View File

@ -52,7 +52,6 @@ public class GetPlayerInfoHandler extends BaseHandler{
ActivityLogic.getInstance().flushEveryDay(user);
}
user.getPlayerInfoManager().setLoginTime(TimeUtils.now());
MapLogic.getInstance().checkIsInMap(user);
Map<Integer, Integer> guidePoints = user.getPlayerInfoManager().getGuidePoints();
List<CommonProto.NewPlayerGuidePoint> list = new ArrayList<>();
for(Map.Entry<Integer,Integer> guideItem : guidePoints.entrySet()){

View File

@ -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();

View File

@ -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<Integer, Integer> 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<Integer, Map<Integer, SCMap>> sCMap = SCMap.sCMap;
for(Integer mapId : sCMap.keySet()){

View File

@ -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),

View File

@ -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()); // 风系伤害加成系数

View File

@ -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()){

View File

@ -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;
}

View File

@ -341,12 +341,24 @@ public class ItemUtil {
return;
}
Map<Integer, Item> itemMap = user.getItemManager().getItemMap();
StringBuilder rewardStr = new StringBuilder();
boolean isFirst = true;
for (Map.Entry<Integer, Item> 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<Integer,Integer> useItemMap) throws Exception{

View File

@ -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("#");