生命相关被动改为由队伍记录

This commit is contained in:
chenxi 2023-04-18 21:32:03 +08:00
parent 7ee1d620bb
commit 0fa378ec88
3 changed files with 35 additions and 4 deletions

View File

@ -25,16 +25,16 @@ end
local function _checkhpLowerThan(unitComp, skill, targetComp, hpPercent) local function _checkhpLowerThan(unitComp, skill, targetComp, hpPercent)
local triggerValue = skill:getPassiveTriggerValue() or 0 local triggerValue = skill:getPassiveTriggerValue() or 0
if hpPercent*DEFAULT_FACTOR < triggerValue then -- 低于指定血量,触发技能 if hpPercent*DEFAULT_FACTOR < triggerValue then -- 低于指定血量,触发技能
local data = skill:getRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0 local data = unitComp.unitEntity:getTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0
if data == 1 then -- 已经触发过了 if data == 1 then -- 已经触发过了
return 0 return 0
end end
skill:setRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 1) unitComp.unitEntity:setTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 1)
return 1 return 1
else else
local data = skill:getRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0 local data = unitComp.unitEntity:getTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0
if data == 1 then -- 已经触发过了,那么需要取消 if data == 1 then -- 已经触发过了,那么需要取消
skill:setRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 0) unitComp.unitEntity:setTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 0)
return -1 return -1
end end
end end

View File

@ -229,11 +229,34 @@ function BattleTeamEntity:handleShield(damageNum)
end end
end end
function BattleTeamEntity:getRecordData(name)
if self.recordData == nil then
self.recordData = {}
end
return self.recordData[name]
end
function BattleTeamEntity:setRecordData(name, value)
if self.recordData == nil then
self.recordData = {}
end
self.recordData[name] = value
end
function BattleTeamEntity:clearRecordData()
if self.recordData then
for k, v in pairs(self.recordData) do
self.recordData[k] = nil
end
end
end
function BattleTeamEntity:die() function BattleTeamEntity:die()
if self.isDead then if self.isDead then
return return
end end
self.isDead = true self.isDead = true
self:clearRecordData()
end end
function BattleTeamEntity:getIsDead() function BattleTeamEntity:getIsDead()

View File

@ -253,6 +253,14 @@ function BattleUnitEntity:getSkillExtraUseTimes(skillId)
return self.skillExtraUseTimes[skillId] or 0 return self.skillExtraUseTimes[skillId] or 0
end end
function BattleUnitEntity:getTeamRecordData(name)
return self.team:getRecordData(name)
end
function BattleUnitEntity:setTeamRecordData(name, value)
self.team:setRecordData(name, value)
end
function BattleUnitEntity:onRoundEnd() function BattleUnitEntity:onRoundEnd()
for k, v in ipairs(self.activeSkills) do for k, v in ipairs(self.activeSkills) do
v:cooldown() v:cooldown()