Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server > CO2 PServer Guides & Releases
You last visited: Today at 15:06

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

Advertisement



How to structure your attack handler proper.

Discussion on How to structure your attack handler proper. within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
How to structure your attack handler proper.

Note: There is no calculations or codes really, but more a good way to structure your attack handler, so it's easy to edit in the future or add new things.

Note 2: It's the way I would do it, maybe you like to it do it different.

Note 3: It's all pseudo.

Let's say you have your main attack handler.
Code:
public static void Attack(Client client)
{
}
Then I would do a main attack handling & split it up to the different attack types. Physical, Magic & Bow.

Code:
public static void Attack(Client client)
{

// Main attack handler here.
    switch (client.AttackType)
    {
        case Physical:
            PhysicalAttack.Process(client);
            break;

        case Magic:
            MagicAttack.Process(client);
            break;

        case Bow:
            BowAttack.Process(client);
            break;
    }

}
Then I would do a class for every attack type & it should contains a void called Process, which is handling the process for that type.

Example:
Code:
public class PhysicalAttack
{
    public static void Process(Client client)
    {
    }
}
Now you already have a good structure for your main attack handler, but how can this be useful?

Instead having a bunch of codes in your attackhandler, then you can easy edit current things or add new things.

Don't make it harder for yourself, that's important.
I would do an integer for every function that should be parsed before the actual attack handler. It could be arena, tournaments or something other.

Then if it returns 0, then it should continue to the main attackhandler. If it returns above 0, then it should not continue to the main attackhandler.

All the calculations etc. should be done before the attackhandler.

Example on how to add a function.
Let's use the current code we have.

Code:
public static int Safe(Client client)
{

    if (client.Map != client.Opponent.Map)
        return 1;//Instead returning true at the start, then do it after the handler.

    return 0;
}
public static void Attack(Client client)
{

if (Safe(client) > 0)
    return;

// Main attack handler here.
    switch (client.AttackType)
    {
        case Physical:
            PhysicalAttack.Process(client);
            break;

        case Magic:
            MagicAttack.Process(client);
            break;

        case Bow:
            BowlAttack.Process(client);
            break;
    }

}
I know there is not much info, but I hope you find it useful.
Remember I would have the functions in a seperate fil!
BaussHacker is offline  
Thanks
2 Users
Old 05/23/2011, 17:26   #2
 
|NeoX's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 237
Received Thanks: 99
I am also a friend of more small voids than one big one.
But seriously, everyone should do it as they like it, sure a company who hires someone will have their standards and your way is much more readable for sure, its up to them how they work.

I agree to your formatting.
Finally you move away from that eye-cancer causing coding style u had when you started
|NeoX is offline  
Old 05/23/2011, 17:32   #3
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885

BOWLATTACK
/troll

Any how I fairly agree with the way it's being handled. It more or less coincides with my system scheme in ConquerServer_v2
InfamousNoone is offline  
Thanks
2 Users
Old 05/23/2011, 17:37   #4
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by InfamousNoone View Post

BOWLATTACK
/troll

Any how I fairly agree with the way it's being handled. It more or less coincides with my system scheme in ConquerServer_v2
Oh wait a minute. I see my spelling mistake.
BaussHacker is offline  
Old 05/24/2011, 00:37   #5
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
... Learn to use boolean return values....

But yes, most public sources already use this type of an idea. I know I personally do.
pro4never is offline  
Old 05/24/2011, 08:20   #6
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by pro4never View Post
... Learn to use boolean return values....

But yes, most public sources already use this type of an idea. I know I personally do.
It doesn't matter. It's not operating faster.
BaussHacker is offline  
Old 05/24/2011, 09:31   #7
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Quote:
Originally Posted by BaussHacker View Post
It doesn't matter. It's not operating faster.
It's not about operating speed here, but how easily read it is. For example, your "Safe" function, whereas Safe is a question that can be answered with yes/no, you should rather return a boolean than an integer.

Safe?
Do this
Not safe?
Do this instead
_Emme_ is offline  
Old 05/24/2011, 09:41   #8
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by EmmeTheCoder View Post
It's not about operating speed here, but how easily read it is. For example, your "Safe" function, whereas Safe is a question that can be answered with yes/no, you should rather return a boolean than an integer.

Safe?
Do this
Not safe?
Do this instead
True that.
BaussHacker is offline  
Old 05/25/2011, 14:03   #9


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
typedef int bool;
KraHen is offline  
Old 05/27/2011, 14:29   #10
 
ImmuneOne's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 754
Received Thanks: 544
Quote:
Originally Posted by KraHen View Post
typedef int bool;
..
ImmuneOne is offline  
Reply


Similar Threads Similar Threads
SQL-DB structure
05/29/2010 - Silkroad Online - 0 Replies
Hey folks, does anyone happen to have the structure of the official SRO SQL-DB? I need no more than the column names and their associated table names (usually located in the DB "INFORMATION_SCHEMA").
[C] Player Structure [PW-MS]
03/16/2010 - PW Hacks, Bots, Cheats, Exploits - 5 Replies
Hi everyone. Just wanna share the stuff i found out when reversing the game. Assuming you are using dll injectiong and you have the base pointer to all player stats, you can simply access all the data from a nice and userfriendly structure. Here how to read from memory: VARBASE *Stats = 0xBASEPOINTER; printf("Player HP: %d/%d", Stats->p_Player->Current_HP, Stats->p_Player->Maximum_HP); And here the structure you need to make this available: typedef unsinged char BYTE;
TQ Database Structure
10/16/2009 - CO2 Private Server - 1 Replies
INSERT INTO `cq_generator` VALUES ('6102', '1075', '0493', '0563', '0021', '0038', '0015', '0001', '0010', '0011', '0000', '0000', '0000', '0000'); index0 = spawnUID index 1 = mapID index 2 = X index 3 = Y index 4 = (not 100%, but i think it's X spawn radius) index 5 = (not 100%, but i think it's Y spawn radius) index 6 = amount to spawn? index 7 = ?
packet structure
03/09/2008 - Conquer Online 2 - 16 Replies
For what I'd like to do, I think packets are the place to start. After that, probably java then C and VB. This is a question for the people here who are self-taught... what resources would you recommend for... 1. understanding packet structure 2. learning some programming language without enrolling at the local university I'm mainly interested in packet structure and how to capture/decipher/edit/send them, and eventually I'd like to "automate" these functions by writing some programs. ...



All times are GMT +1. The time now is 15:10.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.