Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 15:42

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

Advertisement



Any Tips to optimize this Melee code

Discussion on Any Tips to optimize this Melee code within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2007
Posts: 442
Received Thanks: 21
Any Tips to optimize this Melee code

Code:
{
    if (!IsRunning)
        return;
    if (CLooter::instance()->block())
        return;
    // Seek the nearest role which is a monster.
    int px, py;
    CO::CHero::instance()->getCoords(&px, &py);
    CO::CRole* nearRole = NULL;
    int minDist = INT_MAX;
    for (int i = 0; i < CO::CMobList::instance()->size(); ++i)
    {
        CO::CRole* role = (*CO::CMobList::instance())[i];
        if (role == NULL)
            break;
        if (role->alive() && !(role->isPlayer()))
        {
            int rx, ry;
            role->getCoords(&rx, &ry);
            int dx = rx - px;
            int dy = ry - py;
            int dist = dx*dx + dy*dy;
            if (dist < minDist)
            {
                minDist = dist;
                nearRole = role;
            }
        }
    }
    if (nearRole != NULL)
    {
        //if (!(CPathRecorder::instance()->isBlocked()))
        //    CPathRecorder::instance()->block();
        if (minDist < MinAttackDistance*MinAttackDistance)
        {
            CO::CHero::instance()->melee(nearRole);
        }
        else
        {
            int x, y;
            nearRole->getCoords(&x, &y);
            ++x; ++y;
            int dx = x - px;
            int dy = y - py;
            if (dx*dx+dy*dy>=10*10)
            {
                float a = 10.0 / sqrt(dx*dx+dy*dy);
                dx = (int)(a * (float)dx);
                dy = (int)(a * (float)dy);
            }
            x = px + dx;
            y = py + dy;
            CO::Functions::findClearGround(&x, &y);
            CO::CHero::instance()->jump(x, y);
        }
    }
    else
    {
        //if (CPathRecorder::instance()->isBlocked())
        //    CPathRecorder::instance()->unblock();
    }
}
any tips on how to make it faster for fatal strike??,,,
ha.ho.a is offline  
Old 04/18/2017, 08:09   #2
 
donn's Avatar
 
elite*gold: 0
Join Date: Jan 2007
Posts: 485
Received Thanks: 272
Only for fatal strike or you're looking for a code working for any melee attacks? Because for fatal strike you don't need to jump before attack, just send the attack packet.

Also, in CO2 world, jumping 18 coords or 1 coord takes the same amount of time. So finding the closest mob does not always implies a faster melee. Attacking the first mob in your mobs list that is in attack range should save a few loops.
donn is offline  
Thanks
2 Users
Old 04/30/2017, 20:13   #3
 
elite*gold: 0
Join Date: Jan 2009
Posts: 19
Received Thanks: 8
Just wondering... you use some public CO API or made your own?
detuks is offline  
Old 05/01/2017, 01:05   #4
 
elite*gold: 0
Join Date: Sep 2006
Posts: 774
Received Thanks: 8,576
Quote:
Originally Posted by detuks View Post
Just wondering... you use some public CO API or made your own?
phize is offline  
Reply


Similar Threads Similar Threads
Anyone can optimize this code ?
11/30/2013 - CO2 Private Server - 17 Replies
Kindly make this code better guys. I want a port refresher that uses less Cpu usage. static void Port_Refresher() { while (true) { { AuthServer.Disable(); AuthServer = null;
Udobot Source Code & Tips for build a bot
03/16/2013 - DarkOrbit - 28 Replies
Hi, first apologize me because my English is not good, here is the udobot 4 source code for people that wants to know how to build a bot for darkorbit I build my own bot in Visual Basic, works fine and is secure, if you want some tips please put a post and I will help you the udobot source file is in Visual C++ 2008, and txvirus (Udobot's creator) leave this code like a freeware when last Udobot official version was released. Los que hablan espaņol al igual que yo pueden poner sus...
MELEE HIT TIPS *SPECIAL FOR WARRIOR
10/23/2008 - CO2 Exploits, Hacks & Tools - 19 Replies
Btw..Im not sure if this tips has being posted before. But, if not..just give a try ;) First, go to option>hotkeys>sit make a hotkey of CTRL + Z for the sit Now ill show how its work.. Everytime u try to hit the monster.. when the monster near u,hit it..then Press SIT then jump to the others monster
guys, do the melee hack/ atk speed for melee working?
04/29/2008 - RF Online - 4 Replies
i'm asking if its working or not coz i find it hard to make it work.. thanks for replies..



All times are GMT +2. The time now is 15:42.


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.