ON INIT {
 SETNAME [description_giant_slayer]
 SET_PRICE 2000
 SET_MATERIAL WEAPON
 SET_WEAPON_MATERIAL SWORD
 SET_STRIKE_SPEECH [player_strike_strong]
 SET_STEAL 100
//SET_THROW_DAMAGE 2
 SET_DURABILITY 70
 SET_GROUP "BLADE"
 SET_GROUP ARMORY
 SETOBJECTTYPE WEAPON
 SETOBJECTTYPE 2H
 SETEQUIP DAMAGES 14
 SETEQUIP aim_time 1000
 SET §poisonable 1
 SET §enchanted 1
 SETEQUIP critical_hit 12%
 SETEQUIP armor_class 6%
 SETEQUIP STEALTH -15
 SETEQUIP CASTING -15
 ACCEPT
}

ON EQUIPIN {
 PLAY "equip_sword"
 ACCEPT
}

ON INVENTORYUSE {
 IF (^FIGHTING == 1) ACCEPT
 IF (^PLAYER_ATTRIBUTE_STRENGTH < 18) {
  SPEAK -p [player_not_skilled_enough] NOP
  HEROSAY [required_st_18]
  //COLORISE SELF 1 0 0
  ACCEPT
 }
 IF (^PLAYER_SKILL_CLOSE_COMBAT < 80) {
  SPEAK -p [player_not_skilled_enough] NOP
  HEROSAY [required_cc_80]
  //COLORISE SELF 1 0 0
  ACCEPT
 }
 //COLORISE SELF 0 0 0
 EQUIP PLAYER
 ACCEPT
}

