Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Mabinogi
You last visited: Today at 00:35

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] Async task in c++

Discussion on [Release] Async task in c++ within the Mabinogi forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
[Release] Async task in c++

Alright, here comes a little trick you guys can use to write a pake script.
What I gonna introduce is the async function template comes with c++11.

So, simple sample. Suppose you wanna constantly use one skill, in your SendHook function:
Code:
...
int opcode=packet.GetOP();
switch (opcode) {
case 0x6987: int skillID=packet.GetElement(0)->int32;
             if (skillID==AUTO_SKILL) {
               std::async([]() { Sleep(5000); use_skill(AUTO_SKILL); });
             }
             break;
...
}
...
Note a lambda is passed to async call. What is does is basically send 0x6982 to use the same skill 5 seconds after every time the skill was released, assuming the CD is 5 seconds. You can manually adjust the time to wait.

The sample above is the most basic thing async can do. However it's very powerful for writing automated stuff, figure it out.
Caesarw is offline  
Old 12/13/2014, 11:26   #2
♥ Yuuki Asuna ♥



 
DarkOPM's Avatar
 
elite*gold: 45
The Black Market: 140/0/0
Join Date: Jun 2005
Posts: 54,467
Received Thanks: 8,536
Arrow Mabinogi Hacks, Bots, Cheats & Exploits -> Mabinogi

#moved
DarkOPM is offline  
Old 12/15/2014, 09:16   #3
 
Ayamin's Avatar
 
elite*gold: 0
Join Date: Oct 2008
Posts: 345
Received Thanks: 85
Oooo is that similar to an anonymous function?
Ayamin is offline  
Old 12/15/2014, 16:22   #4
 
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
Quote:
Originally Posted by Ayamin View Post
Oooo is that similar to an anonymous function?
yep
the interesting feature of c++ lambda is capture
which can access variables outside the lambda function
Caesarw is offline  
Thanks
1 User
Old 12/16/2014, 12:04   #5
 
elite*gold: 0
Join Date: Mar 2013
Posts: 43
Received Thanks: 10
it looks like c++ has got some sugar, hopefully they solved their garbage collector problems.

and btw,
doing sleep inside async thread is generally bad practice
the whole purpose of async programming is to get rid of things like sleep and poll
if you want a pace limit, build a queue and pace it properly.
ayjani is offline  
Thanks
2 Users
Old 01/28/2015, 01:44   #6
 
elite*gold: 0
Join Date: Oct 2011
Posts: 72
Received Thanks: 19
what about keypresser or u need a specific tool >??
Terrorpur is offline  
Old 02/12/2015, 21:21   #7
 
elite*gold: 0
Join Date: Apr 2014
Posts: 19
Received Thanks: 0
Quote:
Originally Posted by Caesarw View Post
Alright, here comes a little trick you guys can use to write a pake script.
What I gonna introduce is the async function template comes with c++11.

So, simple sample. Suppose you wanna constantly use one skill, in your SendHook function:
Code:
...
int opcode=packet.GetOP();
switch (opcode) {
case 0x6987: int skillID=packet.GetElement(0)->int32;
             if (skillID==AUTO_SKILL) {
               std::async([]() { Sleep(5000); use_skill(AUTO_SKILL); });
             }
             break;
...
}
...
Note a lambda is passed to async call. What is does is basically send 0x6982 to use the same skill 5 seconds after every time the skill was released, assuming the CD is 5 seconds. You can manually adjust the time to wait.

The sample above is the most basic thing async can do. However it's very powerful for writing automated stuff, figure it out.
Could you please tell me how did you manage to call the Send function in the async lambda function? I have tried similar methods but the client crashes every time it reaches the Send function.
Thanks.
anonentity is offline  
Old 02/13/2015, 16:52   #8
 
elite*gold: 0
Join Date: Feb 2012
Posts: 112
Received Thanks: 12
Quote:
Originally Posted by anonentity View Post
Could you please tell me how did you manage to call the Send function in the async lambda function? I have tried similar methods but the client crashes every time it reaches the Send function.
Thanks.
you are right.
all code in aysnc block run in a newly created thread.
so..
put all aysnc tasks outside the client process, then use message to communicate with alissa's window, which will then call send in the main thread.
Caesarw is offline  
Reply


Similar Threads Similar Threads
[Release] Task Killer
02/08/2015 - Diablo 2 - 34 Replies
Ich habe mal ein kleines Programm geschrieben welches Przesse mit keiner rückmeldung schließt... das Programm von Muddy hat mir nichts gebracht da es zwar den Prozess erkannt aber nicht geschlossen hat. Gedacht ist das Programm für Muddys D2NT Bot. (für den Freeze) Was tut dieses Programm?: Es überprüft alle 30 Sekunden ob ein Prozess reagiert. Falls keine Reaktion erfolgt wird der Prozess beendet. (Das Programm überprüft ALLE Prozesse nicht nur Diablo II) Bedienung (XP...
[C#]Async Socket
01/09/2014 - CO2 PServer Guides & Releases - 2 Replies
Hey , this is my first test of coding a socket :D ServerSocket - iPiraTe - Pastebin.com Notice : i didn't finished it yet .. i wanted to know ur opinion first
[Release]Async Sockets (No packet-splitter)
09/20/2012 - CO2 Programming - 16 Replies
So after seeing this thread: http://www.elitepvpers.com/forum/co2-pserver-discu ssions-questions/2129268-problem-packet-splitting. html I thought I'd make some socket server that could handle the packets without needing to split. Source: BasicClient.cs using System;



All times are GMT +2. The time now is 00:35.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.