Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-12-2008, 04:18 AM
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
Default Map Emulation

UPDATES: added click warping, PM opening and nick name display

Since Graal seems to not support maps online anymore, I figured it would be useful to rescript it to replicate the default as much as possible. Huge credit to Tig and PFA for helping me with various problems.

Things to add:
DONE showing the name of selected player from playerlist(I have to figure out how to receive the data from the external, if it's possible).
DONE ctrl+click warping for staff.
> a way to automatically detect gmaps and data about them, instead of adding them.
DONE blinking a players head with a PM bubble if they have sent a PM/toall. I don't know if this is possible though.
> pause/unpause the player.
> perhaps a way to show shrunken heads of the last position of players who left the map. I don't think this will be possible, though.

Anyways, in order to get this to work simply add it to a WNPC and add it to the player. When the map is opened and closed, it hides/shows stats, you should make sure you fix that to work with whatever stats you are showing. All you have to do then is add the needed gmap details to the array and be on your way.

Please post any bugs you encounter with it, or any suggestions for that matter.

Also attached some screenshots of it.

I'VE ATTACHED THE SCRIPT NOW.
Attached Thumbnails
Click image for larger version

Name:	graal_1226456001.png
Views:	615
Size:	9.9 KB
ID:	46458   Click image for larger version

Name:	graal_1226456103.png
Views:	641
Size:	17.0 KB
ID:	46459   Click image for larger version

Name:	graal_1226456089.png
Views:	756
Size:	28.4 KB
ID:	46460   Click image for larger version

Name:	graal_1226456124.png
Views:	624
Size:	8.4 KB
ID:	46461   Click image for larger version

Name:	mapscreen.PNG
Views:	636
Size:	28.3 KB
ID:	46469  

Attached Files
File Type: txt mapscript.txt (7.7 KB, 737 views)

Last edited by DustyPorViva; 11-13-2008 at 04:17 AM..
Reply With Quote
  #2  
Old 11-12-2008, 04:44 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Looks nice
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 11-12-2008, 05:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Looks nice, good work.

Quote:
Originally Posted by DustyPorViva View Post
> a way to automatically detect gmaps and data about them, instead of adding them.
player.gmap.name may help, and getimgwidth() and getimgheight() may also. You'd still need to store the image, but you could do what GK does an always name things the same (yourserver_map-gmapname.png).
Quote:
> blinking a players head with a PM bubble if they have sent a PM/toall. I don't know if this is possible though.
players[i].pmswaiting() - returns boolean
players[i].ismasspm() - returns boolean
players[i].isguildpm() - returns boolean
players[i].openexternalpm(bool) - returns boolean - as parameter specify 'true' if it should display the pm sent by the player, otherwise always open a blank PM window

Those should help. I don't think it's possible to check for toalls messages.
__________________
Reply With Quote
  #4  
Old 11-12-2008, 05:58 AM
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
Quote:
Originally Posted by cbk1994 View Post
player.gmap.name may help, and getimgwidth() and getimgheight() may also. You'd still need to store the image, but you could do what GK does an always name things the same (yourserver_map-gmapname.png).
Problem is, I want this to be functional for everyone. If UN uses this, for example, I don't want them to have to change their map image or anything. getimgwidth and such would work, but it only works when in the cache and I don't want to run loops to check that. There's also the matter of getting the actual gmap name, and since Stefan never took my suggestion for expanding gmap data into variables... well, that's a problem.

Quote:
Originally Posted by cbk1994 View Post
players[i].pmswaiting() - returns boolean
players[i].ismasspm() - returns boolean
players[i].isguildpm() - returns boolean
players[i].openexternalpm(bool) - returns boolean - as parameter specify 'true' if it should display the pm sent by the player, otherwise always open a blank PM window

Those should help. I don't think it's possible to check for toalls messages.
Thanks, already got this done with Tig's help though
For future reference(it took me a while to figure it out), openexternalpm() works as:
PHP Code:
("-Playerlist").openexternalpm({findplayer(player.account)},false); 

Last edited by DustyPorViva; 11-12-2008 at 06:15 AM..
Reply With Quote
  #5  
Old 11-12-2008, 08:42 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Nice one Dusty.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #6  
Old 11-12-2008, 03:50 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Good job, man
Reply With Quote
  #7  
Old 11-12-2008, 04:17 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
I like.
__________________
Reply With Quote
  #8  
Old 11-12-2008, 05:35 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Nice !
Reply With Quote
  #9  
Old 11-12-2008, 08:44 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
I like!
Reply With Quote
  #10  
Old 11-12-2008, 10:50 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
For future reference(it took me a while to figure it out), openexternalpm() works as:
PHP Code:
("-Playerlist").openexternalpm({findplayer(player.account)},false); 
Thanks, I've never used it
__________________
Reply With Quote
  #11  
Old 11-12-2008, 11:50 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Useful.
Reply With Quote
  #12  
Old 11-13-2008, 03:59 AM
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
I've added displayed nicknames, which will display the names of players selected on the playerlist, or yours if none are displayed.

Also had to attach the script now, due to the retarded bad request error. Yay. Oh, and a new screenshot.

edit: sped up the PM bubble blinking and aligned the player nicks a little.

Last edited by DustyPorViva; 11-13-2008 at 04:18 AM..
Reply With Quote
  #13  
Old 02-27-2010, 03:41 AM
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
I've fixed a few things in this a long time ago, but never got around to posting it. Mainly I redid mouse click warping, as the old one is quite bugged. Also added an array of ganis that specify when the player's ani will be set to maps(IE, when you open the map your gani will be changed when you're idle, but not swimming).

Here's the update:
PHP Code:
//#CLIENTSIDE
function Customize() {
  
this.map.transparency 1;  // TRANSPARENCY OF MAP
  
this.map.trueheaddir 0;   // HEADS FACE THE DIRECTION OF PLAYER
  
this.map.scrollspeed 10;  // SPEED OF MAP SCROLLING

  // A LIST OF GMAPS AND APPROPRIATE INFORMATION
  
this.map.list = {
    
//{"gmapname.gmap","mapimage.png",imagewidth,imageheight},
    
{"ow.gmap","ow_map.png",1680,1400},
    {
"ctf.gmap","ctf_map.png",224,56},
  };

  
// LIST OF GANIS THAT CAN BE REPLACED WITH MAP WHEN OPENED/CLOSED
  
this.map.CanGani = {
    
"idle","walk","grab","push","pull","sit","sleep",
  };

}

function 
onCreated() {
  
player.mapopen 0;
  
this.map = new TStaticVar();
  
Customize();
  
disablemap();
}

function 
onKeyPressed(code,key) {
  if (
keydown(7) && player.isreading == false) {
    if (
this.mpressed == false) {
      if (
player.mapopen == 0open();
      else 
close();
    }
    
this.mpressed true;
  }
}

function 
GraalControl.onKeyUp() {
  if (!
keydown(7)) this.mpressed false;
}

public function 
open() {
  
this.map.gmapname this.map.img this.map.imgW this.map.imgH null;
  for (
i:this.map.list) {
    if (
player.gmap.name == i[0]) {
      
this.map.gmapname i[0];
      
this.map.img i[1];
      
this.map.imgW i[2];
      
this.map.imgH i[3];
      break;
    }
  }

  if (
this.map.gmapname == null) return;

  
freezeplayer(.25);
  if (
player.ani.name in this.map.CanGanisetani("maps1",null);

  
showpoly(200,{0,0,GraalControl.width,0,GraalControl.width,GraalControl.height,0,GraalControl.height});
  
changeimgcolors(200,0,0,0,this.map.transparency);
  
changeimgvis(200,10);

  
player.map_pos={
    
int((player.x/player.gmap.width)*this.map.imgW-12),
    
int((player.y/player.gmap.height)*this.map.imgH-16)
  };

  
this.map.pos={int((GraalControl.width-this.map.imgW)/2),int((GraalControl.height-this.map.imgH)/2)};
  if (
this.map.imgW>GraalControl.widththis.map.pos[0]-=player.map_pos[0]-this.map.imgW/2;
  if (
this.map.imgH>GraalControl.heightthis.map.pos[1]-=player.map_pos[1]-this.map.imgH/2;
  
showimg(201,this.map.img,this.map.pos[0],this.map.pos[1]);
  
changeimgvis(201,11);
  
changeimgmode(201,1);
  
changeimgcolors(201,1,1,1,this.map.transparency);

  
showtext(202,20,20,null,"b","Map");
  
changeimgzoom(202,2);
  
changeimgvis(202,15);
  
findimg(202).textshadow=true;
  
findimg(202).shadowoffset={2,2};
  
findimg(202).shadowcolor={0,0,255,255};

  
player.mapopen 1;

  
onTimeout();
}

public function 
close() {
  if (
player.ani.name in this.map.CanGanisetani("maps3",null);
  
hideimgs(200,800+allplayers.size());
  
player.mapopen 0;
}

function 
onTimeout() {
  if (
player.mapopen == 1) {
    if (
keydown2(162,true) && leftmousebutton) {
      
player.chat "warpto " int(((-this.map.pos[0]+mousescreenx)/this.map.imgW)*player.gmap.widthSPC int(((-this.map.pos[1]+mousescreeny)/this.map.imgH)*player.gmap.height);
      
close();
      return;
    }

    
freezeplayer(0.05);
 
    
player.map_pos={int((player.x/player.gmap.width)*this.map.imgW-12),int((player.y/player.gmap.height)*this.map.imgH-16)};
    for (
temp.k=0;k<4;k++) {
      if (
keydown(k)) {
        if (
this.map.imgW>GraalControl.widththis.map.pos[0]-=vecx(k)*this.map.scrollspeed;
        if (
this.map.imgH>GraalControl.heightthis.map.pos[1]-=vecy(k)*this.map.scrollspeed;
      }
    }
    if (
this.map.imgW>GraalControl.width) {
      if (
this.map.pos[0]>0this.map.pos[0]=0;
      if (
this.map.pos[0]<-(this.map.imgW-GraalControl.width)) this.map.pos[0]=-(this.map.imgW-GraalControl.width);
    }
    if (
this.map.imgH>GraalControl.height) {
      if (
this.map.pos[1]>0this.map.pos[1]=0;
      if (
this.map.pos[1]<-(this.map.imgH-GraalControl.height)) this.map.pos[1]=-(this.map.imgH-GraalControl.height);
    }
    
findimg(201).x=this.map.pos[0];
    
findimg(201).y=this.map.pos[1];

    
showimg(300,player.headimg,this.map.pos[0]+player.map_pos[0],this.map.pos[1]+player.map_pos[1]);
    
changeimgpart(300,0,this.map.trueheaddir == 64 player.dir*32,32,32);
    
changeimgzoom(300,.5);
    
changeimgvis(300,13);

    if (
selectedlistplayers.size()=<|| player.account in selectedlistplayers) {
      
showtext(800,this.map.pos[0]+player.map_pos[0]+14,this.map.pos[1]+player.map_pos[1]+24,null,"cb",player.nick);
      
temp.colorap=getAPColors(player.ap);
      
changeimgcolors(800,colorap[0][0]/255,colorap[0][1]/255,colorap[0][2]/255,1);
      
changeimgzoom(800,.9);
      
findimg(800).textshadow true;
      
//findimg(800).shadowcolor={colorap[1][0],colorap[1][1],colorap[1][2],255};    
      
changeimgvis(800,12);
    } else 
hideimg(800);

    
temp.checkplayers=0;
    for (
i:allplayers) {
      if (
i.gmap.name == player.gmap.namecheckplayers++;
    }
    if (
checkplayers<this.realplayers) {
      
hideimgs(301,301+this.realplayers);
      
hideimgs(801,801+this.realplayers);
    }

    
temp.j=0;
    
this.realplayers 0;
    for (
i:allplayers) {
      if (
i.gmap.name == player.gmap.name) {
        
temp.player_pos={int((i.x/i.gmap.width)*this.map.imgW-12),int((i.y/i.gmap.height)*this.map.imgH-16)};
 
        
showimg(301+j,i.headimg,this.map.pos[0]+player_pos[0],this.map.pos[1]+player_pos[1]);
        if (
i.pmswaiting()) {
          if (
timevar2.substring(timevar2.pos(".")+1,1)<5) {
            
findimg(301+j).image="state.png";
            
findimg(301+j).x+=8;
            
findimg(301+j).y+=8;
            
changeimgzoom(301+j,1);
            if (
i.ismasspm()) changeimgpart(301+j,158,0,16,16);
            else if (
i.isguildpm()) changeimgpart(301+j,174,0,16,16);
            else if (
i.isadminchangeimgpart(301+j,158,16,16,16);
            else 
changeimgpart(301+j,142,16,16,16);
          } else {
            
changeimgpart(301+j,0,this.map.trueheaddir == 64 i.dir*32,32,32);
            
changeimgzoom(301+j,.5);
          }

          if (
mousescreenx in |this.map.pos[0]+player_pos[0]+8,this.map.pos[0]+player_pos[0]+24|) {
            if (
mousescreeny in |this.map.pos[1]+player_pos[1]+8,this.map.pos[1]+player_pos[1]+24|) {
             if (
leftmousebutton) ("-Playerlist").openPMWindow({i},false);
            }
          }
        } else {
          
changeimgpart(301+j,0,this.map.trueheaddir == 64 i.dir*32,32,32);
          
changeimgzoom(301+j,.5);
        }
        
changeimgvis(301+j,12);

        if (
i in selectedlistplayers) {
          
showtext(801+j,this.map.pos[0]+player_pos[0]+14,this.map.pos[1]+player_pos[1]+24,null,"cb",i.nick);
          
temp.colorap=getAPColors(i.ap);
          
changeimgcolors(801+j,colorap[0][0]/255,colorap[0][1]/255,colorap[0][2]/255,1);
          
changeimgzoom(801+j,.9);
          
findimg(801+j).textshadow true;
          
//findimg(801+j).shadowcolor={colorap[1][0],colorap[1][1],colorap[1][2],255};
          
changeimgvis(801+j,12);
        } else 
hideimg(801+j);
        
this.realplayers++;
        
j++;
      }
    }
    
    
showtext(203,GraalControl.width-20,20,null,"br","Others: " j);
    
changeimgvis(203,15);
    
findimg(203).textshadow=true;
    
findimg(203).shadowoffset={2,2};
    
findimg(203).shadowcolor={0,0,255,255};

    
setTimer(0.05);
  }
}

// NOT MY WORK BELOW HERE
public function getAPcolors(value) {
  
temp.apcolor = {0,0,0};
  if (
temp.value <= 0apcolor = {64,0,0};
  else if (
temp.value <= 26apcolor =  {128 int(127 * (temp.value 1) / 25),64 int(64 * (temp.value 1) / 25),64 int(64 * (temp.value 1) / 25)};
  else if (
temp.value <= 49apcolor =  {255,int(255 * (temp.value 26) / 24),int(255 * (temp.value 26) / 24)};
  else if (
temp.value <= 55apcolor =  {255,255,255};
  else if (
temp.value <= 60apcolor =  {255 int(127 * (temp.value 55) / 5),255,255 int(127 * (temp.value 55) / 5)};
  else if (
temp.value <= 70apcolor =  {128 int(128 * (temp.value 61) / 10),255,128 int(127 * (temp.value 61) / 10)};
  else if (
temp.value <= 99apcolor =  {0,255 int(255 * (temp.value 70) / 29),255};
  else 
apcolor = {224,196,0};

  
temp.shadowap apcolor;
  if (
temp.value == 100shadowap = {255,255,0};
  else 
temp.shadowap[0] = temp.shadowap[1] = 255 * !(temp.shadowap[0] > 191.25 || temp.shadowap[1] > 191.25);
  
  return {
apcolor,shadowap};

Reply With Quote
  #14  
Old 10-19-2014, 12:03 AM
Jonko Jonko is offline
Registered User
Join Date: Mar 2011
Posts: 12
Jonko is on a distinguished road
Terribly sorry about the necro, but when it's asking for the map image, does that mean that I need to upload an image of what I want the map to look like?
Reply With Quote
  #15  
Old 10-19-2014, 02:51 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Jonko View Post
Terribly sorry about the necro, but when it's asking for the map image, does that mean that I need to upload an image of what I want the map to look like?
Indeed, you can generate one per script or use the level editor (while being in the editing mode, I believe it's the 'M' key)
__________________
MEEP!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:45 AM.


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