//#WEAPONS
ON COMBINE {
 IF (^$PARAM1 ISCLASS "POTION_GREEN") {
  IF (§poisonable == 0) {
   SPEAK -p [player_weapon_not_poisonable] NOP
   ACCEPT
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE < 30) {
   SPEAK -p [player_not_skilled_enough] NOP
   HEROSAY [required_obj_30]
   ACCEPT
  }
  SENDEVENT CUSTOM ^$PARAM1 "EMPTY"
  SET #TMP ~^PLAYER_SKILL_OBJECT_KNOWLEDGE~
  DEC #TMP 27 // donc tmp est entre 3 et 73
  DIV #TMP 3 // donc tmp est entre 1 et 24
  SET_POISONOUS ~#TMP~ ~#TMP~
  SPEAK -p [player_weapon_poisoned] NOP
  ACCEPT
 }
 IF (£reagent == "egg") { 
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (§enchanted == 1) { 
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "DRAGON_EGG" ) {
  IF (^ME ISCLASS "SABRE_METEOR") {
   SET £reagent "egg"
   HALO -ocs 1 1 0 30
   GOTO REGENTMIXED
  }
  IF (^ME ISCLASS "Sword_2handed_METEOR") {
   SET £reagent "egg"
   HALO -ocs 1 1 0 30
   GOTO REGENTMIXED
  }
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (^ME ISCLASS "SABRE_METEOR") {
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (^ME ISCLASS "Sword_2handed_METEOR") {
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "powder_bone" ) {
  SET £reagent "powder_bone"
  HALO -ocs 1 0.5 0 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "GARLIC" ) {
  SET £reagent "garlic"
  HALO -ocs 0.5 1 0 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "powder_water_lily" ) {
  SET £reagent "powder_water_lily"
  HALO -ocs 0.75 0.75 0 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "powder_morning_glory" ) {
  SET £reagent "powder_morning_glory"
  HALO -ocs 0 0.2 1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "dragon_bone_powder" ) {
  SET £reagent "dragon_bone_powder"
  HALO -ocs 0.5 0.6 1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "diamond" ) {
  SET £reagent "diamond"
  HALO -ocs 1 1 1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "emerald" ) {
  SET £reagent "emerald"
  HALO -ocs 0.1 0.5 0.1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "ruby" ) {
  SET £reagent "ruby"
  HALO -ocs 1 0.25 0 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "rock_amikar" ) {
  SET £reagent "rock_amikar"
  HALO -ocs 1 0.9 1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "powder_antidote" ) {
  SET £reagent "powder_antidote"
  HALO -ocs 0.67 0 0.5 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "gem" ) {
  SET £reagent "gem"
  HALO -ocs 0 0.5 1 30
  GOTO REGENTMIXED
  ACCEPT
 }
 IF (^$PARAM1 ISCLASS "golem_heart" ) {
  SET £reagent "golem_heart"
  HALO -ocs 0.5 0.5 0.5 30
  GOTO REGENTMIXED
  ACCEPT
 }
 ACCEPT
}

>>REGENTMIXED
 DESTROY ^$PARAM1
 //HALO -ocs 1 1 0 30
 SPEAK -p [Player_off_interesting] NOP
 ACCEPT


ON SPELLCAST {
 IF (^$PARAM1 != ENCHANT_WEAPON) ACCEPT
 IF (§enchanted == 1) { 
  SPEAK -p [player_no] NOP
  ACCEPT
 }
 IF (£reagent == "none") { 
  SPEAK -p [player_wrong] NOP
  ACCEPT
 }
 PLAY -o "Magic_Spell_Enchant_Weapon"
 IF (£reagent == "egg") {
  IF (^#PARAM2 < 8) {
   SPEAK -p [player_not_skilled_enough] NOP
   ACCEPT
  }
  SET §enchanted 1
  IF (#need_superweapon == 1) {
   QUEST [system_Quest_log_final_meeting]
   HEROSAY [system_questbook_updated]
   PLAY SYSTEM
  }
  IF (#superweapon < 2) {
   SET #weapon_enchanted 2
   SET #need_superweapon 2
   SET #superweapon 2
  }
  UNSET £reagent
  IF (^ME ISCLASS "SABRE_METEOR") REPLACEME "\\WEAPONS\\SABRE_METEOR_ENCHANT\\SABRE_METEOR_ENCHANT" ACCEPT
  IF (^ME ISCLASS "Sword_2handed_METEOR") REPLACEME "\\WEAPONS\\SWORD_2HANDED_METEOR_ENCHANT\\SWORD_2HANDED_METEOR_ENCHANT"
  ACCEPT
 }
 SET §enchanted 1
 IF (£reagent == "powder_bone") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP STRENGTH 1
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP STRENGTH 2
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP STRENGTH 3
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP STRENGTH 4
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP STRENGTH 5
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "GARLIC") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP DEXTERITY 1
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP DEXTERITY 2
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP DEXTERITY 3
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP DEXTERITY 4
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP DEXTERITY 5
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "powder_water_lily") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP CONSTITUTION 1
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP CONSTITUTION 2
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP CONSTITUTION 3
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP CONSTITUTION 4
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP CONSTITUTION 5
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "powder_morning_glory") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP INTELLIGENCE 1
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP INTELLIGENCE 2
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP INTELLIGENCE 3
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP INTELLIGENCE 4
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP INTELLIGENCE 5
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "dragon_bone_powder") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP STRENGTH 1
   SETEQUIP DEXTERITY 1
   SETEQUIP CONSTITUTION 1
   SETEQUIP INTELLIGENCE 1
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP STRENGTH 2
   SETEQUIP DEXTERITY 2
   SETEQUIP CONSTITUTION 2
   SETEQUIP INTELLIGENCE 2
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP STRENGTH 3
   SETEQUIP DEXTERITY 3
   SETEQUIP CONSTITUTION 3
   SETEQUIP INTELLIGENCE 3
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP STRENGTH 4
   SETEQUIP DEXTERITY 4
   SETEQUIP CONSTITUTION 4
   SETEQUIP INTELLIGENCE 4
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP STRENGTH 5
   SETEQUIP DEXTERITY 5
   SETEQUIP CONSTITUTION 5
   SETEQUIP INTELLIGENCE 5
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "diamond") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP ETHERAL_LINK +5%
   SETEQUIP OBJECT_KNOWLEDGE +5%
   SETEQUIP CASTING +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP ETHERAL_LINK +10%
   SETEQUIP OBJECT_KNOWLEDGE +10%
   SETEQUIP CASTING +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP ETHERAL_LINK +15%
   SETEQUIP OBJECT_KNOWLEDGE +15%
   SETEQUIP CASTING +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP ETHERAL_LINK +20%
   SETEQUIP OBJECT_KNOWLEDGE +20%
   SETEQUIP CASTING +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP ETHERAL_LINK +25%
   SETEQUIP OBJECT_KNOWLEDGE +25%
   SETEQUIP CASTING +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "emerald") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP STEALTH +5%
   SETEQUIP MECANISM +5%
   SETEQUIP INTUITION +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP STEALTH +10%
   SETEQUIP MECANISM +10%
   SETEQUIP INTUITION +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP STEALTH +15%
   SETEQUIP MECANISM +15%
   SETEQUIP INTUITION +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP STEALTH +20%
   SETEQUIP MECANISM +20%
   SETEQUIP INTUITION +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP STEALTH +25%
   SETEQUIP MECANISM +25%
   SETEQUIP INTUITION +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
 IF (£reagent == "ruby") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP CLOSE_COMBAT +5%
   SETEQUIP PROJECTILE +5%
   SETEQUIP DEFENSE +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP CLOSE_COMBAT +10%
   SETEQUIP PROJECTILE +10%
   SETEQUIP DEFENSE +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP CLOSE_COMBAT +15%
   SETEQUIP PROJECTILE +15%
   SETEQUIP DEFENSE +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP CLOSE_COMBAT +20%
   SETEQUIP PROJECTILE +20%
   SETEQUIP DEFENSE +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP CLOSE_COMBAT +25%
   SETEQUIP PROJECTILE +25%
   SETEQUIP DEFENSE +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 1.5
  GOTO ENCHANTED
 }
  IF (£reagent == "rock_amikar") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP ARMOR_CLASS +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP ARMOR_CLASS +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP ARMOR_CLASS +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP ARMOR_CLASS +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP ARMOR_CLASS +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 2
  GOTO ENCHANTED
 }
  IF (£reagent == "powder_antidote") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP RESIST_POISON +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP RESIST_POISON +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP RESIST_POISON +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP RESIST_POISON +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP RESIST_POISON +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 2
  GOTO ENCHANTED
 }
  IF (£reagent == "gem") {
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 20) {
   SETEQUIP RESIST_MAGIC +5%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 40) {
   SETEQUIP RESIST_MAGIC +10%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 60) {
   SETEQUIP RESIST_MAGIC +15%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 80) {
   SETEQUIP RESIST_MAGIC +20%
  }
  IF (^PLAYER_SKILL_OBJECT_KNOWLEDGE > 100) {
   SETEQUIP RESIST_MAGIC +25%
  }
  SET §tmp ~^PRICE~
  MUL §tmp 2
  GOTO ENCHANTED
 }
 IF (£reagent == "golem_heart") {
  IF (^PLAYER_SKILL_CASTING < 50) {
   SETEQUIP -s PARALYSE 500
  }
  IF (^PLAYER_SKILL_CASTING > 80) {
   SETEQUIP -s PARALYSE 3000
   SET §tmp ~^PRICE~
   MUL §tmp 3
   GOTO ENCHANTED
   ACCEPT
  }
  IF (^PLAYER_SKILL_CASTING > 50) {
   SETEQUIP -s PARALYSE 1000
  }
  SET §tmp ~^PRICE~
  MUL §tmp 3
  GOTO ENCHANTED
 }
 ACCEPT
}


>>ENCHANTED
  SET_PRICE §tmp
  UNSET §tmp
  UNSET £reagent
 // HALO -ocs 0 1 0 30
  ACCEPT

ON REPAIRED {
 IF (^$PARAM1 == "checkdur") {
  IF (^DURABILITY == ^MAXDURABILITY) {
   SPEAK -p [player_weapon_already_repaired] NOP
   ACCEPT
  }
  SENDEVENT REPAIR ^SENDER ""
  ACCEPT
 }
 SET §tmp ~^MAXDURABILITY~
 REPAIR SELF ~^PLAYER_SKILL_OBJECT_KNOWLEDGE~
 if (^DURABILITY < §tmp) {
  SPEAK -p [player_weapon_repaired_partially] NOP
  ACCEPT
 }
 SPEAK -p [player_weapon_repaired_in_full] NOP
 UNSET §tmp
 ACCEPT
}

ON BREAK {
PLAY "broken_weapon"
 INVENTORY PLAYERADD "\\Provisions\\scrap_metal_big\\scrap_metal_big"
DESTROY SELF
ACCEPT
}

//#
ON DURABILITY {
 SET_DURABILITY -c ~^$PARAM1~
 ACCEPT
}