private static void OnUpdateInternal(float deltaTime) { if (DynelManager.LocalPlayer == null) { return; } DynelManager.Update(); Network.Update(); IPCChannel.Update(); UIController.UpdateViews(); Item.Update(); PerkAction.Update(); Spell.Update(); MovementController.Instance?.Update(); CombatHandler.Instance?.Update(deltaTime); try { OnUpdate?.Invoke(null, deltaTime); } catch (Exception e) { Chat.WriteLine(e.Message); } Chat.Update(); }
public override void Run(string pluginDir) { Chat.WriteLine("APFBuddy Loaded!"); try { Config = Config.Load($"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\AOSharp\\APFBuddy\\Config.json"); ActiveGlobalSettings = Config.GlobalSettings; FSM = BuildFSM(); MovementController = new CombatNavMeshMovementController($"{pluginDir}\\NavMeshes", true); AOSharp.Core.Movement.MovementController.Set(MovementController); Chat.RegisterCommand("apfbuddy", APFBuddyCommand); IPCChannel = new IPCChannel(11); IPCChannel.RegisterCallback((int)IPCOpcode.Start, OnStartMessage); IPCChannel.RegisterCallback((int)IPCOpcode.Stop, OnStopMessage); Team.TeamRequest += OnTeamRequest; Game.OnUpdate += OnUpdate; Game.TeleportEnded += OnZoned; } catch (Exception e) { Chat.WriteLine(e.Message); } }
public void Run(string pluginDir) { Chat.WriteLine("InfBuddy Loaded!"); try { Config = Config.Load($"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\AOSharp\\InfBuddy\\Config.json"); ActiveGlobalSettings = Config.GlobalSettings; _stateMachine = new StateMachine(new IdleState()); NavMeshMovementController = new NavMeshMovementController($"{pluginDir}\\NavMeshes", true); MovementController.Set(NavMeshMovementController); Chat.RegisterCommand("infbuddy", InfbuddyCommand); IPCChannel = new IPCChannel(10); IPCChannel.RegisterCallback((int)IPCOpcode.Start, OnStartMessage); IPCChannel.RegisterCallback((int)IPCOpcode.Stop, OnStopMessage); NpcDialog.AnswerListChanged += NpcDialog_AnswerListChanged; Team.TeamRequest += OnTeamRequest; Game.OnUpdate += OnUpdate; } catch (Exception e) { Chat.WriteLine(e.Message); } }
public static void StartNextRound() { IPCChannel.Broadcast(new StartMessage() { MissionDifficulty = Config.GlobalSettings.MissionDifficulty, MissionFaction = Config.GlobalSettings.MissionFaction }); ActiveGlobalSettings = Config.GlobalSettings.Clone(); }
private static void StartNextRound() { IPCChannel.Broadcast(new StartMessage() { Sector = Config.GlobalSettings.Sector }); ActiveGlobalSettings = Config.GlobalSettings.Clone(); Chat.WriteLine("StartNextRound"); }
private static void OnPluginLoaded(Assembly assembly) { try { IPCChannel.LoadMessages(assembly); } catch (ContractIdCollisionException e) { Chat.WriteLine(e.Message); } }
private void button1_Click(object sender, EventArgs e) { IPCChannel.SendMessage("Client64", "from 32"); }
public Form1() { InitializeComponent(); _ipc = new IPCChannel(this, "Client32"); _ipc.OnMessage += OnMessage; }
public override void Run(string pluginDir) { try { Chat.WriteLine("TestPlugin loaded"); Chat.WriteLine($"LocalPlayer: {DynelManager.LocalPlayer.Identity}"); Chat.WriteLine($" Name: {DynelManager.LocalPlayer.Name}"); Chat.WriteLine($" Pos: {DynelManager.LocalPlayer.Position}"); Chat.WriteLine($" MoveState: {DynelManager.LocalPlayer.MovementState}"); Chat.WriteLine($" Health: {DynelManager.LocalPlayer.GetStat(Stat.Health)}"); /* * Chat.WriteLine("Playfield"); * Chat.WriteLine($" Identity: {Playfield.Identity}"); * Chat.WriteLine($" Name: {Playfield.Name}"); * Chat.WriteLine($" AllowsVehicles: {Playfield.AllowsVehicles}"); * Chat.WriteLine($" IsDungeon: {Playfield.IsDungeon}"); * Chat.WriteLine($" IsShadowlands: {Playfield.IsShadowlands}"); * Chat.WriteLine($" NumDynels: {DynelManager.AllDynels.Count}"); */ Chat.WriteLine("Team:"); Chat.WriteLine($"\tIsInTeam: {Team.IsInTeam}"); Chat.WriteLine($"\tIsLeader: {Team.IsLeader}"); Chat.WriteLine($"\tIsRaid: {Team.IsRaid}"); mc = new MovementController(drawPath: true); foreach (TeamMember teamMember in Team.Members) { Chat.WriteLine($"\t{teamMember.Name} - {teamMember.Identity} - {teamMember.Level} - {teamMember.Profession} - IsLeader:{teamMember.IsLeader} @ Team {teamMember.TeamIndex + 1}"); } Chat.WriteLine("Tests:"); /* * Chat.WriteLine($"Base stat: {DynelManager.LocalPlayer.GetStat(Stat.RunSpeed, 1)}"); * Chat.WriteLine($"Modified stat: {DynelManager.LocalPlayer.GetStat(Stat.RunSpeed, 2)}"); * Chat.WriteLine($"No Trickle stat: {DynelManager.LocalPlayer.GetStat(Stat.RunSpeed, 3)}"); * * Team.Members.ForEach(x => Chat.WriteLine($"{x.Name} IsLeader: {x.IsLeader}")); * * foreach (Room room in Playfield.Rooms) * { * Chat.WriteLine($"Ptr: {room.Pointer.ToString("X4")}\tName: {room.Name}\tIdx: {room.Instance}\tRot: {room.Rotation}\tPos: {room.Position}\tCenter: {room.Center}\tTemplatePos: {room.TemplatePos}\tYOffset: {room.YOffset}\tNumDoors: {room.NumDoors}\tFloor: {room.Floor}"); * } * * //AO3D export * foreach (Room room in Playfield.Rooms) * { * Chat.WriteLine($"new RoomInstance(\"{room.Name}\", {room.Floor}, new Vector3{room.Position}, {(int)room.Rotation / 90}, {room.LocalRect.MinX}, {room.LocalRect.MinY}, {room.LocalRect.MaxX}, {room.LocalRect.MaxY}, new Vector3{room.Center}, new Vector3{room.TemplatePos}),"); * } */ /* * foreach(Spell spell in Spell.List) * { * Chat.WriteLine($"\t{spell.Identity}\t{spell.Name}\t{spell.MeetsUseReqs()}\t{spell.IsReady}"); * } */ foreach (PerkAction perkAction in PerkAction.List) { //Chat.WriteLine($"\t{perk.Identity}\t{perk.Hash}\t{perk.Name}\t{perk.MeetsSelfUseReqs()}\t{perk.GetStat(Stat.AttackDelay)}"); Chat.WriteLine($"{perkAction.Name} = 0x{((uint)perkAction.Hash).ToString("X4")},"); } /* * Chat.WriteLine("Buffs:"); * foreach(Buff buff in DynelManager.LocalPlayer.Buffs) * { * Chat.WriteLine($"\tBuff: {buff.Name}\t{buff.RemainingTime}/{buff.TotalTime}"); * } */ /* * Perk perk; * if(Perk.Find(PerkHash.Gore, out perk)) * { * if(DynelManager.LocalPlayer.FightingTarget != null) * Chat.WriteLine($"Can use perk? {perk.MeetsUseReqs(DynelManager.LocalPlayer.FightingTarget)}"); * } */ /* * Chat.WriteLine("Pet Identities:"); * foreach(Identity identity in DynelManager.LocalPlayer.Pets) * { * Chat.WriteLine($"\t{identity}"); * } * * Chat.WriteLine("Pet Dynels:"); * foreach(SimpleChar pet in DynelManager.LocalPlayer.GetPetDynels()) * { * Chat.WriteLine($"\t{pet.Name}"); * } */ /* * Item item; * if(Inventory.Find(244216, out item)) * { * DummyItem dummyItem = DummyItem.GetFromTemplate(item.Slot); * dummyItem.MeetsUseReqs(); * } */ //DevExtras.LoadAllSurfaces(); /* * MovementController movementController = new MovementController(true); * * List<Vector3> testPath = new List<Vector3> { * new Vector3(438.6, 8.0f, 524.4f), * new Vector3(446.8f, 8.0f, 503.7f), * new Vector3(460.8, 15.1f, 414.0f) * }; * * movementController.RunPath(testPath); */ Chat.WriteLine($"Missions ({Mission.List.Count})"); foreach (Mission mission in Mission.List) { Chat.WriteLine($" {mission.Identity.ToString()}"); Chat.WriteLine($" Source: {mission.Source.ToString()}"); Chat.WriteLine($" Playfield: {mission.Playfield.ToString()}"); Chat.WriteLine($" DisplayName: {mission.DisplayName}"); } /* * List<Item> characterItems = Inventory.Items; * //List<Item> characterItems = Inventory.Items; * * foreach (Item item in characterItems) * { * Chat.WriteLine($"{item.Slot} - {item.LowId} - {item.Name} - {item.QualityLevel} - {item.UniqueIdentity}"); * } */ /* * Chat.WriteLine("Backpacks:"); * * List<Container> backpacks = Inventory.Backpacks; * foreach(Container backpack in backpacks) * { * Chat.WriteLine($"{backpack.Identity} - IsOpen:{backpack.IsOpen}{((backpack.IsOpen) ? $" - Items:{backpack.Items.Count}" : "")}"); * } */ /* * Item noviRing; * if (Inventory.Find(226307, out noviRing)) * { * //noviRing.Equip(EquipSlot.Cloth_RightFinger); * * Container openBag = Inventory.Backpacks.FirstOrDefault(x => x.IsOpen); * if(openBag != null) * { * noviRing.MoveToContainer(openBag); * } * } */ //DynelManager.LocalPlayer.CastNano(new Identity(IdentityType.NanoProgram, 223372), DynelManager.LocalPlayer); _menu = new Menu("TestPlugin", "TestPlugin"); _menu.AddItem(new MenuBool("DrawingTest", "Drawing Test", false)); //_menu.AddItem(new MenuTest("CrashTime", "Inb4 Crash")); OptionPanel.AddMenu(_menu); Chat.RegisterCommand("split", (string command, string[] param, ChatWindow chatWindow) => { if (param.Length < 2) { return; } if (Inventory.Find(int.Parse(param[0]), out Item item)) { item.Split(int.Parse(param[1])); } }); Chat.RegisterCommand("openwindow", (string command, string[] param, ChatWindow chatWindow) => { testWindow = Window.CreateFromXml("Test", $"{pluginDir}\\TestWindow.xml"); testWindow.Show(true); chatWindow.WriteLine($"Window.Pointer: {testWindow.Pointer.ToString("X4")}"); chatWindow.WriteLine($"Window.Name: {testWindow.Name}"); if (testWindow.IsValid) { if (testWindow.FindView("testTextView", out TextView testView)) { Chat.WriteLine($"testTextView.Pointer: {testView.Pointer.ToString("X4")}"); Chat.WriteLine($"testTextView.Text: {testView.Text}"); testView.Text = "1337"; Chat.WriteLine($"testTextView.Text(New): {testView.Text}"); } if (testWindow.FindView("testPowerBar", out PowerBarView testPowerBar)) { Chat.WriteLine($"testPowerBar.Pointer: {testPowerBar.Pointer.ToString("X4")}"); Chat.WriteLine($"testPowerBar.Value: {testPowerBar.Value}"); testPowerBar.Value = 0.1f; } } }); Chat.RegisterCommand("savesettings", (string command, string[] param, ChatWindow chatWindow) => { Settings.Save(); }); Chat.RegisterCommand("test", (string command, string[] param, ChatWindow chatWindow) => { Settings["DrawStuff"] = true; //DynelManager.LocalPlayer.Position += Vector3.Rotate(Vector3.Zero, DynelManager.LocalPlayer.Rotation.Forward, 90); /* * if (Targeting.Target == null) * Chat.WriteLine("No target"); * else * Chat.WriteLine(Targeting.Target.Identity); * * * if (Targeting.TargetChar == null) * Chat.WriteLine("No target or target isn't a char"); * else * Chat.WriteLine(Targeting.TargetChar.Identity); */ if (Spell.Find(85872, out Spell spell)) { Chat.WriteLine($"Drain Self No Target: {spell.MeetsUseReqs()}"); Chat.WriteLine($"Drain Self Self: {spell.MeetsSelfUseReqs()}"); Chat.WriteLine($"Drain Self No Target: {spell.MeetsUseReqs(Targeting.TargetChar)}"); } /* * foreach(Pet pet in DynelManager.LocalPlayer.Pets) * { * Chat.WriteLine(pet.Character != null ? pet.Character.Name : "No pet character found"); * Chat.WriteLine(pet.Type); * } */ //DevExtras.Test(); //if (DynelManager.LocalPlayer.Buffs.Find(215264, out Buff testBuff)) // testBuff.Remove(); /* * if (DynelManager.LocalPlayer.FightingTarget != null) * { * chatWindow.WriteLine(DynelManager.LocalPlayer.GetLogicalRangeToTarget(DynelManager.LocalPlayer.FightingTarget).ToString()); * * * if (Perk.Find("Capture Vigor", out Perk perk)) * { * chatWindow.WriteLine(perk.GetStat(Stat.AttackRange).ToString()); * chatWindow.WriteLine(perk.IsInRange(DynelManager.LocalPlayer.FightingTarget).ToString()); * } * }*/ }); _ipcChannel = new IPCChannel(1); _ipcChannel.RegisterCallback((int)IPCOpcode.Test, (sender, msg) => { TestMessage testMsg = (TestMessage)msg; Chat.WriteLine($"TestMessage: {testMsg.Leet} - {testMsg.Position}"); }); _ipcChannel.RegisterCallback((int)IPCOpcode.Empty, (sender, msg) => { Chat.WriteLine($"EmptyMessage"); }); Settings = new Settings("TestPlugin"); Settings.AddVariable("DrawStuff", false); Settings.AddVariable("AnotherVariable", 1911); Game.OnUpdate += OnUpdate; Game.TeleportStarted += Game_OnTeleportStarted; Game.TeleportEnded += Game_OnTeleportEnded; Game.TeleportFailed += Game_OnTeleportFailed; Game.PlayfieldInit += Game_PlayfieldInit; MiscClientEvents.AttemptingSpellCast += AttemptingSpellCast; //Network.N3MessageReceived += Network_N3MessageReceived; //Network.N3MessageSent += Network_N3MessageSent; //Network.PacketReceived += Network_PacketReceived; //Network.PacketSent += Network_PacketSent; Network.ChatMessageReceived += Network_ChatMessageReceived; Team.TeamRequest += Team_TeamRequest; Team.MemberLeft += Team_MemberLeft; Item.ItemUsed += Item_ItemUsed; NpcDialog.AnswerListChanged += NpcDialog_AnswerListChanged; //DynelManager.DynelSpawned += DynelSpawned; //DynelManager.CharInPlay += CharInPlay; } catch (Exception e) { Chat.WriteLine(e.Message); } }
private void APFBuddyCommand(string command, string[] param, ChatWindow chatWindow) { try { if (param.Length < 1) { PrintAPFBuddyCommandUsage(chatWindow); return; } switch (param[0].ToLower()) { case "start": if (!Team.IsLeader) { chatWindow.WriteLine("Error: Only the team leader can use start", ChatColor.Yellow); return; } if (!Team.IsInTeam || !Team.IsRaid) { chatWindow.WriteLine("Error: Must be in a raid to start", ChatColor.Yellow); return; } if (!Inventory.Find(83919, out _) && !Inventory.Find(152028, out _)) { chatWindow.WriteLine("Error: You need an Aggression Enhancer/Aggression Multiplier in your main inventory to run this bot.", ChatColor.Yellow); return; } IsLeader = true; Start(); break; case "stop": Stop(); IPCChannel.Broadcast(new StopMessage()); break; case "config": if (param.Length == 1) { chatWindow.WriteLine($"APFBuddy Config:", ChatColor.LightBlue); chatWindow.WriteLine($"\tIsLeech({DynelManager.LocalPlayer.Name}): {Config.IsLeech}", ChatColor.LightBlue); return; } if (param.Length < 2) { PrintAPFBuddyCommandUsage(chatWindow); return; } switch (param[1].ToLower()) { case "isleech": if (param.Length == 2) { chatWindow.WriteLine($"IsLeech({DynelManager.LocalPlayer.Name}): {Config.IsLeech}", ChatColor.LightBlue); return; } bool leechValue; if (!bool.TryParse(param[2], out leechValue)) { chatWindow.WriteLine($"Invalid value. Options for isleech are [true|false]", ChatColor.Red); return; } if (Config.CharSettings == null) { Config.CharSettings = new Dictionary <int, CharacterSettings>(); } if (!Config.CharSettings.ContainsKey(Game.ClientInst)) { Config.CharSettings.Add(Game.ClientInst, new CharacterSettings() { IsLeech = leechValue }); } else { Config.CharSettings[Game.ClientInst].IsLeech = leechValue; } chatWindow.WriteLine($"IsLeech is now set to {leechValue}"); break; default: chatWindow.WriteLine($"Config options are [isleech]", ChatColor.Red); return; } Config.Save(); break; case "test": FSM.Fire(Trigger.StartNewRun); break; default: PrintAPFBuddyCommandUsage(chatWindow); break; } } catch (Exception e) { Chat.WriteLine(e.Message); } }
private void InfbuddyCommand(string command, string[] param, ChatWindow chatWindow) { try { if (param.Length < 1) { PrintInfBuddyCommandUsage(chatWindow); return; } switch (param[0].ToLower()) { case "start": if (!Team.IsLeader) { chatWindow.WriteLine("Only the team leader can use start", ChatColor.Yellow); return; } IsLeader = true; Start(); StartNextRound(); break; case "stop": Stop(); IPCChannel.Broadcast(new StopMessage()); break; case "config": if (param.Length == 1) { chatWindow.WriteLine($"Infbuddy Config:", ChatColor.LightBlue); chatWindow.WriteLine($"\tMissionDifficulty(Global): {Config.GlobalSettings.MissionDifficulty}", ChatColor.LightBlue); chatWindow.WriteLine($"\tMissionFaction(Global): {Config.GlobalSettings.MissionFaction}", ChatColor.LightBlue); chatWindow.WriteLine($"\tIsLeech({DynelManager.LocalPlayer.Name}): {Config.IsLeech}", ChatColor.LightBlue); return; } if (param.Length < 2) { PrintInfBuddyCommandUsage(chatWindow); return; } switch (param[1].ToLower()) { case "difficulty": if (param.Length == 2) { chatWindow.WriteLine($"MissionDifficulty(Global): {Config.GlobalSettings.MissionDifficulty}", ChatColor.LightBlue); return; } MissionDifficulty difficultyValue; if (!Enum.TryParse(param[2], true, out difficultyValue)) { chatWindow.WriteLine($"Invalid value. Options for difficulty are [{string.Join("|", Enum.GetNames(typeof(MissionDifficulty)))}]", ChatColor.Red); return; } Config.GlobalSettings.MissionDifficulty = difficultyValue; chatWindow.WriteLine($"Difficulty is now set to {difficultyValue}"); break; case "faction": if (param.Length == 2) { chatWindow.WriteLine($"MissionFaction(Global): {Config.GlobalSettings.MissionFaction}", ChatColor.LightBlue); return; } MissionFaction factionValue; if (!Enum.TryParse(param[2], true, out factionValue)) { chatWindow.WriteLine($"Invalid value. Options for faction are [{string.Join("|", Enum.GetNames(typeof(MissionFaction)))}]", ChatColor.Red); return; } Config.GlobalSettings.MissionFaction = factionValue; chatWindow.WriteLine($"Faction is now set to {factionValue}"); break; case "isleech": if (param.Length == 2) { chatWindow.WriteLine($"IsLeech({DynelManager.LocalPlayer.Name}): {Config.IsLeech}", ChatColor.LightBlue); return; } bool leechValue; if (!bool.TryParse(param[2], out leechValue)) { chatWindow.WriteLine($"Invalid value. Options for isleech are [true|false]", ChatColor.Red); return; } if (Config.CharSettings == null) { Config.CharSettings = new Dictionary <int, CharacterSettings>(); } if (!Config.CharSettings.ContainsKey(Game.ClientInst)) { Config.CharSettings.Add(Game.ClientInst, new CharacterSettings() { IsLeech = leechValue }); } else { Config.CharSettings[Game.ClientInst].IsLeech = leechValue; } chatWindow.WriteLine($"IsLeech is now set to {leechValue}"); break; default: chatWindow.WriteLine($"Config options are [difficulty|faction|isleech]", ChatColor.Red); return; } Config.Save(); break; case "test": _stateMachine.SetState(new MoveToQuestGiverState()); break; default: PrintInfBuddyCommandUsage(chatWindow); break; } } catch (Exception e) { Chat.WriteLine(e.Message); } }
private async void button1_Click(object sender, EventArgs e) { await IPCChannel.SendMessage("Client32", "from 64"); }