战场经验

This commit is contained in:
chenxi 2023-04-19 11:02:51 +08:00
parent 0f2a085877
commit 5328e6dc7c
4 changed files with 21 additions and 2 deletions

View File

@ -895,7 +895,13 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta
return 0
end
local shieldHpBefore = self.unitEntity:getShieldHp()
self.unitEntity:takeDamageOrCure(num)
local hpRealReduce = self.unitEntity:takeDamageOrCure(num)
if hpRealReduce < 0 and self.side == BattleConst.SIDE_DEF then -- 实际掉血了
local exp = self.unitEntity:getExp()
if exp > 0 then
self.battleController:addBattleExp(math.floor(exp/self.unitEntity:getMaxHp()*-hpRealReduce))
end
end
local shieldHpDiff = self.unitEntity:getShieldHp() - shieldHpBefore
if shieldHpDiff < 0 then -- 说明护盾减少了
self:handleShield(shieldHpDiff, self)

View File

@ -416,6 +416,7 @@ function BattleData:addMonster(monsterId, newTeam)
normalSkillCount = monsterInfo.hurt_num,
assistingSkill = nil,
isBoss = monsterInfo.is_boss,
exp = monsterInfo.monster_exp or 0,
attr = {
hp = hp,
max_hp = hp,

View File

@ -129,6 +129,10 @@ function BattleTeamEntity:getHp()
return self.attr.hp
end
function BattleTeamEntity:getMaxHp()
return self.attr.max_hp
end
function BattleTeamEntity:getHpPercent()
return self.attr.hp / self.attr.max_hp
end
@ -216,7 +220,7 @@ function BattleTeamEntity:takeDamageOrCure(num)
hurtEventNum = num
else -- 满血了
-- 这是加血
hurtEventNum = 0
hurtEventNum = self.attr.max_hp - hpBefore
self.attr.hp = self.attr.max_hp
end
return hurtEventNum

View File

@ -177,6 +177,10 @@ function BattleUnitEntity:getHp()
return self.team:getHp()
end
function BattleUnitEntity:getMaxHp()
return self.team:getMaxHp()
end
function BattleUnitEntity:getHpPercent()
return self.team:getHpPercent()
end
@ -237,6 +241,10 @@ function BattleUnitEntity:getBlock()
return self.team:getBlock()
end
function BattleUnitEntity:getExp()
return self.unitData.exp
end
function BattleUnitEntity:addSkillExtraUseTimes(skillId, count)
if self.skillExtraUseTimes == nil then
self.skillExtraUseTimes = {}