Author Topic: Help with pathfind character on ship?  (Read 7801 times)

0 Members and 1 Guest are viewing this topic.

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Help with pathfind character on ship?
« on: November 14, 2010, 09:28:49 AM »
0
I am trying to make a fishing script that collects the new fish, and eventually will have to kill serpents too. Trying to ressurect some old fisher scripts on EUO in order to achieve this


Now that you recall in to a random spot around the mast of the ship, I want to position my character south of the ship mast. Like it used to be.  The only way I can think to do it... never mind, i just thought of the way while typing this. I think.  lol...

so to pathfind to the rear of this ship's mast


using small ship:

find tillerman coords
find location tillerman coords +  3 tiles north
pathfind to there.
 
instead of pathfinding to tillerman and walking 3 steps north, though either way would work.

How would I go about coding this?  Thanks in advance for any help.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help with pathfind character on ship?
« Reply #1 on: November 14, 2010, 10:18:10 AM »
0
That's a really easy sub to write.  I just did it for the FaF, so I know it's possible and a few lines of code. 

You should think through the problem a bit and see if you can write that correction sub yourself.  Things you'll need to know are:

1) your present position
2) finditem of the nearest tillerman
3) compute the X,Y difference between the tillerman and yourself.
4) computer the correction coordinates
5) pathfind to the new location.

Split it up and that should be an easy fix.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #2 on: November 14, 2010, 10:30:22 AM »
0
I'll give it a shot!  Thanks TM

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Help with pathfind character on ship?
« Reply #3 on: November 14, 2010, 10:38:37 AM »
0
Post your snippets if you have trouble and we'll try and work through it with ya.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline _C2_

  • AFK FtW
  • Global Moderator
  • *
  • *
  • Posts: 4077
  • Activity:
    0%
  • Reputation Power: 48
  • _C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!_C2_ has great potential!
  • RIP Pen Trick
  • Respect: +254
  • Referrals: 4
    • View Profile
Re: Help with pathfind character on ship?
« Reply #4 on: November 14, 2010, 10:39:38 AM »
0
i did this


sub move_back
repeat
  finditem ENX g_6 ;enx is mast of old style ship
  wait 20
until #findkind <> -1
set %movex #findx - 1
set %movey #findy - 4
repeat
   event pathfind %movex %movey  ;x/y of first location (not recall point)
   wait 10
until #charposx = %movex && #charposy = %movey
return

You will find that the position on your boat may be different.  So you will have to learn how to set positions similar to how i did it.  there are several ways to skin the same cow though.  I hope you can use this to learn from.

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #5 on: November 14, 2010, 11:02:24 AM »
0
ENX is tillerman no?  PSX is mast... dont confuse me!! lol  would it be easier to just try to get to south of PSX?

Seems like it would be easier to get to the south side of mast instead of messing with tillerman
« Last Edit: November 14, 2010, 11:04:34 AM by seeriusly »

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #6 on: November 14, 2010, 11:29:45 AM »
0
I am missing a very important part of scripting... something I have never understood quite fully that i bet is extremely important to know.

don't laugh...

when you write ([#findkind or #findid etc] <> -1)  it always confuses me. 

the less than, greater than -1 (<> -1) or (= 1) or <> 1  or <> 0

what does that mean in regular english please. I never know when and how to use it

when you punch this into my calculator : (<> -1) to me means -2 or less, and 0 or more infinitely!  I know it has nothing to do with that though

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #7 on: November 14, 2010, 12:04:45 PM »
0
Thankyou C2, that does offer insight

This is what I have so far according to your layout TM.  Am I getting warmer??

Code: [Select]
;CHARPOSY north lower #
;CHARPOSX west lower #

sub movesouthofmast

;1) recall-in position
    set %recallinX #charposx
    set %recallinY #charposy

;2) finditem of the nearest tillerman
    finditem ENX g_6  ;find tillerman within 6 tiles

;3) compute the X,Y difference between the tillerman and yourself.

;4) compute the correction coordinates
;   find location X -1  & Y -4 of tillerman  (this is the spot south of mast on small ship from tillerman)
;   %southofmastx -1 (west one)
;   %southofmasty -4 (north 4) of tillerman location
    set %southofmastX #findx -1
    set %southofmastY #findy -4
;5) pathfind to the new location.

    event pathfind %southofmastx %southofmasty
« Last Edit: November 14, 2010, 12:24:40 PM by seeriusly »

Offline JustAnotherFace

  • Hero Member
  • *
  • Posts: 530
  • Activity:
    0%
  • Reputation Power: 8
  • JustAnotherFace has no influence.
  • Gender: Male
  • My new toy....
  • Respect: +24
  • Referrals: 4
    • View Profile
Re: Help with pathfind character on ship?
« Reply #8 on: November 14, 2010, 12:13:38 PM »
0
I am missing a very important part of scripting... something I have never understood quite fully that i bet is extremely important to know.

don't laugh...

