A little help Please?

07/06/2009 03:05 damianpesta#1
Well I got Andy's DMap's to work with LOTF , I started off with walking but It doesnt seem to work fine since I still can jump on few walls and so on...? A little help? Thats what I got so far.

Code:
                    case 1005:
                        {
                            sbyte AddX = 0;
                            sbyte AddY = 0;
                            byte Dir = (byte)(Data[8] % 8);
                            MyChar.Direction = Dir;

                            switch (Dir)
                            {
                                case 0:
                                    {
                                        AddY = 1;
                                        break;
                                    }
                                case 1:
                                    {
                                        AddX = -1;
                                        AddY = 1;
                                        break;
                                    }
                                case 2:
                                    {
                                        AddX = -1;
                                        break;
                                    }
                                case 3:
                                    {
                                        AddX = -1;
                                        AddY = -1;
                                        break;
                                    }
                                case 4:
                                    {
                                        AddY = -1;
                                        break;
                                    }
                                case 5:
                                    {
                                        AddX = 1;
                                        AddY = -1;
                                        break;
                                    }
                                case 6:
                                    {
                                        AddX = 1;
                                        break;
                                    }
                                case 7:
                                    {
                                        AddY = 1;
                                        AddX = 1;
                                        break;
                                    }
                                    int LocX = 0;
                                    int LocY = 0;
                                    Struct.GameMap DMD = new Struct.GameMap("gamemap.dat");
                                    foreach (Struct.DMap _Map in DMD.Maps)
                                    {
                                        if (!General.Maps.ContainsKey((int)_Map.MapId))
                                        {
                                            Struct.DmapData Mapping = General.Maps[(int)_Map.MapId];
                                            if (!Mapping.CheckLoc((ushort)(LocX + AddX), (ushort)(LocY + AddY)))
                                            {
                                                MyChar.LocX = MyChar.PrevX;
                                                MyChar.LocY = MyChar.PrevY;

                                            }
                                        }
                                    }
                            }
                            World.PlayerMoves(MyChar, Data);

                            MyChar.PrevX = MyChar.LocX;
                            MyChar.PrevY = MyChar.LocY;
                            MyChar.LocX = (ushort)(MyChar.LocX + AddX);
                            MyChar.LocY = (ushort)(MyChar.LocY + AddY);

                            MyChar.TargetUID = 0;
                            MyChar.MobTarget = null;
                            MyChar.PTarget = null;
                            MyChar.TGTarget = null;
                            MyChar.AtkType = 0;
                            MyChar.SkillLooping = 0;                            
                            MyChar.Action = 100;
                            World.SpawnMeToOthers(MyChar, true);
                            World.SpawnOthersToMe(MyChar, true);                            
                            World.SurroundNPCs(MyChar, true);
                            World.SurroundMobs(MyChar, true);
                            World.SurroundDroppedItems(MyChar, true);
                            MyChar.Attacking = false;
                            if (MyChar.Mining)
                                MyChar.Mining = false;

                            break;
                        }
07/06/2009 03:36 PeTe Ninja#2
This could help you idk

ReWritten walk method by EmmeTheCoder
Code:
public void Walk(byte Dir)
{
sbyte x = 0, y = 0;
if (Dir == 0 || Dir == 1 || Dir == 5 || Dir == 7)
x = 1;
if (Dir >= 1 && Dir <= 3)
x = -1;
if (Dir == 1 || Dir == 6 || Dir == 7)
y = 1;
if (Dir >= 3 && Dir <= 5)
y = -1;
X = (ushort)(X + x); Y = (ushort)(Y + y);
}

Hybrid's tip on his method

Quote:
Originally Posted by Hybrid
Fyi the *lotf* one will run faster than yours. You also forget that the client does not send a pre-modulated direction, so unless the caller mods it in the argument, you've missed this as well.

Further more you can see several what I'd assume vital things done;
his code
Code:
// notify other people to move? your function fails to do this
World.PlayerMoves(MyChar, Data);

