-- /\/\ __ _ _ __ __ _ ___ / _\ ___ _ __(_)_ __ | |_ -- / \ / _` | '_ \ / _` |/ _ \\ \ / __| '__| | '_ \| __| -- / /\/\ \ (_| | | | | (_| | (_) |\ \ (__| | | | |_) | |_ -- \/ \/\__,_|_| |_|\__, |\___/\__/\___|_| |_| .__/ \__| -- |___/ |_| -- A WHOLE NEW WORLD -- MangoScript - Bringing a whole new world to MaNGOS -- -- ULD_Ironaya_AI.lua - Script for generic spell casting mobs -- based on ther Herod script by SinnerG -- -- (c) Copyright 2006-2007 by the MangoScript Team -- -- 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 2 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. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- $Id: ULD_Ironaya_AI.lua 01 2007-02-05 13:15:09Z biglad $ -- Create the Mango AIScript Base object ULD_Ironaya_AI = Mango.AIScripts.Create('ULD_Ironaya_AI'); ULD_Ironaya_AI.AgroDistance = 20; -- Experiment with this :p -- Function prototypes (to keep it clean) local ULD_Ironaya_AI_Init; local ULD_Ironaya_AI_MoveInLineOfSight; local ULD_Ironaya_AI_AttackStart; local ULD_Ironaya_AI_DamageInflict; -- this will check if player is drawing agro function ULD_Ironaya_AI.CheckAggro(LuaAI,unit) local data = LuaAI:Data() if LuaAI:GetCreature():GetDistanceSq(unit) < ULD_Ironaya_AI.AgroDistance then LuaAI:DoStartAttack(unit); if (data["IsAttacking"] == false) then data["IsAttacking"] = true; -- Cast first spell (6603 : no stun charge / 32021 : stunning charge) LuaAI:DoSay("I will crush you small one, you and your allies!",0); LuaAI:DoCast(LuaAI:GetCreature(), 6603); LuaAI:SetData(data) end end end function ULD_Ironaya_AI_Init(LuaAI) local data = LuaAI:Data() -- Initialize AI data data = { } data["IsAttacking"] = false; data["Arcing Smash"] = false; data["Arcing Smash2"] = false; data["Arcing Smash3"] = false; data["War Stomp"] = false; data["Knock Away"] = false; data["Death Wish"] = false; LuaAI:SetData(data) return true end function ULD_Ironaya_AI_MoveInLineOfSight(LuaAI,unit) ULD_Ironaya_AI.CheckAggro(LuaAI,unit) -- Check if the guard has to talk or not :) LuaAI:MoveInLineOfSight_agr(unit) end -- Called at each attack of creature by any victim function ULD_Ironaya_AI_AttackStart(LuaAI,unit) local data = LuaAI:Data() --TODO Seems that dont work for now ... dont have time to test --local spellid = 12328 -- Death Wish is default --local randn = rand_range(1,100) -- --if randn > 80 then spellid = 12328 --end -- --LuaAI:GetCreature():StopMoving() --LuaAI:DoCast(unit,spellid) ULD_Ironaya_AI.CheckAggro(LuaAI, unit); LuaAI:DoStartAttack(unit) end function ULD_Ironaya_AI_DamageInflict(LuaAI,unit,amount_damage) local data = LuaAI:Data() local HP = LuaAI:GetCreature():GetHealth(); local MaxHP = LuaAI:GetCreature():GetMaxHealth(); if (data["Death Wish"] == false) then if (100 / MaxHP * HP < 35) then -- Death Wish -- Spell doesnt work local num3 = rand_range(0,100) if (num3 > 50) then spellid = 12328 elseif (num3 < 50) then spellid = 6603 end data["Death Wish"] = true; LuaAI:DoCast(LuaAI:GetCreature(),spellid) LuaAI:SetData(data) return; end end if (data["Knock Away"] == false) then if (100 / MaxHP * HP <= 60) then -- Needs correct percentage! -- Knock Away -- Don't know exact spellid, using this one atm : 23382 local num = rand_range(0,100) if (num >= 50) then LuaAI:DoSay("Get away from me!", 0); -- Was left in for fun else LuaAI:DoSay("Begone with you!", 0); -- Was left in for fun end LuaAI:DoCast(LuaAI:GetCreature(), 23382); data["Knock Away"] = true; LuaAI:SetData(data) return; end end if (data["War Stomp"] == false) then if (100 / MaxHP * HP < 21) then -- War Stomp -- Don't know exact spellid, using this one atm : 19482 -- Description: Knocks nearby enemies back, stunning them. LuaAI:DoCast(LuaAI:GetCreature(), 19482); data["War Stomp"] = true; LuaAI:DoStartAttack(unit) LuaAI:SetData(data) return; end end if (data["Arcing Smash"] == false) then if (100 / MaxHP * HP < 95) then -- not sure if this works -- Arcing Smash -- Don't know exact spellid, using this one atm : 16169 -- Description: Lashes out in a vicious arc, inflicting damage to enemies in a cone in front of the caster. local num1 = rand_range(0,100) if (num1 > 95) then spellid = 16169 elseif (num1 < 95) then spellid = 6603 end LuaAI:DoCast(unit,spellid) data["Arcing Smash"] = true; LuaAI:SetData(data) return; end end if (data["Arcing Smash2"] == false) then if (100 / MaxHP * HP < 45) then -- not sure if this works -- Arcing Smash -- Don't know exact spellid, using this one atm : 16169 -- Description: Lashes out in a vicious arc, inflicting damage to enemies in a cone in front of the caster. local num2 = rand_range(0,100) if (num2 > 80) then spellid = 16169 elseif (num1 < 80) then spellid = 6603 end LuaAI:DoCast(unit,spellid) data["Arcing Smash2"] = true; LuaAI:SetData(data) return; end end if (data["Arcing Smash3"] == false) then if (100 / MaxHP * HP < 25) then -- not sure if this works -- Arcing Smash -- Don't know exact spellid, using this one atm : 16169 -- Description: Lashes out in a vicious arc, inflicting damage to enemies in a cone in front of the caster. local num4 = rand_range(0,100) if (num4 > 85) then spellid = 16169 elseif (num4 < 85) then spellid = 6603 end LuaAI:DoCast(unit,spellid) data["Arcing Smash2"] = true; LuaAI:SetData(data) return; end end end -- Assign the functions ULD_Ironaya_AI.Init = ULD_Ironaya_AI_Init; ULD_Ironaya_AI.MoveInLineOfSight = ULD_Ironaya_AI_MoveInLineOfSight; ULD_Ironaya_AI.AttackStart = ULD_Ironaya_AI_AttackStart; ULD_Ironaya_AI.DamageInflict = ULD_Ironaya_AI_DamageInflict; -- Link the AI to the different scripts -- Note: Only the ones who use the Mango.Scripts method of scripting can use ULD_Ironaya_AI ULD_Ironaya_AI:Register('uld_ironaya');