July 28, 20178 yr I am noticing the wrotation product will immediately use an ability like "Execute" if the target.HealthPercent <= 20 for example. I know there is an option for Thread.Sleep but instead of sleeping the full rotation, is there a good way to add a small random time _r.Next(300, 650) to robotManager.Helpful.Timer? And if so, how would I use it? Thanks!
July 29, 20178 yr Hello @Apexx, so you would like to only delay the current cast or has it a special reason to do that? Otherwise you can still use Thread.Sleep() if the fightclass shouldn't execute anything (for a small time / simple task it's ok i guess). Edited July 29, 20178 yr by reapler
July 29, 20178 yr Hello, https://wrobot.eu/forums/topic/3749-how-to-add-random-delay-to-cast-interrupt/?do=findComment&comment=17612
July 29, 20178 yr Author I am writing a protection warrior fight class, and there are no cast times. I was just wanted to delay abilities like Overpower, Execute, Revenge. Once the ability is usable, it casts it immediately which is really not human-like at all. I try to write my fight classes as human-like as I can, adding randomization, delays, etc. pseudo example: var _timer = new robotManager.Helpful.Timer(_r.Next(300, 650)); if (_timer.IsReady) { // use Revenge }
July 29, 20178 yr @Apexx At your case i would use Thread.Sleep() since, you would need to block your rotation for a short time (but make sure that the ability is really usable). If you would use: var t = Task.Run(async delegate { await Task.Delay(1600); //cast spell }); It will be triggered more than one time if you have a reactive fightclass. So you would need then a boolean to check if any spells are going to be executed. But instead of building such a system, which has most likely the same effect like a sleep, just use a sleep instead. There are may scenarios which still need an active loop in fightclasses for example you have a status bar of all enemy players which updates with each loop(~100ms) so a sleep(long or short) would cause to delay also this update of the bar. So in my eyes Task.Run would be worth if you want explicit to run the thread without lockouts. In your case i wouldn't mind that, events like "EventsLuaWithArgs.OnEventsLuaWithArgs" are still working so you could theoretically interrupt the enemy cast even on a sleeping thread. As i mentioned it's not a big issue to use a sleep here for this short time = > droidz example At the end you can also do a check if it's still clever to cast this spell: For example you have an heal rotation and casting a heal on a 100% health target & bot doesn't interrupt that, because you aren't checking after the cast. With the events you can also check if someone is already casting a heal, on your heal target, so your rotation wouldn't try that. OR you can simply put the tickspeed lower at your fightclass: var timer = new Timer(1000);//tickspeed timer.ForceReady(); while (_isLaunched) { try { if ( Conditions.ProductIsStartedNotInPause && timer.IsReady //&& condition3 ) { //do something every 1 sec } } catch (Exception e) { Logging.WriteError(e.ToString()); } Thread.Sleep(30); } You can also use other examples with a sleep instead of the timer (i don't think that it will change anything). You may also add some other conditions this one is just a template on initialize.
July 29, 20178 yr Author Thanks! So guess something like the following will work alright? Thread.Sleep(_r.Next(300, 650)); Revenge.Launch();
July 29, 20178 yr 11 minutes ago, Apexx said: Thanks! So guess something like the following will work alright? Thread.Sleep(_r.Next(300, 650)); Revenge.Launch(); Yep
Create an account or sign in to comment