Alexandria Uptime: 74.83 Days
Total players online: 5



Take the Tour | Site Map

It is currently Mon Jun 17, 2019 9:27 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Can't chop planted trees
PostPosted: Sat Feb 09, 2019 8:09 am 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 04/22/2014 05:41
Posts: 11
So I don't know if this is easyuo related or if it's a result of the freeshard I play.
I'w never had problem with using an axe on a tree to get wood... Unless I plant the tree myself, if I do the normal approach of finditem on the tree and use axe on lasttarget I get "too far away" even though findx and findy say it's the tile next to me, and when I scan the tile all I get is grass.

Is this a know issue or is it just cus of the shard I play at?


Top
  Profile 
PostPosted: Sat Feb 09, 2019 8:59 am 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 175

Groups:
I believe conventional trees found via either the tile commands (which require MUL files) or possibly evaluating a click location (in the case of Ter Mur resources or the absence of MUL files being setup)? Your planted trees, probably work like an object which has been added to the world, rather than part of the world map and will need the find command to locate those. So you may want 2 routines to find world map trees, then find planted trees using the different commands.

Think of the planted trees as things that are placed on the ground or NPC's as they wander about. Think of conventional trees as part of the static world that are part of the world map. The world map probably needs the tile command, while the things that can be added and wander around (ok, so your planted tree doesn't likely wander anywhere, but it is an addition to the world map) can be found via the finditem command.

From MWinc's Lumberjacker here is a well tested routine that runs through the tile commands to find trees. It sets the #ltarget* variables and returns, so it leaves it in other code to actually use the coordinates:
  1. ;==================================================================
  2. ; Tile scanning Subs
  3. ;==================================================================
  4.  tile init nooverrides
  5.  set %x1 #charposx - 2
  6.  set %y1 #charposy - 2
  7.  set %x_limit #charposx + 2
  8.  set %y_limit #charposy + 2
  9.  
  10. sub tiler
  11.  Tile init Nooverrides
  12.  gosub Diagnostics Tile 0
  13. Tiler:
  14.  set #lpc 100
  15.  tile cnt %x1 %y1
  16.  for %tilekind 1 #tilecnt
  17.   {
  18.   tile get %x1 %y1 %tilekind
  19.   set %8x8_X %x1 / 8
  20.   set %8x8_Y %y1 / 8
  21.   set %8x8 %8x8_X , _ , %8x8_Y
  22.   if TREE in #tilename && %8x8 notin %last8x8  
  23.    {
  24.    set %last8x8 %last8x8 , _ , %8x8
  25.    set %tree_found YES
  26.    set #ltargetx %x1
  27.    set #ltargety %y1
  28.    set #lpc 20
  29.    set %chops 0
  30.    return
  31.    }
  32.   }
  33.  gosub Next_tile
  34.  if %y1 > %y_limit
  35.   {
  36.   gosub Diagnostics Notree 20
  37.   set %init True
  38.   set %tree_found No
  39.   set %y1 #charposy - 2
  40.    set #lpc 20
  41.   set %last8x8 N/A
  42.   }
  43. goto tiler
  44.  
  45. sub Next_Tile
  46.  set %x1 %x1 + 1
  47.  if %x1 > %x_limit
  48.   {
  49.   set %y1 %y1 + 1
  50.   set %x1 #charposx - 2
  51.   }
  52.  


If you have the MUL files setup, using the tile command is demonstrated above to setup the #LTARGET* variables.
If you must find the additions to the map (planted trees), setup the #LTARGET* variables, but use the results from FINDITEM (#FINDX, #FINDY, FINDZ).
If you do not have MUL files setup, then you will need to resort to click locations, which is more complicated, but the following may be useful:

The other way involves translating world coordinates (x, y z) to a screen position to click. This probably wouldn't work for something that is covered, like a chest set on the ground would block the ground - the ground could still be targeted via the tile method (assuming MUL files are setup, of course). The click location will be on whatever is at the top position on the screen.

