:viktor_shop
  if switch viktorIsUpgradingTool
    if variable viktorDaysToComplete <= 0
      history register event variable viktorToolUpgradeEvent
      include variable viktorToolUpgradeEvent
      return
    end

    Viktor "I'm still working on your stuff, so I can't do any other work right now."
    return
  end

  Viktor ("Do you need something?", "Shop", "Just Chat", "Nevermind", "Nevermind")
  if response == "Shop"
    wait 10
    snap
    openBlacksmith
    return
  end

  if response == "Just Chat"
    force chat Viktor
    return
  end    

:viktor_finish_tool_upgrade
  # Before calling this event, set the toolId on Variables.upgradedToolId
  wait 10
  displayItemId variable upgradedToolId
  play sound PickItem

  js window.backupDirection = $gamePlayer._direction;
  + $gamePlayer.setDirection(Direction.DOWN);

  addTool variable upgradedToolId
  wait 60
  displayItemId undefined
  play sound PickItem
  
  js $gamePlayer.setDirection(window.backupDirection);
  + delete window.backupDirection;
  wait 5
  switch viktorIsUpgradingTool OFF
  refresh hud

:hoe_upgrade_complete
  Viktor "Hey <name>, your hoe upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade
  Viktor "It is much lighter now. You can till the ground faster and spend less stamina doing so."

:hoe_copper_upgrade_complete
  variable upgradedToolId copper-hoe
  include hoe_upgrade_complete

:hoe_silver_upgrade_complete
  variable upgradedToolId silver-hoe
  include hoe_upgrade_complete

:hoe_gold_upgrade_complete
  variable upgradedToolId golden-hoe
  include hoe_upgrade_complete

:trigger_tool_copper_upgrade
  Viktor "Alright. Your tool upgrade should be ready tomorrow, don't forget to come pick it up."
  switch viktorIsUpgradingTool ON
  variable viktorDaysToComplete 1
  tool unequip
  setUpgradedToolEvent copper

:trigger_tool_silver_upgrade
  Viktor "Alright. Your tool upgrade should be ready in two days, don't forget to come pick it up."
  switch viktorIsUpgradingTool ON
  variable viktorDaysToComplete 2
  tool unequip
  setUpgradedToolEvent silver

:trigger_tool_gold_upgrade
  Viktor "Alright. Your tool upgrade should be ready in three days, don't forget to come pick it up."
  switch viktorIsUpgradingTool ON
  variable viktorDaysToComplete 3
  tool unequip
  setUpgradedToolEvent gold

:trigger_tool_diamond_upgrade
  Viktor "Alright. Your tool upgrade should be ready in four days, don't forget to come pick it up."
  switch viktorIsUpgradingTool ON
  variable viktorDaysToComplete 4
  tool unequip
  setUpgradedToolEvent diamond

:tool_upgrade_not_enough_exp
  Viktor "I'm sorry <name>, but this tool upgrade is reserved to experienced farmers."

:tool_upgrade_not_enough_exp_fish
  Viktor "I'm sorry <name>, but this tool upgrade is reserved to experienced fishermen."

:trigger_hoe_copper_upgrade
  if exp hoe < 250
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hoe
  include trigger_tool_copper_upgrade

:trigger_hoe_silver_upgrade
  if exp hoe < 750
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hoe
  include trigger_tool_silver_upgrade

:trigger_hoe_gold_upgrade
  if exp hoe < 1500
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hoe
  include trigger_tool_gold_upgrade

:hammer_upgrade_complete
  Viktor "Hey <name>, your hammer upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade
  Viktor "You can now break stones faster and you also have a better chance of not destroying the ores when breaking a node."

:hammer_copper_upgrade_complete
  variable upgradedToolId copper-hammer
  include hammer_upgrade_complete

:hammer_silver_upgrade_complete
  variable upgradedToolId silver-hammer
  include hammer_upgrade_complete

:hammer_gold_upgrade_complete
  variable upgradedToolId golden-hammer
  include hammer_upgrade_complete

:trigger_hammer_copper_upgrade
  if exp mining < 250
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hammer
  include trigger_tool_copper_upgrade

:trigger_hammer_silver_upgrade
  if exp mining < 750
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hammer
  include trigger_tool_silver_upgrade

:trigger_hammer_gold_upgrade
  if exp mining < 1500
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded hammer
  include trigger_tool_gold_upgrade

:sickle_upgrade_complete
  Viktor "Hey <name>, your sickle upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade
  Viktor "It is much lighter and able to cut a wider area now."

:sickle_copper_upgrade_complete
  variable upgradedToolId copper-sickle
  include sickle_upgrade_complete

:sickle_silver_upgrade_complete
  variable upgradedToolId silver-sickle
  include sickle_upgrade_complete

:sickle_gold_upgrade_complete
  variable upgradedToolId golden-sickle
  include sickle_upgrade_complete

:trigger_sickle_copper_upgrade
  if exp sickle < 250
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded sickle
  include trigger_tool_copper_upgrade

:trigger_sickle_silver_upgrade
  if exp sickle < 750
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded sickle
  include trigger_tool_silver_upgrade

:trigger_sickle_gold_upgrade
  if exp sickle < 1500
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded sickle
  include trigger_tool_gold_upgrade

:axe_upgrade_complete
  Viktor "Hey <name>, your axe upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade

:axe_copper_upgrade_complete
  variable upgradedToolId copper-axe
  include axe_upgrade_complete
  Viktor "You can now cut tree stumps, as well as cutting logs faster."

:axe_silver_upgrade_complete
  variable upgradedToolId silver-axe
  include axe_upgrade_complete
  Viktor "You can now cut trees, as well as cutting logs and stumps faster."

:axe_gold_upgrade_complete
  variable upgradedToolId golden-axe
  include axe_upgrade_complete
  Viktor "You can now cut trees, logs and stumps much faster than before."

:trigger_axe_copper_upgrade
  if exp woodcutting < 250
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded axe
  include trigger_tool_copper_upgrade

:trigger_axe_silver_upgrade
  if exp woodcutting < 750
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded axe
  include trigger_tool_silver_upgrade

:trigger_axe_gold_upgrade
  if exp woodcutting < 1500
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded axe
  include trigger_tool_gold_upgrade

:trigger_wateringcan_silver_upgrade
  if exp water < 1000
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded watering-can
  include trigger_tool_silver_upgrade
  variable viktorToolUpgradeEvent wateringcan_silver_upgrade_complete

:trigger_wateringcan_red_upgrade
  if exp water < 2000
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded watering-can
  include trigger_tool_gold_upgrade
  variable viktorToolUpgradeEvent wateringcan_ruby_upgrade_complete

:trigger_wateringcan_green_upgrade
  if exp water < 3000
    include tool_upgrade_not_enough_exp
    return
  end

  variable viktorToolBeingUpgraded watering-can
  include trigger_tool_diamond_upgrade
  variable viktorToolUpgradeEvent wateringcan_green_upgrade_complete

:wateringcan_upgrade_complete
  Viktor "Hey <name>, your watering can upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade

:watering-can_silver_upgrade_complete
  include wateringcan_silver_upgrade_complete

:wateringcan_silver_upgrade_complete
  variable upgradedToolId silver-watering-can
  include wateringcan_upgrade_complete

:wateringcan_ruby_upgrade_complete
  variable upgradedToolId red-watering-can
  include wateringcan_upgrade_complete

:wateringcan_green_upgrade_complete
  variable upgradedToolId green-watering-can
  include wateringcan_upgrade_complete

:trigger_fishingrod_green_upgrade
  variable viktorToolBeingUpgraded fishing-rod
  include trigger_tool_silver_upgrade
  variable viktorToolUpgradeEvent fishingrod_green_upgrade_complete

:fishingrod_green_upgrade_complete
  variable upgradedToolId green-fishing-rod
  include fishingrod_upgrade_complete
  Viktor "With this, fish will swim towards the bait when they are close to it."

:fishingrod_upgrade_complete
  Viktor "Hey <name>, your fishing rod upgrade is complete! Check it out."
  include viktor_finish_tool_upgrade

:trigger_fishingrod_blue_upgrade
  if exp fishing < 1000
    include tool_upgrade_not_enough_exp_fish
    return
  end

  variable viktorToolBeingUpgraded fishing-rod
  include trigger_tool_gold_upgrade
  variable viktorToolUpgradeEvent fishingrod_blue_upgrade_complete

:fishingrod_blue_upgrade_complete
  if exp fishing < 2000
    include tool_upgrade_not_enough_exp_fish
    return
  end

  variable upgradedToolId blue-fishing-rod
  include fishingrod_upgrade_complete
  Viktor "With this, fish will swim towards the bait from a longer distance."
