View Single Post
  #4  
Old 03-09-2010, 08:56 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
Minor oversight with leaps fixed:
PHP Code:
function CheckTiles(cdir,pwrdata,doleap,offsetx,offsety) {
  
// A LAYOUT OF DAMAGE TYPES, USED TO FIND THE CORRECT DAMAGE IN THE ARRAY
  
temp.powerlayout = {"sword","glove","hammer"};

  
// THEN FIND THE INDEX OF THE TYPE. IF NO TYPE FOUND, RESORT TO SWORD POWER
  
temp.dmgtype powerlayout.index(pwrdata[0]) == -powerlayout.index(pwrdata[0]);
  
temp.pwr pwrdata[1] == null pwrdata pwrdata[1];

  
temp.objectdata = {
    
//name,tilecheck,tilereplace,leaptype,powers{sword,glove,hammer},canhide(true/false)
    
{"swamp"     ,{0x1A4,0x1A5,0x1B4,0x1B5},{0x2A7,0x2A8,0x2B7,0x2B8}, 1,{1,0,0},0},
    {
"bush"      ,{0x2  ,0x3  ,0x12 ,0x13 },{0x2A5,0x2A6,0x2B5,0x2B6}, 0,{1,1,1},1},
    {
"stake"     ,{0x14A,0x14B,0x15A,0x15B},{0x70A,0x70B,0x71A,0x71B},-1,{0,0,1},0},
    {
"sign"      ,{0x200,0x201,0x210,0x211},{0x70A,0x70B,0x71A,0x71B}, 3,{2,1,1},0},
    {
"rock"      ,{0x22 ,0x23 ,0x32 ,0x33 },{0x72A,0x72B,0x73A,0x73B}, 2,{2,2,2},1},
    {
"blackrock" ,{0x3DE,0x3DF,0x3EE,0x3EF},{0x72A,0x72B,0x73A,0x73B}, 2,{3,3,3},1},
    {
"vase"      ,{0x2AC,0x2AD,0x2BC,0x2BD},{0x6EA,0x6EB,0x6FA,0x6FB}, 2,{2,1,1},0},
    {
"desertbush",{0x35E,0x35F,0x36E,0x36F},{0x388,0x389,0x389,0x388}, 0,{1,1,1},1},
    {
"lavaswamp" ,{0xBE8,0xBE9,0xBF8,0xBF9},{0xC92,0xC93,0xCA2,0xCA3}, 1,{1,0,0},0},
    {
"lavabush"  ,{0xA02,0xA03,0xA12,0xA13},{0xC90,0xC91,0xCA0,0xCA1}, 0,{2,3,1},1},
    {
"lavasign"  ,{0xC52,0xC53,0xC62,0xC63},{0xC50,0xC51,0xC60,0xC61}, 3,{1,1,1},0},
    {
"lavastone" ,{0xA22,0xA23,0xA32,0xA33},{0xC70,0xC71,0xC80,0xC81}, 2,{3,3,2},1},
    {
"lavavase"  ,{0xC65,0xC66,0xC75,0xC76},{0xC72,0xC73,0xC82,0xC83}, 2,{3,1,1},1},
    {
"snowswamp" ,{0x838,0x839,0x848,0x849},{0x2A7,0x2A8,0x2B7,0x2B8}, 1,{1,1,0},0},
    {
"snowbush"  ,{0x7AC,0x7AD,0x7BC,0x7BD},{0xF02,0xF03,0xF12,0xF13}, 0,{1,0,1},1},
    {
"snowsign"  ,{0x7EB,0x7EC,0x7FB,0x7FC},{0xFE5,0xFE6,0xFF5,0xFF6}, 3,{2,3,1},0},
  };

  
// FIND THE CHECKX AND CHECKY 
  
temp.px int(player.+ (cdir==? -1.5 : (cdir==3.5 1.5))) - offsetx;
  
temp.py int(player.+ (cdir==0    : (cdir==4   2))) - offsety;

  
temp.hitobj = -1// INITIATE NO FOUND OBJECT AS -1
  
for (temp.i=0;i<objectdata.size();i++) {
    
// CHECK IF THE TILE IS IN THE ARRAY
    
if (tiles[px,pyin objectdata[i][1]) {
      
temp.objectdata[i][1].index(tiles[px,py]); // FIND POSITION OF TILE IN ARRAY
      
px px-(j%2);                                 // APPLY X OFFSET
      
py py-int(j/2);                              // APPLY Y OFFSET
      
hitobj i;                                    // ASSIGN FOUND OBJECT
      
break;                                         // STOP CHECKING
    
}
  }

  
// CREATE A BLOCK ARRAY OF THE TILES FOR COMPARISON
  
temp.checktiles = {tiles[px,py],tiles[px+1,py],tiles[px,py+1],tiles[px+1,py+1]};
  
// IF WHOLE BLOCK DOES NOT MATCH THE OBJECT, RETURN NULL (aka not a whole bush)
  
if (@checktiles != @objectdata[hitobj][1]) return;
  
// IF NO OBJECT IS FOUND OR BUG OCCURS, RETURN NULL
  
if (hitobj || hitobj >= objectdata.size()) return;
  
// IF PLAYER DOESN'T HAVE ENOUGH POWER TO DESTROY, RETURN NULL
  // OR IF POWER == 0, RETURN NULL SINCE IT CAN'T BE DESTROYED
  
if (pwr objectdata[hitobj][4][dmgtype] || objectdata[hitobj][4][dmgtype] == 0) return;

  
// REPLACE TILES
  
for (temp.i=0;i<4;i++) {
    
tiles[px+(i%2),py+int(i/2)] = objectdata[hitobj][2][i];
  }
  
updateboard(px,py,2,2); // UPDATE BOARD

  // IF LEAPS ARE SET TO TRUE, PUT A LEAP.
  
if (doleap == true && objectdata[hitobj][3] >= 0putleaps(objectdata[hitobj][3],px,py);

  
// RETURN THE DATA OF OBJECT FOR FURTHER USAGE
  
return objectdata[hitobj];

Reply With Quote