There is a "codename Alexadria project" which contains helpful subs. In there is a "worldXYZtoScreenXY" subroutine which will allow you to convert the X, Y and Z parameter of the found object into coordinates that you can use with the command click. Maybe this can help with your project. It would need to be installed to get all the subs. The installer is found here: http://www.easyuo.com/forum/viewtopic.php?f=12&t=52974

So in this latter method, you would find the object (whether by the find command or the tile command - as appropriate), the use the object's X, Y and Z coordinates to translate to a click location, which could be used by the "last target" command (event macro 22), or a "use last" command (event macro 17), as you have need.

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sat Feb 09, 2019 1:28 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 04/22/2014 05:41
Posts: 11
This is what I was thinking as the "finditem" version, for some reason this only gives "to far away" even though I'm 100% sure I'm standing next to the tree.

Code:
  1. set %axeID UERXGOD
  2. reset:
  3. ignoreitem reset 1
  4. loop:
  5. finditem AHF G_2
  6.         {
  7.         set #LOBJECTID %axeID
  8.         set #LTARGETID #FINDID
  9.         for %lj 1 2
  10.                 {
  11.                 set %ljindex1 #JINDEX
  12.                 event macro 17
  13.                 target
  14.                 if #TARGCURS = 1
  15.                         {
  16.                         repeat
  17.                                 {
  18.                                 event macro 22
  19.                                 }
  20.                         until #TARGCURS = 0
  21.                         }
  22.                 wait 7s
  23.                 set %ljindex2 #JINDEX
  24.                 for %jj %ljindex1 %ljindex2
  25.                         {
  26.                         scanjournal %jj
  27.                         if too_far in #journal
  28.                                 {
  29.                                 set %lj 3
  30.                                 event sysmessage next tree
  31.                                 }
  32.                                 else
  33.                                 {
  34.                                 set %LJ 1
  35.                                 event sysmessage chop chop!
  36.                                 }
  37.                         }
  38.                 }
  39.         ignoreitem #FINDID 1
  40.         }
  41.         else
  42.         {
  43.         goto reset
  44.         }
  45. goto loop


So I figured I'd give "tile" a go, but when doing a tile scan loop I only find the grass under the tree :-/

So that leaves the click approach.... But I just won't do it :-P I hate click, I will try a easyuo/razor combo if it's possible, I'd love to have a 100% easyuo for this but I refuse click :-D

Thanks for the response though :-)


Top
  Profile 
PostPosted: Sat Feb 09, 2019 2:06 pm 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 175

Groups:
You need to verify the documentation rather than make assumptions, because #FINDKIND is not equivalent to #LTARGETKIND.
The typical resource gathering was done historically with the 'tile' information, while you are trying to use the data from 'finditem' - these do not match and you probably need to force the #LTARGETKIND to what you expect to get.

#findkind returns:
-1 = nothing found
0 = object is in a container
1 = object is on the ground (probably what you are getting)

#ltargetkind wants to be:
1 = object
2 = ground, mountain, caves
3 = resource: tree, water (probably what you want to give you lumber)

Futhermore, while I am not testing it, I mentioned above that you wanted to setup the #ltarget variables: #LTARGETX, #LTARGETY, #LTARGETZ, rather than #LTARGETID. You probably will never get resources from an "object" and I think you want to target the location rather than the ID.

If you think about how we use an axe, we can:
-chop lumber from trees
-destroy carpentry items
-change deeded decorations in our house back into deed form
-hit a mobile to inflict damage
If you don't have the parameters correct, then the computer will not respond properly, because it can't read our thoughts. ;)

I would be curious how this change would function on your shard.

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sat Feb 09, 2019 2:25 pm 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 175

Groups:
I just noticed you tried to force ending the "for %lj 1 2" loop by setting %lj to 3 or keeping in the loop by setting it to 1... This will not work. If you really want that kind of functionality you need to change to a while or repeat loop structure. I recently wanted to do that and tested it... to prove the for loop can't be adjusted dynamically.

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sat Feb 09, 2019 2:38 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 04/22/2014 05:41
Posts: 11
The difference in #findkind and #ltargetkind was big news to me :-)
Thanks for that, not that it made much difference here since the planted tree probably is an object :-/

