require "./AI/Const.lua" require "./AI/Util.lua" require "./AI/USER_AI/Config.lua" -- Cosme E. Zamudio Salazar. -- -- -- -- Skills Constants -- Normal Homcus AMI_CASTLING = 1 AMI_DEFENCE = 2 LIF_HEAL = 3 LIF_SCAPE = 4 VAN_CAPRICE = 5 VAN_CHAOTIC = 6 FLI_MOONLIGHT = 7 FLI_FLEET = 8 FLI_SPEED = 9 -- Evo Homcus AMI_BLOODLUST = 10 LIF_CHANGE = 11 VAN_EXPLOSION = 12 FLI_SBR44 = 13 -- Alchemist Skills POTION_PITCHER = 14 SkillID = {"8005","8006","8001","8002","8009","8010","8011","8013","8014","8008","8004","8016","8012","231"} -- Usage. SkillSP[SkillLvl][NameConstant]. i.e.: SkillSP[1][AMI_CASTLING] SkillSP = { {10,20,13,20,22,40,4,30,30,0,0,0,0,1}, -- Lvl1 {10,25,16,25,24,40,8,40,40,0,0,0,0,1}, -- Lvl2 {10,30,19,30,26,40,12,50,50,0,0,0,0,1}, -- Lvl3 {10,35,22,35,28,40,16,60,60,0,0,0,0,1}, -- Lvl4 {10,40,25,40,30,40,20,70,70,0,0,0,0,1} -- Lvl5 } -- Skill Lasting Time. Usage: SkillTime[SkillLvl][NameConstant] SkillTime = { {0,40,0,40,0,0,0,60,60,0,0,0,0,1}, --Lvl1 {0,35,0,35,0,0,0,70,70,0,0,0,0,1}, --Lvl2 {0,30,0,30,0,0,0,80,80,0,0,0,0,1},--Lvl3 {0,25,0,25,0,0,0,90,90,0,0,0,0,1},--Lvl4 {0,20,0,20,0,0,0,120,120,0,0,0,0,1} --Lvl5 } -- --8005 //HAMI_CASTLE --8006 //HAMI_DEFENCE --8001 //HLIF_HEAL#Healing hand# --8002 //HLIF_AVOID --8009 //HFLI_MOON --8010 //HFLI_FLEET --8011 //HFLI_SPEED --8013 //HVAN_CAPRICE --8014 //HVAN_CHAOTIC --8008 //HAMI_BLOODLUST --8004 //HLIF_CHANGE --8016 //HVAN_EXPLOSION --8012 //HFLI_SBR44 --------------------------------------------------------------------------------------------- -- Debug Functions --------------------------------------------------------------------------------------------- function debug(msg,line) TraceAI("=======================") TraceAI(msg) TraceAI("line:"..line) TraceAI("=======================") end function echo(text,var) TraceAI("==========================") TraceAI(text .. ": " .. var) TraceAI("==========================") end --------------------------------------------------------------------------------------------- -- INFO FUNCTIONS --------------------------------------------------------------------------------------------- -- Whats my type of homcus . function imAmistr(MyID) local type=GetV(V_HOMUNTYPE,MyID) return((type==AMISTR) or (type == AMISTR2) or (type == AMISTR_H) or (type == AMISTR_H2)) end function imLif(MyID) local type = GetV(V_HOMUNTYPE,MyID) return((type == LIF) or (type == LIF2) or (type == LIF_H) or (type == LIF_H2)) end function imFilir(MyID) local type = GetV(V_HOMUNTYPE,MyID) return ((type == FILIR) or (type == FILIR2) or (type == FILIR_H) or (type == FILIR_H2)) end function imVanilmirth(MyID) local type = GetV(V_HOMUNTYPE,MyID) return((type == VANILMIRTH) or (type == VANILMIRTH2) or (type == VANILMIRTH_H) or (type == VANILMIRTH_H2)) end -- Im Evol. function imEvo(MyID) local type = GetV(V_HOMUNTYPE,MyID) return((type==VANILMIRTH_H) or (type==VANILMIRTH_H2) or (type == AMISTR_H) or (type == AMISTR_H2) or (type == LIF_H) or (type == LIF_H2) or (type == FILIR_H) or (type == FILIR_H2)) end -- How Much hp ur owner have. Percent Values. function OwnerHPPercent(MyID) local CurrentHP = GetV(V_HP,GetV(V_OWNER,MyID)) local MaxHP = GetV(V_MAXHP,GetV(V_OWNER,MyID)) local Percent = (CurrentHP*100)/MaxHP return Percent end -- My Current HP Percent function MyHPPercent(MyID) local CurrentHP = GetV(V_HP,MyID) local MaxHP = GetV(V_MAXHP,MyID) local Percent = (CurrentHP*100)/MaxHP return Percent end -- My Current HP function MyHP(MyID) return GetV(V_HP,MyID) end -- My MAX HP function MyMAXHP(MyID) return GetV(V_MAXHP,MyID) end -- Returns my number of enemies and a table with their ID's function MyEnemies(MyID) local owner = GetV(V_OWNER,MyID) local actors = GetActors () local enemys = {} local index = 1 local target for i,v in ipairs(actors) do if (v ~= owner and v ~= myid) then if (1 == IsMonster(v)) then target = GetV (V_TARGET,v) if (target == MyID) then enemys[index] = v index = index+1 end end end end return enemys,(index-1) end -- Returns my owner number of enemies and a table with their ID's function MyOwnerEnemies(MyID) local owner = GetV(V_OWNER,MyID) local actors = GetActors () local enemys = {} local index = 1 local target for i,v in ipairs(actors) do if (v ~= owner and v ~= myid) then if (1 == IsMonster(v)) then target = GetV (V_TARGET,v) if (target == owner) then enemys[index] = v index = index+1 end end end end return enemys,(index-1) end --------------------------------------------------------------------------------------------- -- CUSTOM BEHAVIOR FUNCTIONS --------------------------------------------------------------------------------------------- zigzag = 0 function custom_patrol(MyID) local g_ownerx,g_ownery = GetOwnerPosition (MyID) local myx,myy = GetV(V_POSITION,MyID) if (zigzag==0) then local motion = GetV (V_MOTION,MyID) if (motion ~= MOTION_MOVE) then Move (MyID,g_ownerx-2,g_ownery-2) end if (myx == g_ownerx-2) and (myy == g_ownery-2) then zigzag = 1 end elseif (zigzag==1) then if (motion ~= MOTION_MOVE) then Move (MyID,g_ownerx-2,g_ownery+2) end if (myx == g_ownerx-2) and (myy == g_ownery+2) then zigzag = 2 end elseif (zigzag==2) then if (motion ~= MOTION_MOVE) then Move (MyID,g_ownerx+2,g_ownery+2) end if (myx == g_ownerx+2) and (myy == g_ownery+2) then zigzag = 3 end elseif (zigzag==3) then if (motion ~= MOTION_MOVE) then Move (MyID,g_ownerx+2,g_ownery-2) end if (myx == g_ownerx+2) and (myy == g_ownery-2) then zigzag = 0 end end end --------------------------------------------------------------------------------------------- -- AUTO SKILLS FUNCTIONS --------------------------------------------------------------------------------------------- -------------------------- -- Auto Aid Potion: By Kibo -- Initialy it was a BlankZero script. i had to change a lot of things to make it work on eAthena -------------------------- AidPotionFailCounter = 0 AidPotionLastCurrrentHPPercent = 0 AidPotionHomuncHPPercent = 0 AidPotionHomuncLastHPPercent = 0 StartAidPotionTick = 0 AidPotionTried = 0 -- little hack to make it work on eAthena function auto_potion(MyID) AidPotionHomuncHPPercent = MyHPPercent(MyID) if (Auto_AidPotion == 1 and AidPotionHomuncHPPercent < AidPotionAtPercent ) then if (AidPotionTried) then -- After Aid Potion Check if (AidPotionHomuncHPPercent<=AidPotionHomuncLastHPPercent) then -- did it work or i was out of pots? AidPotionFailCounter = AidPotionFailCounter + 1 if (AidPotionFailCounter>5) then --if im out of pots, just try 6 times and stop doing it. Auto_AidPotion=0 end else -- Reset the Failt Counter if i have pots. AidPotionFailCounter = 0 end AidPotionTried=0 -- little hack to make it work on eAthena end CurrentAidPotionTick = GetTick() if (CurrentAidPotionTick - StartAidPotionTick >= 500) then --Have to wait a little bit to make it work again AidPotionTried = 1 SkillObject (MyID, AidPotionLevel, SkillID[POTION_PITCHER], MyID) -- Aid Potion StartAidPotionTick=GetTick() end AidPotionTried = 1 AidPotionHomuncLastHPPercent = MyHPPercent(MyID) else AidPotionTried = 0 end end -------------------------- -- Amistr auto buffs -- Deberia de ser Auto Buffs Generales en una sola funcion. -------------------------- Amistr_SkillDelay = 0 Amistr_Buff_Level = 5 --Amistr_BuffTime = 22 Amistr_NowTick_Buff = 0 Amistr_StartTick_Buff = 0 function amistr_autobuff(MyID) TraceAI("AMISTR_AUTOBUFF_IN") if (Amistr_SkillDelay <= 0 and Amistr_Auto_Buff == 1 and GetV(V_SP, MyID) >= SkillSP[Amistr_Buff_Level][AMI_DEFENCE]) then Amistr_NowTick_Buff = GetTick() echo("Tiempo Restante",(Amistr_NowTick_Buff - Amistr_StartTick_Buff)/1000) if (Amistr_NowTick_Buff - Amistr_StartTick_Buff >= (SkillTime[Amistr_Buff_Level][AMI_DEFENCE]+2) * 1000) then Amistr_StartTick_Buff = GetTick() SkillObject (MyID, tostring(Amistr_Buff_Level), SkillID[AMI_DEFENCE], MyID) Amistr_SkillDelay = 5 end end if (Amistr_SkillDelay > 0) then Amistr_SkillDelay = Amistr_SkillDelay - 1 end end ----------------------------- -- Amistr AutoCastling ----------------------------- function amistr_autocastling(MyID,Lvl) --Personalizado if (GetV(V_SP, myid) >= 50 and imAmistr(myid)) then SkillObject (MyID, "5", "8005", MyID) TraceAI ("AUTO CASTLING") end --Termina end