-- main.lua run when dink is started
local load_sound = dink.load_sound

function main()
  --[[
    let's init all our globals
    These globals are REQUIRED by dink.exe (it directly uses them, removing
    any of these could result in a game crash.
  ]]

  global.create("exp", 0)
  global.create("strength", 3)
  global.create("defense", 0)
  global.create("cur_weapon", 0)
  global.create("cur_magic", 0)
  global.create("gold", 0)
  global.create("magic", 0)
  global.create("magic_level", 0)
  global.create("vision", 0)
  global.create("result", 0)
  global.create("speed", 1)
  global.create("timing", 0)
  global.create("lifemax", 50)
  global.create("life", 10)
  global.create("level", 1)
  global.create("player_map", 1)
  global.create("last_text", 0)
  global.create("update_status", 0)
  global.create("missile_target", 0)
  global.create("enemy_sprite", 0)
  global.create("magic_cost", 0)
  global.create("missle_source", 0)

  -- These globals are stuff we added, which will all be saved with the player
  -- file

  global.create("story", 0)
  global.create("old_womans_duck", 0)
  global.create("nuttree", 0)
  global.create("letter", 0)
  global.create("little_girl", 0)
  global.create("farmer_quest", 0)
  global.create("save_x", 0)
  global.create("save_y", 0)
  global.create("safe", 0)
  global.create("pig_story", 0)
  global.create("wizard_see", 0)
  global.create("mlibby", 0)
  global.create("wizard_again", 0)
  global.create("snowc", 0)
  global.create("duckgame", 0)

  -- Autoincludes are scripts that are included in every other Lua script
  autoinclude("cutscene", "_cutscene")

  -- crap needed for misc
  player:set_speed(3)
  player.frame_delay = 0 -- This command is ignored (as it also is in DinkC) because
                         -- sprite 1 isn't active yet when the main script is run.
                         -- Leaving it in just for completeness.

  -- Let's preload that sprite that's been bugging the hell out of Pap
  dink.preload_seq(373)

  -- if run with -debug option this will be written to debug.txt.
  dink.debug("Dink started. Time to fight for your right to party.")
  -- playmidi("story.mid")

  load_sound("QUACK.WAV",1)
  load_sound("PIG1.WAV",2)
  load_sound("PIG2.WAV",3)
  load_sound("PIG3.WAV",4)
  load_sound("PIG4.WAV",5)
  load_sound("BURN.WAV",6)
  load_sound("OPEN.WAV",7)
  load_sound("SWING.WAV",8)
  load_sound("PUNCH.WAV",9)
  load_sound("SWORD2.WAV",10)
  load_sound("SELECT.WAV",11)
  load_sound("WSCREAM.WAV",12)
  load_sound("PICKER.WAV",13)
  load_sound("GOLD.WAV",14)
  load_sound("GRUNT1.WAV",15)
  load_sound("GRUNT2.WAV",16)
  load_sound("SEL1.WAV",17)
  load_sound("ESCAPE.WAV",18)
  load_sound("NONO.WAV",19)
  load_sound("SEL2.WAV",20)
  load_sound("SEL3.WAV",21)
  load_sound("HIGH2.WAV",22)
  load_sound("FIRE.WAV",23)
  load_sound("SPELL1.WAV",24)
  load_sound("SNARL1.WAV",26)
  load_sound("SNARL2.WAV",27)
  load_sound("SNARL3.WAV",28)
  load_sound("HURT1.WAV",29)
  load_sound("HURT2.WAV",30)
  load_sound("ATTACK1.WAV",31)
  load_sound("CAVEENT.WAV",32)
  load_sound("LEVEL.WAV",33)
  load_sound("SAVE.WAV",34)
  load_sound("SPLASH.WAV",35)
  load_sound("SWORD1.WAV",36)
  load_sound("BHIT.WAV",37)
  load_sound("SQUISH.WAV",38)
  load_sound("STAIRS.WAV",39)
  load_sound("STEPS.WAV",40)
  load_sound("ARROW.WAV",41)
  load_sound("FLYBY.WAV",42)
  load_sound("SECRET.WAV",43)
  load_sound("BOW1.WAV",44)
  load_sound("KNOCK.WAV",45)
  load_sound("DRAG1.WAV",46)
  load_sound("DRAG2.WAV",47)
  load_sound("AXE.WAV",48)
  load_sound("BIRD1.WAV",49)

  load_sound("mystery.wav", 53)
  load_sound("monk.wav", 54)
  load_sound("ezdrummer.ogg", 55)
  load_sound("wololo.wav", 56)
  -- Seth's favourite sample CD
  load_sound("scoringtools.mp3", 57)
  load_sound("fountain.ogg", 58)


  dink.kill_this_task()
end
