private void ActionToAllBot(SAction Action, int j, bool replace) { //j: 1 - All Bot , 2 - Not Main ,3- Main If semiMod bool replaced = false; for (int i = 0; i < SomeSettings.botnumber; i++) { if (i != MainCharacter || (j == 1 || (j == 3 && SomeSettings.BotMod == BotMode.Semi))) { if (replace == true) { for (int k = 0; k < UserBots[i].ActionList.Count; k++) { if (UserBots[i].ActionList[k].Action == BotAction.GoToLocation) { UserBots[i].ActionList[k].Location = Action.Location; replaced = true; } } if (UserBots[i].ActionList.Count == 0 || replaced == false) { UserBots[i].ActionList.Add(Action); } } else { UserBots[i].ActionList.Add(Action); } } } //getActionList(); }
private void moveBotToLocation(GLocation location) { sendconsole("Bot are moving to location", ConsoleLvl.Medium); follow = false; DelActionToAllBot(new SAction(BotAction.FollowMain)); SAction todo = new SAction(); todo.Action = BotAction.GoToLocation; todo.Priority = runToLocationPriority; todo.Location = location; ActionToAllBot(todo, 3, true); }
private void DelActionToAllBot(SAction Action) { for (int i = 0; i < SomeSettings.botnumber; i++) { for (int k = 0; k < UserBots[i].ActionList.Count; k++) { if (UserBots[i].ActionList[k].Action == Action.Action) { UserBots[i].ActionList.RemoveAt(k); } } } }
int IComparable.CompareTo(object obj) { SAction c2 = (SAction)obj; if (this.Priority > c2.Priority) { return(-1); } if (this.Priority < c2.Priority) { return(1); } else { return(0); } }
private void MainThreadLoop(object data) { int id = (int)data; Bot CurrentBot = UserBots[id]; // CurrentBot.BotStart(); while (Thread.CurrentThread.IsAlive) { Thread.Sleep(50); if ((CurrentBot.ID != MainCharacter || SomeSettings.BotMod != BotMode.Classic) && CurrentBot.Objectlist.LocalPlayer.IsAlive) { CurrentBot.refreshInfo(); CurrentBot.refreshList(); SAction AttackM = new SAction(); SAction AttackN = new SAction(); Thread CurrentActionThread; AttackN.Action = BotAction.Attack; AttackN.Priority = AgroPriority; AttackM.Priority = attackMainTargetPriority; AttackM.Action = BotAction.AttackMain; SAction healA = new SAction(); bool AttackNb = false; bool AttackMb = false; bool healAt = false; if (CurrentBot.TargetList.Count != 0) { CurrentBot.ActionList.Add(AttackN); AttackNb = true; } if (CurrentBot.MainTargetList.Count != 0) { CurrentBot.ActionList.Add(AttackM); AttackMb = true; } SAction MaxAction = new SAction(); if (CurrentBot.HealList.Count != 0) { healA.Action = BotAction.Heal; healA.Priority = HealPriority; CurrentBot.ActionList.Add(healA); healAt = true; } CurrentBot.ActionList.Sort(); // bool hasAttackAction; CurrentBot.BreakCurActionB = false; if (CurrentBot.ActionList.Count != 0) { MaxAction = CurrentBot.ActionList[0]; if (MaxAction.Action == BotAction.GoToLocation) { CurrentActionThread = new Thread(delegate() { threadMoveToLoc(id, CurrentBot.ActionList[0].Location); }); GLocation Curloc = CurrentBot.ActionList[0].Location; CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } CurrentBot.ActionList.Remove(MaxAction); } else if (MaxAction.Action == BotAction.FollowMain) { CurrentActionThread = new Thread(delegate() { threadMoveToMain(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } } else if (MaxAction.Action == BotAction.Patrol) { CurrentActionThread = new Thread(delegate() { threadPatrol(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } } else if (MaxAction.Action == BotAction.Attack) { sendconsole("Bot Attacking!", ConsoleLvl.High); CurrentActionThread = new Thread(delegate() { threadAttack(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } } else if (MaxAction.Action == BotAction.AttackMain) { sendconsole("Bot Attacking!", ConsoleLvl.High); CurrentActionThread = new Thread(delegate() { threadAttackMain(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } } else if (MaxAction.Action == BotAction.Heal) { sendconsole("Bot Healing!", ConsoleLvl.High); CurrentActionThread = new Thread(delegate() { threadHeal(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } } else if (MaxAction.Action == BotAction.GotAggro) { sendconsole("Bot Got Aggro!", ConsoleLvl.High); CurrentActionThread = new Thread(delegate() { threadAggro(id); }); CurrentActionThread.Start(); while (CurrentActionThread.IsAlive) { Thread.Sleep(40); } CurrentBot.ActionList.Remove(MaxAction); } if (AttackMb) { CurrentBot.ActionList.Remove(AttackM); } if (AttackNb) { CurrentBot.ActionList.Remove(AttackN); } if (healAt) { CurrentBot.ActionList.Remove(healA); } } } } }