View Single Post
  #30  
Unread 02-10-2005, 10:47 PM
taco-man's Avatar
taco-man taco-man is offline
EQ2MAP Updater Author
This person is a EQ2Map developer.
Interface Author - Click to view interfaces
 
Join Date: Nov 2004
Server: Antonia Bayle
Posts: 1,349
Default

Quote:
Originally Posted by Eloa
ick, taco man, can you send me that calculation code again, the one for the placement of the icon that determines the XML Location? Thanks
It is pretty heavily commented so it should be easy to understand. The 2 variables you want are $MAP_x,$MAP_y
Code:
<?php
//declare variables that would be coming from the database
$Name = "Bog Fairies";
$PathfindLocation = "589,-35,560";
$IconType = "MOB";
$Description = "The boring Description about the bog fairies.";
$ZoneRect = "-844,358,-553,698";

//end declare of database variables
//Assume Map images size
$MAP_1x = 436;
$MAP_1y = 506;

//declare what were global variables in the program that i need
//the 2 below should always be zero
$MAP_0x = 0;
$MAP_0y = 0;
//Icons Width and height
$IconW = 10;
$IconH = 10;
//get the location from a string to 3 variables.
list($LOC_x, $LOC_z, $LOC_y) = explode(",",$PathfindLocation);

//split the zonerect up to something usefull
list($LOC_0x, $LOC_0y, $LOC_1x, $LOC_1x) = explode(",",$ZoneRect);

$LOC_0x = $LOC_0x * -1;

//Calculate WDPP_X and WDPP_Y
$wdpp_x = ((-$LOC_1x - $LOC_0x) / $MAP_1x);
$wdpp_y = (($LOC_1y - $LOC_0y) / $MAP_1y);

//calculate Location
$MAP_x = (((-$LOC_0x + $LOC_x) / $wdpp_x) + $MAP_0x) - ($IconW / 2);
$MAP_y = (((-$LOC_0y + $LOC_y) / $wdpp_y) + $MAP_0y) - ($IconH / 2);
//round the Location so that there are no decimals
$MAP_x = round($MAP_x, 0);
$MAP_y = round($MAP_y, 0);

/*
//remove block comment for "Debug Mode"
echo "MAP_1x: $MAP_1x<BR>MAP_1y: $MAP_1y<br>";
echo "LOC_x: $LOC_x<BR>LOC_y: $LOC_y<BR>";
echo "LOC_0x: $LOC_0x<BR>LOC_0y: $LOC_0y<br>LOC_1x: $LOC_1x<br>LOC_1y: $LOC_1y<BR>";
echo "wdpp_x: $wdpp_x, wdpp_y: $wdpp_y<br>";
*/

//Attempt to output XML
echo "<BR>&lt;Icon IconStyle=\"$IconType\" IconType=\"map\" Location=\"$MAP_x,$MAP_y\" Name=\"$Name\" pathfindlocation=\"$LOC_x, $LOC_z, $LOC_y\" ScrollExtent=\"$IconW,$IconH\" Size=\"$IconW,$IconH\" Tooltip=\"$Name: $Description \" TreatAsButton=\"true\" OnHoverIn=\"Parent.Parent.Parent.Parent.WC_Titlebar.QM_LocEntr y.QM_LocText.LocalText=pathfindlocation Parent.Parent.Parent.Parent.WC_Titlebar.QM_LocEntr y.QM_LocPath.pathfindlocation=pathfindlocation\"/&gt;";
?>
__________________
EQ2MAP Updater Download
EQ2MAP Website
How to Install a custom interface

Last edited by taco-man : 02-10-2005 at 10:51 PM.