(set #ver (/ @installer-version 65536))
(set #inst1 "Heretic_IIA")
(if (>= #ver 44)
    (
	(effect "lower_right" "radial" $C85037 $000000)
	(showmedia "symbol" "Heretic_IIA:Installer Data/backdrop.iff" "center" "none" 0)
    )
)

(if (< #ver 43)
    (
	(exit "Your Installer is too old. Get a new version from Aminet" (quiet))
    )
)

(if (= @language "deutsch")
(
 (set #choice-yes "\x1B[2pJa")
 (set #choice-no "Nein")
 (set #continue "Weiter")
 (set #welcome-prompt (cat
	"Willkommen zum Heretic II Siege Installations-Programm. Es wird Sie schrittweise "
	"durch die Installation führen. Wenn Sie Probleme bekommen, können Sie durch "
	"den Hilfe-Knopf weitere Informationen erhalten. Dieses Programm installiert "
	"auch ein Update für THF.\n"
	"Bitte wählen Sie nun den Installations-Modus."
 ))
    (set #licence-msg (cat
	"Siege ist *kein* offizielles Hyperion Produkt, und neben Hilfe bei Problemen "
        "bei der Installation können wir für Siege *keinerlei* Support bieten, auch etwa "
	"keine Bugfixes. Wir garantieren nicht einmal, dass es auf jedem System läuft."
	"Just take it as it is."
    ))
    (set #not-installed "Heretic II muss installiert sein, um The Siege zu installieren.")
    (set #extract-base "Programm-Dateien werden auf die Festplatte kopiert...")
    (set #finish-msg "The Siege wurde in der Schublade %s erfolgreich installiert\n")
    (set #see-readme "\x1B[2pEinen Blick auf die LIESMICH-Datei werfen")
    (set #register-msg (cat
  	"Um die Installation abzuschließen werden Sie jetzt nach Ihrer Serien-Nummer und "
  	"Benutzer-Informationen wie Namen und Anschrift gefragt. Sie müssen dies ausfüllen "
  	"um den Kundendienst in Anspruch zu nehmen. Geben Sie die Seriennummer sehr sorgfältig "
  	"und genau so wie abgedruckt ein (einschließlich der Bindestriche), da die Installation "
  	"ansonsten nicht funktioniert."
    ))

 (set #not-successful "Die The Siege Installation war nicht erfolgreich. Bitte wiederholen Sie diese, bevor Sie das Update installieren.")
)
(
 (set #choice-yes "\x1B[2pYes")
 (set #choice-no "No")
 (set #continue "Continue")
 (set #welcome-prompt (cat
	"Welcome to the Heretic II The Siege Installation Program. This Utility "
	"will guide you through the Installation in a step-by-step "
	"process. At any time, "
	"if you're stuck, you can press the help button to get more detailed "
	"information. This utility also installs an update for THF.\n"
	"Please indicate your level of expertise."
 ))
    (set #licence-msg (cat
	"Siege is *no* official Hyperion product. This means we can *not* provide "
	"any help in case of problems asides from simple installation help and especially "
        "no bugfixes. We do not even guarantee this will run on every system."
	"Just take it as it is."
    ))
    (set #not-installed "Heretic II needs to be installed to install The Siege.")
    (set #extract-base "Copying program files to your harddisk...")
    (set #finish-msg "The Siege has been installed to %s\n on your system")
    (set #see-readme "\x1B[2pHave a look at the README-File")
    (set #register-msg (cat
	"To conclude the installation process you will be asked for your serial number and "
	"user information, like name, address, city and country. You must fill them "
	"in, otherwise we will not be able to answer your support questions. "
	"Be very careful to type in the serial number as it is printed, including "
	"dashes, otherwise your installation will not work."
    ))
 (set #not-successful "The Siege Installation was unsuccessfull. Please reinstall the game before installing the update.")
)
)

(procedure P_BuildCommandline arg1
    (set #cmdline
	(cat
	    "c/hUnpackH2 -archive \""
	    (arg1)
	    "\" -dest \""
	    (getenv "HereticII/InstallationPath")
	    "\""
	)
    )
)

(procedure P_DoRegister
    (message #register-msg)
    (set #cmdline (cat
	"Heretic_IIA:C/RegisterGUI \""
	(tackon @default-dest "h2siege/game.dll")
	"\" "
    ))
    (set #retval
	(run #cmdline
	(help @run-help)
    ))
    (if (= #retval 10)
	(exit "Internal Error during registering. Please contact tech suport" (quiet))
    )
    (if (= #retval 20)
	(exit #user-abort (quiet))
    )
)


(procedure P_DoRegister2
    (message #register-msg)
    (set #cmdline (cat
	"Heretic_IIA:C/RegisterGUI \""
	(tackon @default-dest "THF/game.dll")
	"\" "
    ))
    (set #retval
	(run #cmdline
	(help @run-help)
    ))
    (if (= #retval 10)
	(exit "Internal Error during registering. Please contact tech suport" (quiet))
    )
    (if (= #retval 20)
	(exit #user-abort (quiet))
    )
)


(procedure P_AskDisk 
	(set #curvol #inst1)
    (set #curvol (cat #curvol ":"))
)

(welcome #welcome-prompt)
(P_AskDisk)
(complete 0)
(set #flag (exists "ENV:HereticII/InstallationPath"))
(if (= #flag 1)
    (
	(set @default-dest (getenv "HereticII/InstallationPath"))
	(if (exists (tackon @default-dest "installer-cookie"))
    (exit #not-successful (quiet))
  )
    )
    (
	(exit #not-installed (quiet))
    )		
)

(set #flag
	(askchoice
	    (prompt #licence-msg)
	    (help @askchoice-help)
	    (default 0)
	    (choices #continue)
	)
    )
    (if (= #flag 1) (exit (quiet)))

(set #dest-dir @default-dir)

(complete 20)

(P_BuildCommandLine "siege.hpa")
(working #extract-base)
(set #status
	(run #cmdline
		(help @run-help)
	)
)

(if (= #status 2)
    (
	(exit #user-abort (quiet))
    )
)
(complete 50)

(complete 80)
(if (not(exists(tackon @default-dest "update-docs/README")))
(copyfiles (source"README") (dest (tackon @default-dest "update-docs")))
)

(complete 90)
(if (not(exists("env:Siege")))(makedir "ENV:Siege"))
(if (not(exists("envarc:Siege")))(makedir "envarc:Siege"))
(copyfiles(source"fighter_Att")(dest "env:Siege"))
(copyfiles(source"fighter_Def")(dest "env:Siege"))
(copyfiles(source"fighter_noteam")(dest "env:Siege"))
(copyfiles(source"cleric_Att")(dest "env:Siege"))
(copyfiles(source"cleric_Def")(dest "env:Siege"))
(copyfiles(source"cleric_noteam")(dest "env:Siege"))
(copyfiles(source"wizard_Att")(dest "env:Siege"))
(copyfiles(source"wizard_Def")(dest "env:Siege"))
(copyfiles(source"Wizard_noteam")(dest "env:Siege"))
(copyfiles(source"necro_Att")(dest "env:Siege"))
(copyfiles(source"necro_Def")(dest "env:Siege"))
(copyfiles(source"necro_noteam")(dest "env:Siege"))
(copyfiles(source"succubus_Att")(dest "env:Siege"))
(copyfiles(source"succubus_Def")(dest "env:Siege"))
(copyfiles(source"succubus_noteam")(dest "env:Siege"))
(copyfiles(source"male_Att")(dest "env:Siege"))
(copyfiles(source"male_Def")(dest "env:Siege"))
(copyfiles(source"male_noteam")(dest "env:Siege"))
(copyfiles(source"female_Att")(dest "env:Siege"))
(copyfiles(source"female_Def")(dest "env:Siege"))
(copyfiles(source"female_noteam")(dest "env:Siege"))

(copyfiles(source"fighter_Att")(dest "envarc:Siege"))
(copyfiles(source"fighter_Def")(dest "envarc:Siege"))
(copyfiles(source"fighter_noteam")(dest "envarc:Siege"))
(copyfiles(source"cleric_Att")(dest "envarc:Siege"))
(copyfiles(source"cleric_Def")(dest "envarc:Siege"))
(copyfiles(source"cleric_noteam")(dest "envarc:Siege"))
(copyfiles(source"wizard_Att")(dest "envarc:Siege"))
(copyfiles(source"wizard_Def")(dest "envarc:Siege"))
(copyfiles(source"Wizard_noteam")(dest "envarc:Siege"))
(copyfiles(source"necro_Att")(dest "envarc:Siege"))
(copyfiles(source"necro_Def")(dest "envarc:Siege"))
(copyfiles(source"necro_noteam")(dest "envarc:Siege"))
(copyfiles(source"succubus_Att")(dest "envarc:Siege"))
(copyfiles(source"succubus_Def")(dest "envarc:Siege"))
(copyfiles(source"succubus_noteam")(dest "envarc:Siege"))
(copyfiles(source"male_Att")(dest "envarc:Siege"))
(copyfiles(source"male_Def")(dest "envarc:Siege"))
(copyfiles(source"male_noteam")(dest "envarc:Siege"))
(copyfiles(source"female_Att")(dest "envarc:Siege"))
(copyfiles(source"female_Def")(dest "envarc:Siege"))
(copyfiles(source"female_noteam")(dest "envarc:Siege"))
(copyfiles(source"Siege")(dest @default-dest))
(copyfiles(source"Siege.info")(dest @default-dest))
(copyfiles(source"Siege.prefs")(dest @default-dest))

(complete 100)
(set #opts
    (askoptions
	(help @askoptions-help)
	(prompt (#finish-msg @default-dest))
	(choices #see-readme)
	(default 1)
    )
)

(if (IN #opts 0)
    (if (>= #ver 44)
	(showmedia "readme" "README" "upper_right" "medium" 1)
	(run "sys:Utilities/Multiview README")
    )
)

