; $VER: v2.0 of install script for "Evil's Doom"
; This intall script was written by MaLC0MN^CBK
; v1.0 --> Race against time: snap, snap, snap...
; v2.0 --> Made it work this time 8)
; v3.0 --> Various additions by CRISP^CBK to make it work more or less like the original installer ;)

(complete 0)

(message "\ncRUX & bAD kARMA\n"
         "bRING tO yOU tODAY\n\n"
         "Evil's Doom\n\n"
         "This install script will extract the ten archives\n"
         "to your chosen destination directory. A drawer will\n"
         "automatically be created there."
)

(if (NOT (askbool (prompt "\nDo you really wish to install \"Evil's Doom\" onto your hard drive?")
                  (help @askchoice-help)
                  (default 0)
                  (choices "Yes" "No")
         )
    )
   (exit "\nThank you, come again." (quiet))
)

(set #destination
     (askdir (prompt "\nPlease select where you want to install \"Evil's Doom\".\nA drawer will be created there.\n")
             (help @askdir-help)
             (disk)
             (default "")
     )
)

(set #realdest (tackon #destination "EvilsDoom"))
(set @default-dest #realdest)

(if (EXISTS #realdest (noreq))
    (exit "\nHey, I think you're trying to fool me here.\nIt seems to me that you've already installed\n\"Evil's Doom\" on your hard drive.\nI don't see why you should install it twice.\n\nOfcourse, I can't tell for sure if that's true.\nBut, there IS a directory with te same name\nand I wouldn't want to mess up its contents 8).\n\nJust do something about it!"
          (quiet)
    )
)

(if (<= (getdiskspace (#destination)) 15155200)
    (exit "\nYou don't seem to have enough space left\nin your chosen destination, sorry.\n\nMake some space and try again."
          (quiet)
    )
)

(makedir #realdest (safe))

(copyfiles (source "CBK-Evil1:C")
           (dest #destination)
           (pattern "EvilsDoom.info")
           (nogauge)
           (optional "force")
           (safe)
)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 1st disk is inserted correctly.\nThe install procedure is about to begin.")
             (help @askdisk-help)
	         (dest "CBK-Evil1")
    )
)

(makeassign "Evil" #realdest (safe))

(set #startup1 (tackon #realdest "StartSaga!"))

(working "Creating startup-file...")
(textfile (dest #startup1)
          (append "Assign >NIL: Evil: \""#realdest"\"\n")
          (include "CBK-Evil1:C/StartSaga!")
)

(working "Copying unarchiver to RAM...")
(copyfiles (source "CBK-Evil1:C")
           (dest "Ram:")
           (pattern "UnLZX")
           (nogauge)
           (optional "force")
           (safe)
)

(complete 1)

(working "Unpacking 1st archive to " #realdest"...")
(set @execute-dir #realdest)
(run ("RAM:UnLZX x CBK-Evil1:EVIL1.lzx"))

(complete 8)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 2nd disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil2")
    )
)

(working "Unpacking 2nd archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil2:EVIL2.lzx"))

(complete 16)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 3d disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil3")
    )
)

(working "Unpacking 3rd archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil3:EVIL3.lzx"))

(complete 24)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 4th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil4")
    )
)

(working "Unpacking 4th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil4:EVIL4.lzx"))

(complete 32)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 5th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil5")
    )
)

(working "Unpacking 5th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil5:EVIL5.lzx"))

(complete 40)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 6th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil6")
    )
)

(working "Unpacking 6th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil6:EVIL6.lzx"))

(complete 48)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 7th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil7")
    )
)

(working "Unpacking 7th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil7:EVIL7.lzx"))

(complete 56)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 8th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil8")
    )
)

(working "Unpacking 8th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil8:EVIL8.lzx"))

(complete 64)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 9th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil9")
    )
)

(working "Unpacking 9th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil9:EVIL9.lzx"))

(complete 72)
(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 10th disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil10")
    )
)

(working "Unpacking 10th archive to " #realdest"...")
(run ("RAM:UnLZX x CBK-Evil10:EVIL10.lzx"))

(complete 80)

(if (= serverMode FALSE)
    (askdisk (prompt "\nPlease make sure the 1st disk is inserted correctly.\nThe install procedure is about to continue.")
             (help @askdisk-help)
	         (dest "CBK-Evil1")
    )
)

(set #startup2 (tackon #realdest "X"))
(set #startup2 (tackon #startup2 "S"))
(set #realsave (tackon #realdest "RealSave"))

(working "Creating second startup-file...")
(textfile (dest #startup2)
          (append "Assign >NIL: Evil: \""#realdest"\"\nAssign >NIL: Saga: \""#realsave"\"\n")
          (include "CBK-Evil1:C/SFile")
)

(complete 85)

(working "Depacking picture data files...")
(run "CBK-Evil1:C/DEPPIC >CON:0/20/600/200/Depacking...")
(delete "Evil:pic/#?.fig")
(delete "Evil:int/#?.fig")
(delete "Evil:theend/#?.fig")
(delete "Evil:x/#?.fig")

(complete 99)

(working "Deleting unarchiver from RAM...")
(delete "Ram:UnLZX" (optional "force") (safe))

(complete 100)

(exit "\nThe install procedure was successful.\n\nYou can find \"Evil's Doom\"\nin " #realdest"\n\nNow go on and enjoy the game!\n\nDon't forget to call our boards!"
      (quiet)
)
