
Code: Select all
--[[
--------------------------------------------------
Copyright (C) 2011 Blastradius
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
--------------------------------------------------
]]--
--- Find the spirit that belongs to the provided player.
--
-- @param Integer Contains the player identifier.
-- @return Entity
function FindSpirit( ID )
-- Check the provided identifier to look for, otherwise use my own identifier.
if ID == nil then
ID = Player:GetID();
end
-- Loop through the available entities to find the spirit.
for EntityID, Entity in DictionaryIterator( EntityList:GetList()) do
-- Check if this monster is a spirit and belongs to me!
if Entity:GetOwnerID() == ID and string.find( Entity:GetName(), "Spirit" ) ~= nil then
return Entity;
end
end
-- Return nothing, the spirit has not been found.
return nil;
end
--- Perform the attack routine on the selected target.
--
-- @param Entity Contains the entity we have targeted.
-- @param double Contains the distance to the target
-- @param bool Indicates whether or not the target is stunned.
-- @param mixed Indicates whether or not to ignore Lumiel's Effect for the fusion chain.
-- @return bool
function Attack( Entity, Range, Stunned, Ignore )
-- Curse of Water
-- Dispel Magic (Enemy has states!)
-- Fear
-- Sandblaster (AOE, Long Duration)
-- Spirit Wrath Position (Shield)
-- Stone Skin
-- Absorb Energy
-- Spirit Absorption (30% mana regen from 10% spirit health)
-- Retrieve the entity state of the target.
local EntityState = Entity:GetState();
-- Retrieve the entity of the player spirit
local SpiritEntity = self:FindSpirit();
-- Check if the entity state is correct.
if EntityState == nil then
return;
end
-- Check if the player spirit is valid.
if SpiritEntity == nil then
-- Summon 1: Summon Earth Spirit
if Helper:CheckAvailable( "Summon Earth Spirit" ) then
Helper:CheckExecute( "Summon Earth Spirit" );
return false;
end
-- Cannot continue until a Spirit is available.
return false;
end
-- Summon 2: Replenish Element
if SpiritEntity:GetHealth() < 60 and Player:GetHealth() > 70 and Helper:CheckAvailable( "Replenish Element" ) then
Helper:CheckExecute( "Replenish Element" );
return;
end
-- Summon 3: Spirit Recovery
if SpiritEntity:GetHealth() < 25 and Helper:CheckAvailable( "Spirit Recovery" ) then
Helper:CheckExecute( "Spirit Recovery" );
return;
end
-- Summon 4: Healing Spirit
if SpiritEntity:GetHealth() < 30 and Helper:CheckAvailable( "Healing Spirit" ) then
Helper:CheckExecute( "Healing Spirit" );
return;
end
-- Spirit Buff 01: Elemental Spirit Armor
if Helper:CheckAvailable( "Elemental Spirit Armor" ) and SpiritEntity:GetState():GetState( Helper:CheckName( "Elemental Spirit Armor" )) == nil then
Helper:CheckExecute( "Elemental Spirit Armor" );
return false;
end
-- Spirit Buff 01: Frenzied Spirit
if Helper:CheckAvailable( "Frenzied Spirit" ) and SpiritEntity:GetState():GetState( Helper:CheckName( "Frenzied Spirit" )) == nil then
Helper:CheckExecute( "Frenzied Spirit" );
return false;
end
if Helper:CheckAvailable( "Sympathetic Mind" ) and SpiritEntity:GetState():GetState( Helper:CheckName( "Sympathetic Mind" )) == nil then
Helper:CheckExecute( "Sympathetic Mind" );
return false;
end
if Helper:CheckAvailable( "Stone Skin" ) and SpiritEntity:GetState():GetState( Helper:CheckName( "Stone Skin" )) == nil then
Helper:CheckExecute( "Stone Skin" );
return false;
end
-- Spirit Buff 01: Armor Spirit
if Helper:CheckAvailable( "Armor Spirit I" ) and SpiritEntity:GetState():GetState( Helper:CheckName( "Armor Spirit" )) == nil then
Helper:CheckExecute( "Armor Spirit" );
return false;
end
-- Spirit Buff 02: Spirit Armor of Darkness
if ( Settings.SpiritMaster.AllowDP or Entity:IsPlayer()) and not Entity:IsDead() and Player:GetDP() >= 2000 and Helper:CheckAvailable( "Spirit Armor of Light" ) and Player:GetState():GetState( Helper:CheckName( "Spirit Armor of Light" )) == nil then
Helper:CheckExecute( "Spirit Armor of Light" );
return false;
end
-- Spirit Buff 02: Spirit Armor of Darkness
if ( Settings.SpiritMaster.AllowDP or Entity:IsPlayer()) and not Entity:IsDead() and Player:GetDP() >= 2000 and Helper:CheckAvailable( "Spirit Armor of Darkness" ) and Player:GetState():GetState( Helper:CheckName( "Spirit Armor of Darkness" )) == nil then
Helper:CheckExecute( "Spirit Armor of Darkness" );
return false;
end
-- Buff 02: Spirit Preserve
if Helper:CheckAvailable( "Spirit Preserve" ) and Player:GetHealth() < 20 then
Helper:CheckExecute( "Spirit Preserve" );
return false;
end
-- Buff 03: Spirit Substitution
if Helper:CheckAvailable( "Spirit Substitution" ) and Player:GetHealth() < 30 then
Helper:CheckExecute( "Spirit Substitution" );
return false;
end
-- Check if this a new target and move the spirit when it is.
if self._LastEntity == nil or self._LastEntity ~= Entity:GetID() then
-- Check if Spirit Threat is available, do not continue until it is.
if not Helper:CheckAvailable( "Spirit Threat" ) then
if self._bPrepareThreat then
self._LastEntity = Entity:GetID();
self._bPrepareThreat = nil;
end
return false;
-- Check if the entity has selected a target.
elseif Entity:GetTargetID() ~= 0 then
Helper:CheckExecute( "Spirit Threat" );
self._bPrepareThreat = true;
return false;
-- Otherwise send the spirit to attack.
elseif self._iClickTime == nil or self._iClickTime < Time() then
DialogList:GetDialog( "pet_dialog/pet_cmd1" ):Click();
self._iClickTime = Time() + 1000;
self._bPrepareThreat = true;
return false;
-- For now, do nothing.
else
return false;
end
end
-- Check if this a new target and move the spirit when it is.
if self._LastEntity == nil or self._LastEntity ~= Entity:GetID() then
-- Check if Spirit Threat is available, do not continue until it is.
if not Helper:CheckAvailable( "Spirit Threat" ) then
if self._bPrepareThreat then
self._LastEntity = Entity:GetID();
self._bPrepareThreat = nil;
end
return false;
-- Check if the entity has selected a target.
elseif Entity:GetTargetID() ~= 0 then
Helper:CheckExecute( "Spirit Threat" );
self._bPrepareThreat = true;
return false;
-- Otherwise send the spirit to attack.
elseif self._iClickTime == nil or self._iClickTime < Time() then
DialogList:GetDialog( "pet_dialog/pet_cmd1" ):Click();
self._iClickTime = Time() + 1000;
self._bPrepareThreat = true;
return false;
-- For now, do nothing.
else
return false;
end
end
-- Chain 1: Remove Shock
if Player:GetHealth() < 70 and Player:GetMana() < 85 and Helper:CheckAvailable( "Vengeful Backdraft" ) then
Helper:CheckExecute( "Vengeful Backdraft" );
return false;
elseif Helper:CheckAvailable( "Flames of Anguish" ) then
Helper:CheckExecute( "Flames of Anguish" );
return false;
elseif Helper:CheckAvailable( "Remove Shock" ) then
Helper:CheckExecute( "Remove Shock" );
return false;
end
-- Chain 2: Stone Shock
if not Stunned and Helper:CheckAvailable( "Stone Shock" ) then
Helper:CheckExecute( "Stone Shock" );
return false;
end
-- Attack 01: Chain of Earth
if Entity:GetHealthCurrent() > 1000 and Helper:CheckAvailable( "Chain of Earth" ) and EntityState:GetState( Helper:CheckName( "Chain of Earth" )) == nil then
Helper:CheckExecute( "Chain of Earth" );
return false;
end
-- Attack 02: Spirit Thunderbolt Claw
if Helper:CheckAvailable( "Spirit Thunderbolt Claw" ) then
Helper:CheckExecute( "Spirit Thunderbolt Claw" );
return false;
end
-- Spirit Buff 02: Spirit Wrath Position
if Helper:CheckAvailable( "Spirit Wrath Position" ) then
Helper:CheckExecute( "Spirit Wrath Position" );
return false;
end
-- Buff 01: Summoning Alacrity
if Helper:CheckAvailable( "Summoning Alacrity" ) then
Helper:CheckExecute( "Summoning Alacrity" );
return false;
end
-- Attack 03: Summon Earth Energy
if Helper:CheckAvailable( "Summon Elemental Servant" ) then
Helper:CheckExecute( "Summon Elemental Servant" );
return false;
end
-- Attack 03: Summon Earth Energy
if Helper:CheckAvailable( "Summon Fire Energy" ) then
Helper:CheckExecute( "Summon Fire Energy" );
return false;
end
-- Stigma 01: Summon Cyclone Servant
if Helper:CheckAvailable( "Summon Wind Servan" ) then
Helper:CheckExecute( "Summon Wind Servant" );
return false;
end
-- Attack 03: Summon Earth Energy
if Helper:CheckAvailable( "Summon Earth Energy" ) then
Helper:CheckExecute( "Summon Earth Energy" );
return false;
end
-- Stigma 01: Summon Cyclone Servant
if Helper:CheckAvailable( "Summon Cyclone Servant" ) then
Helper:CheckExecute( "Summon Cyclone Servant" );
return false;
end
-- Attack 03: Summon Earth Energy
if Helper:CheckAvailable( "Dispel Magic" ) then
Helper:CheckExecute( "Dispel Magic" );
return false;
end
-- Indicates whether or not to preserve mana. Damage-over-time skills are not applied after 50%.
if not Settings.SpiritMaster.AllowPreserveMana or Entity:GetHealth() >= 50 then
-- Attack 04: Erosion
if Helper:CheckAvailable( "Erosion" ) and EntityState:GetState( Helper:CheckName( "Erosion" )) == nil then
Helper:CheckExecute( "Erosion" );
return false;
end
-- Stigma 02: Cyclone of Wrath
if Helper:CheckAvailable( "Cyclone of Wrath" ) and EntityState:GetState( Helper:CheckName( "Cyclone of Wrath" )) == nil then
Helper:CheckExecute( "Cyclone of Wrath" );
return false;
end
-- Stigma 03: Infernal Pain
if Helper:CheckAvailable( "Infernal Pain" ) then
Helper:CheckExecute( "Infernal Pain" );
return false;
end
-- Attack 05: Spirit Erosion
if Helper:CheckAvailable( "Spirit Erosion" ) and Entity:GetHealth() <= 700 then
Helper:CheckExecute( "Spirit Erosion" );
return false;
end
end
-- Attack 05: Spirit Disturbance
if Helper:CheckAvailable( "Spirit Disturbance" ) and SpiritEntity:GetHealth() < 80 then
Helper:CheckExecute( "Spirit Disturbance" );
return false;
end
-- Attack 06: Backdraft
if Helper:CheckAvailable( "Backdraft" ) and Player:GetHealth() < 80 and Player:GetMana() < 90 then
Helper:CheckExecute( "Backdraft" );
return false;
end
-- Attack 07: Spirit Detonation Claw
if Helper:CheckAvailable( "Spirit Detonation Claw" ) then
Helper:CheckExecute( "Spirit Detonation Claw" );
return false;
end
-- Attack 08: Vacuum Choke
if Helper:CheckAvailable( "Vacuum Chok" ) then
Helper:CheckExecute( "Vacuum Choke" );
return false;
end
-- Attack 08: Vacuum Choke
if Helper:CheckAvailable( "Spirit Absorption" ) then
Helper:CheckExecute( "Spirit Absorption" );
return false;
end
-- Attack 08: Vacuum Choke
if Helper:CheckAvailable( "Absorb Energy" ) then
Helper:CheckExecute( "Absorb Energy" );
return false;
end
-- Stigma 04: Weaken Spirit
if Helper:CheckAvailable( "Weaken Spirit" ) then
Helper:CheckExecute( "Weaken Spirit" );
return false;
end
--UTILITY SPELLS
-- Stigma 05: Absorb Vitality
if Helper:CheckAvailable( "Absorb Vitality" ) and Player:GetHealth() < 75 then
Helper:CheckExecute( "Absorb Vitality" );
return false;
end
-- Attack 09: Curse of Fire/Curse of Water
if Helper:CheckAvailable( "Curse of Water" ) and Player:GetHealth() < 38 then
Helper:CheckExecute( "Curse of Water" );
return false;
end
-- Buff 02: Spirit Preserve
if Helper:CheckAvailable( "Spirit Preserve" ) and Player:GetHealth() < 20 then
Helper:CheckExecute( "Spirit Preserve" );
return false;
end
-- Buff 03: Spirit Substitution
if Helper:CheckAvailable( "Spirit Substitution" ) and Player:GetHealth() < 30 then
Helper:CheckExecute( "Spirit Substitution" );
return false;
end
-- Buff 04: Absorb Energy
if Helper:CheckAvailable( "Absorb Energy" ) and Player:GetMana() < 90 then
Helper:CheckExecute( "Absorb Energy" );
return false;
end
-- Buff 05: Spirit Absorption
if Helper:CheckAvailable( "Spirit Absorption" ) and Player:GetMana() < 65 then
Helper:CheckExecute( "Spirit Absorption" );
return false;
end
-- Check if this entity has the Stone Skin state.
if Helper:CheckAvailable( "Sympathetic Mind" ) and EntityState:GetState( "Sympathetic Mind" ) == nil and EntityState:GetState( "Sympathetic Mind" ) == nil
and EntityState:GetState( "Sympathetic Mind" ) == nil and EntityState:GetState( "Sympathetic Mind" ) == nil and EntityState:GetState( "Sympathetic Mind" ) == nil then
Helper:CheckExecute( "Sympathetic Mind" );
return false;
end
-- Check if this entity has the Stone Skin state.
if Helper:CheckAvailable( "Stone Skin" ) and EntityState:GetState( "Stone Skin I" ) == nil and EntityState:GetState( "Stone Skin II" ) == nil
and EntityState:GetState( "Stone Skin III" ) == nil and EntityState:GetState( "Stone Skin IV" ) == nil and EntityState:GetState( "Stone Skin V" ) == nil then
Helper:CheckExecute( "Stone Skin" );
return false;
end
-- Buff 04: Absorb Energy
if Helper:CheckAvailable( "Absorb Energy" ) and Player:GetManaMaximum() - Player:GetManaCurrent() > 526 then
Helper:CheckExecute( "Absorb Energy" );
return false;
end
-- Buff 05: Stone Skin
if Helper:CheckAvailable( "Stone Skin" ) and EntityState:GetState( Helper:CheckName( "Stone Skin" )) == nil then
Helper:CheckExecute( "Stone Skin" );
return false;
end
-- Buff 09: Fine Rally Serum
if Helper:CheckAvailable( "Increase Natural Recovery Serum" ) and EntityState:GetState( Helper:CheckName( "Increase Natural Recovery Serum" )) == nil then
Helper:CheckExecute( "Increase Natural Recovery Serum" );
return false;
end
-- Buff 06: Blessing of Fire
if Helper:CheckAvailable( "Blessing of Fir" ) and EntityState:GetState( Helper:CheckName( "Blessing of Fire" )) == nil then
Helper:CheckExecute( "Blessing of Fire" );
return false;
end
-- Buff 07: Sympathetic Mind
if Helper:CheckAvailable( "Sympathetic Mind" ) and EntityState:GetState( Helper:CheckName( "Sympathetic Mind" )) == nil then
Helper:CheckExecute( "Sympathetic Mind" );
return false;
end
-- Buff 07: Sympathetic Mind
if Helper:CheckAvailable( "Spirit Wrath Position" ) and EntityState:GetState( Helper:CheckName( "Spirit Wrath Position" )) == nil then
Helper:CheckExecute( "Spirit Wrath Position" );
return false;
end
-- Buff 07: Sympathetic Mind
if Helper:CheckAvailable( "Spirit Armor of Darknes" ) and EntityState:GetState( Helper:CheckName( "Spirit Armor of Darkness" )) == nil then
Helper:CheckExecute( "Spirit Armor of Darkness" );
return false;
end
-- Buff 08: Spirit Absorption
if Helper:CheckAvailable( "Spirit Absorption" ) and Player:GetMana() < 70 and self:FindSpirit() ~= nil then
Helper:CheckExecute( "Spirit Absorption" );
return false;
end
end