http://wiki.graal.us/
|
|
Join Date: Nov 2001
Posts: 2,247
|
|
New updates.
Added: - Leaps
- List of Objects to check for
- No longer need to call InitializeTiles()
PHP Code:
testTiles(x,y,mode,leaps,list)
Still all that's required is x and y to check for and return the name of what x and y is on.
Mode is the same, set to true if you wish the tiles to be replaced immediately.
Leaps, set to true to show leaps when tiles are replaced.
list, an array of TileObject definitions to search for, will only check for what's in the list. And will only replace what's in the list.
Example:
PHP Code:
function onCreated(){ join("personal_adam_testtiles"); this.TileObjects.add(newTileObject("BigRock",2,{{354,355,356,357},{370,371,372,373},{386,387,388,389},{402,403,404,405}},{{374,358,359,375},{423,301,301,407},{423,301,301,407},{392,376,377,361}})); } function onMouseDown(){ player.chat = testTiles(mousex,mousey,true,true,{"Bush","Rock","BigRock"}).label; }
Will replace the Bush and Rock and BigRock, with leaps when you click on them.
You will have to update custom tile definitions, by inserting the leap type right after the name, before the tile array.
PHP Code:
//NPC Created by Rogue Shadow (TCN) //AIM: RogueTCN // Run function InitializeTiles() to load definitions from here // temp.test = testTiles(x,y,mode,leaps) if mode is true, replace tiles found, if false return what was found //#CLIENTSIDE function InitializeTiles(){ // Name, leaptype, Tiles to Find, Tiles to Replace with this.TileObjects.add(newTileObject("Bush",0, {{2,3},{18,19}} , {{0x2A5,0x2A6},{0x2B5,0x2B6}} )); this.TileObjects.add(newTileObject("Swamp",1, {{ 420, 421},{436 ,437 }} , {{679, 680},{695 ,696 }} )); this.TileObjects.add(newTileObject("Vase",2, {{684,685},{700,701}} , {{1770,1771},{1786,1787}} )); this.TileObjects.add(newTileObject("Rock",2, {{34,35},{50,51}} , {{1834,1835},{1850,1851}} )); this.TileObjects.add(newTileObject("BlackRock",2, {{990,991},{1006,1007}},{{1834,1835},{1850,1851}} )); this.TileObjects.add(newTileObject("Sign",3, {{512,513},{528,529}} , {{1802,1803},{1818,1819}} )); this.TileObjects.add(newTileObject("Stake",-1, {{1652,1653},{1668,1669}}, {{1802,1803},{1818,1819}} )); this.TileObjects.add(newTileObject("Grass",-1, {{2047,2047},{2047,2047}} , {{1834,1835},{1850,1851}} )); this.InitTileObjects = true; } function newTileObject(label,leap,tiles,replace){ temp.to = new TStaticVar(); temp.to.label = label; temp.to.tiles = tiles; temp.to.replace = replace; temp.to.w = temp.to.tiles[0].size(); temp.to.h = temp.to.tiles.size(); temp.to.leap = leap; return temp.to; } // if label is set it will only replace those tiles in the array function testTiles(testx,testy,mode,leap,labelarray){//mode=true, replace tiles found, false, report name of tiles found if (!this.InitTileObjects)InitializeTiles(); if (labelarray == false){ temp.obj = this.TileObjects; }else{ for (temp.o: this.TileObjects){ if (temp.o.label in temp.labelarray){ temp.obj.add(temp.o); } } } temp.test = checkTiles(temp.testx,temp.testy,temp.obj); if (temp.test != false){ temp.matchx = temp.testx - temp.test[0]; temp.matchy = temp.testy - temp.test[1]; if (matchTiles(temp.matchx,temp.matchy,temp.test[2])){ if (mode){ replaceTiles(temp.matchx,temp.matchy,temp.test[2]); if (temp.leap){ for (temp.i = 0;temp.i < temp.test[2].w; temp.i +=2){ for (temp.j = 0;temp.j < temp.test[2].h; temp.j +=2){ putleaps(temp.test[2].leap,temp.matchx+temp.i,temp.matchy+temp.j); } } } return temp.test[2]; }else return temp.test[2]; } } return false; } function checkTiles(testx,testy,obj) { temp.tile = tiles[temp.testx,temp.testy]; for (temp.o: temp.obj){ for (temp.i = 0; temp.i < temp.o.w; temp.i++ ){ for (temp.j = 0; temp.j < temp.o.h; temp.j++ ){ if (temp.tile == temp.o.tiles[temp.j][temp.i]){ temp.match = {temp.i,temp.j,temp.o}; return temp.match; } } } } return false; } function matchTiles(tilex,tiley,obj){ for (temp.i = 0; temp.i < temp.obj.w; temp.i++){ for (temp.j = 0; temp.j < temp.obj.h; temp.j++){ if (tiles[temp.i+temp.tilex,temp.j+temp.tiley] != temp.obj.tiles[temp.j][temp.i]){ return false; } } } return true; } function replaceTiles(x,y,obj){ for (temp.i = 0; temp.i < temp.obj.w; temp.i++) { for (temp.j = 0; temp.j < temp.obj.h; temp.j++){ tiles[temp.i+x,temp.j+y] = temp.obj.replace[temp.j][temp.i]; updateboard(x,y,temp.obj.w,temp.obj.h); } } }
|
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)
For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
|
|
Last edited by adam; 04-10-2010 at 07:24 AM..
|