moved ally engage stuff to ContentArea onUpdate

This commit is contained in:
Tahir Akhlaq 2017-10-11 19:23:40 +01:00
parent 520ae7a119
commit 27200b8df5
15 changed files with 115 additions and 98 deletions

View file

@ -36,21 +36,22 @@ end
function allyGlobal.HelpPlayers(ally, contentGroupCharas, pickRandomTarget)
if contentGroupCharas then
for _, chara in pairs(contentGroupCharas) do
print("assssss")
if chara then
-- probably a player, or another ally
-- todo: queue support actions, heal, try pull hate off player etc
if chara.IsPlayer() then
if chara:IsPlayer() then
-- do stuff
if not ally.IsEngaged() then
if chara.IsEngaged() then
if not ally:IsEngaged() then
if chara:IsEngaged() then
print("ass")
allyGlobal.EngageTarget(ally, chara.target, nil)
return true
end
end
elseif chara.IsMonster() and chara.IsEngaged() then
if not ally.IsEngaged() then
allyGlobal.EngageTarget(ally, chara.target, nil)
end
elseif chara:IsMonster() and chara:IsEngaged() then
allyGlobal.EngageTarget(ally, chara, nil)
return true
end
end
end
@ -67,14 +68,15 @@ end
function allyGlobal.EngageTarget(ally, target, contentGroupCharas)
if contentGroupCharas then
for _, chara in pairs(contentGroupCharas) do
for chara in contentGroupCharas do
if chara.IsMonster() then
if chara.allegiance ~= ally.allegiance then
ally.Engage(chara)
ally:Engage(chara)
end
end
end
elseif target then
ally.Engage(target)
ally:Engage(target)
ally.hateContainer:AddBaseHate(target);
end
end

View file

@ -1,4 +1,5 @@
require ("global")
require ("ally")
require ("modifiers")
function onCreate(starterPlayer, contentArea, director)
@ -33,6 +34,42 @@ function onCreate(starterPlayer, contentArea, director)
end
function onUpdate(area, tick)
local players = area:GetPlayers()
local mobs = area:GetMonsters()
local allies = area:GetAllies()
local resumeChecks = true
for player in players do
if player then
local exitLoop = false
for ally in allies do
if ally then
if not ally:IsEngaged() then
if player:IsEngaged() then
ally.neutral = false
ally.isAutoAttackEnabled = true
ally:SetMod(modifiersGlobal.Speed, 8)
allyGlobal.EngageTarget(ally, player.target)
exitLoop = true
break
-- todo: support scripted paths
elseif ally:GetSpeed() > 0 then
end
end
end
end
if exitLoop then
resumeChecks = false
break
end
end
end
if not resumeChecks then
return
end
end
function onDestroy()

View file

@ -0,0 +1,22 @@
require ("modifiers")
function onSpawn(mob)
mob:SetMod(modifiersGlobal.Speed, 0)
end
function onDamageTaken(mob, attacker, damage)
if not attacker:IsPlayer() and mob:GetHP() - damage < 0 then
mob:addHP(damage)
end
end
function onCombatTick(mob, target, tick, contentGroupCharas)
if mob:GetSpeed() == 0 then
mob:SetMod(modifiersGlobal.Speed, 8)
end
end
function onDisengage(mob)
mob:SetMod(modifiersGlobal.Speed, 0)
mob:Despawn()
end

View file

@ -1,4 +1,5 @@
require ("global")
require ("modifiers")
require ("ally")
function onSpawn(ally)
@ -6,17 +7,5 @@ function onSpawn(ally)
ally:SetHP(ally:GetMaxHP())
ally.isAutoAttackEnabled = false;
ally.neutral = false
end
function onCombatTick(ally, target, tick, contentGroupCharas)
allyGlobal.onCombatTick(ally, target, tick, contentGroupCharas);
end
function onRoam(ally, contentGroupCharas)
ally.detectionType = 0xFF
ally.isMovingToSpawn = false
ally.neutral = false
ally.animationId = 0
allyGlobal.onCombatTick(ally, nil, nil, contentGroupCharas)
ally:SetMod(modifiersGlobal.Speed, 0)
end

View file

@ -1,22 +1,10 @@
require ("global")
require ("ally")
function onSpawn(ally)
ally:SetMaxHP(69420)
ally:SetHP(ally:GetMaxHP())
ally.isAutoAttackEnabled = false
ally.isAutoAttackEnabled = false;
ally.neutral = false
ally:SetMod(modifiersGlobal.Speed, 0)
end
function onCombatTick(ally, target, tick, contentGroupCharas)
allyGlobal.onCombatTick(ally, target, tick, contentGroupCharas)
end
function onRoam(ally, contentGroupCharas)
ally.detectionType = 0xFF
ally.isMovingToSpawn = false
ally.neutral = false
ally.animationId = 0
allyGlobal.onCombatTick(ally, contentGroupCharas)
end