[Release]Fixed SS/FB System

02/02/2010 00:49 Hanibal#31
When I changed public class MyMath - public static class MyMath you can't attack anything on my server and it spams an error in the console which goes to this line

Code:
GetMobTargets(Single);
02/02/2010 03:30 kamote#32
Quote:
Originally Posted by walmartboi View Post
It's not other areas in the source, it's in what he posted:

Code:
public static List<coords> bresenham(int x0, int y0, int x1, int y1)
        {
            List<coords> ThisLine = new List<coords>();

            int dy = y1 - y0;
            int dx = x1 - x0;
            int stepx, stepy;

            if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
            if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
            dy <<= 1;                                                  
            dx <<= 1;                                                  

            [COLOR="Red"]ThisLine.Add(x0, y0);[/COLOR]
            if (dx > dy)
            {
                int fraction = dy - (dx >> 1);                         
                while (x0 != x1)
                {
                    if (fraction >= 0)
                    {
                        y0 += stepy;
                        fraction -= dx;                                
                    }
                    x0 += stepx;
                    fraction += dy;                                   
                    [COLOR="Red"]ThisLine.Add(x0, y0);[/COLOR]
                }
            }
            else
            {
                int fraction = dx - (dy >> 1);
                while (y0 != y1)
                {
                    if (fraction >= 0)
                    {
                        x0 += stepx;
                        fraction -= dy;
                    }
                    y0 += stepy;
                    fraction += dx;
                    [COLOR="Red"]ThisLine.Add(x0, y0);[/COLOR]
                }
            }
            return ThisLine;
        }
Marked the errors in red.

change those with this one
Quote:
ThisLine.Add(new coords((ushort)x0, (ushort)y0));
02/02/2010 08:42 walmartboi#33
No, it's all good, I got mine working perfectly + added a few more angles that were missed in the initial algorithm. :)
02/05/2010 00:47 © Haydz#34
I rarely ever say this but, this is actually a very good release.

Albeit, very different to my implementation, but still, nice to see something useful released.

Also take a look at the DDA line algorithm that TQ uses for fastblade and scentsword.

It can be found in the EO Source - 'BaseFunc.cpp - DDALine'

However the above needs converting to C#
02/05/2010 01:00 Arcо#35
Quote:
Originally Posted by © Haydz View Post
I rarely ever say this but, this is actually a very good release.

Albeit, very different to my implementation, but still, nice to see something useful released.

Also take a look at the DDA line algorithm that TQ uses for fastblade and scentsword.

It can be found in the EO Source - 'BaseFunc.cpp - DDALine'

However the above needs converting to C#
Wow.
Coming from you that means alot.
Seriously.
Thanks haydz:]
02/05/2010 03:22 glover#36
It's work perfectly without errors. Dudes try to learn copy & paste ^^
02/05/2010 09:27 gulpi_de_gulat#37
wow its works perfect thankz
02/08/2010 23:48 CompacticCo#38
Very nice dude, keep it up!
02/08/2010 23:55 copz1337#39
lol damn you just released the most important fix for the source. >.<
02/10/2010 10:55 5555#40
ive error ,
Quote:
foreach (Character C in World.H_Chars.Values)
{
if (C.Alive && (C != User || Info.Damageing == DamageType.HealHP || Info.Damageing == DamageType.HealMP))
{
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(C.Loc.X, C.Loc.Y)) || Info.Targetting != TargetType.Linear)
if (C.PKAble(User.PKMode, User) && !PlayerTargets.Contains(C) && !World.NoPKMaps.Contains(User.Loc.Map) || Info.ExtraEff == ExtraEffect.UnMount)
if (Game.World.NoPKMaps.Contains(User.Loc.Map) && GetDamage(C) == 0 || !Game.World.NoPKMaps.Contains(User.Loc.Map) || (Info.ExtraEff == ExtraEffect.UnMount && C.StatEff.Contains(StatusEffectEn.Ride)) && C.Equips.Steed.Plus < User.Equips.Steed.Plus)
if (true)
PlayerTargets.Add(C, GetDamage(C));
}
}
} expected

