466
Ideas and suggestions / Re: Revive location indicator [mini-map option]
« on: April 01, 2014, 10:53:32 pm »
I still do not see why a database is required.
Even if all 50 Asia world outposts are implemented - these still would static points on the map and easy to add to a list. So the below web code will still be more or less instantaneous.
NOTE: the mini-map doesn't seem to show you your exact coordinates (e.g. 54N 97.78E --> 54N 97.79E jumps to 54N 97.81E). May need to put a 0.04 buffer in the to ensure you get to the right revive.
Even if all 50 Asia world outposts are implemented - these still would static points on the map and easy to add to a list. So the below web code will still be more or less instantaneous.
NOTE: the mini-map doesn't seem to show you your exact coordinates (e.g. 54N 97.78E --> 54N 97.79E jumps to 54N 97.81E). May need to put a 0.04 buffer in the to ensure you get to the right revive.
Code: [Select]
<html>
// This code is public domain. It can be used and changed without violating copyright.
// However, it would be nice to have an acknowledgement of Event "Jane" Savon's contribution.
<script>
// Data
var defaultRevives = [
["Mugen Village",49.56, 85.79],
["New Urengoy",58.61, 94.61],
["Norilsk",60.72, 101.14],
["Saransk", 50.98, 100.68],
["Saransk West",51.16, 94.69],
["Surgot",54.59, 87.98],
["Turukhansk",56.17, 101.87]
];
// Classes
function Player(north,east) {
var mNorth = north;
var mEast = east;
this.GetPosition = function() { // --> Point
var point = new Point();
point.North = mNorth;
point.East = mEast;
return point;
}
}
function Point() {
this.North = 0;
this.East = 0;
this.ToString = function() { // --> String
return this.North.toFixed(2) "N " this.East.toFixed(2) "E";
}
}
function Revive(name,north,east) {
var mName = name;
var mNorth = north;
var mEast = east;
var mId = Revive.id ;
this.GetId = function() { // --> id
return mId;
}
this.GetName = function() { // --> name
return mName;
}
this.GetPosition = function() { // --> Point
var point = new Point()
point.East = mEast;
point.North = mNorth;
return point;
}
}
Revive.id = 0;
function Revives() {
var list = new Array();
this.Add = function(revive) { // --> void
list[revive.GetId()] = revive
}
this.GetByName = function(name) { // --> revive
for (i=0; i<list.length; i ) {
if (list[i].GetName() == name) {
return list[i];
}
};
}
this.GetList = function() { // --> revives list
return list;
}
}
// Functions
function GetNearestRevive(revives, point) { // --> Point
var nearestRevive = null;
var nearestDistance = Math.pow(2,32) -1;
var reviveList = revives.GetList();
var reviveCount = reviveList.length;
for (i=0; i< reviveCount; i ) {
revive = reviveList[i];
position = revive.GetPosition();
dist = Math.pow(
Math.pow((point.East - position.East),2) Math.pow((point.North - position.North),2)
,0.5);
if (dist < nearestDistance) {
nearestDistance = dist;
nearestRevive = revive;
}
}
return nearestRevive;
}
function SetRevives(reviveList) { // --> Revives
var revive;
var revives = new Revives();
for (i=0; i<reviveList.length; i ) {
revive = new Revive(reviveList[i][0],reviveList[i][1],reviveList[i][2]);
revives.Add(revive);
}
return revives;
}
// Main
var revives = SetRevives(defaultRevives);
var player = new Player(54,97.77);
var revivePoint = GetNearestRevive(revives,player.GetPosition());
alert("Player at " player.GetPosition().ToString() " revives at: " revivePoint.GetName());
var player = new Player(54,97.78);
var revivePoint = GetNearestRevive(revives,player.GetPosition());
alert("Player at " player.GetPosition().ToString() " revives at: " revivePoint.GetName());
</script>
</html>
