Wall pass Protection

08/08/2012 02:51 marlyandedsel#1
I have code like this:
PHP Code:
 suse.X;
                                            
suse.Y;
                                            
attack.X;
                                            
attack.Y;
                                            for (
int xs 0xs attack.Xxs++)
                                            {
                                                for (
int ys 0ys attack.Yys++)
                                                {
                                                    if (
attacker.Owner.Map.Floor[xsys,MapObjectType.InvalidCast,null])
                                                        break;
                                                }
                                            } 
that thing wont work, I have used it for Dragon Whirl, but still they can pass it in the wall(eg. Guild War Wall) you guys hope good idea how to make it work? thanks ....
08/08/2012 06:00 .Kinshi#2
You're setting the attack.X & Y to the X and Y first, then looping but not changing it.
In the loop set the attack.X & Y to the xs and ys, only if its valid.
Code:
                                            for (int xs = attack.X; xs < X; xs++) 
                                            { 
                                                for (int ys = attack.Y; ys < Y; ys++) 
                                                { 
                                                    if (attacker.Owner.Map.Floor[xs, ys,MapObjectType.InvalidCast,null]) 
                                                        break; 
                                                    else {
                                                        attack.X = xs;
                                                        attack.Y = ys;
                                                    }
                                                } 
                                            }
Something like that, ish.
08/09/2012 15:18 -impulse-#3
@ Kin: What you do there is just get the farthest good coordinates in a radius calculated with the given X and Y.... which is far from right. You should use DDA Line algorithm or Bresenham's algorithm to compute the line where your character should move then get some coordinates that are valid.
08/09/2012 16:41 .Kinshi#4
Quote:
Originally Posted by -impulse- View Post
@ Kin: What you do there is just get the farthest good coordinates in a radius calculated with the given X and Y.... which is far from right. You should use DDA Line algorithm or Bresenham's algorithm to compute the line where your character should move then get some coordinates that are valid.
Well, yeah.
I just modified what he had to make a bit more sense.
08/09/2012 23:09 pro4never#5
From a geometry standpoint, this is a fairly simple problem.

#1: Create a line (drop in start x/y, end x/y to produce the line formula)
#2: Run a for loop for the distance traveled iterating along the line
#3: Check each coord generated versus dmap

As soon as an coord iteration hits an invalid coord then you can break the loop and this is the maximum distance you can travel along that direction. Use the coords of previous iteration as your stop location as you've run into something here.
08/11/2012 13:01 marlyandedsel#6
Quote:
Originally Posted by -impulse- View Post
@ Kin: What you do there is just get the farthest good coordinates in a radius calculated with the given X and Y.... which is far from right. You should use DDA Line algorithm or Bresenham's algorithm to compute the line where your character should move then get some coordinates that are valid.

Thank You Very Much Impulse as always.

@pro4never: Thank You Pro you given me a very good hint.
08/19/2012 05:49 marlyandedsel#7
What I have did is like this:

PHP Code:
 aInLineAlgorithm algo = new aInLineAlgorithm(attacker.Xattacker.Yattack.Xattack.Y4aInLineAlgorithm.Algorithm.DDA);
                                            foreach (var 
coord in algo.getCoords)
                                            {
                                                
Console.WriteLine("Coord X and Y: " coord.X.ToString() + " , " coord.Y.ToString());
                                                if (
attacker.Owner.Map.Floor[coord.Xcoord.YMapObjectType.InvalidCastnull])
                                                    break;
                                            } 
I have manage to display the coordinate that will pass thru but idk why still can pass thru it.... is there something to add ? because the checking is not working. Thank You Impulse giving me hint.

Regards
Edsel.