Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Custom map (https://forums.graalonline.com/forums/showthread.php?t=69472)

contiga 10-17-2006 03:10 PM

Custom map
 
Not that others may use this, but I just wanted to show the script, and get some oppinions on it. Maybe tips to improve it?

- Contiga

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
map.offset_x = map.offset_y = 0;
  
map.movespeed = 10;
  
map.status = 0;
}

function 
onKeyPressed( num, key, scan) {
  if ( 
key = "m") {
    if ( 
isonmap) {
      
map.update = true;
      
map.status = 1 - map.status;
    }
    
setTimer( 0.05);
  }
}

function 
loadPos() {
  
setAni( "bomyisland_map-unfold", "");
  
map.offset_x = ( player.x * ( map.i_width / map.r_width)) - ( screenwidth / 2) + 16;
  
map.offset_y = ( player.y * ( map.i_height / map.r_height)) - ( screenheight / 2) + 32;
  
fixMapPos();
  
map.update = false;
  
map.wait = 1;
}

function 
onTimeout() {
  if ( 
map.status == 1) {
    if ( 
isonmap) drawMap();
    else 
hideMap();
  }
  else 
hideMap();
}

public function 
turnOff()
  
map.status = 0;

function 
hideMap() {
  
setAni( "bomyisland_map-fold", "");
  
hideImgs( 200, map.images_index);
  
disabledaynight = false;
}

function 
drawMap() {
  
freezeplayer( .1);
  if ( 
map.wait > 0)
    
map.wait -= 0.1;
  
disabledaynight = true;
  
hideImgs( 200, map.images_index); 
  
map.images_index = 200;
  
map.r_width = map.r_height = int( 64 * 25); 
  
map.background_poly = { 0, 0, screenwidth, 0, screenwidth, screenheight, 0, screenheight};
  
map.co_ordinates = { map.offset_x, map.offset_y, screenwidth - 32, screenheight - 32};
  
map.i_width = imgwidth( newmainmap.png); 
  
map.i_height = imgheight( newmainmap.png);
  
fixMapPos();
  
drawImg( "bomyisland_bigmap.png", 16, 16, 17, 1, 0.8, 1, map.co_ordinates);
  
drawPoly( map.background_poly, 16, 0.7, 1, { 0, 0, 0});
  
map.objects.clear(); 
  
map.objects.add( { "*" @ player.account, int( player.x), int( player.y), player.head, { 0, 64, 32, 32}});
  
map.objects.add( { "Train", serverr.train_1[ 0], serverr.train_1[ 1], "trainicon.png", { 0, 0, 32, 32}});
  for ( 
pl: allplayers) {
    if ( 
pl.level.starts( "world"))
      
map.objects.add( { "*" @ pl.account, int( pl.x), int( pl.y), pl.head, { 0, 64, 32, 32}});
  }
  for ( 
o: map.objects) {
    
obj_new_x = ( o[ 1] * ( map.i_width / map.r_width)) - map.offset_x;
    
obj_new_y = ( o[ 2] * ( map.i_height / map.r_height)) - map.offset_y;
    if ( 
obj_new_x in | 0, screenwidth| && obj_new_y in | 0, screenheight|) {
      
drawImg( o[ 3], obj_new_x, obj_new_y, 19, 0.5, 1, 1, o[ 4]);
      if ( 
mousescreenx in | obj_new_x + 8, obj_new_x + 24| && mousescreeny in | obj_new_y + 8, obj_new_y + 24|) {
        
drawText( o[ 0], obj_new_x + 26, obj_new_y + 4, "Arial", 0.8, "bi", { 1, 1, 1}, 19);
        
obj_polygon_1 = { obj_new_x + 26, obj_new_y + 4, obj_new_x + 30 + getTextWidth( 0.8, "Arial", "bi", o[ 0]), obj_new_y + 4, obj_new_x + 30 + getTextWidth( 0.8, "Arial", "bi", o[ 0]), obj_new_y + 24, obj_new_x + 26, obj_new_y + 24};
        
obj_polygon_2 = { obj_new_x + 6, obj_new_y + 4, obj_new_x + 26, obj_new_y + 4, obj_new_x + 26, obj_new_y + 24, obj_new_x + 6, obj_new_y + 24};
        
drawPoly( obj_polygon_1, 18, 0.7, 1, { 1, 0.5, 0}); drawPoly( obj_polygon_2, 18, 0.6, 1, { 0, 1, 0});
      }
    }
  }
  if ( 
keydown( 0) || mousescreeny in | 0, 16|) map.offset_y = max( 0, map.offset_y - map.movespeed);
  if ( 
keydown( 1) || mousescreenx in | 0, 16|) map.offset_x = max( 0, map.offset_x - map.movespeed);
  if ( 
keydown( 2) || mousescreeny in | screenheight - 16, screenheight|) map.offset_y = min( map.i_height - screenheight + 32, map.offset_y + map.movespeed);
  if ( 
keydown( 3) || mousescreenx in | screenwidth - 16, screenwidth|) map.offset_x = min( map.i_width - screenwidth + 32, map.offset_x + map.movespeed);
  
findWeapon( "*Inventory").invOff();
  if ( 
map.update == true)
    
loadPos();
  
setTimer( 0.05);
}

