position of target click

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
phao
UOX3 Newbie
Posts: 24
Joined: Sat Aug 11, 2007 7:27 pm
Has thanked: 0
Been thanked: 0

position of target click

Post by phao »

See, i'd like to know if there is some way to get the position of the click when i use:

Code: Select all

socket.CustomTarger(arg1, arg2);
it'll appear a target on the user screen and when he clicks in some place I need the x, z, y of the position that he clicks.

Taking advantage of this question i'd like to know if that position (that i've got from the click) is walkable, and got the true/false result by some function or method.

does anyone knows?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

cIn the callback function, you can use:

Code: Select all

		var targX;
		var targY;
		var targZ;
		if( !socket.GetWord( 1 ) && ourObj )
		{ //get coordinates from targeted object
			targX = ourObj.x;
			targY = ourObj.y;
			targZ = ourObj.z;
		}
		else
		{ //get coordinates from targeted location
			targX = socket.GetWord( 11 );
			targY = socket.GetWord( 13 );
			targZ = socket.GetSByte( 16 ) + GetTileHeight( socket.GetWord( 17 ) );
		}
As for checking whether or not a tile is walkable... ideally we'd have a JS Method or something to check that for a given tile, but since we haven't (I think), you can do something like this:
First, create an array of tile-ids that the user shouldn't be able to walk on:

Code: Select all

var invalidTiles = new Array( "id1", "id2", "id3", "etc" );
Next, use GetTileIDAtMapCoord along with the coordinates of the location the player targeted, and search through the arraylist to see if it contains this tileID:

Code: Select all

			var TargMapTileID = GetTileIDAtMapCoord( targX, targY, pUser.worldnumber );
			for( var i = 0; i < invalidTiles.length; i++ )
			{
			   	if( TargMapTileID == invalidTiles[i] )
			   	{
			        pUser.SysMessage( "Invalid tile!" );
			       	break;
				}
		    }			


Not a very easy way of doing it I guess, but only one I can think of.
-= Ho Eyo He Hum =-
Post Reply