View Single Post
  #33  
Old 11-12-2014, 02:30 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Okay still scratching my head over this. Can someone please help me figure out a more logical way to actually dig a hole because my hole, keeps digging OVER the npc I dig up when it's a block and its getting frustrating.

PHP Code:
function onCreated() {  
  
// Tiles that we can dig up, I am using INT not HEX
  
this.checkTiles = {
    
0, 1, 680, 695, 696, 2047, 679, 907, 48,
    
49, 1647, 1734, 2103, 16, 2102, 1767, 1782,
    
1783, 1405, 3049, 1386, 1387, 3048, 1735,
    
1751, 1750
  
};
}
function 
onActionServerside() {
  
// We want to dig :)
  
if ( params[0] == "dig" ) {
    if ( 
DigUp() == false ) {
      
DigRandomItem();
     }
    
  }
}

function 
DigRandomItem() {
  
temp.random = int(random(0,100));
  
  if ( 
temp.random in |0,75| ) {
    return 
"worm";
  }
  
  if ( 
temp.random in |76,100| ) {
    return 
"gralat";
  }
  
  return 
false;
}

function 
DigUp() {

  
// Variables
  
this.digx = player.x + 1.0 + vecx(player.dir) * 2;
  
this.digy = player.y + 1.0 + vecy(player.dir) * 2;
  
  
// Check putnpc2's
  
for(temp.n : findareanpcs(this.digx, this.digy, 2, 2)){
    
triggerclient("gui", this.name, "play", "crush.wav");
    return 
true; // cannot dig
  
}
  
  
// Check Tiles
  
for ( this.iy = 0; this.iy < 2; this.iy ++ ) {
    for ( 
this.ix = 0; this.ix < 2; this.ix ++ ) {
      
this.checkX = this.digx + this.ix;
      
this.checkY = this.digy + this.iy;
      if ( !(
tiles[this.checkX,this.checkY] in this.checkTiles) ) {
        
triggerclient("gui", this.name, "play", "crush.wav");
        return 
true; // cannot dig
      
}
    }
  }

  
temp.hole = putnpc2(this.digx, this.digy, "");
  
temp.hole.join("shovel-hole");
  
temp.hole.drawunderplayer();
    
  
temp.item = DigRandomItem();
    
  if ( 
temp.item == "gralat" ) {
    
temp.object = putnpc2(this.digx, this.digy, "");
    
temp.object.join("gralats");
    
temp.object.rupees = 1;
  } else {
    
    if ( 
temp.item == "worm" ) {
      
temp.object = putnpc2(this.digx, this.digy, "");
      
temp.object.join("shovel-item");
      
temp.object.image = "block.png";
    }
  }
  
triggerclient("gui", this.name, "play", "lift.wav");
}

//#CLIENTSIDE
function onWeaponFired() {
  
// Show player digging
  
freezeplayer(0.8);
  
setani("partasti_shovel", "partasti_shovel.png"); 
  
triggerserver("gui", this.name, "dig");
}

function 
onActionClientside() {
  if ( 
params[0] == "play" ) {
    
play(params[1]);
  }
} 
And the hole,

PHP Code:
// Join to all the hole's dug up by a shovel

function onCreated() {
  
setimg("partasti_dirthole.png");
  
dontblock();
  
drawunderplayer();
  
sleep(5);
  
destroy();
} 
Reply With Quote