function 
fixMapPos() {
  
map.offset_y = max( 0, map.offset_y); 
  
map.offset_y = min( map.i_height - screenheight + 32, map.offset_y);
  
map.offset_x = min( map.i_width - screenwidth + 32, map.offset_x); 
  
map.offset_x = max( 0, map.offset_x);
}

function 
drawPoly( ip, il, ia, im, ic) {
  
map.images_index ++;
  
with ( findImg( map.images_index)) {
    
polygon = ip; layer = il; alpha = ia; mode = im;
    
red = ic[ 0]; green = ic[ 1]; blue = ic[ 2];
  }
}

function 
drawImg( im, ix, iy, il, iz, ia, imode, ipart) {
  
map.images_index ++;
  
with ( findImg( map.images_index)) {
    
image = im; x = ix; y = iy; layer = il;
    
zoom = iz; alpha = ia; mode = imode;
  } 
changeImgPart( map.images_index, ipart[ 0], ipart[ 1], ipart[ 2], ipart[ 3]);
}

function 
drawText( tm, tx, ty, tf, tz, ts, tc, tl) {
  if ( 
tc = 0) tc = { 1, 1, 1};
  
map.images_index ++;
  
with ( findImg( map.images_index)) {
    
x = tx; y = ty; font = tf; zoom = tz; text = tm; style = ts;
    
red = tc[ 0]; blue = tc[ 2]; green = tc[ 1]; layer = tl + 1;
  }
  
map.images_index ++;
  
with ( findImg( map.images_index)) {
    
x = tx + 1; y = ty + ( 2 - ( 1 / 16)); font = tf; zoom = tz;
    
text = tm; style = ts; red = blue = green = 0; layer = tl;
  }
}

function 
onMouseDown( button) {
  switch ( 
button) {
    case 
"left":
      if ( 
map.status = 0) return "";
      if ( 
keydown2( 162, true)) {
        
map.warp_x = ( ( mousescreenx + map.offset_x) - 16) * ( map.r_width / map.i_width);
        
map.warp_y = ( ( mousescreeny + map.offset_y) - 16) * ( map.r_height / map.i_height);
        
player.chat = "warpto " @ int( map.warp_x) @ " " @ int( map.warp_y) @ " newmain.gmap";
        
map.status = 0;
      }
      break;
  }
} 


Twinny 10-17-2006 03:47 PM

Quote:

Originally Posted by contiga (Post 1232048)
Not that others may use this

Did you somehow miss the point of the code gallery? Isn't this like a share the wealth sub forum?

contiga 10-17-2006 09:41 PM

Quote:

Originally Posted by Twinny (Post 1232077)
Did you somehow miss the point of the code gallery? Isn't this like a share the wealth sub forum?

What I ment, is not entirely copy, but get the base from it perhaps.. ^^ I don't want to see an exact copy of it on another server tho..

JkWhoSaysNi 10-31-2006 09:30 PM

How about a feature list?

I couldn't get it to work. The map never displays. Anyway, I released a custom map a while back how does it compare?

xXziroXx 11-11-2006 03:55 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1238110)
I released a custom map a while back

So did I :) . And Contiga, this forum is for sripts to be released for anyone to use it anywhere. Dont like it? Dont post.


All times are GMT +2. The time now is 12:46 PM.

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