[Guide] make Effects viewable by players

03/09/2010 03:53 kamote#1
I feel so darn` to found out this late... in Character.cs there is a pre-made void/method called SendScreen() which has a code that would send packets to any nearby players from the executor player.

With this we may able now to use SendScreen instead of using AddSend method to any Effect code that we want... example in my previous CoolEffect UPDATE I used to have this code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewestCOServer.PacketHandling
{
   class CoolEffect
    {
        public static void ActiveCool(Main.GameClient MyClient)
        {
            byte counter = 0;

            for (byte i = 1; i < 9; i++)
            {
                if (i == 7) i++;
                Game.Item I = MyClient.MyChar.Equips.Get(i);
                if (I.ID != 0)
                {
                    Game.ItemIDManipulation Q = new CoPinoy.Game.ItemIDManipulation(I.ID);
                    if (Q.Quality == Game.Item.ItemQuality.Super)
                        counter += 1;
                }
            }

            if (MyClient.MyChar.Job >= 100)
                if (counter == 6)
                    counter = 7;
            if (MyClient.MyChar.Job >= 40 && MyClient.MyChar.Job <= 45)
                if (counter == 6)
                {
                    Game.Item I = MyClient.MyChar.Equips.Get(5);
                    I.ID = MyClient.MyChar.Equips.LeftHand.ID;
                    if (I.ID == 0)
                        counter = 7;
                }
            new Thread(delegate()
            {
                [COLOR="Blue"]foreach (Game.Character CC in Game.World.H_Chars.Values)[/COLOR]
                {
                   [COLOR="Lime"] if (CC.Loc.Map == MyClient.MyChar.Loc.Map && MyMath.InBox(MyClient.MyChar.Loc.X, MyClient.MyChar.Loc.Y, CC.Loc.X, CC.Loc.Y, 100))[/COLOR]
                    {
                        if (counter == 7)
                        {
                            if (MyClient.MyChar.Job >= 10 && MyClient.MyChar.Job <= 15)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "warrior"));
                            else if (MyClient.MyChar.Job >= 20 && MyClient.MyChar.Job <= 25)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "fighter"));
                            else if (MyClient.MyChar.Job >= 100)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "taoist"));
                            else if (MyClient.MyChar.Job >= 39 && MyClient.MyChar.Job <= 46)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "archer"));
                            else if (MyClient.MyChar.Job >= 50 && MyClient.MyChar.Job <= 55)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "Ninja120"));
                        }
                        else
                        {
                            if (MyClient.MyChar.Job >= 10 && MyClient.MyChar.Job <= 15)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "warrior-s"));
                            else if (MyClient.MyChar.Job >= 20 && MyClient.MyChar.Job <= 25)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "fighter-s"));
                            else if (MyClient.MyChar.Job >= 100)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "taoist-s"));
                            else if (MyClient.MyChar.Job >= 39 && MyClient.MyChar.Job <= 46)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "archer-s"));
                            else if (MyClient.MyChar.Job >= 50 && MyClient.MyChar.Job <= 55)
                                CC.MyClient.[COLOR="Red"]AddSend[/COLOR](Packets.String(MyClient.MyChar.EntityID, 10, "Ninja120"));
                        }
                    }
                    MyClient.MyChar.Action = 100;
                }
            }).Start();   
        }
    }
}
obviously in this code I uses a for each loop(in color blue) that would map/iterate the number of players in the game and in side the loop i have a conditional statement(in color green) that would check either a particular player that has been mapped from the game is a nearby player, If so the latter effect will be executed. this algorithm is likely similar to the algorithm in SendScreen() method found in Character.cs, so therefore we may able to change the code above and make it look simpler like this.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NewestCOServer.PacketHandling
{
   class CoolEffect
    {
        public static void ActiveCool(Main.GameClient MyClient)
        {
            byte counter = 0;

            for (byte i = 1; i < 9; i++)
            {
                if (i == 7) i++;
                Game.Item I = MyClient.MyChar.Equips.Get(i);
                if (I.ID != 0)
                {
                    Game.ItemIDManipulation Q = new CoPinoy.Game.ItemIDManipulation(I.ID);
                    if (Q.Quality == Game.Item.ItemQuality.Super)
                        counter += 1;
                }
            }

            if (MyClient.MyChar.Job >= 100)
                if (counter == 6)
                    counter = 7;
            if (MyClient.MyChar.Job >= 40 && MyClient.MyChar.Job <= 45)
                if (counter == 6)
                {
                    Game.Item I = MyClient.MyChar.Equips.Get(5);
                    I.ID = MyClient.MyChar.Equips.LeftHand.ID;
                    if (I.ID == 0)
                        counter = 7;
                }
                if (counter == 7)
                {
                  if (MyClient.MyChar.Job >= 10 && MyClient.MyChar.Job <= 15)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "warrior"));
                            else if (MyClient.MyChar.Job >= 20 && MyClient.MyChar.Job <= 25)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "fighter"));
                            else if (MyClient.MyChar.Job >= 100)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "taoist"));
                            else if (MyClient.MyChar.Job >= 39 && MyClient.MyChar.Job <= 46)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "archer"));
                            else if (MyClient.MyChar.Job >= 50 && MyClient.MyChar.Job <= 55)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "Ninja120"));
                        }
                        else
                        {
                            if (MyClient.MyChar.Job >= 10 && MyClient.MyChar.Job <= 15)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "warrior-s"));
                            else if (MyClient.MyChar.Job >= 20 && MyClient.MyChar.Job <= 25)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "fighter-s"));
                            else if (MyClient.MyChar.Job >= 100)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "taoist-s"));
                            else if (MyClient.MyChar.Job >= 39 && MyClient.MyChar.Job <= 46)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "archer-s"));
                            else if (MyClient.MyChar.Job >= 50 && MyClient.MyChar.Job <= 55)
                                MyClient.MyChar.SendScreen(Packets.String(MyClient.MyChar.EntityID, 10, "Ninja120"));
                        }
                    }
                    MyClient.MyChar.Action = 100;
                }
            }).Start();   
        }
    }
}
03/09/2010 04:07 copz1337#2
gj
03/09/2010 04:48 -NewDawn-#3
Shouldn't it be MyClient.MyChar.SendScreen?
good job btw.
03/09/2010 04:48 walmartboi#4
Very nice. Wouldn't of thought of this by myself, so you deserve my special thanks. :P
03/09/2010 05:35 salem rey#5
I got error, dont have definition of SendScreen.
03/09/2010 05:41 walmartboi#6
Quote:
Originally Posted by salem rey View Post
I got error, dont have definition of SendScreen.
Dude, it's not 'really' that hard to fix that, just a simple adding of GC or MyChar(which ever one it is) will fix it.
03/09/2010 05:57 salem rey#7
Can you tell me how to do it? im a super noob please.?
03/09/2010 06:23 walmartboi#8
Quote:
Originally Posted by salem rey View Post
Can you tell me how to do it? im a super noob please.?
No offense, but if you can't trouble-shoot simple errors like that by yourself, you shouldn't have a private server of ANY KIND. You've been around here for over a month, you should at least know how some of the things in your server run.
03/09/2010 06:28 kamote#9
Quote:
Originally Posted by salem rey View Post
Can you tell me how to do it? im a super noob please.?
sorry if i forgot MyChar in my example code above.

anyway do it this way... MyClient.MyChar.SendScreen or if you're using GC ... it should be GC.MyChar.SendScreen
03/09/2010 07:15 -NewDawn-#10
Quote:
Originally Posted by walmartboi View Post
No offense, but if you can't trouble-shoot simple errors like that by yourself, you shouldn't have a private server of ANY KIND. You've been around here for over a month, you should at least know how some of the things in your server run.
damn... what crawled up your ass?
Help the community- don't criticize it.
03/09/2010 08:40 ramix#11
why ppl you not use this

Quote:
Game.World.Action(GC.MyChar, Packets.String(GC.MyChar.EntityID, 10, "warrior").Get);

that is more simple and work 100%
03/09/2010 08:43 Arcо#12
Quote:
Originally Posted by ramix View Post
why ppl you not use this




that is more simple and work 100%
Won't that show it to EVERYONE in the server instead of just people in your area?
03/09/2010 08:52 pro4never#13
Quote:
Originally Posted by -NewDawn- View Post
damn... what crawled up your ass?
Help the community- don't criticize it.
It comes to a point (rather often on epvp) where people just need the truth. If you've read any of her threads he/she doesn't really understand English and doesn't even try half the time. People have tried to help and offered a number of times but it turns into them being expected to do it line by line 100 pct themselves with him/her not even trying.

When it gets to that point, a little criticism is deserved imo. He wasn't being overly harsh.

</offtopic>

Looks to be a good release... shocking that lotf doesn't have something like this built in but I suppose it shouldn't be.
03/09/2010 09:27 LegalConquer#14
yeh i agree she was here when i first started on the forums and it looked like she was here quite sometime when i started making my own p server and ive basicly debugged mine 100% and shes still getting stuck on stuff like that... shes not even trying tbh, she needs to start meeting us half way at some point.
03/09/2010 09:29 ramix#15
Quote:
Originally Posted by .Arco View Post
Won't that show it to EVERYONE in the server instead of just people in your area?
show only the ppl is in the area... i tested and works good for me...