back_recharge
wangyuan 2019-06-05 11:29:24 +08:00
parent 68ce55cd67
commit dafe5073cc
3 changed files with 98 additions and 222 deletions

View File

@ -23,88 +23,6 @@ local propertyList = {
RoleDataName.MaxHp,
}
local function chooseTarget(role, chooseId)
local chooseType = floor(chooseId / 10000) % 10
local chooseWeight = floor(chooseId / 100) % 10
local sort = floor(chooseId / 10) % 10
local num = chooseId % 10
local arr
if chooseType == 1 then
arr = BattleLogic.Query(function (r) return r.camp == role.camp end)
elseif chooseType == 2 then
if role.lockTarget and num == 1 then --嘲讽时对单个敌军生效
return {role.lockTarget}
end
arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end)
elseif chooseType == 3 then
if role.ctrl_blind then --致盲时自身变随机友军
arr = BattleLogic.Query(function (r) return r.camp == role.camp end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {role}
elseif chooseType == 4 then
if role.lockTarget then --嘲讽时对仇恨目标生效
return {role.lockTarget}
end
if role.ctrl_blind then --致盲时仇恨目标变随机
arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {BattleLogic.GetAggro(role.camp)}
else
arr = BattleLogic.Query()
end
if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效
BattleUtil.RandomList(arr)
elseif chooseWeight == 1 then
BattleUtil.Sort(arr, function(a, b)
local r1 = a:GetRoleData(RoleDataName.Hp)
local r2 = b:GetRoleData(RoleDataName.Hp)
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)
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)
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)
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)
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)
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)
if sort == 1 then return r1 > r2 else return r1 < r2 end
end)
end
return arr
end
--被动技能表
local passivityList = {
--发动技能时,[a]的概率将[b]*[c]算作[d]计算
@ -136,7 +54,7 @@ local passivityList = {
local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 20001)
local arr = BattleUtil.ChooseTarget(role, 20001)
if arr[1] then
BattleUtil.CalDamage(role, arr[1], dt, f2)
end
@ -154,7 +72,7 @@ local passivityList = {
local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f3, function ()
local arr = chooseTarget(role, 40000)
local arr = BattleUtil.ChooseTarget(role, 40000)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, RoleDataName.CureFacter, f1, 3))
end
@ -187,7 +105,7 @@ local passivityList = {
local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 10321)
local arr = BattleUtil.ChooseTarget(role, 10321)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.HOT, f3, 1, floor(role:GetRoleData(propertyList[pro]) * f2)))
end
@ -207,7 +125,7 @@ local passivityList = {
local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 10001)
local arr = BattleUtil.ChooseTarget(role, 10001)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f3, propertyList[pro1], floor(role:GetRoleData(propertyList[pro2]) * f2), 1))
end
@ -322,7 +240,7 @@ local passivityList = {
return
end
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 20000)
local arr = BattleUtil.ChooseTarget(role, 20000)
for i=1, #arr do
BattleUtil.CalDamage(role, arr[i], dt, f2)
end
@ -349,7 +267,7 @@ local passivityList = {
return
end
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 20001)
local arr = BattleUtil.ChooseTarget(role, 20001)
if arr[1] then
BattleUtil.ApplyDamage(role, arr[1], floor(role:GetRoleData(propertyList[pro]) * f2))
end
@ -426,7 +344,7 @@ local passivityList = {
local ct = args[4]
local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 40000)
local arr = BattleUtil.ChooseTarget(role, 40000)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct))
end
@ -443,7 +361,7 @@ local passivityList = {
local ct = args[4]
local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 10000)
local arr = BattleUtil.ChooseTarget(role, 10000)
for i=1, #arr do
arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro1], f1, ct))
end
@ -544,7 +462,7 @@ local passivityList = {
local f1 = args[2]
local OnDead = function(atkRole)
local arr = chooseTarget(role, 10000)
local arr = BattleUtil.ChooseTarget(role, 10000)
for i=1, #arr do
BattleUtil.CalTreat(role, arr[i], floor(role:GetRoleData(propertyList[pro]) * f1))
end
@ -579,7 +497,7 @@ local passivityList = {
local OnBuffCaster = function(buff)
if buff.type == BuffName.Control then
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(buff.target, 10000)
local arr = BattleUtil.ChooseTarget(buff.target, 10000)
for i=1, #arr do
BattleUtil.CalDamage(role, arr[i], dt, f2)
end
@ -665,7 +583,7 @@ local passivityList = {
local ct = args[4]
local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 20000)
local arr = BattleUtil.ChooseTarget(role, 20000)
for i=1, #arr do
arr[i]:AddBuff(Buff.Create(role, BuffName.PropertyChange, f2, propertyList[pro], f1, ct))
end
@ -681,7 +599,7 @@ local passivityList = {
local OnSkillCastEnd = function(skill)
BattleUtil.RandomAction(f1, function ()
local arr = chooseTarget(role, 20001)
local arr = BattleUtil.ChooseTarget(role, 20001)
if arr[1] then
arr[1]:AddBuff(Buff.Create(role, BuffName.Control, f2, 1))
end
@ -854,7 +772,7 @@ local passivityList = {
local ct = args[4]
local OnSkillCastEnd = function(skill)
local arr = chooseTarget(role, 40000)
local arr = BattleUtil.ChooseTarget(role, 40000)
if arr[1] then
local buff = Buff.Create(role, BuffName.PropertyChange, 0, propertyList[pro], f1, ct)
buff.cover = true

View File

@ -6,127 +6,6 @@ local min = math.min
--local RoleDataName = RoleDataName
--local BattleEventName = BattleEventName
local function chooseTarget(role, chooseId, exceptList)
local chooseType = floor(chooseId / 10000) % 10
local chooseWeight = floor(chooseId / 100) % 10
local sort = floor(chooseId / 10) % 10
local exceptNum = exceptList.size
local num = chooseId % 10
local arr
if chooseType == 1 then
arr = BattleLogic.Query(function (r)
for i=1, exceptList.size do
if r.uid == exceptList.buffer[i].uid then
return false
end
end
return r.camp == role.camp
end)
elseif chooseType == 2 then
if role.lockTarget and num == 1 then --嘲讽时对单个敌军生效
return {role.lockTarget}
end
arr = BattleLogic.Query(function (r)
for i=1, exceptList.size do
if r.uid == exceptList.buffer[i].uid then
return false
end
end
return r.camp ~= role.camp
end)
elseif chooseType == 3 then
if role.ctrl_blind then --致盲时自身变随机友军
arr = BattleLogic.Query(function (r)
for i=1, exceptList.size do
if r.uid == exceptList.buffer[i].uid then
return false
end
end
return r.camp == role.camp
end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {role}
elseif chooseType == 4 then
if role.lockTarget then --嘲讽时对仇恨目标生效
return {role.lockTarget}
end
if role.ctrl_blind then --致盲时仇恨目标变随机
arr = BattleLogic.Query(function (r)
for i=1, exceptList.size do
if r.uid == exceptList.buffer[i].uid then
return false
end
end
return r.camp ~= role.camp
end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {BattleLogic.GetAggro(role.camp)}
else
arr = BattleLogic.Query()
end
if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效
BattleUtil.RandomList(arr)
elseif chooseWeight == 1 then
BattleUtil.Sort(arr, function(a, b)
local r1 = a:GetRoleData(RoleDataName.Hp)
local r2 = b:GetRoleData(RoleDataName.Hp)
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)
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)
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)
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)
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)
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)
if sort == 1 then return r1 > r2 else return r1 < r2 end
end)
end
if exceptNum > 0 then
local count = #arr
for i=1, min(exceptNum, count) do
for j=count, i+1, -1 do
arr[j] = arr[j-1]
end
arr[i] = exceptList.buffer[i]
end
end
return arr
end
local effectPool = BattleObjectPool.New(function ()
return { type = 0, args = {}} -- type, {args, ...}
end)
@ -137,7 +16,7 @@ end)
Skill = {}
function Skill:New()
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass = 0,choosedList = BattleList.New(),isTeamSkill=false }
local o = {cd=0,effectList = BattleList.New(),owner=0,sp=0,spPass = 0,isTeamSkill=false }
setmetatable(o, self)
self.__index = self
return o
@ -152,7 +31,6 @@ function Skill:Init(role, effectData)
self.owner = role
self.sp = 0
self.spPass = 0
self.choosedList:Clear()
self.isTeamSkill = false
for i=2, #effectData do
@ -202,7 +80,7 @@ function Skill:Cast()
for i=1, self.effectList.size do
local effectGroup = self.effectList.buffer[i]
local chooseId = effectGroup.chooseId
local arr = chooseTarget(self.owner, chooseId, self.choosedList)
local arr = BattleUtil.ChooseTarget(self.owner, chooseId)
if #arr > 0 then
--效果延迟1帧生效
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
@ -237,7 +115,7 @@ function Skill:Cast()
BattleLogic.WaitForTrigger(d * (j-1), function()
local r = arr[index]
if not r or r.isDead then --当被选取的目标已经死亡或者没有,则重新选取,若重新选取的目标也死亡或者没有,则从之前的目标中选取第一个不死亡的
arr = chooseTarget(self.owner, chooseId, self.choosedList)
arr = BattleUtil.ChooseTarget(self.owner, chooseId)
r = arr[index]
if not r then --当没有新增的被选取目标时,可能为空
for i=1, #arr do
@ -251,7 +129,6 @@ function Skill:Cast()
end
end
end
self.choosedList:Add(r)
takeEffect(self.owner, r, effects, cd)
end)
end
@ -291,7 +168,6 @@ function Skill:Cast()
BattleLogic.SetSkillUsable(self.owner.camp, false)
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)