ive added it, but it doesnt working sorry guys im a newbie :( gimme answer please
02/10/2010 12:58 StarEvaAfta!~#41
Great Release bro +
02/20/2010 11:11 jackmacc#42
The call is ambiguous between the following methods or properties: 'NewestCOServer.MyMath.LineCoords(ushort, ushort, ushort, ushort, byte)' and 'NewestCOServer.MyMath.LineCoords(ushort, ushort, ushort, ushort, byte)'


Anyone wanna help? I got 4 of those errors lol
02/20/2010 14:05 StarEvaAfta!~#43
Error on every coords , HELP MEH :*(
02/25/2010 03:18 killersub#44
Quote:
Originally Posted by .Arco View Post
Big credits to saint for showing me the geometry behind this.

First go to MyMath.cs and search for
Code:
public static class MyMath
and over that put this:
Code:
public struct coords
    {
        public int X;
        public int Y;

        public coords(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }

Next go to MyMath.cs and search for
Code:
static Random Rnd = new Random();
Under that insert this:
Code:
public static bool Contains(this coords[] Coords, coords Check)
        {
            foreach (coords Coord in Coords)
                if (Coord.X == Check.X && Check.Y == Coord.Y)
                    return true;
            return false;
        }
        public static List<coords> LineCoords(ushort userx, ushort usery, ushort shotx, ushort shoty, byte length)
        {
            double dir = Math.Atan2(shoty - usery, shotx - userx);
            double f_x = (Math.Cos(dir) * length) + userx;
            double f_y = (Math.Sin(dir) * length) + usery;

            return bresenham(userx, usery, (int)f_x, (int)f_y);
        }
        public static void Add(this List<coords> Coords, int x, int y)
        {
            coords add = new coords((ushort)x, (ushort)y);
            if (!Coords.Contains(add))
                Coords.Add(add);
        }
        public static List<coords> bresenham(int x0, int y0, int x1, int y1)
        {
            List<coords> ThisLine = new List<coords>();

            int dy = y1 - y0;
            int dx = x1 - x0;
            int stepx, stepy;

            if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
            if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
            dy <<= 1;                                                  
            dx <<= 1;                                                  

            ThisLine.Add(x0, y0);
            if (dx > dy)
            {
                int fraction = dy - (dx >> 1);                         
                while (x0 != x1)
                {
                    if (fraction >= 0)
                    {
                        y0 += stepy;
                        fraction -= dx;                                
                    }
                    x0 += stepx;
                    fraction += dy;                                   
                    ThisLine.Add(x0, y0);
                }
            }
            else
            {
                int fraction = dx - (dy >> 1);
                while (y0 != y1)
                {
                    if (fraction >= 0)
                    {
                        x0 += stepx;
                        fraction -= dy;
                    }
                    y0 += stepy;
                    fraction += dx;
                    ThisLine.Add(x0, y0);
                }
            }
            return ThisLine;
        }
Now open Skills.cs and go to this line:
Code:
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist) && GuildWars.War && User.MyGuild != GuildWars.LastWinner)
Replace all this:
Code:
                    if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist) && GuildWars.War && User.MyGuild != GuildWars.LastWinner)
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.ThePole.EntityID, GetDamage(GuildWars.ThePole.CurHP));

                    if (GuildWars.War && !GuildWars.TheRightGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist))
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.TheRightGate.EntityID, GetDamage(GuildWars.TheRightGate.CurHP));

                    if (GuildWars.War && !GuildWars.TheLeftGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist))
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.TheLeftGate.EntityID, GetDamage(GuildWars.TheLeftGate.CurHP));
With this:
Code:
                    List<coords> Line = new List<coords>(5);
                    if (Info.Targetting == TargetType.Linear)
                        Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
                    if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) <= Info.MaxDist) && GuildWars.War && User.MyGuild != GuildWars.LastWinner)
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(GuildWars.ThePole.Loc.X, GuildWars.ThePole.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.ThePole.EntityID, GetDamage(GuildWars.ThePole.CurHP));

                    if (GuildWars.War && !GuildWars.TheRightGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) <= Info.MaxDist))
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(GuildWars.TheRightGate.Loc.X, GuildWars.TheRightGate.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.TheRightGate.EntityID, GetDamage(GuildWars.TheRightGate.CurHP));

                    if (GuildWars.War && !GuildWars.TheLeftGate.Opened && (!RangeFromChar && MyMath.PointDistance(AimX, AimY, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist || MyMath.PointDistance(User.Loc.X, User.Loc.Y, GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) <= Info.MaxDist))
                        if (Info.Targetting == TargetType.Sector && InSector(GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y) || Info.Targetting != TargetType.Sector)
                            if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(GuildWars.TheLeftGate.Loc.X, GuildWars.TheLeftGate.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                MiscTargets.Add(GuildWars.TheLeftGate.EntityID, GetDamage(GuildWars.TheLeftGate.CurHP));
Now still in Skills.cs, search for:
Code:
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
Under that put this
Code:
                    List<coords> Line = new List<coords>(5);
                    if (Info.Targetting == TargetType.Linear)
                        Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
Now find this:
Code:
                        foreach (Mob M in MapMobs.Values)
                        {
                            if (M.Alive)
                            {
                                if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, M.Loc.X, M.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) <= Info.MaxDist)
                                    if (Info.Targetting == TargetType.Sector && InSector(M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Sector)
                                        if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Linear)
                                            if (User.PKMode == PKMode.PK || !M.NeedsPKMode && !MobTargets.Contains(M))
                                                MobTargets.Add(M, GetDamage(M));
                            }
                        }
