// NPC made by aylad
if(created){
  setimg diceicon.gif;
}
if(playerenters){
  timeout=.05;
}
if(timeout){
  if(strequals(#w,Dice (6))){
    setstring W,diceicon.gif;
  }
  timeout=.05;
}
if (playertouchsme) {
  toweapons Dice (6);
  hidelocal;
  dontblocklocal;
}
if(weaponfired){
  dice=6;
  this.roll=1;
  freezeplayer 1;
  playersprite=33;
  roll1=int(random(1,7));
  roll2=int(random(1,7));
  if(playerdir=0){
    this.showx=playerx+1;
    this.showy=playery-2;
    this.showz=0;
  }
  if(playerdir=3){
    this.showx=playerx+3;
    this.showy=playery+1;
    this.showz=2;
  }
  if(playerdir=1){
    this.showx=playerx-2;
    this.showy=playery+1;
    this.showz=2;
  }
  if(playerdir=2){
    this.showx=playerx;
    this.showy=playery+3;
    this.showz=2;
  }
  this.shows=0;
  showimg 0,dice.gif,this.showx,this.showy;
  changeimgvis 0,this.showz;
  timeout=.05;
}
if(timeout){
  if(this.roll=1){
    changeimgpart 0,this.shows*32,32,32,32;
    this.shows++;
    if(this.shows>6){
      this.roll=2;
    }
    if(this.shows=3){
      play crush.wav;
    }
  }
  if(this.roll=2){
    this.roll=0;
    showimg 1,dice.gif,playerx-1,playery-2;
    showimg 2,dice.gif,playerx+1,playery-2;
    changeimgpart 1,roll1*32,0,32,32;
    changeimgpart 2,roll2*32,0,32,32;
    sleep 2;
    hideimg 0;
    hideimg 1;
    hideimg 2;
    dice=0;
  }
  timeout=.05;
}
if(playerenters){
  hideimg 0;
  hideimg 1;
  hideimg 2;
  dice=0;
}