And when you say use #ltargetx #ltargety I guess you refer to tile, I will look in to that some more since it seems to be what most people use, and I have been using it aswell in downloaded scripts, it just won't work with these trees.

Oh and about the rather wierd way to force the for loop to end works great ;-) been using it in some other scripts but yes, doing it with a while would be a better solution I guess.


Top
  Profile 
PostPosted: Sat Feb 09, 2019 5:09 pm 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 175

Groups:
I think the official way to end a loop is controlled via "continue" and "break" commands. ;)

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun Feb 10, 2019 12:58 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 04/22/2014 05:41
Posts: 11
It took a while but i actually figured out what you meant with using #LTARGETX,Y,Z instead ;D i'w never used it like that before. i always though that event macro 22 only goes for the #LTARGETID and thats it,

I did some changes to the script:
Code:
  1. set %axeID UERXGOD
  2. reset:
  3. ignoreitem reset 1
  4. loop:
  5. finditem YGF G_1
  6.         {
  7.         set #LOBJECTID %axeID
  8. ;       set #LTARGETID #FINDID
  9.         set #lTargetX #FINDX
  10.         set #lTargetY #FINDY
  11.         set #lTargetZ 0
  12.         set #lTargetKind 3
  13.         set #LTARGETTILE 0
  14.         for %lj 1 2
  15.                 {
  16.                 set %ljindex1 #JINDEX
  17.                 event macro 17
  18.                 target
  19.                 if #TARGCURS = 1
  20.                         {
  21.                         repeat
  22.                                 {
  23.                                 event macro 22
  24.                                 }
  25.                         until #TARGCURS = 0
  26.                         }
  27.                 wait 20
  28.                 set %ljindex2 #JINDEX
  29.                 for %jj %ljindex1 %ljindex2
  30.                         {
  31.                         scanjournal %jj
  32.                         if any_wood in #journal
  33.                                 {
  34.                                 set %lj 3
  35.                                 }
  36.                                 else
  37.                                 {
  38.                                 set %lj 1
  39.                                 }
  40.                         }
  41.                 }
  42.         ignoreitem #FINDID 1
  43.         }
  44.         else
  45.         {
  46.         goto reset
  47.         }
  48. goto loop
  49.  


and this one works better...but not really working though :P it says "Select a tree to chop." "looping aborted", i tested this on the tree manualy and that works... but then i tested to ground....thats where i get the same message :P so now i'm trying to use the axe on the ground,

Tried to read more into the Tile command and all it can find seems to be the damn grass tile, seems like planted trees are treated as objects here and i probably wont get this working unless i use click :/


Top
  Profile 
PostPosted: Sun Feb 10, 2019 8:19 pm 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 175

Groups:
why are you setting #ltargetz to 0? It should be set to the value of #findz.

I think if it is set to 0, it assumes your #charposz... so likely the ground level... that is my expectation. However, your planted tree is likely higher than the ground level.

If you pay attention to the various location settings for x, y & z, it changes x and y may be the same on various facets, but the z will be different. This is not the way to tell which facet you are on, but it is still important. You can actually find or target things at great distance in game if the x, y and z are not set carefully.

So try setting #LTARGETZ and see if that improves the result.

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun Feb 10, 2019 8:59 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 04/22/2014 05:41
Posts: 11
yea that was stupid of me to leave there :P #FINDZ returns 0, i was experimenting with setting the Z level to different values to maybe force the script too look higher :P

The trees itself consists of 2 Types, YGF (The Stem) and AHF (the leafs), Harvesting "Manually" works on both stem and leafs, i was kind of hoping that a higher Z lvl would find AHF :P but they all return Z 0 when using finditem anyway.


Top
  Profile 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.