And replace it with this:
Code:
                        foreach (Mob M in MapMobs.Values)
                        {
                            if (M.Alive)
                            {
                                if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, M.Loc.X, M.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) <= Info.MaxDist)
                                    if (Info.Targetting == TargetType.Sector && InSector(M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Sector)
                                        if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(M.Loc.X, M.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                            if (User.PKMode == PKMode.PK || !M.NeedsPKMode && !MobTargets.Contains(M))
                                                MobTargets.Add(M, GetDamage(M));
                            }
                        }
Next replace this:
Code:
                    foreach (Character C in World.H_Chars.Values)
                    {
                        if (C.Alive && (C != User || Info.Damageing == DamageType.HealHP || Info.Damageing == DamageType.HealMP))
                        {
                            if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
                                if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
                                    if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Linear)
                                        if (C.PKAble(User.PKMode, User) && !PlayerTargets.Contains(C) && !World.NoPKMaps.Contains(User.Loc.Map) || Info.ExtraEff == ExtraEffect.UnMount)
                                            if (Game.World.NoPKMaps.Contains(User.Loc.Map) && GetDamage(C) == 0 || !Game.World.NoPKMaps.Contains(User.Loc.Map) || (Info.ExtraEff == ExtraEffect.UnMount && C.StatEff.Contains(StatusEffectEn.Ride)) && C.Equips.Steed.Plus < User.Equips.Steed.Plus)
                                                if (User.MyClient.GM && C.EntityID == User.EntityID || !User.MyClient.GM)
                                                PlayerTargets.Add(C, GetDamage(C));
                        }
                    }
With:
Code:
                    foreach (Character C in World.H_Chars.Values)
                    {
                        if (C.Alive && (C != User || Info.Damageing == DamageType.HealHP || Info.Damageing == DamageType.HealMP))
                        {
                            if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
                                if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
                                    if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(C.Loc.X, C.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                        if (C.PKAble(User.PKMode, User) && !PlayerTargets.Contains(C) && !World.NoPKMaps.Contains(User.Loc.Map) || Info.ExtraEff == ExtraEffect.UnMount)
                                            if (Game.World.NoPKMaps.Contains(User.Loc.Map) && GetDamage(C) == 0 || !Game.World.NoPKMaps.Contains(User.Loc.Map) || (Info.ExtraEff == ExtraEffect.UnMount && C.StatEff.Contains(StatusEffectEn.Ride)) && C.Equips.Steed.Plus < User.Equips.Steed.Plus)
                                                if (true)
                                                    PlayerTargets.Add(C, GetDamage(C));
                        }
                    }
Then replace this:
Code:
                    foreach (NPC C in World.H_NPCs.Values)
                    {
                        if ((C.Flags == 21 || C.Flags == 22) && User.Level >= C.Level)
                        {
                            if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
                                if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
                                    if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Linear)
                                        if (!NPCTargets.Contains(C))
                                            NPCTargets.Add(C, GetDamage(C));
                        }
                    }
With:
Code:
                    List<coords> Line = new List<coords>(5);
                    if (Info.Targetting == TargetType.Linear)
                        Line = MyMath.LineCoords(User.Loc.X, User.Loc.Y, AimX, AimY, 10);
                    foreach (NPC C in World.H_NPCs.Values)
                    {
                        if ((C.Flags == 21 || C.Flags == 22) && User.Level >= C.Level)
                        {
                            if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, C.Loc.X, C.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, C.Loc.X, C.Loc.Y) <= Info.MaxDist)
                                if (Info.Targetting == TargetType.Sector && InSector(C.Loc.X, C.Loc.Y) || Info.Targetting != TargetType.Sector)
                                    if (Info.Targetting == TargetType.Linear && Line.Contains(new coords(C.Loc.X, C.Loc.Y)) || Info.Targetting != TargetType.Linear)
                                        if (!NPCTargets.Contains(C))
                                            NPCTargets.Add(C, GetDamage(C));
                        }
                    }
And bam that should be it!
If Saint posts on this thread people should thank him as well.
I did this with NO errors and debugged it fine...when I get into the game I can fb/ss anything EXCEPT players lol...that's jus no fun...can anyone hlp me put it so that it attack players too >.>, and btw nice job .Arco!
03/29/2010 15:35 -NewDawn-#45
Great Job Arco =] Got it working on the first. Awesome release ^^, I don't think I could have figured that out any time soon. lol