gornov.12345 1 Posted March 29 Share Posted March 29 @Droidz Good afternoon. I encountered a problem that my bot does not respond to an attack from a renegade. I'm trying to create a plugin so that my character can respond to attacks from any players, but it's not working yet. Here is my code, added it to the .cs, but the bot doesn’t even see my plugin. Please help me with this, because my bot stands out very much when it just runs and absorbs all the player's attacks. I would be very grateful for your help. using PluginTutorial; using robotManager.Helpful; using System.Collections.Generic; using System.Drawing; using System.Threading; using wManager.Plugin; using wManager.Wow.Helpers; using wManager.Wow.ObjectManager; namespace YourNamespace { public class Class1 { private WoWUnit? attacker; public void Run() { var enemies = ObjectManager.GetWoWUnitAttackables().Where(u => u.IsTargetingMe && u.IsPlayer); if (enemies.Any()) { foreach (var enemy in enemies) { Logging.Write($"Attacking player {enemy.Name} in response to being attacked."); Attack(enemy); } } } public void OnEvent(EventArgs args) { if (args is WRobotEventUnitBeingAttacked) { var eventArgs = (WRobotEventUnitBeingAttacked)args; attacker = eventArgs.Attacker; } } private void Attack(WoWUnit target) { target.Target; MovementManager.StopMove(); } } } Link to comment https://wrobot.eu/forums/topic/15429-plugin-for-robotsresponse-to-player-attack/ Share on other sites More sharing options...
Droidz 2738 Posted March 29 Share Posted March 29 Hello, Your code is wrong, the code would look more like this (not tested): using System.Linq; using System.Windows.Forms; using robotManager.Helpful; using wManager.Wow.Bot.States; using wManager.Wow.Helpers; using wManager.Wow.ObjectManager; public class Main : wManager.Plugin.IPlugin { public void Initialize() { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += (engine, state, cancelable) => { if (state is IsAttacked && Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause) { var enemies = ObjectManager .GetObjectWoWPlayer() .Where(u => u.IsValid && u.IsAlive && u.PlayerFaction != ObjectManager.Me.PlayerFaction && u.IsTargetingMe && u.InCombatFlagOnly ); if (enemies.Any()) { var enemy = enemies.First(); Logging.Write($"Attacking player {enemy.Name} in response to being attacked."); Fight.StartFight(enemy.Guid); } } }; } public void Dispose() { Logging.Write("Disposed."); } public void Settings() { MessageBox.Show("No settings for this plugin."); } } Link to comment https://wrobot.eu/forums/topic/15429-plugin-for-robotsresponse-to-player-attack/#findComment-69230 Share on other sites More sharing options...
gornov.12345 1 Posted March 29 Author Share Posted March 29 I added the plugin to the folder plugins/ When starting wrobots the plugin does not load - Error to load plugin Link to comment https://wrobot.eu/forums/topic/15429-plugin-for-robotsresponse-to-player-attack/#findComment-69234 Share on other sites More sharing options...
gornov.12345 1 Posted March 30 Author Share Posted March 30 Everything worked. It was necessary to remove the "$" sign in the code and enable .cs in plugins. Thanks Link to comment https://wrobot.eu/forums/topic/15429-plugin-for-robotsresponse-to-player-attack/#findComment-69239 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now