Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-31-2007, 08:15 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Mini map

Here's a little minimap I made. The options are in the onCreated() function.
Just for note, by bottom-right-most level, I mean the .nw filename of the level in the bottomright corner of the map. This helps determine the maps maxsize. This only works if the levels are loaded in a gmap.
PHP Code:
function onActionserverside() {
  if (
params[0]=="indoor") {
    for (
plallplayerspl.triggerclient("gui",name,"indoor",params[1]);
  }
  if (
params[0]=="removehead") {
    for (
plallplayerspl.triggerclient("gui",name,"removehead",params[1]);
  }
}

//#CLIENTSIDE

function onCreated() {
  
this.mapimg="vs_map.png"// FULL SIZE map image name(same image used for big maps, NOT mini-maps)
  
this.BRlevel="vs_world-c3.nw"// Filename of the bottom-right-most level
  
this.mapsize=120// Desired size of the mini-map to be shown(NOT the size of the mini-map image)

  
new GuiScrollCtrl("Mapback") {
    
profile=GuiBlueScrollProfile;
    
width=height=thiso.mapsize;
    
x=20;
    
y=screenheight-(Mapback.height+40);
    
hScrollBar=vScrollBar="alwaysOff";
    
useOwnProfile=true;
    
profile.transparency=0;
    
profile.border=1;
    
profile.borderthickness=1;

    new 
GuiShowImgCtrl("Mapimg") {
      
image=thiso.mapimg;
      
mode=1;
      
red=blue=green=.95;
      
alpha=.85;
      
x=0;
      
y=0;
      
width=getimgwidth(this.image);
      
height=getimgheight(this.image);
    }
  }
  
onTimeout();
}

function 
onPlayerenters() {
  if (
player.gmap==null) {
    
Mapimg.clearcontrols();
    
triggerserver("gui",name,"indoor",player.account);
    
Mapimg.hide();
  } else 
Mapimg.show();
  
Mapback.active=false;
  
onTimeout();
}

function 
onTimeout() {
  
//Mapback.y=(ChatBar.visible==1?ChatBar.y:screenheight)-(Mapback.height+20); 
  
temp.scroll={int((player.x/((getmapx(this.BRlevel)+1)*64))*(Mapimg.width-Mapback.width+2)),int((player.y/((getmapy(this.BRlevel)+1)*64))*(Mapimg.height-Mapback.height+2))};
  
Mapback.scrollto(temp.scroll[0],temp.scroll[1]);

  if (
player.gmap!=nullshowhead(player.account,player.headimg,player.x,player.y,player.dir);
  for (
plallplayers) {
    if (
pl.gmap!=nullshowhead(pl.account,pl.headimg,pl.x,pl.y,pl.dir);
  }
  (
"Head_" player.account).bringtofront();

  
setTimer(0.05);
}

function 
showhead(mapaccount,head,onmapx,onmapy,headdir) {
  
temp.headloc={int((onmapx/((getmapx(this.BRlevel)+1)*64))*Mapimg.width),int((onmapy/((getmapy(this.BRlevel)+1)*64))*Mapimg.height)};
  
with("Mapimg") {
    new 
GuiShowImgCtrl("Head_" mapaccount) {
      
image=head;
      
x=temp.headloc[0]-12;
      
y=temp.headloc[1]-12;
      
party=headdir*32;
      
parth=partw=32;
      
zoom=.5;
      
mode=1;
      
alpha=mapaccount==player.account?1:.65;
      
width=height=32;
      
layer=4;
    }  
  }
}

function 
onActionclientside() {
  if (
params[0]=="indoor") {
    if (
params[1]!=player.account) ("Head_" params[1]).zoom=.25;
  }
  if (
params[0]=="removehead") {
    if (
params[1]!=null && params[1]!=player.account) ("Head_" params[1]).destroy();
  }

And this bit needs to be in the Control-NPC:
PHP Code:
function onPlayerLogout() {
  for (
plallplayerspl.triggerclient("gui","-minimap","removehead",params[0]);

And a screencap(may be faint, but you can see someone else on there)
Attached Thumbnails
Click image for larger version

Name:	minimapscreen.JPG
Views:	459
Size:	73.7 KB
ID:	42248  

Last edited by DustyPorViva; 07-31-2007 at 10:45 PM..
Reply With Quote
  #2  
Old 07-31-2007, 10:34 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
:O nice job
__________________
**FLIP OUT**
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.