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 06-20-2016, 05:31 PM
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
Gmap boundary visualization

Recently I was dealing with NPCs that relied on boundaries of their local level instead of the gmap and needed to know precisely where the boundaries of these levels were in relation to the gmap. So I wrote this up really quick. Figured it would be useful for others.

What it does is show the boundaries of every level on the gmap, along with the level name in each quadrant so you can know exactly what level you're in and what the adjacent levels are.

Click image for larger version

Name:	tHNuJrJ.png
Views:	146
Size:	118.3 KB
ID:	55905

Graal Script Code:
//#CLIENTSIDE
const PIXEL 1/16;
const 
DITHER "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEB***CdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABZLziQAAAAJ0Uk5T/wDltzBKAAAA8ElEQVR42uzSAQ0AAAyDMObf9IW8qQNCjdfSwAE4AAfgAByAA3AADsABOAAH4AAcgANwAA7AATgAB+AAHIADcAAOwAE4AAfgAByAA3AADsABOAAH4AAcgANwAA7AATgAB+AAHIADcAAOwAE4AAfgAByAA3AADsABOAAH4AAcgANwAA7AATgAB+AAHIADcAAOwAE4AAfgAByAA3AADsABOAAH4AAcgANwAA7AATgAB+AAHIADcAAOwAE4AAfgAByAA3AADsABOAAH4AAcgANwAA7AATgAB+AAHIADcAAOwAE4AAfgAByAA2gdAAAA//8DAMT8gAEYBi5NAAAAAElFTkSuQmCC";
function 
onCreated() {
  
// Load dither pattern from base64 and save it as an image
  
temp.filename "levelgrid_dither.png";
  if (!
fileexists(temp.filename)) {
    
temp.file base64decode(DITHER);
    
temp.file.savestring(temp.filename0);
  }
}

function 
onPlayerEnters() {
  
this.ind 200// Initiate showimg index at 200
  
hideimgs(200,300);

  if (
player.gmap.name == null) return; // Only show on gmaps

  // Locations of all adjacent levels
  
temp.bounds = {
    {-
64,-64},{0,-64},{64,-64},
    {-
64},{0},{640},
    {-
6464},{064},{6464},
  };

  
// Detect proper level name
  
temp.level player.gmap == null player.level player.gmap;

  for (
temp.i=0;temp.i<temp.bounds.size();temp.i++) {
    
temp.px player.temp.bounds[temp.i][0];
    
temp.py player.temp.bounds[temp.i][1];

    
temp.int(temp.px/64)*64;
    
temp.int(temp.py/64)*64;

    
temp.lvl level.getmappartfile(temp.x+1,temp.y+1);

    
// Draw 4 dashed (white) line lines
    
temp.color = {255,255,255};
    
drawLine(200,{temp.x,temp.y},{temp.x+64,temp.y},PIXEL,temp.color,1);
    
drawLine(201,{temp.x,temp.y},{temp.x,temp.y+64},PIXEL,temp.color,1);
    
drawLine(202,{temp.x,temp.y+64-PIXEL},{temp.x+64,temp.y+64-PIXEL},PIXEL,temp.color,1);
    
drawLine(203,{temp.x+64-PIXEL,temp.y},{temp.x+64-PIXEL,temp.y+64},PIXEL,temp.color,1);

    
// Draw 4 dashed lines(blue) a pixel diagonally to the south-east for a shadow
    
temp.int(temp.px/64)*64 PIXEL;
    
temp.int(temp.py/64)*64 PIXEL;
    
temp.color = {8,10,252};

    
drawLine(204,{temp.x,temp.y},{temp.x+64,temp.y},PIXEL,temp.color,0);
    
drawLine(205,{temp.x,temp.y},{temp.x,temp.y+64},PIXEL,temp.color,0);
    
drawLine(206,{temp.x,temp.y+64-PIXEL},{temp.x+64,temp.y+64-PIXEL},PIXEL,temp.color,0);
    
drawLine(207,{temp.x+64-PIXEL,temp.y},{temp.x+64-PIXEL,temp.y+64},PIXEL,temp.color,0);
 
    
// Draw the level name in each corner of the quadrant
    
temp.texts = {
      {
.35     ,.15 32      ""},
      {
64 .35,.15 32      "r"},
      {
64 .3563 .15 32"r"},
      {
.35     63 .15 32""},
    };
    for (
temp.temp.texts) {
      
with (findimg(this.ind)) {
        
text temp.lvl;
        
temp.temp.j[0];
        
temp.temp.j[1];
        
32;
        
layer 0;
        
style temp.j[2];
        
zoom .5;
        
textshadow true;
        
font "verdana";
      }
      
this.ind++;
    }
  }
}

// Drawing a single polygon line does not allow you to apply a texture
// So instead we'll adapt Chompy's drawline function from: http://forums.graalonline.com/forums/showthread.php?t=78427
// This draws a line with a thickness, and 4 points, allowing a texture to be applied
// In this case, we use the dither image we generated to create a dashed-line effect
public function drawLine(indexxy1xy2thicknesscolorlay) {
  
with(findimg(this.ind)) {
    
dimension 3;
    
polygon = {
      
xy1[0], xy2[1] -32, -32,
      
xy2[0], xy1[1] -32, -32,
      
xy2[0]+thicknessxy1[1]+thickness -32, -32,
      
xy1[0]+thicknessxy2[1]+thickness -32, -32,
    };
    
red color[0]/255;
    
green color[1]/255;
    
blue color[2]/255;
    
alpha .99;

    
mode 1;
    
layer lay;

    
image "levelgrid_dither.png";
  }
  
this.ind++;

Reply With Quote
  #2  
Old 06-20-2016, 07:43 PM
PlanetOscar PlanetOscar is offline
Registered User
Join Date: Aug 2015
Location: Sweden
Posts: 177
PlanetOscar is just really nicePlanetOscar is just really nice
Looks awesome
Reply With Quote
  #3  
Old 06-20-2016, 11:00 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Didn't realize you were still actively developing for Graal.

Also great tool, can think of a few situations where this would have been useful.
__________________
Save Classic!
Reply With Quote
  #4  
Old 06-21-2016, 05:56 AM
Sky Sky is offline
GK Manager
Sky's Avatar
Join Date: Sep 2002
Location: PA, USA
Posts: 622
Sky is a glorious beacon of lightSky is a glorious beacon of lightSky is a glorious beacon of light
Send a message via AIM to Sky Send a message via Skype™ to Sky
Nice, this could be very helpful on GK! Thanks, Dusty.
__________________
Sky
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 08:46 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.