Andreavnn 0 Posted December 29, 2017 Share Posted December 29, 2017 Is there an "Additional C# Code" the will make the bot wait if your pet has the effect "Feed Pet Effect?" I have the bot feeding my pet finally, but it won't wait until for the buff's duration. I am using an addon to feed the Pet automatically. Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/ Share on other sites More sharing options...
Droidz 2738 Posted December 31, 2017 Share Posted December 31, 2017 Hello, try code like (not tested): static Main() { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += delegate (Engine engine, State state, CancelEventArgs cancelable) { if (!string.IsNullOrWhiteSpace(state.DisplayName) && state.DisplayName == "Regeneration" && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect") && !state.NeedToRun) { while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect")) { Thread.Sleep(800); } } }; } Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37243 Share on other sites More sharing options...
Andreavnn 0 Posted December 31, 2017 Author Share Posted December 31, 2017 @Droidz Is this how I would combine these two codes together? Or is that something that can't be done this way? static Main() { wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => { if (unit.IsValid && ObjectManager.Target.IsTargetingMyPet && ObjectManager.Target.GetDistance <= 12) { wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 2000); } { robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += delegate (Engine engine, State state, CancelEventArgs cancelable) { if (!string.IsNullOrWhiteSpace(state.DisplayName) && state.DisplayName == "Regeneration" && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect") && !state.NeedToRun) { while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect")) { Thread.Sleep(800); } }; } Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37247 Share on other sites More sharing options...
Droidz 2738 Posted December 31, 2017 Share Posted December 31, 2017 static Main() { wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => { if (unit.IsValid && ObjectManager.Target.IsTargetingMyPet && ObjectManager.Target.GetDistance <= 12) { wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 2000); } }; robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += delegate (Engine engine, State state, CancelEventArgs cancelable) { if (!string.IsNullOrWhiteSpace(state.DisplayName) && state.DisplayName == "Regeneration" && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect") && !state.NeedToRun) { while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect")) { Thread.Sleep(800); } } }; } Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37249 Share on other sites More sharing options...
Droidz 2738 Posted December 31, 2017 Share Posted December 31, 2017 https://wrobot.eu/forums/topic/7634-movement-follow-path-strafing-or-running-backwards/?do=findComment&comment=34860 it is better code to move back Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37250 Share on other sites More sharing options...
Andreavnn 0 Posted December 31, 2017 Author Share Posted December 31, 2017 So like this? I think I am understanding this a bit more know. I only know very little about #C from grade school like 12 years ago static Main() { wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => { var me = wManager.Wow.ObjectManager.ObjectManager.Me; if (wManager.Wow.Helpers.Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && unit.IsValid && !me.IsCast && unit.IsGoodInteractDistance) // put here your conditions to running backwards { var p = robotManager.Helpful.Math.GetPosition2DOfAngleAndDistance(me.Position, robotManager.Helpful.Math.GetAngle(unit.Position, me.Position), wManager.Wow.Helpers.CustomClass.GetRange - unit.GetDistance - 12); var z = wManager.Wow.Helpers.PathFinder.GetZPosition(p); if (z != 0) { p.Z = z; wManager.Wow.Bot.Tasks.GoToTask.ToPosition(p, 3.5f, true, context => (wManager.Wow.Helpers.Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause)); } } }; }; robotManager.Events.FiniteStateMachineEvents.OnBeforeCheckIfNeedToRunState += delegate (Engine engine, State state, CancelEventArgs cancelable) { if (!string.IsNullOrWhiteSpace(state.DisplayName) && state.DisplayName == "Regeneration" && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect") && !state.NeedToRun) { while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore && ObjectManager.Pet.IsValid && ObjectManager.Pet.IsAlive && ObjectManager.Pet.HaveBuff("Feed Pet Effect")) { Thread.Sleep(800); } } }; } Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37258 Share on other sites More sharing options...
Droidz 2738 Posted January 5, 2018 Share Posted January 5, 2018 remoive ";" line 20 Link to comment https://wrobot.eu/forums/topic/8133-conditional-additional-c-code/#findComment-37399 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