Page 1 of 1

ta script: add get coords commands

Posted: 26 Jan 2011, 07:34
by nmaligec
I noticed that there is no way to get a player's map coordinates. It should be easy to expose a get coord command for scripting. What about a set player coords, can this be done, along with the appropriate client update?

For npcs, would it be possible to get/set their coords?

I would really want to be able to get/set mob coords. I know there is currently no way to interact with mobs through scripting. If we can get the mob's id when it is created and store it, then it would be possible to interact with it through specialized commands? Maybe have a special spawnOne command that spawns one mob and returns its id.

Re: ta script: add get coords commands

Posted: 28 Mar 2011, 18:03
by Snurayroth
Im totally New to TMW, im from the eAthena forum and worked for years with eAthena.
I dont know how eAthena works with the TMW client, i suspect ur eAthena(TMW) no longer corresponds to the original eAthena but usually ... erm take a look:

Code: Select all

*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})

This function will locate a character object, NPC object or pet's coordinates 
and place their coordinates into the variables specified when calling it. It 
will return 0 if the search was successful, and -1 if the parameters given were 
not variables or the search was not successful.

Type is the type of object to search for:

  0 - Character object
  1 - NPC object
  2 - Pet object
  3 - Monster object.
  
While 3 is meant to look for a monster object, no searching will be done if you 
specify type 3, and the function will always return -1.

The search string is optional. If it is not specified, the location of the 
invoking character will always be returned for types 0 and 2, the location of 
the NPC running this function for type 1.
If a search string is specified, for types 0 and 1, the character or NPC with 
the specified name will be located. If type is 3, the search will locate the 
current pet of the character who's name is given in the search string, it will 
NOT locate a pet by name.

What a mess. Example, a working and tested one now:

    prontera.gat,164,301,3|	|script|	|Meh|	|730,{
        mes "My name is Meh. I'm here so that Nyah can find me.";
        close;
    }

    prontera.gat,164,299,3|	|script|	|Nyah|	|730,{
        mes "My name is Nyah.";
        mes "I will now search for Meh all across the world!";
        if (getmapxy(@mapname$,@mapx,@mapy,1,"Meh")!=0) goto Notfound;
        mes "And I found him on map "+@mapname$+" at X:"+@mapx+" Y:"+@mapy+" !";
        close;
    Notfound:
        mes "I can't seem to find Meh anywhere!";
        close;
   }
   
Notice that NPC objects disabled with 'disablenpc' will still be located. 

I hope I could help you with this. My english isn't very good. sorry xD

Re: ta script: add get coords commands

Posted: 28 Mar 2011, 21:42
by nmaligec
Your knowledge of eAthena scripting is very helpful, especially for fakenpcname. Unfortunately tmwAthena is lacking several commands. getmapxy is one of them. In the manual I was referencing it said getmapxy did not work properly for mobs, I guess they fixed it since the manual version I was looking at.

The commands I am most bummed about not having are:
  • setcell/setwall
  • areamobuseskill
  • for (no built in loops!)
  • if, with multiple statements
  • anything that acesses a spawned mobs info (you can get the mob db info but not current hp or location)
  • a command that lets you do something to all pcs in an area/map.
  • clone (not crucial but it would have been fun)
If you are interested in knowing what commands are currently implemented you can sorta get a list by checking out the source code for scripts. Check lines 115-318, the format is
int buildin_commandname (struct script_state *st);

here is the link (be patient if it doesnt load right away, it is a large file):
http://gitorious.org/tmw-eathena/mainli ... p/script.c

Re: ta script: add get coords commands

Posted: 29 Mar 2011, 22:17
by Zutan
The manaplus client is able to show map co-ordinates, is that client side?

Re: ta script: add get coords commands

Posted: 29 Mar 2011, 22:34
by Freeyorp101
This is regarding tmwAthena scripting and has absolutely nothing to do with what the client displays.


---Freeyorp

Re: ta script: add get coords commands

Posted: 30 Mar 2011, 06:47
by Crush
The normal client also displays map coordinates in the F10 window. We have this feature for ages. It's funny how many features are attributed to the ManaPlus patch although they have been core features of the unmodified client for ages. But, as Freeyorp pointed out, this is off topic.

Re: ta script: add get coords commands

Posted: 31 Mar 2011, 23:07
by Zutan
Ohh. Thanks for that. I use .29 1.0 and manaplus almost everyday sometimes things jump out more on one client than the others.

So the client does the calculating of that from data files I am guessing. Does the server see players when monsters with aggro come into view?

Re: ta script: add get coords commands

Posted: 01 Apr 2011, 00:48
by Freeyorp101
The server has the complete state of the game world at any time.


---Freeyorp