Register for your free account! | Forgot your password?

Go Back   elitepvpers MMORPGs Conquer Online 2 CO2 Private Server
You last visited: Today at 16:41

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

Advertisement



is that a to large Packet ?

Discussion on is that a to large Packet ? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
is that a to large Packet ?

so i though about adding some cases to this packet an im not sure how bad it is or the The consequences of what i have added to the packet and i though that it might be to large to be sent everytime the player use the skill but im not sure so i need some advice .

this is how the packet looks like and what i have added is to fix the archerban/PoisonStar

PHP Code:
public static byte[] Action(uint EntityIDDictionary<uintintTargetsushort SkillIdbyte SkillLvlushort Xushort Y)
        {
            
byte[] Packet;
            
Packet = new byte[32 + (Targets.Count) * 12];
            
COPacket P = new COPacket(Packet);
            
P.WriteUshortAddPos2((ushort)(Packet.Length 8));
            
P.WriteUshortAddPos2((ushort)0x451);
            
P.WriteUintAddPos4(EntityID);
            
P.WriteUshortAddPos2(X);
            
P.WriteUshortAddPos2(Y);
            
P.WriteUshortAddPos2(SkillId);
            
P.WriteUshortAddPos2(SkillLvl);
            if (
Targets == null)
            {
                
P.WriteUintAddPos4(0);
            }
            else
                
P.WriteUintAddPos4((uint)(Targets.Count));
            if (
Targets != null)
                if (
SkillId != 6002 && SkillId != 6004)
                {
                   foreach (
KeyValuePair<uintintDE in Targets)
                    {
                        
P.WriteUintAddPos4(((uint)DE.Key));
                        
P.WriteUintAddPos4((uint)DE.Value);
                        
P.WriteUintAddPos4(0);
                    }
                }
                else
                {
                    foreach (
KeyValuePair<uintintDE in Targets)
                    {
                        
NPC N = (NPC)WorldTables.H_NPCs[DE.Key];
                        
Character Attacker = (Character)WorldTables.H_Chars[EntityID];
                        
Character Target = (Character)WorldTables.H_Chars[DE.Key];
                        if (
== null)
                        {
                            if (
SkillId == 6002)
                            {
                                
P.WriteUintAddPos4(((uint)DE.Key));
                                
P.WriteUintAddPos4((uint)DE.Value);
                                if ((
Target.Potency) > (Attacker.Potency))
                                {
                                    switch (
SkillLvl)
                                    {
                                        case 
0:
                                            {
                                                if (
MyMath.ChanceSuccess(10))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
1:
                                            {
                                                if (
MyMath.ChanceSuccess(13))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
2:
                                            {
                                                if (
MyMath.ChanceSuccess(16))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
3:
                                            {
                                                if (
MyMath.ChanceSuccess(19))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
4:
                                            {
                                                if (
MyMath.ChanceSuccess(23))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                    }
                                    
                                }
                                else
                                {
                                    switch (
SkillLvl)
                                    {
                                        case 
0:
                                            {
                                                if (
MyMath.ChanceSuccess(15))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
1:
                                            {
                                                if (
MyMath.ChanceSuccess(20))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
2:
                                            {
                                                if (
MyMath.ChanceSuccess(25))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
3:
                                            {
                                                if (
MyMath.ChanceSuccess(30))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                        case 
4:
                                            {
                                                if (
MyMath.ChanceSuccess(35))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.AintUseDrugs SkillId;
                                                    
Target.UseDrugs DateTime.Now;
                                                }
                                                break;
                                            }
                                    }
                                }
                            }
                            else
                            {
                                if ((
Target.Potency) > (Attacker.Potency))
                                {
                                    switch (
SkillLvl)
                                    {
                                        case 
0:
                                            {
                                                if (
MyMath.ChanceSuccess(10))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
1:
                                            {
                                                if (
MyMath.ChanceSuccess(13))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
2:
                                            {
                                                if (
MyMath.ChanceSuccess(16))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
3:
                                            {
                                                if (
MyMath.ChanceSuccess(19))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
4:
                                            {
                                                if (
MyMath.ChanceSuccess(23))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                    }
                                }
                                else
                                {
                                    switch (
SkillLvl)
                                    {
                                        case 
0:
                                            {
                                                if (
MyMath.ChanceSuccess(15))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
1:
                                            {
                                                if (
MyMath.ChanceSuccess(20))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
2:
                                            {
                                                if (
MyMath.ChanceSuccess(25))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
3:
                                            {
                                                if (
MyMath.ChanceSuccess(30))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                        case 
4:
                                            {
                                                if (
MyMath.ChanceSuccess(35))
                                                {
                                                    
P.WriteUintAddPos4(1);
                                                    
Target.Flying false;
                                                }
                                                break;
                                            }
                                    }
                                }
                            }
                        }
                        else
                        {
                            
uint Chance 0;
                            switch(
SkillLvl)
                            {
                                case 
0:
                                    {
                                        
Chance 20;
                                        break;
                                    }
                                case 
2:
                                    {
                                        
Chance 30;
                                        break;
                                    }
                                case 
3:
                                    {
                                        
Chance 50;
                                        break;
                                    }
                                case 
4:
                                    {
                                        
Chance 70;
                                        break;
                                    }
                            }
                            if (
MyMath.ChanceSuccess(Chance))
                            {
                                
P.WriteUintAddPos4(((uint)DE.Key));
                                
P.WriteUintAddPos4((uint)DE.Value);
                                
P.WriteUintAddPos4(1);
                            }
                            else
                            {
                                
P.WriteUintAddPos4(((uint)DE.Key));
                                
P.WriteUintAddPos4((uint)DE.Value);
                                
P.WriteUintAddPos4(0);
                            }
                        }
                    }
                }
            return 
P.AddTQServer8Byte();
        } 
also i wold like to ask,
Should i keep the cases/if statements in a sided void or its fine to have it like what it is

SORRY ITS TO DAMN LONG .
{ Angelius } is offline  
Old   #2
 
taylor2846's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
what source are you using.
taylor2846 is offline  
Old   #3
 
elite*gold: 0
Join Date: Jan 2011
Posts: 2
Received Thanks: 0
please cud sum 1 help me set up a mir server ?
7upguy123 is offline  
Old   #4
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 506
Why did you name those methods like that? Instead you could have used an extra parameter for 'how much to add to the position' LOL.
Basser is offline  
Old   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
I seriously would take out all of that processing and do it somewhere else, the packet is meant to be a template, you drop data in and send it, thats as far as it goes really.
Korvacs is offline  
Thanks
1 User
Old   #6
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
@ taylor2846

Creating My own source :xD

@Basser

That packet is the Result of a quick packet testing it's meant to fix the poisonstar/archerban with out using any other resources (THE PACKET IS THE SKILL)
so far....
i do care about yeah its working but also paying attention the packet size and other stuff .
the less = more Theory and than i can clean/sort **** out

@Korvacs

Thank you
{ Angelius } is offline  
Old   #7
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
Completely agree with korv. There is WAY too much coded into that packet.


Packets should be used for ONE thing in my mind... sending the **** effect. Any other server side stuff should be done in your spell handler which calls the packet.


Personally I use a sendspell class and a Target class (which controls the target uid, dmg and the hit bool)


Example usage..

SendSpell S = new SendSpell(Attacker, X, Y, Skill)
S.Targets.Add(new Target(TargetUID, Dmg, Hit));

Then when ready just do

S.Send();

Simplifies my multi target spells significantly. The class itself is also quite simple just allowing for a list of targets and then construct the packet (size and all) when I run the Send method. Send also does the actual sending of the packet (so it's a void, not a byte[] return type) which further simplifies things. If you think about it though I already have the targets and attacker information so it's easy to determine who all needs to receive the packet. Just ToScreen(Packet, Attacker);
pro4never is offline  
Thanks
1 User
Reply




All times are GMT +2. The time now is 16:43.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

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