(
    (set #wormsdone
	(askbool
	    (prompt "Have you installed Worms itself yet?")
	    (help "It's a simple question. You weren't planning on lying to me, were you?")
	)
    )

    (if #wormsdone
	(set #dest
	    (askdir
		(prompt "Select the drawer Worms was installed in")
		(help @askdir-help)
		(default "SYS:Worms")
	    )
	)
	(
	    (set @app-name "Worms")
	    (set #dest
		(askdir
		    (prompt "Select the drawer to install Worms and WormsShell in. "
			"A new drawer will be created there for them.")
		    (help @askdir-help)
		    (default @default-dest)
		)
	    )
	)
    )

    (if #wormsdone

	;See if Worms is in selected dir or in WORMS subdir

	(if (not (exists (tackon #dest "HDWORM")))
	    (
		(set #dest (tackon #dest "WORMS"))
		(if (not (exists (tackon #dest "HDWORM")))
		    (abort "Worms is not installed in the selected drawer.")
		)
	    )
	)

	;Otherwise create the Worms subdir

	(
	    (set #dest (tackon #dest "Worms"))
	    (makedir #dest (infos))
	)
    )

    (set @default-dest #dest)

    (if #wormsdone
	(
	    (set #delicon 1)
	    (if (= @user-level 2)
		(set #delicon
		    (askbool
			(prompt "Would you like to delete the old icon for HDWORM?")
			(help "Since WormsShell creates a new icon labelled Worms "
			    "which you can use to start Worms through WormsShell, "
			    "you shouldn't need the old icon any more.")
		    )
		)
	    )
	    (set #cleanup 1)
	    (if (= @user-level 2)
		(set #cleanup
		    (askbool
			(prompt "Would you like to remove the unnecessary "
			    "files which the Worms installer copied to your hard drive?")
			(help "This procedure will delete the files which Worms installs "
			    "to your hard drive but are only required when running from "
			    "floppy disks:"
			    "· devs/system-configuration\n"
			    "· Disk.info\n"
			    "· INSTALL(.info)\n"
			    "· libs/#?.library\n"
			    "· OCEAN\n"
			    "· Run\n"
			    "· s/startup-sequence\n"
			    "· TEAM17")
		    )
		)
	    )
	)
	(
	    (if (= @language "english")
		(set #langs 1)
		(if (= @language "français")
		    (set #langs 2)
		    (if (= @language "deutsch")
			(set #langs 4)
			(set #langs 0)
		    )
		)
	    )
	    (set #langs
		(askoptions
		    (prompt "Which languages would you like to install?")
		    (help "Speech samples for the chosen languages will be "
			"installed for you. You must choose at least one "
			"language. Each time you run Worms, you will be "
			"asked which language to use.")
		    (choices "[2pEnglish" "Français" "Deutsch")
		    (default #langs)
		)
	    )
	    (if (= #langs 0)
		(abort "You failed to select any languages.")
	    )
	)
    )

    (set #guide
	(askbool
	    (prompt "Do you want to install the WormsShell guide file?")
	    (help "This is the file you should have read before starting "
		"this installation. Even if you have already read it, "
		"you may want to have it to hand in case you want to "
		"make changes to your Worms and WormsShell installations.")
	)
    )

    ;Ask whether to set the two switches

    (set #sheep
	(askbool
	    (prompt "Do you want Worms to start with Sheep Mode on?")
	    (help "Sheep Mode gives you lots of extra explosive weapons in every round.")
	)
    )

    (set #cprot
	(askbool
	    (prompt "Do you want to leave the copy-protection enabled?")
	    (help "I suppose you might want to do this if you can hide the code booklet "
		"from Worms-addicted friends/relatives who don't know about WormsShell.")
	)
    )

    ;Install WormsShell itself

    (working "Installing WormsShell")

    (copyfiles (source "Worms") (dest #dest) (help "") (prompt ""))
    (copyfiles (source "WormsShell") (dest #dest) (infos) (noposition) (help "") (prompt ""))

    (if #guide
	(copyfiles (source "WormsShell.guide") (dest #dest) (infos) (noposition) (help "") (prompt ""))
    )

    (if #wormsdone
	(
	    ;Modify existing Worms installation

	    (working "Removing unneeded files")

	    ;Delete icon if requested

	    (if #delicon (delete (tackon #dest "HDWORM.info")))

	    ;Delete unneeded files if requested

	    (if #cleanup
		(
		    (delete (tackon #dest "devs") (all))
		    (delete (tackon #dest "Disk.info"))
		    (delete (tackon #dest "INSTALL") (infos))
		    (delete (tackon #dest "libs") (all))
		    (delete (tackon #dest "OCEAN"))
		    (delete (tackon #dest "Run"))
		    (delete (tackon #dest "s") (all))
		    (delete (tackon #dest "TEAM17"))
		)
	    )
	)
    )

    (if (not #wormsdone)
	(
	    ;Install Worms

	    ;Install main Worms files

	    (askdisk
		(prompt "Insert Worms disk 1")
		(help @askdisk-help)
		(dest "TW1")
	    )
	    (working "Installing Worms program")
	    (copyfiles (source "TW1:FLOPPYWORM") (dest #dest))
	    (copyfiles (source "TW1:WORMS") (dest #dest) (newname "HDWORM"))
	    (working "Installing Worms graphics")
	    (copyfiles (source "TW1:TWSTUFF") (dest (tackon #dest "TWSTUFF")) (all))
	    (working "Installing Worms basic samples")
	    (copyfiles (source "TW1:TW500") (dest (tackon #dest "TW500")) (all))
	    (working "Installing default Worm and team lists")
	    (copyfiles (source "TW1:TEAMLIST") (dest #dest))
	    (copyfiles (source "TW1:WORMLIST") (dest #dest))
	    (working "Installing custom landscapes")
	    (makedir (tackon #dest "TWCUSTOM") (infos))
	    (copyfiles (source "TW1:TWCUSTOM") (dest (tackon #dest "TWCUSTOM")) (all))

	    ;Install requested languages

	    (if (in #langs 0)
		(
		    (tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR1" "ENGLISH"))
		    (if (not (in #langs 1))
			(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR2" "ENGLISH")))
		    (if (not (in #langs 2))
			(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR3" "ENGLISH")))
		    (askdisk
			(prompt "Insert Worms disk 2")
			(help @askdisk-help)
			(dest "TW2")
		    )
		    (working "Installing English samples")
		    (makedir (tackon #dest "ENGLISH") (infos))
		    (copyfiles (source "TW2:TWENGLISH") (dest (tackon #dest "ENGLISH")) (all))
		)
	    )
	    (if (in #langs 1 2)
		(
		    (askdisk
			(prompt "Insert Worms disk 3")
			(help @askdisk-help)
			(dest "TW3")
		    )
		    (if (in #langs 1)
			(
			    (if (not (in #langs 0))
				(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR1" "FRANCAIS")))
			    (tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR2" "FRANCAIS"))
			    (if (not (in #langs 2))
				(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR3" "FRANCAIS")))
			    (working "Installant les échantillons françaises")
			    (makedir (tackon #dest "FRANCAIS") (infos))
			    (copyfiles (source "TW3:TWFRENCH") (dest (tackon #dest "FRANCAIS")) (all))
			)
		    )
		    (if (in #langs 2)
			(
			    (if (not (in #langs 0))
				(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR1" "DEUTSCH")))
			    (if (not (in #langs 1))
				(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR2" "DEUTSCH")))
			    (tooltype (dest (tackon #dest "WormsShell")) (settooltype "SAMPLEDIR3" "DEUTSCH"))
			    (working "Installing die Deutschen Geräusche")
			    (makedir (tackon #dest "DEUTSCH") (infos))
			    (copyfiles (source "TW3:TWGERMAN") (dest (tackon #dest "DEUTSCH")) (all))
			)
		    )
		)
	    )
	)
    )

    ;Set the switches as requested

    (if #sheep
	(tooltype (dest (tackon #dest "WormsShell")) (settooltype "SHEEPMODE" ""))
	(tooltype (dest (tackon #dest "WormsShell")) (settooltype "(SHEEPMODE)" ""))
    )
    (if #cprot
	(tooltype (dest (tackon #dest "WormsShell")) (settooltype "(DEPROTECT)" ""))
	(tooltype (dest (tackon #dest "WormsShell")) (settooltype "DEPROTECT" ""))
    )

    (if (not #wormsdone)
	(
	    ;Get boot-menu version (if available)

	    (set #bmversion (/ (getversion "bootmenu" (resident)) 65536))

	    (if (= #bmversion 0)
		(
		    (set #breakproc (cat
			"· Remove any floppy disks.\n"
			"· Reboot your Amiga.\n"
			"· Wait for the Commodore copyright message to appear on the screen.\n"
			"· Press Control-D. You should see the message \"*** BREAK\" or similar.\n")
		    )
		    (set #cmdline "execute Worms")
		)
		(
		    (if (< #bmversion 39)
			(set #breakproc (cat
			    "· Remove any floppy disks.\n"
			    "· Reboot your Amiga.\n"
			    "· Hold down both mouse buttons until a screen labelled \"Boot Menu\" appears.\n"
			    "· Click on \"Advanced Options\".\n"
			    "· Click on the cycle-gadget labelled \"Startup-Sequence\".\n"
			    "· Click on \"Use\".\n"
			    "· Click on the button for your hard drive - probably marked \"" (getdevice "SYS:")
				"\".\n"
			    "· Wait for a window containing a copyright notice to appear.")
			)
			(set #breakproc (cat
			    "· Remove any floppy disks.\n"
			    "· Reboot your Amiga.\n"
			    "· Hold down both mouse buttons until a screen labelled \"Amiga Early Startup"
				"Control\" appears.\n"
			    "· Click on \"Boot With No Startup-Sequence\".\n"
			    "· Wait for a window containing a copyright notice to appear.")
			)
		    )
		    (set #cmdline "Worms")
		)
	    )

	    (message "IMPORTANT: If you do not have enough memory to run Worms "
		"after booting normally, Worms will either die (leaving you with a blank screen) "
		"or else exit with an error message. In this case, you will have to run Worms "
		"manually from the CLI. This is not as hard as it may sound, but you may want "
		"to write down these instructions for future reference. These are specific "
		"to your particular Amiga and are therefore not contained in the WormsShell guide."
		"To run Worms from the CLI:\n"
		#breakproc
		"· Type 'cd \"" #dest "\"' and press Return.\n"
		"· Type '" #cmdline "' and press Return.")
	)
    )
)