// update the old location, your function fails to do this
MyChar.PrevX = MyChar.LocX;
MyChar.PrevY = MyChar.LocY;

// update the current location, your function *does* do this
MyChar.LocX = (ushort)(MyChar.LocX + AddX);
MyChar.LocY = (ushort)(MyChar.LocY + AddY);
funny thing the original walk method has that what hybrid said his doesnt.

[Only registered and activated users can see links. Click Here To Register...]
07/06/2009 03:51 damianpesta#3
Quote:
Originally Posted by PeTe Ninja View Post
This could help you idk

ReWritten walk method by EmmeTheCoder
Code:
public void Walk(byte Dir)
{
sbyte x = 0, y = 0;
if (Dir == 0 || Dir == 1 || Dir == 5 || Dir == 7)
x = 1;
if (Dir >= 1 && Dir <= 3)
x = -1;
if (Dir == 1 || Dir == 6 || Dir == 7)
y = 1;
if (Dir >= 3 && Dir <= 5)
y = -1;
X = (ushort)(X + x); Y = (ushort)(Y + y);
}

Hybrid's tip on his method



his code
Code:
// notify other people to move? your function fails to do this
World.PlayerMoves(MyChar, Data);

// update the old location, your function fails to do this
MyChar.PrevX = MyChar.LocX;
MyChar.PrevY = MyChar.LocY;

// update the current location, your function *does* do this
MyChar.LocX = (ushort)(MyChar.LocX + AddX);
MyChar.LocY = (ushort)(MyChar.LocY + AddY);
funny thing the original walk method has that what hybrid said his doesnt.

[Only registered and activated users can see links. Click Here To Register...]

Well it wont help cause its up to the DMap's Im waiting for someone experienced now to tell me what is wrong cause im not getting any errors, nor warnings
07/06/2009 04:00 PeTe Ninja#4
Oh ok, well dont know if this also helps but check out

Code:
public static void PlayerMoves(Character MovingChar, byte[] Data)
in world.cs
07/06/2009 15:32 damianpesta#5
Quote:
Originally Posted by PeTe Ninja View Post
Oh ok, well dont know if this also helps but check out

Code:
public static void PlayerMoves(Character MovingChar, byte[] Data)
in world.cs
Well I know that the DMap part has to be there , I think I just fucked up DMaps part.
07/06/2009 17:06 _Emme_#6
Is the maps you can still jump on walls etc have their MapID added in GameMaps.Maps?
07/06/2009 18:06 damianpesta#7
Quote:
Originally Posted by EmmeTheCoder View Post
Is the maps you can still jump on walls etc have their MapID added in GameMaps.Maps?
Yeah , I've got the main ones loaded , like twin city , am and so on
07/06/2009 18:57 _Emme_#8
Well, what I meant was, is DMaps loaded in the map you could still jump walls on?
07/06/2009 19:19 damianpesta#9
Quote:
Originally Posted by EmmeTheCoder View Post
Well, what I meant was, is DMaps loaded in the map you could still jump walls on?
Yep , may I just add you Cause Im having issues with something else as well?

Well the second problem is that I messed up some packet , because I got Hybrid's NPC's (INI ones) to work with my LOTF Source and they all loading fine and It says that they are spawned , im not getting any errors on it.So I bet that I didnt get the NPC's Spawn Packet to work.Any help?

#Bump , bump , bump!!

Bump!!! Is there nobody that is actually willing to help?

#Bump!!

#merged
07/07/2009 20:00 danielachraf#10
3rd bump for a little help ?? oh my bad :)
07/07/2009 22:11 alexbigfoot#11
My opinion:

WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW!

Dude, was you drunk when you wrote this thing?

It should be like:

Struct.DmapData Mapping = null;
if(General.Maps.TryGetValue(MyChar.LocMap, out Mapping))
{
if (!Mapping.CheckLoc((ushort)(LocX + AddX), (ushort)(LocY + AddY)))
{
MyChar.LocX = MyChar.PrevX;
MyChar.LocY = MyChar.PrevY;
}
else
{ /*Pullback*/}
}