miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Weapon/WeaponCondition.lua

223 lines
7.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

WeaponCondition = {}
local this = WeaponCondition
local skillRound={}
local enSkillRound={}
local _ConditionConfig = {
[0] = function(skill, condition) --0:无限制条件
return true
end,
[1] = function(skill, condition) --1我方任意神将生命百分比 【比较类型】 N万分比
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
-- 获取该技能相同阵营人物
local roleList = RoleManager.Query(function(role)
return role.camp == skill.owner.camp
end)
-- 判断
for _, role in ipairs(roleList) do
local hpf = role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp)
if BattleUtil.CompareValue(hpf, comValue/10000, comType) then
return true
end
end
return false
end,
[2] = function(skill, condition) --2:回合数 【比较类型】 N
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
-- 获取当前回合
local curRound = BattleLogic.GetCurRound()
return BattleUtil.CompareValue(curRound, comValue, comType)
end,
[3] = function(skill, condition) --2:回合数 【比较类型】 N 且 概率为 N
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local rand = condition[4]
-- 获取当前回合
local curRound = BattleLogic.GetCurRound()
local isRoundOk = BattleUtil.CompareValue(curRound, comValue, comType)
-- 判断概率
local r = Random.Range01()
local isRandomOk = r <= rand/10000
return isRoundOk and isRandomOk
end,
[4] = function(skill, condition) --4:场上燃烧目标的数量 【比较类型】 N
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
-- 当前释放技能的单位的职业
local professionId = skill.owner.professionId
local list = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
if not list then
return false
end
local num=0
for key, value in pairs(list) do
local isHave=BattleLogic.BuffMgr:HasBuff(value, BuffName.DOT, function(buff) return buff.damageType == 1 end)
if isHave then
num=num+1
end
end
return BattleUtil.CompareValue(num, comValue, comType)
end,
[5] = function(skill, condition) --5敌方上场神将数量 且概率(万分比)
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local rand = condition[4]
local roleList = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
local isEnough=BattleUtil.CompareValue(#roleList, comValue, comType)
local r = Random.Range01()
-- 判断概率
if isEnough then
return rand/10000>r
end
return false
end,
[6] = function(skill, condition) --6敌方任意神将生命百分比 【比较类型】 N万分比
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local round = condition[4]
-- 获取该技能相同阵营人物
local roleList = RoleManager.Query(function(role)
return role.camp ~= skill.owner.camp
end)
-- 判断
local r = Random.Range01()
for _, role in ipairs(roleList) do
local hpf = role:GetRoleData(RoleDataName.Hp) / role:GetRoleData(RoleDataName.MaxHp)
if BattleUtil.CompareValue(hpf, comValue/10000, comType) then
return round/10000>r
end
end
return false
end,
[7] = function(skill, condition) --7敌方上场神将数量 且概率(万分比)(检测放逐)
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local rand = condition[4]
local roleList = RoleManager.QueryIncludeExile(function(role)
return role.camp ~= skill.owner.camp
end)
--判断场上敌方数量是否足够
local isEnough=BattleUtil.CompareValue(#roleList, comValue, comType)
if isEnough then
local ishave=false
--是否有没被放逐的目标
local list=skill.owner.exileTargets
for key, value in pairs(roleList) do
if not BattleUtil.ChecklistIsContainValue(list,value) then
ishave=true
break
end
end
if ishave then
local r = Random.Range01()
-- 判断概率
if isEnough then
return rand/10000>r
end
end
return false
end
return false
end,
[8] = function(skill, condition) --6:回合cd数限制
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
-- 获取当前回合
local curRound = BattleLogic.GetCurRound()
--我方主角技能计算回合
if skill.owner.camp==0 then
if not skillRound[skill.id] then
skillRound[skill.id]=curRound
return true
else
if curRound==skillRound[skill.id]+comValue then
skillRound[skill.id]=curRound
return true
end
end
else
--敌方主角技能计算回合
if not enSkillRound[skill.id] then
enSkillRound[skill.id]=curRound
return true
else
if curRound==enSkillRound[skill.id]+comValue then
enSkillRound[skill.id]=curRound
return true
end
end
end
return false
end,
[9] = function(skill, condition) --6:我方道系非治疗数量
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
local list=RoleManager.Query(function(role) return role.camp==skill.owner.camp and role.element==BattleRoleElementType.DAO and role.job~=1 end)
return BattleUtil.CompareValue(#list, comValue, comType)
end,
[10] = function(skill, condition) --10神兵所属神将生命百分比 【比较类型】 N万分比
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
if skill.ownHero==nil or skill.ownHero:IsDead() then
--LogError("没有持有者")
return false
end
-- 判断
local hpf = skill.ownHero:GetRoleData(RoleDataName.Hp) / skill.ownHero:GetRoleData(RoleDataName.MaxHp)
--LogError("hpf==="..hpf)
if BattleUtil.CompareValue(hpf, comValue/10000, comType) then
--LogError("触发技能"..hpf)
return true
end
return false
end,
}
-- 条件检测
function WeaponCondition.CheckCondition(skill, condition)
if not condition then
--LogError("condition==")
return true
end
local conId = condition[1]
local comType = condition[2]
local comValue = condition[3]
--LogError("conid=="..conId.." comtype=="..comType.." comvalue=="..comValue)
return _ConditionConfig[conId](skill, condition)
end
-- 清除缓存
function WeaponCondition.ClearCache()
if skillRound then
skillRound={}
end
if enSkillRound then
enSkillRound={}
end
end
return WeaponCondition