- UID
- 512010
- 帖子
- 10
- 精华
- 0
- 威望
- 0
- 阅读权限
- 100
- 注册时间
- 2009-2-8
|
8#
发表于 2009-3-20 16:49
| 只看该作者
local object = 0
-- 1: SAFETY FIRSTY! Is the homunculus is under attack?
local Agressor = GetMyEnemy_AttackingMe(MyID) -- get TactData too
local AgBehav, AgSkill, AgLevel, AgAlche
if Agressor ~= 0 then
if (HomunHPPerc < HP_PERC_DANGER) or (HTact.Behav == BEHA_avoid) or (HTact.Behav == BEHA_coward) then
MyState = EVADE_ST -- flee away if HP < secure level
MyEnemy = Agressor
Evade_ComeBackTime = EVADE_COMEBACK
Log(string.format("[ -> EVADE_ST] GetMyNextTarget() attacked by enemy(%d) (avoid/coward mode or while HP < HP_PERC_DANGER)", MyEnemy))
return 0
else -- we are not in danger for now: save these data and let's check for other threats first
AgBehav = HTact.Behav
AgSkill = HTact.Skill
AgLevel = HTact.Level
AgAlche = HTact.Alche
if KILL_YOUR_ENEMIES_1ST == true then -- ... unless KILL_YOUR_ENEMIES_1ST is enabled
Log(string.format("GetMyNextTarget() <defensive scan + KILL_YOUR_ENEMIES_1ST> attacked by enemy(%d)", Agressor))
HTact.Behav = AgBehav
HTact.Skill = AgSkill
HTact.Level = AgLevel
HTact.Alche = AgAlche
return Agressor
end
end
end
-- 2: if the owner or a friend is under attack, help him/her
object = GetEnemyOf(OwnerID)
if object ~= 0 then
if GetV(V_MOTION, object) == MOTION_DEAD then
object = 0
end
end
if object == 0 then
local actors = GetActors()
for i,v in ipairs(actors) do
if (v ~= OwnerID and v ~= MyID) then
if (0 == IsMonster(v)) then
object = GetEnemyOf(v)
if GetV(V_MOTION, object) == MOTION_DEAD then
object = 0
end
if (object ~= 0) then
if ((GetV (V_HOMUNTYPE, v) < 1) or (GetV (V_HOMUNTYPE, v) > 16)) then DoSkill_AAS(AAH, v)
break
end
end
end
end
end
end
if object ~= 0 then
Log(string.format("GetMyNextTarget() the owner or a friend is attacked by enemy(%d):", object))
HTact = GetFullTact(GetV(V_HOMUNTYPE, object))
if (HTact.Behav ~= BEHA_avoid) then
return object
end
end
-- 3: if the homunculus is under attack (and his/her life is not in danger, see priority 1)
if Agressor ~= 0 then
Log(string.format("GetMyNextTarget() <defensive scan> attacked by enemy(%d)", Agressor))
HTact.Behav = AgBehav
HTact.Skill = AgSkill
HTact.Level = AgLevel
HTact.Alche = AgAlche
return Agressor
end
-- 4: if the owner or a friend is attacking --> cooperate
local OwnerMotion = GetV(V_MOTION, OwnerID)
local CooTarget = 0
object = GetV(V_TARGET, OwnerID)
if (object ~= 0) and (OwnerMotion == MOTION_ATTACK or OwnerMotion == MOTION_ATTACK2) then
CooTarget = object
end
if CooTarget == 0 then -- Owner is not attacking. Maybe a friend?
local FriendMotion = 0
for i,v in Friends do
if (v ~= OwnerID and v ~= MyID) then
if (0 == IsMonster(v)) then
object = GetV(V_TARGET, v)
FriendMotion = GetV(V_MOTION, v)
if (object ~= 0) and (FriendMotion == MOTION_ATTACK or FriendMotion == MOTION_ATTACK2) then
CooTarget = object
break
end
end
end
end
end
if CooTarget ~= 0 then
Log(string.format("GetMyNextTarget() cooperative target(%d) found:", CooTarget))
HTact = GetFullTact(GetV(V_HOMUNTYPE, CooTarget))
if (HTact.Behav ~= BEHA_avoid) then
return CooTarget
end
end
-- 5: aggressive, if HPs are OK and a target is near
if HomunHPPerc > HP_PERC_SAFE2ATK
then
object = GetMyEnemy_AnyNoKS(MyID) -- get TactData too
if (object ~= 0) then
Log(string.format("GetMyNextTarget() <aggressive scan> target(%d) found", object))
return object
end
end
return 0
end |
|