View File

@ -17,6 +17,88 @@ local function clamp(v, minValue, maxValue)
return v
end
function BattleUtil.ChooseTarget(role, chooseId)
local chooseType = floor(chooseId / 10000) % 10
local chooseWeight = floor(chooseId / 100) % 10
local sort = floor(chooseId / 10) % 10
local num = chooseId % 10
local arr
if chooseType == 1 then
arr = BattleLogic.Query(function (r) return r.camp == role.camp end)
elseif chooseType == 2 then
if role.lockTarget and num == 1 then --嘲讽时对单个敌军生效
return {role.lockTarget}
end
arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end)
elseif chooseType == 3 then
if role.ctrl_blind then --致盲时自身变随机友军
arr = BattleLogic.Query(function (r) return r.camp == role.camp end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {role}
elseif chooseType == 4 then
if role.lockTarget then --嘲讽时对仇恨目标生效
return {role.lockTarget}
end
if role.ctrl_blind then --致盲时仇恨目标变随机
arr = BattleLogic.Query(function (r) return r.camp ~= role.camp end)
BattleUtil.RandomList(arr)
return {arr[1]}
end
return {BattleLogic.GetAggro(role.camp)}
else
arr = BattleLogic.Query()
end
if chooseWeight == 0 or role.ctrl_blind then --致盲时排序无效
BattleUtil.RandomList(arr)
elseif chooseWeight == 1 then
BattleUtil.Sort(arr, function(a, b)
local r1 = a:GetRoleData(RoleDataName.Hp)
local r2 = b:GetRoleData(RoleDataName.Hp)
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)
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)
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)
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)
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)
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)
if sort == 1 then return r1 > r2 else return r1 < r2 end
end)
end
return arr
end
function BattleUtil.CreateBuffId(skill, index)
local id = 0
if skill.preAI then --主动技能生成buff