-- 936AI Ver 0.13test4 by936 -- 設定箇所 ---------------------------- SearchRange = 11 -- 索敵距離 (初期値 11) LeadoffAttack = 0 -- 先制攻撃をする 0 = ON , 1 = OFF AttackHPP = 30 -- ホムHP%が指定以上の時先制攻撃 (初期値 30) RmtoHPP = 100 -- ホムHP%が指定以上の時待機時主人の元に戻る (初期値 100) RmtoSPP = 100 -- ホムSP%が指定以上の時待機時主人の元に戻る (初期値 100) FollowDistance = 3 -- 指定距離ホムが離れたら追従する (初期値 3) PatrolFlg = 1 -- くるくるする 0 = ON , 1 = OFF PatrolRange = 12 -- くるくるする距離 (1〜12) (初期値 12) PatrolHPP = 100 -- ホムHP%が指定以上の時くるくるする (初期値 100) PatrolSPP = 100 -- ホムSP%が指定以上の時くるくるする (初期値 100) TyrannicalFlg = 1 -- 共闘する 0 = ON , 1 = OFF FBMInPlayer = 6 -- 他プレイヤーから指定範囲内の敵を攻撃しない (初期値 6) FBMNearOwner = -1 -- 他プレイヤーが居ても主人の指定周囲以内の敵を攻撃(-1 or 1) (初期値 -1) ManyTargetFlg = 1 -- 複数のPCにタゲられている敵を優先 0 = ON , 1 = OFF AttackBioplant = 1 -- バイオプラントを攻撃 0 = ON , 1 = OFF AtkPriorityFlg = 2 -- タゲられている敵の攻撃順位 0 = 主人>ホム , 1 = ホム>主人 , 2 = 主人>友達>ホム AtkOwnPriority = 50 -- ホム>主人 時、主人のHP%が指定以下の時 主人>ホム に切り替える (初期値 50) AttackNearOwner = 1 -- 主人の回りの敵から攻撃する 0 = ON , 1 = OFF ChangeAttack = 0 -- 攻撃中にタゲを変更する 0 = ON , 1 = OFF NoOwnerTarget = 0 -- 主人がタゲている敵を攻撃 0 = ON , 1 = OFF , 2 = 後回し DefenseTarget = 1 -- 主人をタゲている敵をスタック中でも優先 0 = ON , 1 = OFF FriendTarget = 0 -- 友達を攻撃している敵を優先 0 = ON , 1 = OFF IgnoreTarget = 1 -- 主人をタゲている敵を無視 0 = ON , 1 = OFF IgnoreTargetCnt = 1 -- 指定数を超えたら間引く (初期値 1) ITRandomFlg = 0 -- 間引く敵をランダムにする 0 = ON , 1 = OFF ITCangeFlg = 50 -- 主人のHP%が指定以下になったらオフにする (初期値 50) AsSl,AsSh = 0,100 -- ホムSP%が指定以上、尚かつ指定以下の時攻撃スキル発動 (初期値 0,100) AsSkillLv = 5 -- 攻撃スキルのレベル (初期値 5) SkillLvControl = 1 -- 残りSP%によって攻撃スキルのレベルを調整する 0 = ON , 1 = OFF FirstSkillDelay = 2 -- 初回スキル後指定秒間攻撃スキルを使用しない(秒) (初期値 2) SPrestoreFlg = 1 -- 初撃スキル後SP回復 0 = ON , 1 = OFF AsFleetMoveFlg = 1 -- フリットムーブを使用 0 = ON , 1 = OFF FleetMoveLv = 5 -- スキルのレベル (初期値 5) FleetMoveHPP = 100 -- ホムHP%が指定以下の時スキル発動 (初期値 100) FMl,FMh = 0,50 -- ホムSP%が指定以上、尚かつ指定以下の時スキル発動 (初期値 0,50) AsDeffenceFlg = 1 -- ディフェンスを使用 0 = ON , 1 = OFF DeffenceLv = 5 -- スキルのレベル (初期値 5) DeffenceHPP = 100 -- ホムHP%が指定以下の時スキル発動 (初期値 100) DFl,DFh = 0,100 -- ホムSP%が指定以上、尚かつ指定以下の時スキル発動 (初期値 0,100) AsBloodLustFlg = 1 -- ブラッドラストを使用 0 = ON , 1 = OFF BloodLustLv = 3 -- スキルのレベル (初期値 3) BloodLustHPP = 50 -- ホムHP%が指定以下の時スキル発動 (初期値 50) BLl,BLh = 0,100 -- ホムSP%が指定以上、尚かつ指定以下の時スキル発動 (初期値 0,100) GrazingFlg = 1 -- キャッスリングを使用して移動する 0 = ON , 1 = OFF GrazingNearPC = 6 -- 他プレイヤーの指定範囲以内に移動しない (初期値 6) GrazingOwnerHPP = 100 -- 主人のHP%が指定以上の時移動する (初期値 100) GrazingHPP = 100 -- ホムのHP%が指定以上の時移動する (初期値 100) GrazingSPP = 100 -- ホムのSP%が指定以上の時移動する (初期値 100) AsCVFlg = 1 -- カオティックベネディクションを使用 0 = ON , 1 = OFF CVAttackFlg = 0 -- 攻撃中にカオティックベネディクションを使用 0 = ON , 1 = OFF CVPriority = 0 -- 主人とホムのどちらのHPを優先するか 0 = 主人 , 1 = ホム CVl,CVh = 0,100 -- ホムのSP%が指定以上、尚かつ指定以下の時カオベネ発動 (初期値 0,100) CVOwnerHPP = 50 -- 主人のHP%が指定未満の時カオティックベネディクション発動 (初期値 50) CVHomuHPP = 50 -- ホムのHP%が指定未満の時カオティックベネディクション発動 (初期値 50) CVOwnerLv = 3 -- 主人に発動するレベル (初期値 3) CVHomuLv = 5 -- ホムに発動するレベル (初期値 5) CVComplete = 1 -- 待機時SPが100%なら全快まで回復させる 0 = ON , 1 = OFF AsTHFlg = 1 -- 治癒の手を使用 0 = ON , 1 = OFF THl,THh = 0,100 -- ホムのSP%が指定以上、尚かつ指定以下の時治癒の手発動 (初期値 0,100) THHPP = 50 -- 主人のHP%が指定未満の時治癒の手発動 (初期値 50) THLv = 5 -- スキルのレベル (初期値 5) THCount = 100 -- 治癒の手の使用回数の上限 (初期値 100) AsEAvoidFlg = 1 -- 緊急回避を使用 0 = ON , 1 = OFF EAvoidLv = 5 -- スキルのレベル (初期値 5) EAl,EAh = 0,100 -- ホムSP%が指定以上、尚かつ指定以下の時スキル発動 (初期値 0,100) MultiAttack = 1 -- 進化用1サイクル攻撃回数 (1〜3) (初期値 1) MotionCancel = 0 -- 攻撃時移動モーションキャンセル 0 = ON , 1 = OFF ZeroMC = 1 -- 攻撃時ゼロ移動モーションキャンセル 0 = ON , 1 = OFF ZeroMC_HPP = 50 -- ホムHP%が指定未満の時ゼロ移動モーションキャンセル (初期値 50) ZeroMC_SPP = 50 -- ホムSP%が指定未満の時ゼロ移動モーションキャンセル (初期値 50) AttackRange = 0 -- 指定数離れて通常攻撃 (0〜1) (初期値 0) StackTime = 20 -- 指定時間同じ敵を攻撃していたらスタックしたと見なす(秒) (初期値 20) NoDamageStcTime = 2 -- ノーダメージスタック時移動を始める時間(秒) (初期値 2) AutoFriendFlg = 1 -- 自動友達登録を使用 0 = ON , 1 = OFF AutoFriendCount = 10 -- 自動友達登録のし易さ (初期値 10) AFSkillRange = 2 -- 主人とホムの指定周囲以内でスキルを使用したPCもカウントする (初期値 2) MineEscapeFlg = 1 -- マリンスフィアーを回避 0 = ON , 1 = OFF FixedCPFlg = 1 -- 固定砲台モードを使用 0 = ON , 1 = OFF AutoExit = 1 -- 寝落ち防止対策 0 = ON , 1 = OFF ExitLimitTime = 60 -- 寝落ち防止対策の実行時間(分) (初期値 60) AutoExit2 = 1 -- 指定時間後に自動終了を使用 0 = ON , 1 = OFF ExitLimitTime2 = 60 -- 指定時間後に自動終了(分) (初期値 60) AutoEnd = 1 -- HP判定での自動終了を使用 0 = ON , 1 = OFF AutoEndOwnerHP = 25 -- 主人のHP%が指定未満の時自動終了 (初期値 25) AutoEndMyHP = 25 -- ホムのHP%が指定未満の時自動終了 (初期値 25) PcListFlg = 1 -- PCのIDをリストに保存 0 = ON , 1 = OFF -- 設定ここまで ---------------------------- V_OWNER = 0 V_POSITION = 1 V_TYPE = 2 V_MOTION = 3 V_ATTACKRANGE = 4 V_TARGET = 5 V_SKILLATTACKRANGE = 6 V_HOMUNTYPE = 7 V_HP = 8 V_SP = 9 V_MAXHP = 10 V_MAXSP = 11 ------------------------------ LIF = 1 AMISTR = 2 FILIR = 3 VANILMIRTH = 4 LIF2 = 5 AMISTR2 = 6 FILIR2 = 7 VANILMIRTH2 = 8 LIF_H = 9 AMISTR_H = 10 FILIR_H = 11 VANILMIRTH_H = 12 LIF_H2 = 13 AMISTR_H2 = 14 FILIR_H2 = 15 VANILMIRTH_H2 = 16 ------------------------------ MOTION_STAND = 0 MOTION_MOVE = 1 MOTION_ATTACK = 2 MOTION_DEAD = 3 MOTION_DAMAGED = 4 MOTION_PICKUP = 5 MOTION_SIT = 6 MOTION_SKILL = 7 MOTION_CASTING = 8 MOTION_ATTACK2 = 9 ------------------------------ NONE_CMD = 0 MOVE_CMD = 1 STOP_CMD = 2 ATTACK_OBJECT_CMD = 3 ATTACK_AREA_CMD = 4 PATROL_CMD = 5 HOLD_CMD = 6 SKILL_OBJECT_CMD = 7 SKILL_AREA_CMD = 8 FOLLOW_CMD = 9 ------------------------------ IDLE_ST = 0 FOLLOW_ST = 1 CHASE_ST = 2 ATTACK_ST = 3 MOVE_CMD_ST = 4 STOP_CMD_ST = 5 ATTACK_OBJECT_CMD_ST = 6 ATTACK_AREA_CMD_ST = 7 PATROL_CMD_ST = 8 HOLD_CMD_ST = 9 SKILL_OBJECT_CMD_ST = 10 SKILL_AREA_CMD_ST = 11 FOLLOW_CMD_ST = 12 FIXEDARTILLERY_ST = 13 SPR_ST = 14 ------------------------------ ResCmdList = {first = 0, last = -1} List = {} ActorsList = {} MyID = 0 MyOwner = GetV(V_OWNER,MyID) OwnerX, OwnerY = -1,-1 HomuX, HomuY = -1,-1 OwnerMotion = -1 HomuMotion = -1 OwnerTarget = 0 HomuTarget = 0 OwnerHPP = 0 HomuHPP = 0 HomuSPP = 0 Dis2OwnerHomu = 0 Dis4OwnerHomu = 0 GetTime = 0 MoveX, MoveY = -1,-1 LastDistance = 0 LastDistanceFlg = 0 MyState = IDLE_ST MyEnemy = 0 LastAttackEnemy = 0 AttackedFlag = 0 FlwMovItv = 0 MyMotionCancel = 0 CallFlag = 0 StcFlg = 0 StackList = {} PCList = {} MostPriorityList = {} PriorityList = {} IgnoreList = {} NoSkillList = {} FriendList = {} NeighborListCount = {} NeighborListTarget = {} IgnoreOwnerCount = 0 IgnoreOwnerList = {} OutRangePCList = {} SPrItv = 0 ResetMoveToOwnerItv = 0 ResetMoveToOwnerFlg = 0 FirstSkillDelayItv = 0 SkillDelayItv = 0 AsSkillDelay = 0 AsSkillCoolTime = {} GetPCItv = 0 ExitCheckItv = 0 StackTimeItv = 0 TimeStackEnemy = 0 StackCount = 0 ITCangeStatus = 0 StartTime = 0 NoDamageFlg = 0 NoDamageItv = 0 PatrolVector = 0 PatrolHomuItv = 0 PatrolX,PatrolY = -1,-1 PatrolHomuX,PatrolHomuY = -1,-1 CastlingItv = 0 GrazingVector = 0 GrazingMotionItv = 0 PDiceX,PDiceY = -1,-1 ExitEventX,ExitEventY = -1,-1 ExitTime = 0 AtkPriorityFlgTemp = 0 ZeroMCTerget = MyOwner THUseCount = 0 StartOwnerHPP = 0 StartHomuHPP = 0 --------------------------- TOUCH_OF_HEAL = 8001 EMERGENCY_AVOID = 8002 CASTLING = 8005 DEFENCE = 8006 BLOOD_LUST = 8008 MOONLIGHT = 8009 FLEET_MOVE = 8010 CAPRICE = 8013 CHAOTIC_VENEDICTION = 8014 --------------------------- SKILLDATA = {} SKILLDATA[TOUCH_OF_HEAL] = { {SP = 13,Delay = 20140,CoolTime = 0}, {SP = 16,Delay = 20140,CoolTime = 0}, {SP = 19,Delay = 20140,CoolTime = 0}, {SP = 22,Delay = 20140,CoolTime = 0}, {SP = 25,Delay = 20140,CoolTime = 0}, } SKILLDATA[EMERGENCY_AVOID] = { {SP = 20,Delay = 40000,CoolTime = 0}, {SP = 25,Delay = 35140,CoolTime = 0}, {SP = 30,Delay = 35140,CoolTime = 0}, {SP = 35,Delay = 35140,CoolTime = 0}, {SP = 40,Delay = 35140,CoolTime = 0}, } SKILLDATA[CASTLING] = { {SP = 10,Delay = 2000,CoolTime = 0}, {SP = 10,Delay = 2000,CoolTime = 0}, {SP = 10,Delay = 2000,CoolTime = 0}, {SP = 10,Delay = 2000,CoolTime = 0}, {SP = 10,Delay = 2000,CoolTime = 0}, } SKILLDATA[DEFENCE] = { {SP = 20,Delay = 39580,CoolTime = 0}, {SP = 25,Delay = 34580,CoolTime = 0}, {SP = 30,Delay = 30140,CoolTime = 0}, {SP = 35,Delay = 30140,CoolTime = 0}, {SP = 40,Delay = 30140,CoolTime = 0}, } SKILLDATA[BLOOD_LUST] = { {SP = 120,Delay = 300140,CoolTime = 0}, {SP = 120,Delay = 600140,CoolTime = 0}, {SP = 120,Delay = 900140,CoolTime = 0}, } SKILLDATA[MOONLIGHT] = { {SP = 4,Delay = 2340,CoolTime = 0}, {SP = 8,Delay = 2340,CoolTime = 0}, {SP = 12,Delay = 2340,CoolTime = 0}, {SP = 16,Delay = 2340,CoolTime = 0}, {SP = 20,Delay = 2340,CoolTime = 0}, } SKILLDATA[FLEET_MOVE] = { {SP = 30,Delay = 60140,CoolTime = 0}, {SP = 40,Delay = 70140,CoolTime = 0}, {SP = 50,Delay = 80140,CoolTime = 0}, {SP = 60,Delay = 90140,CoolTime = 0}, {SP = 70,Delay = 120140,CoolTime = 0}, } SKILLDATA[CAPRICE] = { {SP = 22,Delay = 2440,CoolTime = 0}, {SP = 24,Delay = 2590,CoolTime = 0}, {SP = 26,Delay = 2740,CoolTime = 0}, {SP = 28,Delay = 2840,CoolTime = 0}, {SP = 30,Delay = 3040,CoolTime = 0}, } SKILLDATA[CHAOTIC_VENEDICTION] = { {SP = 40,Delay = 3440,CoolTime = 0}, {SP = 40,Delay = 3440,CoolTime = 0}, {SP = 40,Delay = 3440,CoolTime = 0}, {SP = 40,Delay = 3440,CoolTime = 0}, {SP = 40,Delay = 3440,CoolTime = 0}, } ------------------------------ BOOSTSKILLDATA = {} BOOSTSKILLDATA[FLEET_MOVE] = {Lv = FleetMoveLv,HPP = FleetMoveHPP,Low = FMl,High = FMh} BOOSTSKILLDATA[DEFENCE] = {Lv = DeffenceLv ,HPP = DeffenceHPP ,Low = DFl,High = DFh} BOOSTSKILLDATA[BLOOD_LUST] = {Lv = BloodLustLv,HPP = BloodLustHPP,Low = BLl,High = BLh} ------------------------------ function List.pushleft (list, value) local first = list.first-1 list.first = first list[first] = value; end ------------------------------ function List.popleft (list) local first = list.first if (first > list.last) then return nil end local value = list[first] list[first] = nil list.first = first + 1 return value end ------------------------------ function List.clear (list) for i,v in ipairs(list) do list[i] = nil end list.first = 0 list.last = -1 end ------------------------------ function OnSKILL_OBJECT_CMD (level,skill,id) SkillObject(MyID,level,skill,id) end ------------------------------ function ProcessCommand (msg) if (msg[1] == MOVE_CMD) then OnMOVE_CMD (msg[2],msg[3]) elseif (msg[1] == SKILL_OBJECT_CMD) then OnSKILL_OBJECT_CMD (msg[2],msg[3],msg[4],msg[5]) elseif (msg[1] == FOLLOW_CMD) then OnFOLLOW_CMD () end end ------------------------------ function ReserveCommand (rmsg) local id = 0 local EnemyX, EnemyY = -1,-1 if (OwnerX == -1 or HomuX == -1) then return end if (rmsg[1] == MOVE_CMD) then EnemyX, EnemyY = rmsg[2],rmsg[3] id = GetXYID(EnemyX, EnemyY) elseif (rmsg[1] == ATTACK_OBJECT_CMD) then id = rmsg[2] EnemyX,EnemyY = GetV(V_POSITION,id) end if (id == MyOwner) then FriendList = FormatList() SaveList("Friend",FriendList) Move(MyID,OwnerX + math.random(-1,1),OwnerY +1) return elseif (IsPlayer(id) == 0 or IsHomunclus(id) == 0)then FriendList = AddList2(FriendList,id,0) SaveList("Friend",FormFriendList(FriendList)) Move (MyID,EnemyX,EnemyY - 1) return elseif (IsMob(id) == 0 and IsDead(id) == 1) then if (MyState == FOLLOW_CMD_ST) then if (OwnerMotion == MOTION_STAND) then NoSkillList = AddList2(NoSkillList,id,1) SaveList("NoSkill",NoSkillList) Move (MyID,OwnerX + 1,OwnerY) return elseif (OwnerMotion == MOTION_SIT) then MostPriorityList = AddList2(MostPriorityList,id,1) SaveList("MostPriority",MostPriorityList) Move (MyID,OwnerX - 1,OwnerY) return end else if (OwnerMotion == MOTION_STAND) then PriorityList = AddList2(PriorityList,id,1) SaveList("Priority",PriorityList) Move (MyID,OwnerX,OwnerY - 1) return elseif (OwnerMotion == MOTION_SIT) then IgnoreList = AddList2(IgnoreList,id,1) SaveList("Ignore",IgnoreList) Move (MyID,OwnerX - 1,OwnerY) return end end end end ------------------------------ function OnMOVE_CMD (x,y) if (math.abs(HomuX - x) + math.abs(HomuY - y) > 15) then List.pushleft(ResCmdList,{MOVE_CMD,x,y}) x = math.floor((HomuX + x) / 2) y = math.floor((HomuY + y) / 2) end Move(MyID,x,y) MoveX = x MoveY = y IsMoveCmdStack() MyState = MOVE_CMD_ST end ------------------------------ function OnMOVE_CMD_ST () IsMoveCmdStack() if (HomuX == MoveX and HomuY == MoveY) then MyState = IDLE_ST end end ------------------------------ function IsMoveCmdStack () if (HomuMotion == MOTION_DAMAGED or HomuMotion == MOTION_MOVE) then StcFlg = 0 StcItv = 0 elseif (StcFlg == 0 and HomuMotion == MOTION_STAND) then StcFlg = 1 StcItv = GetTick() elseif (StcFlg ~= 0 and GetTick() > StcItv + 550) then StcFlg = 0 List.clear (ResCmdList) MyState = IDLE_ST end end ------------------------------ function OnFOLLOW_CMD () if (MyState ~= FOLLOW_CMD_ST) then MyEnemy = 0 MyState = FOLLOW_CMD_ST SaveTime("OsTime",os.time()) elseif (FixedCPFlg == 0) then MyEnemy = 0 MyState = FIXEDARTILLERY_ST Move(MyID,OwnerX + math.random(-1,1),OwnerY +1) else ResetEnemy() end end ------------------------------ function OnFOLLOW_CMD_ST () if (Dis2OwnerHomu <= 2) then AsChaoticV() AsTouchOfHeal() elseif (OwnerMotion == MOTION_MOVE and GetTime > FlwMovItv + 450) then AsEAvoid() Move(MyID,OwnerX + math.random(-1,1),OwnerY +1) FlwMovItv = GetTime elseif (OwnerMotion == MOTION_STAND or OwnerMotion == MOTION_SIT or Dis4OwnerHomu >= 13) then MoveToOwner(MyID) end end ------------------------------ function OnIDLE_ST () if (CallFlag == 0) then CallFlag = 1 StartTime = GetTime StartOwnerHPP = OwnerHPP StartHomuHPP = HomuHPP MostPriorityList = LoadList("MostPriority") PriorityList = LoadList("Priority") IgnoreList = LoadList("Ignore") NoSkillList = LoadList("NoSkill") FriendList = LoadList("Friend") ExitTime = LoadTime("OsTime") if (FixedCPFlg == 0) then MyState = FIXEDARTILLERY_ST return end ITCangeStatus = IgnoreTarget AtkPriorityFlgTemp = AtkPriorityFlg end StackList = FormatList() StcFlg = 0 NoDamageItv = 0 NoDamageFlg = 0 if (GoFollow() == 0) then return end if (StartTime + 2000 > GetTime and (OwnerMotion ~= MOTION_ATTACK)) then return end local object = GetMyEnemyAB(SearchRange) if(object ~= 0) then MyEnemy = object BoostSkill() FirstSkillDelayItv = GetTime AsSkillAttack(AsSkillLv,MyEnemy) GoATTACK(MyEnemy) if (IsDead(MyEnemy) == 0) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) ResetEnemy() return elseif (SPrestoreFlg == 0) then SPrItv = GetTime MyState = SPR_ST return else MyState = CHASE_ST return end end AsChaoticV() AsTouchOfHeal() if (IsHomuType(MyID) == AMISTR and GrazingFlg == 0 and HomuHPP >= GrazingHPP and HomuSPP >= GrazingSPP and OwnerHPP >= GrazingOwnerHPP) then Grazing() elseif (PatrolFlg == 0 and HomuHPP >= PatrolHPP and HomuSPP >= PatrolSPP) then Kurukuru(PatrolRange) else ResetMoveToOwner(7) end end ------------------------------ function OnSPR_ST() if (GetTime > SPrItv + 4100 or GetV(V_SP,MyID) == GetV(V_MAXSP,MyID)) then MyState = CHASE_ST SPrItv = 0 return end if (GetDistance4(MyOwner,MyEnemy) > FBMNearOwner and SearchInPlayer(FBMInPlayer,MyEnemy) == 0) then if (HomuMotion == MOTION_MOVE) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) else MoveToOwner(MyID) end IsStack() GetEnemy() return end if (IsDead(MyEnemy) == 0) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) ResetEnemy() return end AsSkillAttack(AsSkillLv,MyEnemy) if (IsInAttackSight(MyEnemy) == 0) then Attack(MyID,MyEnemy) if (MotionCancel == 0) then AttackMotionCancel(MyEnemy) end end end ------------------------------ function OnFOLLOW_ST() if (Dis2OwnerHomu <= 3) then MyState = IDLE_ST elseif (OwnerMotion == MOTION_MOVE and GetTime > FlwMovItv + 450) then AsEAvoid() Move(MyID,OwnerX + math.random(-1,1),OwnerY +1) FlwMovItv = GetTime elseif (OwnerMotion == MOTION_STAND or OwnerMotion == MOTION_SIT) then MoveToOwner(MyID) MyState = IDLE_ST end end ------------------------------ function OnCHASE_ST () if (OutskirtMove(13) == 0) then IsStack() GetEnemy() return end if (GoFollow() == 0) then return end if ((GetDistance4(MyOwner,MyEnemy) > FBMNearOwner and (SearchInPlayer(FBMInPlayer,MyEnemy) == 0 or (GetDistance4(MyOwner,MyEnemy) >= 14 and 14 > SearchRange))) or GetDistance4(MyOwner,MyEnemy) == -1) then if (GetNearestActor2(MyEnemy,GetPlayer(2,FBMInPlayer,MyID)) ~= 0) then InsideMove(3) MoveToOwner(MyID) elseif (HomuMotion == MOTION_MOVE) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) end IsStack() GetEnemy() return end if (IsDead(MyEnemy) == 0) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) ResetEnemy() return end BoostSkill() AsSkillAttack(AsSkillLv,MyEnemy) if (GetDistance4(MyID,MyEnemy) > 4) then AsEAvoid() end if (IsInAttackSight(MyEnemy) == 0) then GoATTACK(MyEnemy) MyState = ATTACK_ST return end MoveToNear2(MyEnemy,AttackRange) IsMoveStack() end ------------------------------ function OnATTACK_ST () StackCount = 0 local object = GetMyEnemyAB(SearchRange) if(object ~= 0 and object ~= MyEnemy and (ChangeAttack == 0 or (ChangeAttack == 1 and IsDead(MyEnemy) == 0))) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) MyEnemy = object NoDamageItv = 0 NoDamageFlg = 0 BoostSkill() FirstSkillDelayItv = GetTime AsSkillAttack(AsSkillLv,MyEnemy) GoATTACK(MyEnemy) if (SPrestoreFlg == 0) then SPrItv = GetTime MyState = SPR_ST return else MyState = CHASE_ST return end end if (IsDead(MyEnemy) == 0) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) ResetEnemy() return end if (GoFollow() == 0) then return end AsChaoticV() AsTouchOfHeal() AsSkillAttack(AsSkillLv,MyEnemy) if (IsInAttackSight(MyEnemy) == 0) then AttackedFlag = 1 Attack(MyID,MyEnemy) if (MotionCancel == 0) then AttackMotionCancel(MyEnemy) end else MyState = CHASE_ST return end IsTimeStack(MyEnemy) IsNoDamageStack(MyEnemy) end ------------------------------ function OnFIXEDARTILLERY_ST () if (StartTime + 2000 > GetTime) then return end local object = GetMyEnemyAB(SearchRange) if(object ~= 0) then if (CVAttackFlg == 0) then AsChaoticV() end if (IsInAttackSight(object) == 0) then MyEnemy = object else AsSkillAttack(AsSkillLv,object) end else AsChaoticV() StackList = FormatList() return end AsTouchOfHeal() if (IsDead(MyEnemy) == 0) then MyEnemy = 0 return end AsSkillAttack(AsSkillLv,MyEnemy) if (IsInAttackSight(MyEnemy) == 0) then Attack(MyID,MyEnemy) if (MotionCancel == 0) then AttackMotionCancel(MyEnemy) end end IsTimeStack(MyEnemy) end ------------------------------ function GetMyEnemyAB (range) local ManyTargetActors = ActorsList local OwnerMonster = {} local OwnerMonsterIndex = 1 local BothMonster = {} local BothMonsterIndex = 1 local HomuMonster = {} local HomuMonsterIndex = 1 local ManyTargetEnemy = 1 local ManyTargetIndex = 1 local ManyTargetEnemyIndex = 1 local PriorityMonster = {} local PriorityMonsterIndex = 1 local MostPriorityMonster = {} local MostPriorityMonsterIndex = 1 local WaitMonster = 0 local BP ={} local BPIndex = 1 local FriendMonster = {} local FriendMonsterIndex = 1 local Monster = {} local MonsterIndex = 1 local Player = {} local PlayerIndex = 1 local Enemys = {} local EnemysIndex = 1 local NearEnemy = 0 local IgnoreOwnerCountTemp = 0 local IgnoreOwnerListTemp = {} local MineEscapeEnemy = 0 for i,v in ipairs(ActorsList) do if (IsDead(v) == 1 and MineEscapeFlg == 0 and MineEscape(v) == 0) then MineEscapeEnemy = 1 break end if (TyrannicalFlg == 1) then v = OutRangePC(v) end if (IsListIDChack(StackList,v) == 0 and IsDead(v) == 0) then StackList = DelList(StackList,v,0) end AutoRegFriend(v) if (IsDead(v) == 1 and MyOwner ~= v and MyID ~= v) then local VTargetEnemy = GetV(V_TARGET,v) IsDelStack(v) if (IsListIDChack(StackList,v) == 1) then if not (NoOwnerTarget == 1 and OwnerTarget == v) then if (TyrannicalFlg == 1 and (IsPlayer(v) == 0 or IsHomunclus(v) == 0) and IsListIDChack(FriendList,v) == 1) then Player[PlayerIndex] = v PlayerIndex = PlayerIndex + 1 elseif (NoOwnerTarget == 2 and OwnerTarget == v) then WaitMonster = v elseif (IsMob(v) == 0) then if (OwnerTarget == v or VTargetEnemy == MyOwner) then if (MyState ~= FIXEDARTILLERY_ST) then if (IgnoreTarget == 1 or (NoOwnerTarget == 0 and OwnerTarget == v)) then OwnerMonster[OwnerMonsterIndex] = v OwnerMonsterIndex = OwnerMonsterIndex + 1 elseif (IgnoreOwnerCount >= IgnoreTargetCnt or IgnoreOwnerCountTemp >= IgnoreTargetCnt) then if (ITRandomFlg == 0) then OwnerMonster[OwnerMonsterIndex] = v OwnerMonsterIndex = OwnerMonsterIndex + 1 elseif (IsListIDChack(IgnoreOwnerList,v) == 0 or IsListIDChack(IgnoreOwnerListTemp,v) == 0) then IgnoreOwnerListTemp = AddList(IgnoreOwnerListTemp,v) IgnoreOwnerCountTemp = IgnoreOwnerCountTemp + 1 else OwnerMonster[OwnerMonsterIndex] = v OwnerMonsterIndex = OwnerMonsterIndex + 1 end else IgnoreOwnerListTemp = AddList(IgnoreOwnerListTemp,v) IgnoreOwnerCountTemp = IgnoreOwnerCountTemp + 1 end else HomuMonster[HomuMonsterIndex] = v HomuMonsterIndex = HomuMonsterIndex + 1 end elseif ((MyState ~= IDLE_ST and HomuTarget == v) and (VTargetEnemy == MyID or (VTargetEnemy <= 0 and LastAttackEnemy == v))) then BothMonster[BothMonsterIndex] = v BothMonsterIndex = BothMonsterIndex + 1 elseif (VTargetEnemy == MyID or (HomuTarget == v and (TyrannicalFlg == 0 or (TyrannicalFlg == 1 and (VTargetEnemy <= 0 or IsListIDChack(FriendList,VTargetEnemy) == 0 or IsDead(VTargetEnemy) == 0 or IsMob(VTargetEnemy) == 0))))) then HomuMonster[HomuMonsterIndex] = v HomuMonsterIndex = HomuMonsterIndex + 1 end end if (LeadoffAttack == 0 and range >= GetDistance4(MyOwner,v) and HomuHPP >= AttackHPP) then if (ManyTargetFlg == 0 and TyrannicalFlg == 0) then ManyTargetIndex = GetTargetCountActor(v,ManyTargetActors) if (IsMob(v) == 0 and ManyTargetEnemyIndex < ManyTargetIndex) then ManyTargetEnemy = v ManyTargetEnemyIndex = ManyTargetIndex end end if (IsMob(v) == 0 and IsHerb(v) == 1 and (TyrannicalFlg == 0 or (TyrannicalFlg == 1 and (VTargetEnemy <= 0 or VTargetEnemy == MyID or (OwnerTarget == v and NoOwnerTarget == 0) or VTargetEnemy == MyOwner or IsListIDChack(FriendList,VTargetEnemy) == 0 or IsDead(VTargetEnemy) == 0 or IsMob(VTargetEnemy) == 0)))) then if (IsListTypeChack(MostPriorityList,v) == 0) then MostPriorityMonster[MostPriorityMonsterIndex] = v MostPriorityMonsterIndex = MostPriorityMonsterIndex + 1 end if (IsListTypeChack(PriorityList,v) == 0) then PriorityMonster[PriorityMonsterIndex] = v PriorityMonsterIndex = PriorityMonsterIndex + 1 end if (FriendTarget == 0 and IsListIDChack(FriendList,VTargetEnemy) == 0) then FriendMonster[FriendMonsterIndex] = v FriendMonsterIndex = FriendMonsterIndex + 1 end if (IsListTypeChack(IgnoreList,v) == 1 and IsBioplant(v) == 1 and IsListIDChack(IgnoreOwnerList,v) ~= 0 and IsListIDChack(IgnoreOwnerListTemp,v) ~= 0) then Monster[MonsterIndex] = v MonsterIndex = MonsterIndex + 1 end if (AttackBioplant == 0 and IsBioplant(v) == 0) then BP[BPIndex] = v BPIndex = BPIndex + 1 end end end end end end end IgnoreOwnerList = IgnoreOwnerListTemp IgnoreOwnerCount = IgnoreOwnerCountTemp if (TyrannicalFlg == 1 and PlayerIndex > 1) then for i,v in ipairs(Monster) do local dis_player = 100 dis_player = GetDistance2(v,GetNearestActor2(v,Player)) if ((-1 < dis_player and FBMInPlayer <= dis_player) or GetDistance4(MyOwner,v) <= FBMNearOwner) then Enemys[EnemysIndex] = v EnemysIndex = EnemysIndex + 1 end end else Enemys = Monster EnemysIndex = MonsterIndex end if (MineEscapeEnemy == 0) then if (MostPriorityMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(MostPriorityMonster)),4) elseif (AtkPriorityFlg ~= 1 and OwnerMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(PriorityChack(OwnerMonster))),0) elseif (AtkPriorityFlg == 2 and FriendMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(FriendMonster)),6) elseif (ManyTargetEnemyIndex > 1) then NearEnemy = ManyTargetEnemy elseif (BothMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(BothMonster)),1) elseif (HomuMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(PriorityChack(HomuMonster))),2) elseif (AtkPriorityFlg == 1 and OwnerMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(PriorityChack(OwnerMonster))),0) elseif (WaitMonster > 0) then NearEnemy = WaitMonster elseif (PriorityMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(PriorityMonster)),3) elseif (AtkPriorityFlg ~= 2 and FriendMonsterIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(FriendMonster)),6) elseif (EnemysIndex > 1) then NearEnemy = AttackPriority(MyEnemy,GetNearestActor2(MyID,GetOwnerNearestActor(Enemys)),5) elseif (BPIndex > 1) then NearEnemy = GetNearestActor2(MyID,GetOwnerNearestActor(BP)) end if (NearEnemy > 0) then LastAttackEnemy = NearEnemy return NearEnemy end else ResetEnemy() return 0 end return 0 end ------------------------------ function AttackPriority (enemy,newenemy,no) local Monster = newenemy if (IsDead(enemy) == 1 and enemy ~= 0 and enemy ~= newenemy) then if (no == 0 and (NoOwnerTarget ~= 2 or (NoOwnerTarget == 2 and OwnerTarget ~= enemy)) and (OwnerTarget == enemy or GetV(V_TARGET,enemy) == MyOwner)) then Monster = enemy elseif (no == 1 and (GetV(V_TARGET,enemy) == MyID or GetV(V_TARGET,enemy) == MyOwner)) then Monster = enemy elseif (no == 2 and (NoOwnerTarget ~= 2 or (NoOwnerTarget == 2 and OwnerTarget ~= enemy)) and (HomuTarget == enemy or GetV(V_TARGET,enemy) == MyID or GetV(V_TARGET,enemy) <= 0 or GetV(V_TARGET,enemy) == MyOwner)) then Monster = enemy elseif (no == 3 and IsListTypeChack(PriorityList,enemy) == 0 and GetV(V_HOMUNTYPE,enemy) == GetV(V_HOMUNTYPE,newenemy)) then Monster = enemy elseif (no == 4 and IsListTypeChack(MostPriorityList,enemy) == 0 and GetV(V_HOMUNTYPE,enemy) == GetV(V_HOMUNTYPE,newenemy)) then Monster = enemy elseif (no == 5 and IsDead(HomuTarget) == 0) then Monster = enemy elseif (no == 6 and IsListTypeChack(FriendList,GetV(V_TARGET,enemy)) == 0) then Monster = enemy end end return Monster end ------------------------------ function GoATTACK (enemy) if (IsInAttackSight(enemy) == 0 and (TyrannicalFlg == 0 or GetDistance4(MyOwner,enemy) <= FBMNearOwner or GetNearestActor2(enemy,GetPlayer(2,FBMInPlayer,MyID)) == 0)) then AttackedFlag = 1 Attack(MyID,enemy) if (MotionCancel == 0) then AttackMotionCancel(enemy) end end end ------------------------------ function GoFollow () local Distance = Dis4OwnerHomu if (Dis2OwnerHomu > FollowDistance and OwnerMotion == MOTION_MOVE and Distance > LastDistance) then AsEAvoid() MoveToOwner(MyID) MyState = FOLLOW_ST LastDistance = Distance return 0 end LastDistance = Distance return 1 end ------------------------------ function AsSkillAttack (SkillLv,Enemy) local SkillType = 0 if (IsHomuType(MyID) == VANILMIRTH) then SkillType = CAPRICE elseif (IsHomuType(MyID) == FILIR) then SkillType = MOONLIGHT else return end if (SkillType ~= 0 and IsListTypeChack(NoSkillList,Enemy) ~= 0 and GetV(V_SP,MyID) >= SKILLDATA[SkillType][SkillLv].SP and AsSl <= HomuSPP and HomuSPP <= AsSh and GetTime > SkillDelayItv + AsSkillDelay and (GetTime < FirstSkillDelayItv + 450 or GetTime > FirstSkillDelayItv + FirstSkillDelay * 1000)) then AsProbability = math.floor(HomuSPP *0.15 * HomuSPP /15 + (100 - HomuHPP) * (100 - HomuHPP) *0.02 + (GetTargetCountActor2(ActorsList) -1) *6) if (AsProbability <= 0) then AsProbability = 1 end if (14 >= GetDistance4(MyID,Enemy) and (AsProbability >= math.random(1,100) or HomuSPP >= 100 or MyState == FIXEDARTILLERY_ST)) then if (SkillLvControl == 0) then SkillLv = math.ceil(HomuSPP / 20) if (1 > SkillLv) then SkillLv = 1 end end SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[SkillType][SkillLv].Delay SkillObject (MyID,SkillLv,SkillType,Enemy) end end end ------------------------------ function AsEAvoid () local SkillType = 0 local SkillLv = EAvoidLv if (IsHomuType(MyID) == LIF and AsEAvoidFlg == 0) then SkillType = EMERGENCY_AVOID if (GetV(V_SP,MyID) >= SKILLDATA[SkillType][SkillLv].SP and EAl <= HomuSPP and HomuSPP <= EAh and GetTime > SkillDelayItv + AsSkillDelay) then SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[SkillType][SkillLv].Delay SkillObject(MyID,SkillLv,SkillType,MyID) end end end ------------------------------ function AsTouchOfHeal () local SkillType = 0 local SkillLv = 0 if (IsHomuType(MyID) == LIF and AsTHFlg == 0 and THHPP > OwnerHPP and THCount > THUseCount) then SkillType = TOUCH_OF_HEAL SkillLv = THLv else return end if (SkillType ~= 0 and ((GetV(V_SP,MyID) >= SKILLDATA[SkillType][SkillLv].SP and THh >= HomuSPP and HomuSPP >= THl) and GetTime > SkillDelayItv + AsSkillDelay)) then THUseCount = THUseCount +1 SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[SkillType][SkillLv].Delay SkillObject(MyID,SkillLv,SkillType,MyID) end end ------------------------------ function AsChaoticV () local SkillType = 0 local SkillLv = 0 if (IsHomuType(MyID) == VANILMIRTH and AsCVFlg == 0 and (MyState ~= ATTACK_ST or (CVAttackFlg == 0 and MyState == ATTACK_ST))) then if (CVComplete == 0 and HomuSPP >= 100 and (MyState == IDLE_ST or MyState == FOLLOW_CMD_ST) and IgnoreOwnerCount == 0) then if (100 > OwnerHPP) then SkillLv = CVOwnerLv elseif (100 > HomuHPP) then SkillLv = CVHomuLv end elseif ((CVPriority == 0 and CVOwnerHPP > OwnerHPP) or (CVPriority == 1 and HomuHPP > CVHomuHPP and CVOwnerHPP > OwnerHPP)) then SkillLv = CVOwnerLv elseif (CVHomuHPP > HomuHPP) then SkillLv = CVHomuLv end if (SkillLv ~= 0) then SkillType = CHAOTIC_VENEDICTION end else return end if (SkillType ~= 0 and ((GetV(V_SP,MyID) >= SKILLDATA[SkillType][SkillLv].SP and CVh >= HomuSPP and HomuSPP >= CVl) and GetTime > SkillDelayItv + AsSkillDelay)) then SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[SkillType][SkillLv].Delay SkillObject(MyID,SkillLv,SkillType,MyID) end end ------------------------------ function BoostSkill () local UseSkill = 0 local SkillType = {FLEET_MOVE,DEFENCE,BLOOD_LUST} local SkillLv = 0 for i,v in ipairs(SkillType) do if (AsSkillCoolTime[v] == nil) then AsSkillCoolTime[v] = 0 end if (((IsHomuType(MyID) == FILIR and v == FLEET_MOVE and AsFleetMoveFlg == 0) or (IsHomuType(MyID) == AMISTR and ((v == DEFENCE and AsDeffenceFlg == 0) or (v == BLOOD_LUST and AsBloodLustFlg == 0)))) and GetV(V_SP,MyID) >= SKILLDATA[v][BOOSTSKILLDATA[v].Lv].SP and BOOSTSKILLDATA[v].HPP >= HomuHPP and BOOSTSKILLDATA[v].Low <= HomuSPP and HomuSPP <= BOOSTSKILLDATA[v].High and GetTime > SkillDelayItv + AsSkillDelay and GetTime > AsSkillCoolTime[v] + SKILLDATA[v][BOOSTSKILLDATA[v].Lv].CoolTime) then UseSkill = v SkillLv = BOOSTSKILLDATA[v].Lv end end if (UseSkill ~= 0) then SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[UseSkill][SkillLv].Delay AsSkillCoolTime[UseSkill] = GetTime SkillObject (MyID,SkillLv,UseSkill,MyID) end end ------------------------------ function Grazing() local WPdistance = GetWPDistance(ActorsList,MyID) local GrazingDis = 8 local SkillLv = 5 local SkillType = 0 if (IsHomuType(MyID) == AMISTR) then SkillType = CASTLING else return end if (SkillType ~= 0 and GetV(V_SP,MyID) >= SKILLDATA[SkillType][SkillLv].SP and GetTime > SkillDelayItv + AsSkillDelay and HomuMotion ~= MOTION_MOVE) then if (OwnerMotion == MOTION_MOVE or OwnerMotion == MOTION_PICKUP or OwnerMotion == MOTION_ATTACK or OwnerMotion == MOTION_SKILL or OwnerMotion == MOTION_CASTING) then GrazingMotionItv = GetTime end if (Dis4OwnerHomu >= GrazingDis and GetTime > GrazingMotionItv + 5000 and (WPdistance >= 5 or WPdistance == -1)) then CastlingItv = GetTime SkillDelayItv = GetTime AsSkillDelay = SKILLDATA[SkillType][SkillLv].Delay if (OwnerX > PDiceX and OwnerY > PDiceY) then GrazingVector = 2 elseif (OwnerX < PDiceX and OwnerY > PDiceY) then GrazingVector = 3 elseif (OwnerX < PDiceX and OwnerY < PDiceY) then GrazingVector = 0 elseif (OwnerX > PDiceX and OwnerY < PDiceY) then GrazingVector = 1 end SkillObject(MyID,SkillLv,SkillType,MyID) else GrazingMove() end end if (GetTime < CastlingItv + 450) then ExitEventX,ExitEventY = OwnerX, OwnerY InsideMove(4) MoveToOwner(MyID) end end ------------------------------ function GrazingMove () local WPdistance = GetWPDistance(ActorsList,MyID) local DisA,DisB = 8,13 local DisAtemp,DisBtemp = DisA,DisB for i = 1,100 do if (math.random(0,19) == 0) then DisA = math.floor(DisAtemp / 2) DisB = math.floor(DisAtemp / 2 + math.random(1,2)) else DisA = DisAtemp DisB = DisBtemp end local Xi = math.random(1,4) if (Xi == 1) then PDiceX = OwnerX + math.random(DisA,DisB) PDiceY = OwnerY + math.random(-DisBtemp,DisBtemp) elseif (Xi == 2) then PDiceX = OwnerX + math.random(-DisB,-DisA) PDiceY = OwnerY + math.random(-DisBtemp,DisBtemp) elseif (Xi == 3) then PDiceX = OwnerX + math.random(-DisBtemp,DisBtemp) PDiceY = OwnerY + math.random(DisA,DisB) elseif (Xi == 4) then PDiceX = OwnerX + math.random(-DisBtemp,DisBtemp) PDiceY = OwnerY + math.random(-DisB,-DisA) end local dis_player = GetDistance(PDiceX,PDiceY,GetNearestActor(PDiceX,PDiceY,GetPlayer(0,14,MyOwner))) if (14 >= GetDistance3(OwnerX,OwnerY,PDiceX,PDiceY) and HomuX ~= PDiceX and HomuY ~= PDiceY and (WPdistance >= 5 or WPdistance == -1) and (dis_player > GrazingNearPC or dis_player == -1)) then if (GrazingVector == 0) then if not (OwnerX > PDiceX and OwnerY > PDiceY) then break end elseif (GrazingVector == 1) then if not (OwnerX < PDiceX and OwnerY > PDiceY) then break end elseif (GrazingVector == 2) then if not (OwnerX < PDiceX and OwnerY < PDiceY) then break end elseif (GrazingVector == 3) then if not (OwnerX > PDiceX and OwnerY < PDiceY) then break end end end if (i == 100) then if (5 > WPdistance) then InsideMove(4) MoveToOwner (MyID) else PDiceX,PDiceY = HomuX,HomuY end GrazingVector = math.random(0,3) break end end if (HomuMotion ~= MOTION_MOVE) then if (14 < GetDistance3(HomuX,HomuY,PDiceX,PDiceY)) then Move(MyID,math.floor((HomuX + PDiceX) / 2) ,math.floor((HomuY + PDiceY) / 2)) else Move(MyID,PDiceX,PDiceY) end end end ------------------------------ function AttackMotionCancel (enemy) if (MyState == ATTACK_ST and (Dis4OwnerHomu >= 13 or (Dis4OwnerHomu >= 12 and 14 > GetDistance4(MyOwner,MyEnemy)))) then InsideMove(2) else local enemyX,enemyY = GetV(V_POSITION,enemy) if(MyState == ATTACK_ST and ZeroMC_HPP < HomuHPP and ZeroMC_SPP < HomuSPP and 11 >= Dis4OwnerHomu) then if(MyMotionCancel == 0) then Move(MyID,enemyX + 1,enemyY) MyMotionCancel = 1 elseif(MyMotionCancel == 1) then Move(MyID,enemyX,enemyY + 1) MyMotionCancel = 2 elseif(MyMotionCancel == 2) then Move(MyID,enemyX - 1,enemyY) MyMotionCancel = 3 elseif(MyMotionCancel == 3) then Move(MyID,enemyX,enemyY - 1) MyMotionCancel = 0 end return end if (ZeroMC == 0) then if not (NoDamageFlg == 1 and GetTime > NoDamageItv + 2000) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) end end end end ------------------------------ function OutRangePC (enemy) local VTargetEnemy = GetV(V_TARGET,enemy) local EnemyMotion = GetV(V_MOTION,enemy) if (VTargetEnemy > 100000 and GetV(V_MOTION,VTargetEnemy) == -1) then if (EnemyMotion == MOTION_ATTACK or EnemyMotion == DAMAGED or EnemyMotion == MOTION_SKILL or EnemyMotion == MOTION_CASTING or OutRangePCList[enemy] == nil) then OutRangePCList[enemy] = GetTime return -1 elseif(GetTime > OutRangePCList[enemy] + 1950 or OutRangePCList[enemy] == 0 or enemy == -1) then OutRangePCList[enemy] = 0 return enemy else return -1 end else OutRangePCList[enemy] = nil return enemy end end ------------------------------ function IsMoveStack () local VTargetEnemy = GetV(V_TARGET,MyEnemy) if (StcFlg ~= 2 and (HomuMotion == MOTION_DAMAGED or HomuMotion == MOTION_MOVE)) then StcFlg = 0 elseif (StcFlg == 0 and HomuMotion == MOTION_STAND) then StcFlg = 1 elseif (StcFlg == 1) then StcFlg = 2 if (StackCount <= 10) then if (4 >= GetDistance4(MyOwner,MyEnemy) or 5 >= GetDistance4(MyID,MyEnemy)) then if (math.mod(StackCount,2) == 0) then InsideMove(2) else MoveToOwner(MyID) end else if (math.mod(StackCount,2) == 0) then MiddleMove(MyEnemy) else RandomMove(MyEnemy,2,5) end end elseif (StackCount <= 20) then if (4 >= GetDistance4(MyOwner,MyEnemy)) then if (math.mod(StackCount,2) == 0) then RandomMove(MyID,2,5) else MoveToOwner(MyID) end else if (math.mod(StackCount,2) == 0) then RandomMove(MyID,2,5) else RandomMove(MyEnemy,2,5) end end elseif (StackCount <= 30) then if (4 >= GetDistance4(MyOwner,MyEnemy)) then if (math.mod(StackCount,2) == 0) then InsideMove(3) else MoveToOwner(MyID) end else if (math.mod(StackCount,2) == 0) then MiddleMove(MyEnemy) else RandomMove(MyID,1,8) end end else WideRandomMove() end StackCount = StackCount + 1 end if (StcFlg == 2) then StcFlg = 0 IsStack() GetEnemy() elseif (IsDelStackDis() == 0) then Move(MyID,GetV(V_POSITION,ZeroMCTerget)) GetEnemy() end end ------------------------------ function IsStack () StackList = AddList(StackList,MyEnemy) MyEnemy = 0 end ------------------------------ function GetEnemy () IsDelStackDis() local object = GetMyEnemyAB(SearchRange) if(object ~= 0) then MyEnemy = object NoDamageItv = 0 NoDamageFlg = 0 FirstSkillDelayItv = GetTime AsSkillAttack(AsSkillLv,MyEnemy) GoATTACK(MyEnemy) MyState = CHASE_ST else MyState = IDLE_ST end end ------------------------------ function IsTimeStack (Enemy) if (TimeStackEnemy == Enemy and GetTime > StackTimeItv + StackTime * 1000) then if not (GetV(V_TARGET,MyEnemy) == MyID and IsInAttackSight(v) == 0) then StackList = AddList(StackList,Enemy) MyEnemy = 0 TimeStackEnemy = 0 StackTimeItv = 0 if (MyState ~= FIXEDARTILLERY_ST) then MoveToOwner (MyID) if (HomuMotion ~= MOTION_MOVE) then InsideMove(2) end end end elseif(TimeStackEnemy ~= Enemy or TimeStackEnemy == 0) then TimeStackEnemy = Enemy StackTimeItv = GetTime if (IsListIDChack(StackList,Enemy) == 0) then StackList = DelList(StackList,Enemy,0) end end end ------------------------------ function IsNoDamageStack (Enemy) if (GetV(V_MOTION,Enemy) ~= MOTION_DAMAGED and IsInAttackSight(MyEnemy) == 0) then if (NoDamageFlg == 0) then NoDamageItv = GetTime NoDamageFlg = 1 elseif (NoDamageFlg == 1 and GetTime > NoDamageItv + (NoDamageStcTime * 1000) and HomuMotion ~= MOTION_MOVE) then if (OutskirtMove(13) == 0) then NoDamageItv = 0 NoDamageFlg = 0 IsStack() GetEnemy() return end local range = 2 if(MyMotionCancel == 0) then Move(MyID,HomuX,HomuY - range) MyMotionCancel = 1 elseif(MyMotionCancel == 1) then Move(MyID,HomuX + range,HomuY) MyMotionCancel = 2 elseif(MyMotionCancel == 2) then Move(MyID,HomuX,HomuY + range) MyMotionCancel = 3 elseif(MyMotionCancel == 3) then Move(MyID,HomuX - range,HomuY) MyMotionCancel = 0 end end else NoDamageFlg = 0 end end ------------------------------ function IsDelStack (Enemy) local VTargetEnemy = GetV(V_TARGET,Enemy) local dis = GetDistance4(MyID,Enemy) if (Dis4OwnerHomu <= 1)then StackList = FormatList() elseif (IsListIDChack(StackList,Enemy) == 0 and ((VTargetEnemy == MyID and IsInAttackSight(Enemy) == 0) or (DefenseTarget == 0 and (OwnerTarget == Enemy or VTargetEnemy == MyOwner)) or (0 <= dis and dis <= 1))) then StackList = DelList(StackList,Enemy,0) MyEnemy = 0 end end ------------------------------ function IsDelStackDis () local flg = 0 for i,v in ipairs(ActorsList) do local dis = GetDistance4(MyID,v) if (IsListIDChack(StackList,v) == 0 and 0 <= dis and dis <= 1) then flg = 1 StackList = DelList(StackList,v,0) end end if (flg == 1) then return 0 else return 1 end end ------------------------------ function IsInAttackSight (id) if (id == nil) then return 1 end local range = GetDistance4(MyID,id) if (2 >= range and range >= 0) then return 0 else return 1 end end ------------------------------ function IsPlayer (id) if (id < 100000) then return 1 end local etype = GetV(V_HOMUNTYPE,id) if ( 0 <= etype and etype <= 25) then return 0 elseif (4001 <= etype and etype <= 4049) then return 0 elseif (4054 <= etype and etype <= 4087) then return 0 elseif (4211 <= etype and etype <= 4212) then return 0 else return 1 end end ------------------------------ function IsNPC (id) local etype = GetV(V_HOMUNTYPE,id) if (etype <= 1000 and IsPlayer(id) == 1 and IsHomunclus(id) == 1) then return 0 else return 1 end end ------------------------------ function IsMob (id) if (IsMonster(id) == 1 and id < 100000 and IsNPC(id) == 1) then return 0 else return 1 end end ------------------------------ function IsHomunclus (id) local etype = GetV(V_HOMUNTYPE,id) if (id < 0 or 65535 < id) then return 1 elseif (etype >= 1 and etype <= 16 and IsMonster(id) == 0) then return 0 else return 1 end end ------------------------------ function IsBioplant (id) local etype = GetV(V_HOMUNTYPE,id) if (etype == 1579 or etype == 1589 or etype == 1575 or etype == 1555 or etype == 1590 or (2042 <= etype and etype <= 2046)) then return 0 else return 1 end end ------------------------------ function IsHerb (id) local etype = GetV(V_HOMUNTYPE,id) if (1078 <= etype and etype <= 1085) then return 0 else return 1 end end ------------------------------ function IsHomuType (id) local etype = GetV (V_HOMUNTYPE,id) if (etype == VANILMIRTH or etype == VANILMIRTH_H or etype == VANILMIRTH2 or etype == VANILMIRTH_H2) then return VANILMIRTH elseif (etype == LIF or etype == LIF_H or etype == LIF2 or etype == LIF_H2) then return LIF elseif (etype == FILIR or etype == FILIR_H or etype == FILIR2 or etype == FILIR_H2) then return FILIR elseif (etype == AMISTR or etype == AMISTR_H or etype == AMISTR2 or etype == AMISTR_H2) then return AMISTR else return 0 end end ------------------------------ function IsHomu_HType (id) local etype = GetV (V_HOMUNTYPE,id) if (etype == VANILMIRTH_H or etype == VANILMIRTH_H2) then return VANILMIRTH elseif (etype == LIF_H or etype == LIF_H2) then return LIF elseif (etype == FILIR_H or etype == FILIR_H2) then return FILIR elseif (etype == AMISTR_H or etype == AMISTR_H2) then return AMISTR else return 0 end end ------------------------------ function IsDead (id) local motion = GetV(V_MOTION,id) if (motion == -1 or motion == MOTION_DEAD or GetDistance2(MyOwner,id) == -1 or GetV(V_HOMUNTYPE,id) <= 0 or id <= 0 or 100000 - LastAttackEnemy == id) then return 0 else return 1 end end ------------------------------ function ResetEnemy () MyEnemy = 0 MyState = IDLE_ST ResetMoveToOwnerFlg = 0 end ------------------------------ function GetHPP (id) local HPP = 0 HPP = GetV(V_HP,id) / GetV(V_MAXHP,id) * 100 if (HPP > 100) then HPP = 100 end return HPP end ------------------------------ function GetSPP (id) local SPP = 0 SPP = GetV(V_SP,id) / GetV(V_MAXSP,id) * 100 if (SPP > 100) then SPP = 100 end return SPP end ------------------------------ function GetTargetCountActor (id,actors) local index = 1 for i,v in ipairs(actors) do if (v ~= MyOwner and v ~= MyID and (IsPlayer(v) == 0 or IsHomunclus(v) == 0) and GetV(V_TARGET,v) == id) then index = index + 1 end end return index end ------------------------------ function GetTargetCountActor2 (actors) local count = 0 for i,v in ipairs(actors) do if (v ~= MyOwner and v ~= MyID and IsMob(v) == 0 and (GetV(V_TARGET,v) == MyID or GetV(V_TARGET,v) == MyOwner)) then count = count + 1 end end return count end ------------------------------ function GetPlayer (type,range,id) local players = {} local index = 1 for i,v in ipairs(ActorsList) do if (v ~= MyOwner and v ~= MyID and IsDead(v) == 1 and range >= GetDistance4(id,v) and IsListIDChack(FriendList,v) == 1) then if (type == 0 and IsPlayer(v) == 0) then players[index] = v index = index + 1 elseif (type == 1 and IsHomunclus(v) == 0) then players[index] = v index = index + 1 elseif (type == 2 and (IsPlayer(v) == 0 or IsHomunclus(v) == 0)) then players[index] = v index = index + 1 end end end return players end ------------------------------ function GetNearestActor (x,y,actors) local result = 0 local min_dis = 100 local dis = 100 for i,v in ipairs(actors) do dis = GetDistance(x,y,GetV(V_POSITION,v)) if (dis < min_dis and dis ~= -1) then result = v min_dis = dis end end return result end ------------------------------ function GetNearestActor2 (id,actors) local result = 0 local min_dis = 100 local dis = 100 for i,v in ipairs(actors) do dis = GetDistance2(id,v) if (dis < min_dis and dis ~= -1) then result = v min_dis = dis end end return result end ------------------------------ function GetOwnerNearestActor (actors) local result = 0 local min_dis = 100 local dis = 0 local monstor = {} local index = 1 if (AttackNearOwner == 0) then for i,v in ipairs(actors) do dis = GetDistance2(MyOwner,v) if (dis < min_dis and dis ~= -1) then result = v min_dis = dis end end end if (result ~= 0) then for i,v in ipairs(actors) do dis = GetDistance2(MyOwner,v) if (dis == min_dis) then monstor[index] = v index = index + 1 end end return monstor else return actors end end ------------------------------ function PriorityChack (actors) local monstor = {} local index = 1 for i,v in ipairs(actors) do if (IsListTypeChack(PriorityList,v) == 0) then monstor[index] = v index = index + 1 end end if (index > 1) then return monstor else return actors end end ------------------------------ function GetXYID(dx,dy) local players = 0 for i,v in ipairs(ActorsList) do local x,y = GetV(V_POSITION,v) if (x == dx and y == dy) then players = v break end end return players end ------------------------------ function GetDistance (x1,y1,x2,y2) if (x1 == -1 or x2 == -1 or y1 == nil or y2 == nil) then return -1 end return math.floor(math.sqrt((x1-x2)^2+(y1-y2)^2)) end ------------------------------ function GetDistance2 (id1, id2) local x1,y1 = GetV(V_POSITION,id1) local x2,y2 = GetV(V_POSITION,id2) if (x1 == -1 or x2 == -1) then return -1 end return GetDistance (x1,y1,x2,y2) end ------------------------------ function GetDistance3 (x1,y1,x2,y2) if (x1 == -1 or x2 == -1 or y1 == nil or y2 == nil) then return -1 end return math.max(math.abs(x1 - x2),math.abs(y1 - y2)) end ------------------------------ function GetDistance4 (id1,id2) local x1,y1 = GetV(V_POSITION,id1) local x2,y2 = GetV(V_POSITION,id2) if (x1 == -1 or x2 == -1) then return -1 end return GetDistance3 (x1,y1,x2,y2) end ------------------------------ function GetWPDistance (List,id) for i, v in ipairs(List) do if (GetV(V_HOMUNTYPE,v) == 45) then return GetDistance4(v,id) end end return -1 end ------------------------------ function MoveToNear (enemy,dis) local EnemyX,EnemyY = GetV (V_POSITION,enemy) local DisX,DisY = EnemyX, EnemyY if (EnemyX > HomuX) then DisX = EnemyX - dis elseif (EnemyX < HomuX) then DisX = EnemyX + dis end if (EnemyY > HomuY) then DisY = EnemyY - dis elseif (EnemyY < HomuY) then DisY = EnemyY + dis end Move(MyID,DisX,DisY) end ------------------------------ function MoveToNear2 (id,dis) local EnemyX,EnemyY = GetV(V_POSITION,id) local DisX,DisY = HomuX,HomuY local distance = 12 if (GetDistance4(MyOwner,id) >= distance + 1) then if (Dis4OwnerHomu >= distance) then if (math.abs(OwnerX - EnemyX) > math.abs(OwnerY - EnemyY)) then if (EnemyX > OwnerX) then DisX = OwnerX + distance DisY = math.floor((EnemyY + HomuY) / 2) elseif (EnemyX < OwnerX) then DisX = OwnerX - distance DisY = math.floor((EnemyY + HomuY) / 2) end else if (EnemyY > OwnerY) then DisX = math.floor((EnemyX + HomuX) / 2) DisY = OwnerY + distance elseif (EnemyY < OwnerY) then DisX = math.floor((EnemyX + HomuX) / 2) DisY = OwnerY - distance end end else if (math.abs(OwnerX - EnemyX) > math.abs(OwnerY - EnemyY)) then if (EnemyX > OwnerX) then DisX = OwnerX + distance DisY = EnemyY elseif (EnemyX < OwnerX) then DisX = OwnerX - distance DisY = EnemyY end else if (EnemyY > OwnerY) then DisX = EnemyX DisY = OwnerY + distance elseif (EnemyY < OwnerY) then DisX = EnemyX DisY = OwnerY - distance end end end Move(MyID,DisX,DisY) else MoveToNear(id,dis) end end ------------------------------ function MiddleMove (id) local EnemyX,EnemyY = GetV(V_POSITION,id) Move(MyID,math.floor((EnemyX + HomuX) / 2),math.floor((EnemyY + HomuY) / 2)) end ------------------------------ function ResetMoveToOwner(range) if (Dis2OwnerHomu > range and HomuHPP >= RmtoHPP and HomuSPP >= RmtoSPP) then if (ResetMoveToOwnerFlg == 0) then ResetMoveToOwnerFlg = 1 ResetMoveToOwnerItv = GetTime elseif (GetTime > ResetMoveToOwnerItv + 1000 and ResetMoveToOwnerFlg == 1) then ResetMoveToOwnerFlg = 0 MoveToOwner (MyID) end end end ------------------------------ function InsideMove (range) local DiceX,DiceY = -1,-1 if (math.abs(OwnerX - HomuX) > math.abs(OwnerY - HomuY)) then if (OwnerX < HomuX) then Move(MyID,HomuX - 1,HomuY) elseif (OwnerX > HomuX) then Move(MyID,HomuX + 1,HomuY) end else if (OwnerY < HomuY) then Move(MyID,HomuX,HomuY - 1) elseif (OwnerY > HomuY) then Move(MyID,HomuX,HomuY + 1) end end if (HomuMotion ~= MOTION_MOVE) then for i = 1,100 do if (math.abs(OwnerX - HomuX) > math.abs(OwnerY - HomuY)) then if (OwnerX < HomuX) then DiceX,DiceY = HomuX - math.random(range),HomuY + math.random(-range,range) elseif (OwnerX > HomuX) then DiceX,DiceY = HomuX + math.random(range),HomuY + math.random(-range,range) end else if (OwnerY < HomuY) then DiceX,DiceY = HomuX + math.random(-range,range),HomuY - math.random(range) elseif (OwnerY > HomuY) then DiceX,DiceY = HomuX + math.random(-range,range),HomuY + math.random(range) end end if (14 >= GetDistance3(OwnerX,OwnerY,DiceX,DiceY)) then break end if (i == 100) then DiceX,DiceY = OwnerX,OwnerY break end end Move(MyID,DiceX,DiceY) end end ------------------------------ function OutskirtMove (Dis) local Distance = Dis4OwnerHomu if (Dis <= Dis4OwnerHomu) then if (LastDistanceFlg > 0) then LastDistanceFlg = LastDistanceFlg + 1 MoveToOwner(MyID) if (LastDistanceFlg > 5) then LastDistanceFlg = 0 end elseif (OwnerMotion == MOTION_MOVE and Distance > LastDistance) then LastDistanceFlg = LastDistanceFlg + 1 MoveToOwner(MyID) else Move(MyID,GetV(V_POSITION,ZeroMCTerget)) InsideMove(2) LastDistance = Distance end else LastDistance = Distance return 1 end return 0 end ------------------------------ function WideRandomMove () local DiceX = OwnerX - math.random(-14,14) local DiceY = OwnerY - math.random(-14,14) if (HomuMotion ~= MOTION_MOVE) then if (14 < GetDistance3(HomuX,HomuY,DiceX,DiceY)) then Move(MyID,math.floor((HomuX + DiceX) / 2) ,math.floor((HomuY + DiceY) / 2)) else Move(MyID,DiceX,DiceY) end end end ------------------------------ function RandomMove (id,short,long) local EnemyX,EnemyY = GetV(V_POSITION,id) local DiceX,DiceY = 0,0 for i = 1,100 do DiceX = EnemyX - math.random(-long,long) DiceY = EnemyY - math.random(-long,long) if (14 >= GetDistance3(OwnerX,OwnerY,DiceX,DiceY) and GetDistance3(HomuX,HomuY,DiceX,DiceY) >= short and HomuX ~= DiceX and HomuY ~= DiceY) then break end if (i == 100) then DiceX,DiceY = OwnerX,OwnerY break end end if (HomuMotion ~= MOTION_MOVE) then Move(MyID,DiceX,DiceY) end end ------------------------------ function Kurukuru (range) if ((PatrolX == HomuX and PatrolY == HomuY) or GetTime > PatrolHomuItv + 2000) then PatrolHomuItv = GetTime PatrolHomuX,PatrolHomuY = HomuX,HomuY PatrolVector = PatrolVector + 1 elseif (PatrolHomuX == HomuX and PatrolHomuY == HomuY and GetTime > PatrolHomuItv + 450) then PatrolHomuItv = GetTime PatrolVector = PatrolVector + 1 Move(MyID,math.floor((HomuX + PatrolX) / 2),math.floor((HomuY + PatrolY) / 2)) else return end if (PatrolVector == 1) then PatrolX,PatrolY = OwnerX,OwnerY - range elseif (PatrolVector == 2) then PatrolX,PatrolY = math.ceil(OwnerX - (range /2)),OwnerY - range elseif (PatrolVector == 3) then PatrolX,PatrolY = OwnerX - range,OwnerY - range elseif (PatrolVector == 4) then PatrolX,PatrolY = OwnerX - range,math.ceil(OwnerY - (range /2)) elseif (PatrolVector == 5) then PatrolX,PatrolY = OwnerX - range,OwnerY elseif (PatrolVector == 6) then PatrolX,PatrolY = OwnerX - range,math.ceil(OwnerY + (range /2)) elseif (PatrolVector == 7) then PatrolX,PatrolY = OwnerX - range,OwnerY + range elseif (PatrolVector == 8) then PatrolX,PatrolY = math.ceil(OwnerX - (range /2)),OwnerY + range elseif (PatrolVector == 9) then PatrolX,PatrolY = OwnerX,OwnerY + range elseif (PatrolVector == 10) then PatrolX,PatrolY = math.ceil(OwnerX + (range /2)),OwnerY + range elseif (PatrolVector == 11) then PatrolX,PatrolY = OwnerX + range,OwnerY + range elseif (PatrolVector == 12) then PatrolX,PatrolY = OwnerX + range,math.ceil(OwnerY + (range /2)) elseif (PatrolVector == 13) then PatrolX,PatrolY = OwnerX + range,OwnerY elseif (PatrolVector == 14) then PatrolX,PatrolY = OwnerX + range,math.ceil(OwnerY - (range /2)) elseif (PatrolVector == 15) then PatrolX,PatrolY = OwnerX + range,OwnerY - range elseif (PatrolVector == 16) then PatrolX,PatrolY = math.ceil(OwnerX + (range /2)),OwnerY - range PatrolVector = 0 else PatrolVector = 0 end Move(MyID,PatrolX,PatrolY) end ------------------------------ function SearchInPlayer (Range,Enemy) local ETarget = GetV(V_TARGET,Enemy) if (TyrannicalFlg == 1 and (ETarget <= 0 or IsListIDChack(FriendList,ETarget) == 0 or IsDead(ETarget) == 0 or IsMob(ETarget) == 0)) then local dis_player = 100 dis_player = GetDistance2(Enemy,GetNearestActor2(Enemy,GetPlayer(2,14,MyOwner))) if (-1 < dis_player and dis_player <= Range) then return 0 end end return 1 end ------------------------------ function AutoRegFriend (pc) if (AutoFriendFlg == 0 and MyOwner ~= pc and MyID ~= pc and TyrannicalFlg == 1 and IsDead(pc) == 1 and (IsPlayer(pc) == 0 or IsHomunclus(pc) == 0) and IsListIDChack(FriendList,pc) == 1) then local TargetPC = GetV(V_TARGET,pc) local TargetPCTarget = GetV(V_TARGET,GetV(V_TARGET,pc)) local NeighborMotion = GetV(V_MOTION,pc) if (NeighborListTarget[pc] == nil) then NeighborListTarget[pc] = 0 end if (NeighborListCount[pc] == nil) then NeighborListCount[pc] = 1 end if ((NeighborListTarget[pc] ~= TargetPC and TargetPC > 0 and (TargetPCTarget == MyOwner or TargetPCTarget == MyID)) and (NeighborMotion == MOTION_ATTACK or NeighborMotion == MOTION_ATTACK2 or NeighborMotion == MOTION_SKILL or NeighborMotion == MOTION_CASTING)) then NeighborListTarget[pc] = TargetPC NeighborListCount[pc] = NeighborListCount[pc] + 1 elseif ((GetDistance4(MyOwner,pc) <= AFSkillRange or GetDistance4(MyID,pc) <= AFSkillRange) and (NeighborMotion == MOTION_ATTACK or NeighborMotion == MOTION_SKILL or NeighborMotion == MOTION_CASTING or NeighborMotion == 13 or NeighborMotion == 35 or NeighborMotion == 38)) then NeighborListCount[pc] = NeighborListCount[pc] + 0.25 end if (NeighborListCount[pc] >= AutoFriendCount) then FriendList = AddList(FriendList,pc) SaveList("Friend",FormFriendList(FriendList)) end end end ------------------------------ function MineEscape (id) local SetID = 1142 if (GetV(V_HOMUNTYPE,id) == SetID) then if (MineEscapeFlg == 0) then IgnoreList = AddList(IgnoreList,SetID) else IgnoreList = DelList(IgnoreList,SetID,1) end local EnemyX, EnemyY = GetV(V_POSITION,id) local DiceX,DiceY = 0,0 local Dice = 0 local range = 3 AsSkillAttack(5,id) if (GetDistance4(id,MyID) < 8) then for i = 1,100 do Dice = math.random(1,11) if (EnemyX <= HomuX and HomuY < EnemyY) then if (Dice == 1 or Dice == 8) then DiceX,DiceY = HomuX + range,HomuY elseif (Dice == 2 or Dice == 9) then DiceX,DiceY = HomuX,HomuY - range elseif (Dice == 3 or Dice == 10) then DiceX,DiceY = HomuX + range, HomuY + range elseif (Dice == 4 or Dice == 11) then DiceX,DiceY = HomuX - range, HomuY - range elseif (Dice == 5) then DiceX,DiceY = HomuX - math.ceil(range * 1.5),HomuY elseif (Dice == 6) then DiceX,DiceY = HomuX,HomuY + math.ceil(range * 1.5) elseif (Dice == 7) then DiceX,DiceY = HomuX + math.ceil(range * 1.5),HomuY - math.ceil(range * 1.5) end elseif (EnemyX > HomuX and HomuY <= EnemyY) then if (Dice == 1 or Dice == 8) then DiceX,DiceY = HomuX - range, HomuY elseif (Dice == 2 or Dice == 9) then DiceX,DiceY = HomuX, HomuY - range elseif (Dice == 3 or Dice == 10) then DiceX,DiceY = HomuX - range, HomuY + range elseif (Dice == 4 or Dice == 11) then DiceX,DiceY = HomuX + range, HomuY - range elseif (Dice == 5) then DiceX,DiceY = HomuX + math.ceil(range * 1.5),HomuY elseif (Dice == 6) then DiceX,DiceY = HomuX,HomuY + math.ceil(range * 1.5) elseif (Dice == 7) then DiceX,DiceY = HomuX - math.ceil(range * 1.5),HomuY - math.ceil(range * 1.5) end elseif (EnemyX < HomuX and HomuY >= EnemyY) then if (Dice == 1 or Dice == 8) then DiceX,DiceY = HomuX + range, HomuY elseif (Dice == 2 or Dice == 9) then DiceX,DiceY = HomuX, HomuY + range elseif (Dice == 3 or Dice == 10) then DiceX,DiceY = HomuX - range, HomuY + range elseif (Dice == 4 or Dice == 11) then DiceX,DiceY = HomuX + range, HomuY - range elseif (Dice == 5) then DiceX,DiceY = HomuX - math.ceil(range * 1.5),HomuY elseif (Dice == 6) then DiceX,DiceY = HomuX,HomuY - math.ceil(range * 1.5) elseif (Dice == 7) then DiceX,DiceY = HomuX + math.ceil(range * 1.5),HomuY + math.ceil(range * 1.5) end elseif (EnemyX >= HomuX and HomuY > EnemyY) then if (Dice == 1 or Dice == 8) then DiceX,DiceY = HomuX - range, HomuY elseif (Dice == 2 or Dice == 9) then DiceX,DiceY = HomuX, HomuY + range elseif (Dice == 3 or Dice == 10) then DiceX,DiceY = HomuX + range, HomuY + range elseif (Dice == 4 or Dice == 11) then DiceX,DiceY = HomuX - range, HomuY - range elseif (Dice == 5) then DiceX,DiceY = HomuX + math.ceil(range * 1.5),HomuY elseif (Dice == 6) then DiceX,DiceY = HomuX,HomuY - math.ceil(range * 1.5) elseif (Dice == 7) then DiceX,DiceY = HomuX - math.ceil(range * 1.5),HomuY + math.ceil(range * 1.5) end end if (13 >= GetDistance3(OwnerX,OwnerY,DiceX,DiceY)) then break end if (i == 100) then DiceX,DiceY = OwnerX,OwnerY break end end if (HomuMotion ~= MOTION_MOVE) then Move(MyID,DiceX,DiceY) end end return 0 end return 1 end ------------------------------ function IsListIDChack (List,id) for i, v in pairs(List) do if (v == id) then return 0 end end return 1 end ------------------------------ function IsListTypeChack (List,id) local etype = GetV(V_HOMUNTYPE,id) for i, v in pairs(List) do if (v == etype) then return 0 end end return 1 end ------------------------------ function AddList (list,id) list[id] = id return list end ------------------------------ function AddList2 (listtable,id,type) local list = {} local ListFlg = 0 if (type == 1) then id = GetV(V_HOMUNTYPE,id) end for i,v in pairs(listtable) do if (v == id) then ListFlg = 1 break end end if (ListFlg == 0) then listtable[id] = id return listtable elseif (ListFlg == 1) then for i,v in pairs(listtable) do if (v ~= id) then list[v] = v end end return list end end ------------------------------ function DelList (listtable,id,type) local list = {} local ListFlg = 0 if (type == 1) then id = GetV(V_HOMUNTYPE,id) end for i,v in pairs(listtable) do if (v == id) then ListFlg = 1 break end end if (ListFlg == 1) then for i,v in pairs(listtable) do if (v ~= id) then list[v] = v end end return list end end ------------------------------ function FormatList () local list = {} return list end ------------------------------ function SaveList (file,listtable) local filename = "./AI/USER_AI/"..file..".ini" fp = io.open(filename, "w") if(fp == nil) then return end for i,v in pairs(listtable) do fp:write(string.format("%d\n", v)) end fp:close() end ------------------------------ function LoadList (file) local filename = "AI/USER_AI/"..file..".ini" local list = {} fp = io.open(filename, "r") if (fp ~= nil) then while true do local id = fp:read() if (id == nil) then break end list[id] = tonumber(id) end fp:close() else io.output(filename) end return list end ------------------------------ function FormFriendList (listtable) local list = {} for i,v in pairs(listtable) do if (tonumber(v) > 100000) then list[v] = v end end return list end ------------------------------ function LoadTime (file) local filename = "AI/USER_AI/"..file..".ini" local time = 0 fp = io.open(filename, "r") if (fp ~= nil) then time = fp:read() if (time ~= nil) then time = tonumber(time) else time = 0 end fp:close() else io.output(filename) end return time end ------------------------------ function SaveTime (file,time) local filename = "./AI/USER_AI/"..file..".ini" fp = io.open(filename, "w") if(fp == nil) then return end fp:write(string.format("%d\n",time)) ExitTime = tonumber(time) fp:close() end ------------------------------ function IgnoreTargetCange () if (ITCangeStatus == 0 and OwnerHPP <= ITCangeFlg) then IgnoreTarget = 1 else IgnoreTarget = 0 end end ------------------------------ function GetPC (file) local filename = "AI/USER_AI/"..file..".log" fp = io.open(filename, "a") if (fp ~= nil) then for i,v in ipairs(ActorsList) do if (v ~= MyOwner and IsPlayer(v) == 0 and PCList[v] == nil) then PCList[v] = v fp:write(string.format("[%s] %s\t%s\n",os.date("%m/%d %H:%M") ,v ,GetV(V_HOMUNTYPE,v))) end end fp:close() else io.output(filename) end GetPCItv = GetTime end ------------------------------ function ExitEvent () do local timestamp = os.time() ExitEvent = function() if (ExitEventX ~= OwnerX or ExitEventY ~= OwnerY) then ExitEventX,ExitEventY = OwnerX,OwnerY timestamp = os.time() ExitCheckItv = GetTime return end if (os.difftime(os.time(),timestamp) >= ExitLimitTime * 60 - 60) then MoveToOwner(MyID) end if (os.difftime(os.time(),timestamp) >= ExitLimitTime * 60) then os.exit() end end end end ------------------------------ function ExitEvent2 () if (ExitTime ~= 0) then if (tonumber(os.time()) - ExitTime < ExitLimitTime2 * 60 and tonumber(os.time()) - ExitTime >= ExitLimitTime2 * 60 - 60) then MoveToOwner(MyID) end if (ExitLimitTime2 * 60 + 10 > tonumber(os.time()) - ExitTime and tonumber(os.time()) - ExitTime >= ExitLimitTime2 * 60) then os.exit() end end end ------------------------------ function AutoEndEvent () if ((GetTime > StartTime + 60000 and (OwnerHPP < AutoEndOwnerHP or HomuHPP < AutoEndMyHP)) or (StartTime + 60000 >= GetTime and (StartOwnerHPP * 0.5 >= OwnerHPP or StartHomuHPP * 0.5 >= HomuHPP))) then os.exit() end end ------------------------------ function DempseyRoll (flg) if (flg == 1) then if (MyState == ATTACK_ST and AttackedFlag == 1 and MultiAttack >= 3) then Attack(MyID,MyEnemy) if (MotionCancel == 0) then AttackMotionCancel(MyEnemy) end AttackedFlag = 0 end else if (MyState == ATTACK_ST and AttackedFlag == 1 and MultiAttack >= 2) then if (IsDead(MyEnemy) == 1) then Attack(MyID,MyEnemy) if (MotionCancel == 0) then AttackMotionCancel(MyEnemy) end if (MultiAttack == 2) then AttackedFlag = 0 end else AttackedFlag = 0 end elseif (MultiAttack == 1) then AttackedFlag = 0 end end end ------------------------------ function GetStatus () ActorsList = GetActors() OwnerX, OwnerY = GetV(V_POSITION,MyOwner) HomuX, HomuY = GetV(V_POSITION,MyID) OwnerMotion = GetV(V_MOTION,MyOwner) HomuMotion = GetV(V_MOTION,MyID) OwnerTarget = GetV(V_TARGET,MyOwner) HomuTarget = GetV(V_TARGET,MyID) OwnerHPP = GetHPP(MyOwner) HomuHPP = GetHPP(MyID) HomuSPP = GetSPP(MyID) Dis2OwnerHomu = GetDistance2(MyOwner,MyID) Dis4OwnerHomu = GetDistance4(MyOwner,MyID) GetTime = GetTick() math.randomseed(GetTime) end ------------------------------ function CmdMsg () local cmd = List.popleft(ResCmdList) if (cmd ~= nil) then ProcessCommand(cmd) end local msg = GetMsg (MyID) local rmsg = GetResMsg (MyID) if (msg[1] ~= NONE_CMD) then ProcessCommand (msg) elseif (rmsg[1] ~= NONE_CMD) then ReserveCommand (rmsg) end end ------------------------------ function AI (myid) MyID = myid GetStatus() DempseyRoll(1) IgnoreTargetCange() CmdMsg() if (MyState == IDLE_ST) then OnIDLE_ST() elseif (MyState == CHASE_ST) then OnCHASE_ST() elseif (MyState == ATTACK_ST) then OnATTACK_ST() elseif (MyState == FIXEDARTILLERY_ST) then OnFIXEDARTILLERY_ST() elseif (MyState == FOLLOW_ST) then OnFOLLOW_ST() elseif (MyState == SKILL_OBJECT_CMD_ST) then OnSKILL_OBJECT_CMD_ST() elseif (MyState == SPR_ST) then OnSPR_ST() elseif (MyState == MOVE_CMD_ST) then OnMOVE_CMD_ST() elseif (MyState == FOLLOW_CMD_ST) then OnFOLLOW_CMD_ST() end if (AtkPriorityFlgTemp == 1 and AtkOwnPriority >= OwnerHPP) then AtkPriorityFlg = 0 else AtkPriorityFlg = AtkPriorityFlgTemp end if (MyState ~= FIXEDARTILLERY_ST) then OutskirtMove(13) end DempseyRoll(2) if (PcListFlg == 0 and GetTime - GetPCItv > 2100) then GetPC("PC") end if (AutoExit == 0 and GetTime - ExitCheckItv > 1950) then ExitEvent() end if (AutoExit2 == 0 and MyState ~= FOLLOW_CMD_ST) then ExitEvent2() end if (AutoEnd == 0 and (MyState ~= FOLLOW_CMD_ST and MyState ~= IDLE_ST)) then AutoEndEvent() end end