This compass uses polygons to point towards a set objective.
The destination is hardcoded at function changedestination() but it’d work with a little tweaking.
The direction the compass first points at a level that was pregenerated with numbers corresponding to its coordinates, then points at the coordinates inside that level.
Beware the low quality of the video, I didn’T want ot eat up my data for a single example vid.
Bootstrap starts the npcw, my server was designed to have a bootstrap every level so things like this compass get activated on login.
[CODE]
// NPC made by 2ndwolf
if (playerenters) {
if(!isweapon) toweapons compass;
hide;
}
if (bootstrap) {
showstats 1791;
start();
}
if(timeout){
if(this.hidemode=0){
//TODO Manage indexes
showimg 1000,hud_compass.png,32,screenheight-(48+32);
changeimgvis 1000,4;
this.Rdestination = {(this.objlvlCoords[0]-playerx+(this.Iobjlevelx-1)*64)-((this.Icurrlevelx-1)*64),
(this.objlvlCoords[1]-playery+(this.Iobjlevely-1)*64)-((this.Icurrlevely-1)*64)};
if(abs(this.Rdestination[0])>1||abs(this.Rdestination[1])>1){
this.info = getangle(-this.Rdestination[0],-this.Rdestination[1]);
this.pindir = this.info;
} else this.info += .2%6.28;
showpoly 1002,{32+48/2+(cos((this.info+1.57*3)%6.28)*5),
screenheight-32-24-(sin((this.info+1.57*3)%6.28)*5),
32+48/2-(cos(this.info)*22), //needle point
screenheight-32-24+(sin(this.info)*22), //needle point
32+48/2+(cos((this.info-1.57*3)%6.28)*5),
screenheight-32-24-(sin((this.info-1.57*3)%6.28)*5) //right when north
};
changeimgvis 1002,5;
changeimgcolors 1002,0,.7,.3,1;
showpoly 1003,{32+48/2+(cos((this.info+1.57*3)%6.28)*5),
screenheight-32-24-(sin((this.info+1.57*3)%6.28)*5),
32+48/2-(cos(this.info)*-22), //needle point
screenheight-32-24+(sin(this.info)*-22), //needle point
32+48/2+(cos((this.info-1.57*3)%6.28)*5),
screenheight-32-24-(sin((this.info-1.57*3)%6.28)*5) //right when north
};
changeimgvis 1003,5;
changeimgcolors 1003,0.7,0,0,1;
timeout = 0.05;
}
/* if(leftmousebutton&&
mousescreenx in |32,48+32|&&
mousescreeny in |screenheight-(32+48),screenheight-32|){
//TODO, show destination menu
}
*/
}
function changedestination(){
setstring client.Sobjectivelevel,wolf1__21-20.nw;
this.objlvlCoords = {32,60};
}
function calculdestination(){
setstring this.Scurrlevel,#L;
this.Iobjlevelx = strtofloat(#e(7,2,#s(client.Sobjectivelevel)));
this.Iobjlevely = strtofloat(#e(10,2,#s(client.Sobjectivelevel)));
if(startswith(wolf,#L)){
this.Icurrlevelx = strtofloat(#e(7,2,#L));
this.Icurrlevely = strtofloat(#e(10,2,#L));
}
}
function start(){
this.Iplayersize = 1;
if(startswith(wolf,#L)){
this.hidemode = 0;
changedestination();
calculdestination();
} else {
this.hidemode = 1;
hideimg 1000;
hideimg 1002;
hideimg 1003;
}
timeout = 0.05;
}[/CODE]
[video=youtube;4cTSyk9amdA]https://www.youtube.com/watch?v=4cTSyk9amdA[/video]