Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Default Map Emulation (https://forums.graalonline.com/forums/showthread.php?t=82758)

DustyPorViva 11-12-2008 04:18 AM

Default Map Emulation
 
6 Attachment(s)
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.

Tigairius 11-12-2008 04:44 AM

Looks nice :)

cbk1994 11-12-2008 05:55 AM

Looks nice, good work.

Quote:

Originally Posted by DustyPorViva (Post 1441501)
> 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.

DustyPorViva 11-12-2008 05:58 AM

Quote:

Originally Posted by cbk1994 (Post 1441519)
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 (Post 1441519)
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); 


xXziroXx 11-12-2008 08:42 AM

Nice one Dusty.

Codein 11-12-2008 03:50 PM

Good job, man :D

Crono 11-12-2008 04:17 PM

I like.

Soala 11-12-2008 05:35 PM

Nice ! ^^

[email protected] 11-12-2008 08:44 PM

I like! ^^

cbk1994 11-12-2008 10:50 PM

Quote:

Originally Posted by DustyPorViva (Post 1441520)
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 :p

WhiteDragon 11-12-2008 11:50 PM

Useful.

DustyPorViva 11-13-2008 03:59 AM

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.

DustyPorViva 02-27-2010 03:41 AM

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};



Jonko 10-19-2014 12:03 AM

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?

callimuc 10-19-2014 02:51 PM

Quote:

Originally Posted by Jonko (Post 1732105)
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)

scriptless 10-19-2014 05:31 PM

Quote:

Originally Posted by callimuc (Post 1732122)
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)

Some people this "press m" feature is not working for. Also it's better to use other methods for higher quality. The real confusion comes in when you add minimap and finding the right size for them.

Jonko 10-19-2014 08:30 PM

Quote:

Originally Posted by scriptless (Post 1732125)
Some people this "press m" feature is not working for. Also it's better to use other methods for higher quality. The real confusion comes in when you add minimap and finding the right size for them.

This was my next question. What size should the image of the minimap be?

Jakov_the_Jakovasaur 10-19-2014 08:38 PM

Quote:

Originally Posted by Jonko (Post 1732132)
This was my next question. What size should the image of the minimap be?

size does not matter, as if a players x is 50% along the width of a gmap, any good map system would be drawing the player x 50% along the width of the minimap image too

scriptless 10-20-2014 12:58 AM

Quote:

Originally Posted by Jakov_the_Jakovasaur (Post 1732133)
size does not matter, as if a players x is 50% along the width of a gmap, any good map system would be drawing the player x 50% along the width of the minimap image too

I think he was asking a question similar to one I asked before. I had previously asked with not much help if there were limitations to the size of minimaps. For example are minima's that are 1000x1000x pixels even able to be drawn or does the game go, lol no way, and not even try and show it. And to that question I do not have an answer yet. I just found an old minimap and I am using that for now on the project I am doing.

Jakov_the_Jakovasaur 10-20-2014 05:06 AM

Quote:

Originally Posted by scriptless (Post 1732149)
I think he was asking a question similar to one I asked before. I had previously asked with not much help if there were limitations to the size of minimaps. For example are minima's that are 1000x1000x pixels even able to be drawn or does the game go, lol no way, and not even try and show it. And to that question I do not have an answer yet. I just found an old minimap and I am using that for now on the project I am doing.

i wouldnt be surprised if the game stopped drawing it at 1024px, but having a "minimap" that large would be ridiculous anyway

Inari 10-20-2014 06:24 PM

Why not have the client draw the map as the player moves along?


All times are GMT +2. The time now is 01:49 AM.

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