when you write ([#findkind or #findid etc] <> -1)  it always confuses me. 

the less than, greater than -1 (<> -1) or (= 1) or <> 1  or <> 0

what does that mean in regular english please. I never know when and how to use it

when you punch this into my calculator : (<> -1) to me means -2 or less, and 0 or more infinitely!  I know it has nothing to do with that though

<>.... Not Equal
Therefore, <> -1  is NOT EQUAL to -1

>= ..... Greater than or Equal To

<=.........Less than or Equal to

Check out this page, it will help you out!
http://wiki.easyuo.com/index.php?title=Operators

JaF
All that tyranny needs to gain a foothold is for people of good conscience to remain silent.
Thomas Jefferson

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #9 on: November 14, 2010, 12:16:00 PM »
0
I am missing a very important part of scripting... something I have never understood quite fully that i bet is extremely important to know.

don't laugh...

when you write ([#findkind or #findid etc] <> -1)  it always confuses me. 

the less than, greater than -1 (<> -1) or (= 1) or <> 1  or <> 0

what does that mean in regular english please. I never know when and how to use it

when you punch this into my calculator : (<> -1) to me means -2 or less, and 0 or more infinitely!  I know it has nothing to do with that though

<>.... Not Equal
Therefore, <> -1  is NOT EQUAL to -1

>= ..... Greater than or Equal To

<=.........Less than or Equal to

Check out this page, it will help you out!
http://wiki.easyuo.com/index.php?title=Operators

JaF

Thankyou, I didn't think it was logical... thought it might have meant something else.

Offline JustAnotherFace

  • Hero Member
  • *
  • Posts: 530
  • Activity:
    0%
  • Reputation Power: 8
  • JustAnotherFace has no influence.
  • Gender: Male
  • My new toy....
  • Respect: +24
  • Referrals: 4
    • View Profile
Re: Help with pathfind character on ship?
« Reply #10 on: November 14, 2010, 12:25:28 PM »
0
No problem.

From C2's snippet above:

Code: [Select]
repeat
  finditem ENX g_6 ;enx is mast of old style ship
  wait 20
until #findkind <> -1

He is searching for ENX (mast or whatever ENX is) on the ground within 6 tiles in any direction from your character position.
If ENX is not found within 6 tiles it waits 20 and then searches again.
Until the #findkind is NOT EQUAL to -1.

If you notice, when you search for something if you do not find the something the #findkind will always be -1.  So C2 is telling his script when the #findkind is not equal to -1 or effectively "nothing" (in other words when the code FINDS the ENX) then the code can break out of the repeat loop and execute the line of code that follows the until.

Hope that makes sense, and helps you out some.

JaF

All that tyranny needs to gain a foothold is for people of good conscience to remain silent.
Thomas Jefferson

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #11 on: November 14, 2010, 12:39:05 PM »
0
Ooohhhh!  Makes perfect sense. Thank you

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #12 on: November 14, 2010, 12:41:37 PM »
0
well, I don't know if this is how I should do it, but it sure works!

Code: [Select]
gosub movesouthofmast
sub movesouthofmast
repeat
    finditem ENX g_10  ;find tillerman within 10 tiles
    wait 20
until #findkind <> -1
    set %southofmastX #findx - 1
    set %southofmastY #findy - 3
repeat
    event pathfind %southofmastx %southofmasty
    wait 10
until #charposx = %southmastx && #charposy = %southofmasty
    return
    halt
« Last Edit: November 14, 2010, 12:47:45 PM by seeriusly »

Offline seeriuslyTopic starter

  • Full Member
  • ***
  • Posts: 219
  • Activity:
    0%
  • Reputation Power: 6
  • seeriusly has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: Help with pathfind character on ship?
« Reply #13 on: November 14, 2010, 12:47:02 PM »
0
spoke too soon, it doesn't stop pathfinding...  :-[

edit: Spoke too soon again!  had a typo. WOOHOO!!!

@ TM:

your list you gave me:

1) your present position
2) finditem of the nearest tillerman
3) compute the X,Y difference between the tillerman and yourself.
4) computer the correction coordinates
5) pathfind to the new location.

Do I really need 1, 3 & 4?  Am I overlooking something I may need in the rest of the script?
 

« Last Edit: November 14, 2010, 01:00:54 PM by seeriusly »

Offline JustAnotherFace

  • Hero Member
  • *
  • Posts: 530
  • Activity:
    0%
  • Reputation Power: 8
  • JustAnotherFace has no influence.
  • Gender: Male
  • My new toy....
  • Respect: +24
  • Referrals: 4
    • View Profile
Re: Help with pathfind character on ship?
« Reply #14 on: November 14, 2010, 12:52:19 PM »
0
well, I don't know if this is how I should do it, but it sure works!

Code: [Select]
gosub movesouthofmast
sub movesouthofmast
repeat
    finditem ENX g_10  ;find tillerman within 10 tiles
    wait 20
until #findkind <> -1
    set %southofmastX #findx - 1
    set %southofmastY #findy - 3
repeat
    event pathfind %southofmastx %southofmasty #charposZ
    wait 10
until #charposx = %southmastx && #charposy = %southofmasty
    return
    halt

That looks like it should work.  The only thing I would suggest is putting in some type of failsafe.  What happens if there is an impassible object between you and where you are going, or sitting right on the spot where you are trying to go to? In theory, your code could possibly get stuck in an infinite loop trying to pathfind to that exact spot.

Maybe something like this

Code: [Select]
repeat
    event pathfind %southofmastx %southofmasty #charposZ
    wait 10
until #charposx = %southmastx && #charposy = %southofmasty || %safetytimer > 5s

Of course you would have to set your %safetytimer prior to this line in the script.

Just a thought......

JaF
All that tyranny needs to gain a foothold is for people of good conscience to remain silent.
Thomas Jefferson

Tags: