// Tafiok's chest at home

ON INIT {
 INVENTORY ADD "QUEST_ITEM\\GEM_DEALER_BADGE\\GEM_DEALER_BADGE"
 INVENTORY ADDMULTI "QUEST_ITEM\\ACTIONS_MINES\\ACTIONS_MINES" 4
 INVENTORY ADDMULTI "Jewelry\\Gold_coin\\Gold_coin" 1200
 INVENTORY ADD "JEWELRY\\DIAMOND\\DIAMOND"
 set §genInv 0
 SET £type "chest_2"
 SET §lockpickability 40
 SET §trap_lockpickability 20
 SETTRAP 15
 SET §fired 0
 ACCEPT
}

ON LOAD {
 USE_MESH "CHEST_2\CHEST_2.TEO"
 ACCEPT
}

ON INVENTORY2_OPEN {
  IF (§unlock == 0) ACCEPT
  IF (§fired == 0) {
    IF (^DIST_PLAYER < 400) DO_DAMAGE PLAYER 10
    SET §fired 1
    SETTRAP -1
  }
>>RANDOM_ITEM
 IF ( §genInv == 1 ) ACCEPT
  IF (#RANDOMIZER < 4) INVENTORY ADD "JEWELRY\\EMERALD\\EMERALD"
  IF (#RANDOMIZER == 4) INVENTORY ADD "JEWELRY\\DIAMOND\\DIAMOND"
  IF (#RANDOMIZER == 5) INVENTORY ADD "JEWELRY\\RUBY\\RUBY"
  IF (#RANDOMIZER == 6) INVENTORY ADD "JEWELRY\\AMETHYST\\AMETHYST"
  IF (#RANDOMIZER > 6) INVENTORY ADD "JEWELRY\\SAPPHIRE\\SAPPHIRE"
 set §genInv 1
 ACCEPT
}

ON TRAP_DISARMED {
 SET §fired 1
 ACCEPT
}