ON INIT {
 SETNAME [description_anvil]
 SET_MATERIAL METAL
 SET_SHADOW OFF
 SET §inuse 0		// Used to check if weapon is already in repair
 SET £weapon "NONE"
 SET §speaking 0		// Used to check if player is speaking
 SET §norepeat 0		// Used to check speach frequency
 ACCEPT
}

>>MAIN_repairing
  IF (^DIST_PLAYER < 300) {
    ACCEPT
  }
 TIMERmainrep OFF
 SET §inuse 0
 TIMERrepair OFF
 TIMERklong OFF
 ACCEPT

ON COMBINE {
  IF (§inuse == 1) ACCEPT
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE < 10) {
    SPEAK -p [player_not_skilled_enough] NOP
    HEROSAY [required_obj_10]
    ACCEPT
  }
 IF (^$PARAM1 ISCLASS "scrap_metal_big" ) {
  TIMERoff OFF
  TIMERhit -m 3 500 PLAY -o "ANVIL_HIT"
  TIMERadd 1 2 INVENTORY PLAYERADD \\QUEST_ITEM\\metal_chunk\\metal_chunk
  DESTROY ^$PARAM1
  ACCEPT
 }
  SET £weapon ^$PARAM1
  IF (£weapon ISGROUP ARMORY) {
    SENDEVENT REPAIRED £weapon "checkdur"
   }
  ELSE {
    SPEAK -p [player_off_impossible] NOP
  }
 ACCEPT
}

ON REPAIR {
 SET §inuse 1
 TIMERmainrep 0 1 GOTO MAIN_repairing
 TIMERklong 3 1 PLAY "Anvil_hit"
 TIMERrepair 1 4 GOTO REPAIR
 ACCEPT
}

ON ACTION {
 IF (§speaking == 1) ACCEPT
 IF (§norepeat > 5) SET §norepeat 0
 INC §norepeat 1
 IF (§norepeat > 1) ACCEPT
 SET §speaking 1
 SPEAK -p [Player_anvil_use] SET §speaking 0
 ACCEPT
}

>>REPAIR
 SENDEVENT REPAIRED £weapon ""
 TIMERmainrep OFF
 SET §inuse 0
 ACCEPT 