Author Topic: pathfinding  (Read 4785 times)

0 Members and 1 Guest are viewing this topic.

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    0%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
pathfinding
« on: June 09, 2016, 06:09:21 PM »
0
hi all! any ideas on the best way to pathfind? Im working on an npc scanner type thing, and some of the npc's I need to find are in houses. This is what i have so far, and im getting 0's for the co-ordinates.

Code: [Select]
        static void moveToNpc(PlayerMobile P, Mobile target, ushort locX, ushort locY, sbyte locZ)
        {
            //Stealth.Client.newMoveXY(locX, locY, true, 0, true);
            //Stealth.Client.MoveXYZ(locX, locY, locZ, 1, 1, true);
            //P.Movement.MoveXYZ(locX, locY, locZ, 1, 1, true);
            MovingHelper moveToTarg = MovingHelper.GetMovingHelper();
            moveToTarg.AutoOpenDoors = true;
            List<MyPoint> path = moveToTarg.GetPathArray(locX, locY, true, 2);
            foreach(MyPoint point in path)
            {
                P.Movement.MoveXYZ(point.X, point.Y, (sbyte)point.Z, 0, 0, true);
               
            }
        }


Post Merge: June 10, 2016, 09:05:15 PM
updated my code
Code: [Select]
        static void moveToNpc(PlayerMobile P, Mobile target, ushort locX, ushort locY, sbyte locZ)
        {
            MovingHelper moveToTarg = MovingHelper.GetMovingHelper();
            moveToTarg.AutoOpenDoors = true;
            List<MyPoint> path = moveToTarg.GetPathArray(locX, locY, true, 1);
            if (path.Count() < 1)
                ErrorExit("no path has been created to npc");
            foreach(MyPoint point in path)
            {
                Console.WriteLine("pointX: " + point.X + " " + "pointY: " + point.Y);
                if (point.X == 0 || point.Y == 0)
                {
                    moveToTarg.SetBadLocation(point.X, point.Y);
                    break;
                }
                moveToTarg.MoveXYZ(point.X, point.Y, (sbyte)point.Z, 0, 0, true);
            }
        }

still not working, but I added the console.writeline so i could see what kind of points I was getting. The points in path are valid, except for the last Y location is 0. So that messes it up somewhere. Also my character wont move... Im not sure if im doing something wrong...
« Last Edit: June 10, 2016, 09:05:15 PM by smitty »

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    0%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: pathfinding
« Reply #1 on: June 13, 2016, 05:07:34 PM »
0
still havent figured this out. When i use GetPathArray this is what the output looks like when standing in the same room as the target npc on the opposite wall:
pathX: 32256 pathY: 2565
pathX: 32256 pathY: 2821
pathX: 32256 pathY: 3077
pathX: 32256 pathY: 3333
pathX: 32256 pathY: 3589
pathX: 0       pathY: 0

So this is kinda weird... x position of my character is 1406 and y pos is 1800 so... not sure what the numbers generated by getpatharray are. any help or advice would be amazing :]

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: pathfinding
« Reply #2 on: June 14, 2016, 12:45:50 AM »
0
can you test it in inbuild pascal? maybe there is an api bug then i can interfere and fix

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    0%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: pathfinding
« Reply #3 on: June 14, 2016, 03:05:51 PM »
0
I have never attempted anything in pascal, looks like i get to read through all your tutorials! (learning how to program) I really feel like I can get the character to move, Just the positions generated by getpatharray are really crazy. So really all that would need to happen is just stand next to an npc and use getpatharray then have it output co-ords for testing purposes. If theres a way to get a character to walk into a building that does not involve getpatharray im all for it.

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: pathfinding
« Reply #4 on: June 15, 2016, 06:10:40 AM »
0
i will look at it once i find some time.. time is random and rare lately :/

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: pathfinding
« Reply #5 on: June 15, 2016, 10:51:28 AM »
0
Tested it.. Looks like a bug on Stealth API.. Same goes towards GetPathArray3D.
I will look what i can do..

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    0%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: pathfinding
« Reply #6 on: June 15, 2016, 02:33:22 PM »
0
oh my goodness yes! thank you so much haha. I have been going crazy! i kept thinking i was doing something wrong! you are amazing crome <3

Tags: