Author Topic: Effective Ship Movement  (Read 5146 times)

0 Members and 1 Guest are viewing this topic.

Offline KryzTopic starter

  • Jr. Member
  • **
  • Posts: 33
  • Activity:
    0%
  • Reputation Power: 1
  • Kryz has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Effective Ship Movement
« on: August 11, 2015, 08:57:07 PM »
0
Hey So I am working on my monger script, decided it was time to start diving into actual ship movement. I am looking for advice on how to effectively move the ship to a set of coordinates with little to no issues and no multiple commands, IE don't yell forward three times etc. This is what I have at the moment. Its a bit wonky at the end coordinates. Let me know what y'all think and if you know of a better way to go about this let me know i'm open to anything. I seem to always miss the target by 1 or 2 tiles and then the end mess happens.

Code: [Select]
Sub ShipGoToLocation
Set %GoalX #CHARPOSX + 10 ;change these values to set destination
Set %GoalY #CHARPOSY - 20 ; change these values to set destination

NavStart:
if #CHARPOSY > %GoalY
   {
   ;;;
   if #CHARPOSX = %GoalX
      {
      event Macro 3 0 Forward
   while #CHARPOSY > %GoalY + 1
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   ;;;
   if #CHARPOSX > %GoalX
      {
      event Macro 3 0 forward left
   while #CHARPOSX > %GoalX +1 && #CHARPOSY > %GoalY + 1
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   ;;;
   if #CHARPOSX < %GoalX
      {
      event Macro 3 0 forward right
   while #CHARPOSX < %GoalX +1 && #CHARPOSY > %GoalY + 1
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if #CHARPOSY = %GoalY
   {
   if #CHARPOSX = %GoalX
      {
      event Macro 3 0 stop
      halt
      }
   ;;;
   if #CHARPOSX > %GoalX
      {
      event Macro 3 0 left
   while #CHARPOSX > %GoalX +1 && #CHARPOSY = %GoalY
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      
      }
   ;;;
   if #CHARPOSX < %GoalX
      {
      event Macro 3 0 right
   while #CHARPOSX < %GoalX && #CHARPOSY = %GoalY
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   }
if #CHARPOSY < %GoalY
   {
   if #CHARPOSX = %GoalX
      {
      event Macro 3 0 back
   while #CHARPOSX < %GoalX && #CHARPOSY < %GoalY
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   if #CHARPOSX > %GoalX
      {
      event Macro 3 0 back left
   while #CHARPOSX > %GoalX && #CHARPOSY < %GoalY
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   if #CHARPOSX < %GoalX
      {
      event Macro 3 0 forward right
   while #CHARPOSX < %GoalX && #CHARPOSY < %GoalY
         {

         }
   event Macro 3 0 stop
   GOTO NavStart
      }
   }

   halt
« Last Edit: August 11, 2015, 09:57:24 PM by Kryz »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Effective Ship Movement
« Reply #1 on: August 11, 2015, 09:29:20 PM »
0
Don't forget the "forward one" and "backward one" style commands when you need to get exact.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KryzTopic starter

  • Jr. Member
  • **
  • Posts: 33
  • Activity:
    0%
  • Reputation Power: 1
  • Kryz has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Effective Ship Movement
« Reply #2 on: August 11, 2015, 09:42:45 PM »
0
So essentially I should run these within 5 or so and then go to a precise mode at that point? I don't think I need it to get the exact coordinates, IE its not TMapping a chest... If I am in the right subserver exact Coord's aren't going to break me. The way I have it now might be overkill. Ill probably redo for within a range of 5 and ignore getting the precise.

That could work with minimal code, easy enough just some fine tuning.

TM did you see anything way out of place or a way to clean up my sub a little bit?
« Last Edit: August 11, 2015, 09:47:48 PM by Kryz »

Offline KaliOfLS

  • That's "Dr." Kali to you!
  • Sr. Member
  • *
  • Posts: 406
  • Activity:
    0%
  • Reputation Power: 6
  • KaliOfLS has no influence.
  • Gender: Male
  • Respect: +33
  • Referrals: 2
    • View Profile
Re: Effective Ship Movement
« Reply #3 on: August 11, 2015, 10:10:04 PM »
0
This is an example of how I might do it.  There leaves a lot to be worked over.  

This assumes the boat is facing north.  It doesn't turn the boat to make easy to pass things.  There is no journal checking for "We've stopped moving".  

Code: [Select]




set !NewX #CharPosX + 40
set !NewY #CharPosY + 40
gosub MoveBoat !NewX !NewY
display ok #result

halt

sub MoveBoat
    if %0 <> 2
       return #false
    namespace push
    namespace local MoveBoat , #systime , #charid

    set !DestX %1
    set !DestY %2
    set !dX ABS ( !DestX - #charposx ) / 2
    set !dY ABS ( !DestY - #charposy ) / 2
    set !TimeOut #scnt + !dX + !dY + 1
   
    set #result #false

    while !DestX <> #charposx && !DestY <> #charposy && !TimeOut > #scnt
    {
        ;North and South axis
        if !DestY < #charposy
        {
           event macro 3 0 forward
           while !DestY < #charposy
           {
                 if !TimeOut < #scnt
                 {
                    event macro 3 0 stop
                    break
                 }
           }
           event macro 3 0 stop
        }
        else
        {
           if !DestY > #charposy
           {
              event macro 3 0 backward
              while !DestY > #charposy
              {
                  if !TimeOut < #scnt
                  {
                      event macro 3 0 stop
                      break
                  }
              }
              event macro 3 0 stop
            }
        }
        ;East and West Axis
        if !DestX < #charposx
        {
           event macro 3 0 left
           while !DestX < #charposx
           {
                 if !TimeOut < #scnt
                 {
                    event macro 3 0 stop
                    break
                 }
           }
           event macro 3 0 stop
        }
        else
        {
           if !DestX > #charposx
           {
              event macro 3 0 right
              while !DestX > #charposx
              {
                  if !TimeOut < #scnt
                  {
                      event macro 3 0 stop
                      break
                  }
              }
              event macro 3 0 stop
            }
        }
    }

    if !DestX = #charposx && !DestY = #charposy
       set #result #true

    namespace clear
    namespace pop
return #result
« Last Edit: August 11, 2015, 10:12:56 PM by KaliOfLS »
R~~~~ B~~~~~~~~ 
^ real life signature for sure

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Effective Ship Movement
« Reply #4 on: August 15, 2015, 12:14:01 PM »
0
Do the event macro move commands work while you are piloting a boat?
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline KaliOfLS

  • That's "Dr." Kali to you!
  • Sr. Member
  • *
  • Posts: 406
  • Activity:
    0%
  • Reputation Power: 6
  • KaliOfLS has no influence.
  • Gender: Male
  • Respect: +33
  • Referrals: 2
    • View Profile
Re: Effective Ship Movement
« Reply #5 on: August 15, 2015, 12:42:27 PM »
0
I tried issuing the move command while piloting the boat but not specifically the event macro keys.  Good question...  but this works perfectly for me... maybe under lag or poor scripting you can br off a tile or two but is exact x y important?  Not usually if you're not doing 8x8
R~~~~ B~~~~~~~~ 
^ real life signature for sure

Tags: