Jump to content

About This File

I've been using Schedule product for a while now but was not able to figure out how to shutdown pc after it's done.

I am still not lvl 60 so I use the Scheduler in a way that it ends with /To home, in other words it uses HS.

So I coded this plugin to check HS cooldown. If it is on CD, which means the Scheduler has finished, it shuts down the PC.

 

WARNING: do not start bot with this plugin enabled when having your HS on CD, it will shut your PC down right then and there, obviously ;)


User Feedback

Recommended Comments

reapler

Posted

@Seminko nice to have the plugin. I'd recommend to check the duration off your hearthstone rather to just check if it's on cooldown or using events for it:

        wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaWithArgs += (id, args) =>
        {
            if (id == wManager.Wow.Enums.LuaEventsId.UNIT_SPELLCAST_SUCCEEDED && args[0] == "player" && args[1] == "Hearthstone")
            {
                robotManager.Helpful.Logging.Write("Player casted hearthstone\n=>Start Shutdown in 3 seconds");
                var t = System.Threading.Tasks.Task.Run(async delegate
                {
                    await System.Threading.Tasks.Task.Delay(3000);
                    robotManager.Helpful.Logging.Write("Shutdown...");
		    Thread.Sleep(100)
                    Process.Start("shutdown", "/s /t 0");
                });
            }
        };

It needs no loop.

Seminko

Posted

Will look into it. Thanks!

Seminko

Posted

20 hours ago, reapler said:

@Seminko nice to have the plugin. I'd recommend to check the duration off your hearthstone rather to just check if it's on cooldown or using events for it:

It needs no loop.

wManager.Wow.Enums.LuaEventsId doesn't containt definition for UNIT_SPELLCAST_SUCCEEDED

I'm using vanilla wrobot

reapler

Posted

@Seminko I haven't currently the binaries for vanilla, but you can try this instead

            float minutesLeft = 29.5f; //define this above loop     if patch is wotlk or above else use 59.5f for vanilla and tbc
            if (wManager.Wow.Helpers.SpellManager.GetSpellCooldownTimeLeft(8690) / 1000 / 60 > minutesLeft) // if HS is used, wait 15 seconds, write into log file and shutdown the computer
            {
                Logging.Write("Shutdown in 15 seconds");
                Thread.Sleep(15000);
                Process.Start("shutdown", "/s /t 0");
            }

I'm pretty sure someone can provide you the event because this is bogus to check in loop ;)

Seminko

Posted

32 minutes ago, reapler said:

@Seminko I haven't currently the binaries for vanilla, but you can try this instead


            float minutesLeft = 29.5f; //define this above loop     if patch is wotlk or above else use 59.5f for vanilla and tbc
            if (wManager.Wow.Helpers.SpellManager.GetSpellCooldownTimeLeft(8690) / 1000 / 60 > minutesLeft) // if HS is used, wait 15 seconds, write into log file and shutdown the computer
            {
                Logging.Write("Shutdown in 15 seconds");
                Thread.Sleep(15000);
                Process.Start("shutdown", "/s /t 0");
            }

I'm pretty sure someone can provide you the event because this is bogus to check in loop ;)

How is this different to what I'm doing? I'm checking for item cooldown, you're checking for spell cooldown.

reapler

Posted

oh haven't looked there, it doesn't matter.

Seminko

Posted

13 hours ago, reapler said:

oh haven't looked there, it doesn't matter.

I would really like to try the event, without the while loops. I saw you giving the exact code with UNIT_SPELLCAST_SUCCEEDED to someone and he "liked" it so presumably it works. Not sure why it doesn't work for my particular case. Maybe cause it's a plugin and with how they are structured?

reapler

Posted

@Seminko It's because the events are different from vanilla to wotlk. I had assumed you are using some higher client since you post your plugin here.

For vanilla you might look in your decompiler under LuaEventsId.

"SPELLCAST_START" looks fine for your goal for finished cast dunno.

           if (id == wManager.Wow.Enums.LuaEventsId.SPELLCAST_START && args[0] == "player" && args[1] == "Hearthstone")

The "args[]" should be also fine (i don't think they have changed something as it was replaced by "UNIT_SPELLCAST_START" in 2.4).

Otherwise you can test & lookup what's in the arguments or use other LuaEventsId:

        wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaWithArgs += (id, args) =>
        {
            if (id == wManager.Wow.Enums.LuaEventsId.SPELLCAST_START)
            {
                for (var i = 0; i < args.Count; i++)
                {
                    robotManager.Helpful.Logging.Write("args["+i+"] contains: "+args[i]);
                }
            }
        };

 

×
×
  • Create New...