CoolEffect 5165 (impulse)

05/15/2012 01:03 U2_Caparzo#1
emmm yes, this a noob release i know, but i'm starting to "work" in this source and i want to share somethings including when they are easy to do, so maybe u can help me to improve the code and improve my skills at coding :p

look for this in entity.cs

public Enums.ConquerAction Action

under the set statment (i dk how to call it :c)

HandleCoolEffect((Enums.ConquerAction)SpawnPacket[63]);

then add this where u want in entity.cs

Code:
        void HandleCoolEffect(Enums.ConquerAction action)
        {
            bool FullSuper = true;
            if (action != Enums.ConquerAction.Cool || Owner.Equipment.TryGetItem(3) == null)
                return;
            else
            {
                uint ID = Owner.Equipment.TryGetItem(3).ID;
                if (IsSuper(ID))
                {
                    Network.GamePackets.StringPacket stringPacket = new Network.GamePackets.StringPacket(true);
                    stringPacket.UID = this.UID;
                    stringPacket.Type = Network.GamePackets.StringPacket.Effect;
                    for (byte i = 1; i < 8; i++)
                    {
                        if (i == 7)
                            continue;
                        if (this.Owner.Equipment.TryGetItem(i) != null)
                        {
                            if (!IsSuper(this.Owner.Equipment.TryGetItem(i).ID))
                            {
                                FullSuper = false;
                                break;
                            }
                        }
                        else
                        {
                            FullSuper = false;
                            break;
                        }
                    }
                    switch (this.Class / 10 * 10)
                    {
                        case 10:
                            {
                                stringPacket.Texts.Add(FullSuper ? "warrior" : "warrior-s");
                                break;
                            }
                        case 20:
                            {
                                stringPacket.Texts.Add(FullSuper ? "fighter" : "fighter-s");
                                break;
                            }
                        case 45:
                            {
                                stringPacket.Texts.Add(FullSuper ? "archer" : "archer-s");
                                break;
                            }
                        case 50:
                            {
                                return;
                            }
                        case 130:
                        case 140:
                            {
                                stringPacket.Texts.Add(FullSuper ? "taoist" : "taoist-s");
                                break;
                            }
                    }
                    Owner.Send(stringPacket);
                }
            }
        }
        bool IsSuper(uint ID)
        {
            return (ID - 9) % 10 == 0;
        }
thanks for read :)
05/15/2012 01:22 Spirited#2
This might help you in your switch statement:
this.Class / 10 * 10.

Also, instead of this:
Code:
if (FullSuper)
    stringPacket.Texts.Add("fighter");
else
    stringPacket.Texts.Add("fighter-s");
You could just do this:
stringPacket.Texts.Add(FullSuper ? "fighter" : "fighter-s");
05/15/2012 01:34 nTL3fTy#3
You could also do it the proper way: [Only registered and activated users can see links. Click Here To Register...]
05/15/2012 01:37 U2_Caparzo#4
Quote:
Originally Posted by Fаng View Post
This might help you in your switch statement:
this.Class / 10 * 10.
srry but i don't understand why :(
#EDIT ohhh i see, lol, 130-139 / 10 = 13 ^^ forgot that too :s


Quote:
Originally Posted by Fаng View Post
Also, instead of this:
Code:
if (FullSuper)
    stringPacket.Texts.Add("fighter");
else
    stringPacket.Texts.Add("fighter-s");
You could just do this:
stringPacket.Texts.Add(FullSuper ? "fighter" : "fighter-s");
totally forgot about that, thanks :)

Quote:
Originally Posted by nTL3fTy View Post
You could also do it the proper way: [Only registered and activated users can see links. Click Here To Register...]
i'll try, thanks too :)

#EDIT
updated.
05/21/2012 09:59 I don't have a username#5
Code:
                    for (byte i = 1; i < 8; i++)
                    {
                        if (i == 7)
                            continue;
Can you see your mistake?

i < 8, that means your for loop will go up to when i is equal to 7
You're telling your loop to continue when i gets to 7, however there is nothing looped after that.

Just do:
Code:
                    for (byte i = 1; i < 7; i++)
                    {
05/21/2012 18:01 U2_Caparzo#6
Quote:
Originally Posted by I don't have a username View Post
Code:
                    for (byte i = 1; i < 8; i++)
                    {
                        if (i == 7)
                            continue;
Can you see your mistake?

i < 8, that means your for loop will go up to when i is equal to 7
You're telling your loop to continue when i gets to 7, however there is nothing looped after that.

Just do:
Code:
                    for (byte i = 1; i < 7; i++)
                    {
Inventory = 0,
Head = 1,
Necklace = 2,
Armor = 3,
RightWeapon = 4,
LeftWeapon = 5,
Ring = 6,
Bottle = 7,
Boots = 8,

the mistake was that the number in the loop should be 9 :s