ScriptUO
Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: seeriusly on November 14, 2010, 09:28:49 AM
-
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.
-
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.
-
I'll give it a shot! Thanks TM
-
Post your snippets if you have trouble and we'll try and work through it with ya.
-
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.
-
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
-
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
-
Thankyou C2, that does offer insight
This is what I have so far according to your layout TM. Am I getting warmer??
;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
-
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
-
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.
-
No problem.
From C2's snippet above:
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
-
Ooohhhh! Makes perfect sense. Thank you
-
well, I don't know if this is how I should do it, but it sure works!
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
-
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?
-
well, I don't know if this is how I should do it, but it sure works!
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
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
-
spoke too soon, it doesn't stop pathfinding... :-[
Haha...... funny, I was typing my last post as you wrote this one.......... I must be clairvoyant!
JaF
-
spoke too soon, it doesn't stop pathfinding... :-[
Haha...... funny, I was typing my last post as you wrote this one.......... I must be clairvoyant!
JaF
I had a typo... it works!!!
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 = %southofmastx && #charposy = %southofmasty
;return
halt
-
Ok, it works... but with your typo you at least experienced what "could" happen. I still suggest the failsafe. Your choice of course, its your code :)
JaF
-
hmmm, a failsafe. *thinks* what could go wrong? or do you mean another check to see if char is in right location?
-
hmmm, a failsafe. *thinks* what could go wrong? or do you mean another check to see if char is in right location?
a fail safe would be an alternate way to get out of a repeat loop... so until you fing the mast or until the timer is up etc. so if a recall failed then you wouldnt be stuck in that loop
-
do #scnt is the variable in uo that is the current time. the first line below i add time to the current time to set a safety time.
the last line, the until line, i keep sending it to repeat that area of code until if does not find or ( || ) means or the preset time is reached. 25 = 25 seconds when doing timers... diff than wait 20
set %safety_timer_long #scnt + 25
repeat
if #menubutton = pause
gosub pause
cmpPix 1 f
{
gosub healpet
}
finditem %killit
until #findcnt < 1 || #scnt > %safety_timer_long
-
@ JaF:
I missed your earlier post about the failsafe. I can see the importance. Better yet then, I'd want it to take me to the other side of the ship mast.... DOH!!! Here we go again!
Thank you guys, I really appreciate your help. Let me know if I can be of service.
-
set %safetytime #scnt + 15
repeat
event pathfind %southofmastx %southofmasty #charposZ
wait 10
until #charposx = %southofmastx && #charposy = %southofmasty || #scnt > %safetytime
set %safetytime #scnt + 15
repeat
event pathfind %southofmastx1 %southofmasty1 #charposZ
wait 10
until #charposx = %southofmastx1 && #charposy = %southofmasty1 || #scnt > %safetytime
if #charposx = ( %southofmastx1 && #charposy = %southofmasty1 ) || #charposx = ( southofmastx && #charposy = southofmasty )
gosub NEXTSUB
else
{
Display You can not get to either of your preset pathfinding spots. Script will now halt.
halt
}
You would have to set your %southofmastx1 and %southofmasty1 positions of course. I would set them just below the line where you set the %southofmastx..... positions.
JaF
-
Thankyou JaF... I think I will leave it how it is with the timeout only for now. Only thing that could get in the way of my location I want to get to is a stray meteorite. I think.... *crosses fingers* but I am glad to have learned that little tid-bit, because it will come in handy for future subs.
-
:) Good Luck!
JaF
-
That is so great of you guys to help "Seeriusly". You all seemed to jump right in there and give him a helping hand. I am impressed at how responsive all you guys were too!
OH and JaF -- I had that Avatar first! :D Pretty cool Avatar, isn't it!? ;)
-
That is so great of you guys to help "Seeriusly". You all seemed to jump right in there and give him a helping hand. I am impressed at how responsive all you guys were too!
OH and JaF -- I had that Avatar first! :D Pretty cool Avatar, isn't it!? ;)
Ooops LOL...I KNEW I stole that avatar from somewhere, just couldnt remember from where... I should of guessed it was from here! lol.... I will change it :) Sorry about that Oracle!
JaF
-
using #findkind <> -1 is a bad habbit that seems to spread like the plaugue...
Although it works its not easy to make sense of... better is to use #findcnt (the count of the number of items found 0...x )
#findcnt > 0 = #findkind <> -1
just my 2cents.
-
wow it sounds so logical! Thanks EN