View Single Post
  #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