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 10-17-2006, 03:10 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
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;
  }
} 
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #2  
Old 10-17-2006, 03:47 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by contiga View Post
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?
Reply With Quote
  #3  
Old 10-17-2006, 09:41 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Quote:
Originally Posted by Twinny View Post
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..
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote
  #4  
Old 10-31-2006, 09:30 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
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?
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #5  
Old 11-11-2006, 03:55 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by JkWhoSaysNi View Post
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
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:51 AM.


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