You last visited: Today at 02:09
Advertisement
[Release]Fixed SS/FB System
Discussion on [Release]Fixed SS/FB System within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
02/01/2010, 06:25
#1
elite*gold: 0
Join Date: Oct 2009
Posts: 8,784
Received Thanks: 5,304
[Release]Fixed SS/FB System
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.
02/01/2010, 06:27
#2
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Great job.
+k
Edit: Got a couple errors when adding this.
FIXED -> Namespace "coords" could not be found. Are you missing an assemble reference?
HELP -> No overload for method 'Add' takes 2 arguments.
02/01/2010, 07:04
#3
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
Sounds like the ones saying no overload for method 'add' takes 2 arguments are things in the source referring to the old function. Go to where they are and try to correct them (so they match how the new function works) using the fixed skill system as an example.
@ thread, not read through the entire math of that but assuming it works. Nice job.
02/01/2010, 07:09
#4
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
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.
02/01/2010, 07:12
#5
elite*gold: 0
Join Date: May 2008
Posts: 66
Received Thanks: 2
yes i get these too
02/01/2010, 07:16
#6
elite*gold: 0
Join Date: Oct 2009
Posts: 8,784
Received Thanks: 5,304
Thats odd I don't get these at all.
And my code seems to be exactly the same.
02/01/2010, 07:22
#7
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Yeah, it's a very odd error, I can't find a fix for it.
02/01/2010, 07:35
#8
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
Quote:
Originally Posted by
.Arco
Thats odd I don't get these at all.
And my code seems to be exactly the same.
You most likely have a second void that only uses 2 inputs and that's why it works for you.
02/01/2010, 07:55
#9
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Yeah, can you help us out a little bit arco?
02/01/2010, 08:01
#10
elite*gold: 0
Join Date: Oct 2009
Posts: 8,784
Received Thanks: 5,304
Yeah I'm looking right now.
02/01/2010, 08:20
#11
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Alrighty, it might just be that you have an extra definition that we don't have.
02/01/2010, 08:50
#12
elite*gold: 0
Join Date: Oct 2009
Posts: 8,784
Received Thanks: 5,304
public struct coords
{
public int X;
public int Y;
public coords(int x, int y)
{
this.X = x;
this.Y = y;
}
}
was supposed to go OVER MyMath, not under.
02/01/2010, 08:52
#13
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Nope, that still does not work. Add me on msn
so we can figure this out.
02/01/2010, 08:53
#14
elite*gold: 0
Join Date: Oct 2009
Posts: 8,784
Received Thanks: 5,304
Quote:
Originally Posted by
walmartboi
Nope, that still does not work. Add me on msn
so we can figure this out.
You moved it from under to over?
02/01/2010, 08:55
#15
elite*gold: 0
Join Date: Dec 2007
Posts: 378
Received Thanks: 163
Nevermind, got it working, I'll post the results of how good it is when I build my source.
Edit: Works great while sitting down, but there are a few bugs when you ss/fb a monster while in air. But overall, great work! :P +k
Similar Threads
[Request]Fixed FB/SS system
05/03/2011 - CO2 Private Server - 4 Replies
Most LOTF sources have this problem. If you jump and fb or ss in mid air the aim is off, if anyone can fix it on this source and upload it will get +thanks.
http://www.elitepvpers.com/forum/attachments/co2-p server-discussions-questions/28202d1251773349-re-r elease-pazeco-v2-pazeco-v2.rar
Castle system Fixed DB
07/08/2008 - EO PServer Hosting - 7 Replies
Fixed all the castle problem ! just download the DB files and replace u old DBfiles ( close u sql before u replace it )
Mariokiller64's System bug fixed :)(Feb 24th)
03/02/2008 - GunZ - 1 Replies
What this system has.
1.Meds heal 23HP and AP. (lol 23 no one will notice :P)
2.World Items heal 50 HP and AP
3.You can swear.
4.Monsters do 0 damage and do no skills on you.
5.You do not need a non updating launcher BECAUSE the launcher does not detect any changes of the maps or system.mrs files :P.
6.Remember that no CRC injecting is needed.
[Release] FlyFF Termination (System Crashes Fixed!
09/28/2007 - Flyff - 11 Replies
At Locking please .
All times are GMT +2. The time now is 02:12 .