;;   ___________		     _________		      _____  __
;;   \_	  _____/______   ____   ____ \_   ___ \____________ _/ ____\/  |_
;;    |    __) \_  __ \_/ __ \_/ __ \/    \  \/\_  __ \__  \\   __\\   __|
;;    |     \   |  | \/\  ___/\  ___/\     \____|  | \// __ \|  |   |  |
;;    \___  /   |__|    \___  >\___  >\______  /|__|  (____  /__|   |__|
;;	  \/		    \/	   \/	     \/		   \/
;;  ______________________                           ______________________
;;			  T H E   W A R   B E G I N S
;;	   FreeCraft - A free fantasy real time strategy game engine
;;
;;	freecraft.ccl	-	The craft configuration language.
;;
;;	(c) Copyright 1998-2003 by Lutz Sammer
;;
;;	FreeCraft is free software; you can redistribute it and/or modify
;;	it under the terms of the GNU General Public License as published
;;	by the Free Software Foundation; only version 2 of the License.
;;
;;	FreeCraft is distributed in the hope that it will be useful,
;;	but WITHOUT ANY WARRANTY; without even the implied warranty of
;;	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;	GNU General Public License for more details.
;;
;;	$Id: freecraft.ccl,v 1.117 2003/02/28 20:02:54 jsalmon3 Exp $

(writes nil "FreeCraft default config file loading ...\n")

; Config file version
(define media-version (list 'fcmp-wc2 'class 'wc2 'version '(1 18 0)))

;; FIXME: Needed until new ui code is working
(define define-old-ui define-ui)

;;-----------------------------------------------------------------------------
;;	Config-Part
;;-----------------------------------------------------------------------------

;;	Edit the next sections to get your look and feel.

;;	Set the game contrast,brightness,saturation.
(set-contrast! 100) (set-brightness! 0) (set-saturation! 100)
;(set-contrast! 110) (set-brightness! 15) (set-saturation! 100)

;;	Enter your default title screen.
(set-title-screen! "graphics/ui/freecraft.png")
;(set-title-screen! "videos/splash2.avi")

;;	Enter your title music.
(set-title-music! "music/default.mod")
;(set-title-music! "music/Matthew_T._Yankovich---_Twilight_March.ogg")

;;	Enter your default menu background.
(set-menu-background! "graphics/ui/Menu background without title.png")

;;	Enter your default menu background with title.
(set-menu-background-with-title!
  "graphics/ui/Menu background with title.png")

;;	Enter your menu music.
(set-menu-music! "music/default.mod")

;;	If color-cycle-all is off (#f) only the tileset and global palette are
;;	color cycled.  Otherwise (#t) all palettes are color cycled.
(set-color-cycle-all! #t)
;(set-color-cycle-all! #f)

;;-----------------------------------------------------------------------------
;;	Music play list -	Insert your titles here

;
;;	Create a list from the directory content
;
(define (dir->list s . prepend)
  (define (aux d rl p)
    (let ((q (readdir d)))
      (if (equal? q ()) (begin (closedir d) rl)
          (if (or (equal? q ".") (equal? q "..")) (aux d rl p)
              (aux d (cons (string-append p q) rl) p)))))
  (aux (opendir s) () (if (string? (car prepend)) (car prepend) "")))

;; Uncomment to play automatic all music
;; FIXME: Comments are wrong, system dependend stuff didn't belong into the
;;	  config files.
(if (eq? (os-classification) (intern "win32"))
  (define play-list
    (dir->list (string-append (library-path) "/music/*") "music/"))
  (define play-list
    (dir->list (string-append (library-path) "/music") "music/")))

;; Comment this, if you use above
;(define play-list (list "music/default.mod"))

;;-----------------------------------------------------------------------------

;;	Set selection style, show what units the user had selected.
;;		#f			None
;;		'rectangle		Rectangle around unit
;;		'circle			Circle around unit
;;		'alpha-rectangle	Rectangle with alpha around unit
;;		'alpha-circle		Circle with alpha around unit
;;		'corners		Draw corners of rectangle
;;
(set-selection-style! 'corners)

;;	How the sight range of the selected unit is shown on map.
;;		#f			None
;;		'rectangle		Alpha rectangle around unit
;;		'circle			Alpha circle around unit
;;		#t			Rectangle around unit
;;
(set-show-sight-range! #f)
;(set-show-sight-range! #t)

;;	Enable/disable display of attack range of the selected unit on map.
(set-show-attack-range! #f)
;(set-show-attack-range! #t)

;;	Enable/disable display of reaction range of the selected unit on map.
(set-show-reaction-range! #f)

;;	Enable/disable display of the orders of the selected unit on map.
;(set-show-orders! #t)
(set-show-orders! 2)

;;	Enable/disable the short display of the orders after command.
;;	FIXME: planned
;(set-order-feedback! #t)
;(set-order-feedback! #f)

;;	Define the mana/energy decoration.
;;	FIXME: Planned?
;;
;;	(set-mana-style!
;;		'sprite (...)
;;		'horizontal
;;		'vertical
;;		'no-full
;;		'on-top
;;		'only-selected
;;		'background-long
;;	  )

;;	Define the health decoration.
;;	FIXME: Planned?
;;
;;	(set-health-style!
;;		'sprite (...)
;;		'horizontal
;;		'vertical
;;		'no-full
;;		'on-top
;;		'only-selected
;;		'background-long
;;	  )

;;	Define mana-sprite.
;;
;;	(mana-sprite file hotx hoty width height)
;;
;(mana-sprite	"graphics/ui/mana.png"		 -7  -7   7   7)
(mana-sprite	"graphics/ui/mana2.png"		  0  -1  31   4)

;;	Define health-sprite.
;;
;;	(mana-sprite file hotx hoty width height)
;;
;(health-sprite	"graphics/ui/health.png"	  1  -7   7   7)
(health-sprite	"graphics/ui/health2.png"	  0  -4  31   4)

;;	Uncomment next, to get a health bar to the left of the unit
;(show-health-bar)

;;	Uncomment next, to get a health dot to the left of the unit
(show-health-dot)

;;	Uncomment next, to get a mana bar to the right of the unit
;(show-mana-bar)

;;	Uncomment next, to get a mana dot to the right of the unit
(show-mana-dot)

;;	Uncomment next, to get no full bars or dots.
(show-no-full)

;;	Uncomment next, to show always bars or dots.
;(show-full)

;;	Uncomment next, to show health bars vertical.
;(show-health-vertical)

;;	Uncomment next, to show health bars horizontal.
;(show-health-horizontal)

;;	Uncomment next, to show mana bars vertical.
;(show-mana-vertical)

;;	Uncomment next, to show mana bars horizontal.
;(show-mana-horizontal)

;;	Uncomment next, to show energy bars and dots only for selected units
;(show-energy-selected-only)

;;	Uncomment next, to show bars and dots always on top.
;;	FIXME: planned feature
(decoration-on-top)

;;	Define shadow-sprite.
;;
;;	(shadow-sprite file hotx hoty width height)
;;
(shadow-sprite "graphics/missiles/unit shadow.png"	3 42	32 32)

;;	Define spell-sprite.
;;
;;	(shadow-sprite file hotx hoty width height)
;;
(spell-sprite "graphics/ui/bloodlust,haste,slow,invisible,shield.png"
  1 1	16 16)

;;	Edit this to enable/disable the original game resource line.
(set-original-resources! #f)
;(set-original-resources! #t)

;;	Uncomment next, to enable fancy building (random mirroring buildings)
(set-fancy-buildings! #t)
;(set-fancy-buildings! #f)

;;	Edit this to enable/disable show tips at the start of a level
(set-show-tips! #t)

;;-----------------------------------------------------------------------------
;;	Game modification

;;	Edit this to enable/disable hit point regeneration for all units
;(set-hitpoint-regeneration! #t)
(set-hitpoint-regeneration! #f)

;;	Edit this to enable/disable XP to add more damage to attacks
;(set-xp-damage! #t)
(set-xp-damage! #f)

;;	Edit this to enable/disable extended features.
;;		Currently enables some additional buttons.
(define extensions #t)
;(define extensions #f)

;;	Edit this to enable/disable the training queues.
(set-training-queue! #t)
;(set-training-queue! #f)

;;	Edit this to enable/disable building capture.
;(set-building-capture! #t)
(set-building-capture! #f)

;;	Set forest regeneration speed. (n* seconds, 0 = disabled)
;;	(Auf allgemeinen Wunsch eines einzelnen Herrn :)
(set-forest-regeneration! 0)
;(set-forest-regeneration! 5)

;;	Set depleted % for gold-mines. (n percent, 0 = disabled)
(set-goldmine-depleted! 0)
;(set-goldmine-depleted! 5)

;;	Set burning building percent and rate. (n percent, h HP/second)
;;	Buildings with less than n% HP lose h HP every second.
;(set-burn-buildings! 25 2)

;;	Edit this to enable/disable the reveal of the attacker.
;(set-reveal-attacker! #t)
(set-reveal-attacker! #f)

;;-----------------------------------------------------------------------------

;;	If you prefer fighters are attacking by right clicking empty space
;;	uncomment this (you must comment the next).
;;	FIXME: this option will be renamed
;(right-button-attacks)

;;	If you prefer fighters are moving by right clicking empty space
;;	uncomment this.
;;	FIXME: this option will be renamed
(right-button-moves)

;;	Change next, for the wanted mouse speed. (only SVGALIB)
(set-mouse-adjust! 15)

;;	Change next, for the wanted mouse scale. (only SVGALIB)
(set-mouse-scale! 1)

;;	Edit this to enable/disable grabbing the mouse.
(set-grab-mouse! #f)

;;	Edit this to enable/disable stopping scrolling on mouse leave.
(set-leave-stops! #t)

;;	Edit this to enable/disable mouse scrolling.
(set-mouse-scroll! #t)
;(set-mouse-scroll! #f)

;;	Edit this to enable/disable keyboard scrolling.
(set-key-scroll! #t)
;(set-key-scroll! #f)

;;	Set keyboard scroll speed in frames (1=each frame,2 each second,...)
(set-key-scroll-speed! 1)

;;	Set mouse scroll speed in frames (1=each frame,2 each second,...)
(set-mouse-scroll-speed! 1)

;;	Change next, for the wanted double-click delay (in ms).
(set-double-click-delay! 300)

;;	Change next, for the wanted hold-click delay (in ms).
(set-hold-click-delay! 1000)

;;	Edit this to enable/disable the display of the command keys in buttons.
(set-show-command-key! #t)
;(set-show-command-key! #f)

;;	Edit this reverse middle mouse button map move direction.
(set-reverse-map-move! #f)
;(set-reverse-map-move! #t)

;;	Uncomment next, to reveal the complete map.
;(reveal-map)

;;	Choose your default fog of war state (enabled #t/disabled #f).
;;		disabled is a C&C like fog of war.
(set-fog-of-war! #t)
;(set-fog-of-war! #f)

;;	Choose your default for minimap with/without terrain.
(set-minimap-terrain! #t)
;(set-minimap-terrain! #f)

;;	Choose your default for the fog of war style.
;; Planned	(set-fog-of-war-style! 'original)
;; 		(set-fog-of-war-style! 'alpha-gray)
;(original-fog-of-war)
(alpha-fog-of-war)

;;	If you use gray style fog of war set the contrast,brightness,saturation
(set-fog-of-war-contrast!    30)
(set-fog-of-war-brightness!  10)
(set-fog-of-war-saturation! 100)

;;-----------------------------------------------------------------------------

;;	Edit next to increase the speed, for debugging.

;;	Decrease the mining time by this factor.
;(set-speed-mine! 10)
;;	Decrease the time in a gold deposit by this factor.
;(set-speed-gold! 10)
;;	Decrease the time for chopping a tree by this factor.
;(set-speed-chop! 10)
;;	Decrease the time in a wood deposit by this factor.
;(set-speed-wood! 10)
;;	Decrease the time for haul oil by this factor.
;(set-speed-haul! 10)
;;	Decrease the time in an oil deposit by this factor.
;(set-speed-oil! 10)
;;	Decrease the time to build a unit by this factor.
;(set-speed-build! 10)
;;	Decrease the time to train a unit by this factor.
;(set-speed-train! 10)
;;	Decrease the time to upgrade a unit by this factor.
;(set-speed-upgrade! 10)
;;	Decrease the time to research by this factor.
;(set-speed-research! 10)

;;	You can do all the above with this
(set-speeds! 1)

;;-----------------------------------------------------------------------------

;;	Define default resources

;; FIXME: Must be removed: Use and write (define-resource)
;;
;;	(define-resource 'gold 'name "Gold"
;;	  'start-resource-default 2000
;;	  'start-resource-low 2000
;;	  'start-resource-medium 5000
;;	  'start-resource-high 10000
;;	  'income 100)
;;	  FIXME: Must describe how geting resources work.
;;

(define-default-resources
  0   2000 1000 1000   1000 1000 1000)

(define-default-resources-low
  0   2000 1000 1000   1000 1000 1000)

(define-default-resources-medium
  0   5000 2000 2000   2000 2000 2000)

(define-default-resources-high
  0  10000 5000 5000   5000 5000 5000)

(define-default-incomes
  0    100  100  100    100  100  100)

(define-default-actions
  'stop 'mine 'chop 'drill 'mine 'mine 'mine)

(define-default-resource-names
  'time 'gold 'wood 'oil 'ore 'stone 'coal)

;;-----------------------------------------------------------------------------

;;	Change the global sound volume (from 0 min to 256 max)
(set-sound-volume! 128)

;;	Change the music volume (from 0 min to 256 max)
(set-music-volume! 128)

;;-----------------------------------------------------------------------------

;;	A* configuration, FIXME: currently not correct supported.
(no-a-star)
;(a-star)
;(a-star-fixed-unit-cost 1000)
;(a-star-moving-unit-cost 2)

;;-----------------------------------------------------------------------------

;;	All player food unit limit
(set-all-players-food-unit-limit! 200)
;;	All player building limit
(set-all-players-building-limit! 200)
;;	All player total unit limit
(set-all-players-total-unit-limit! 400)

;;-----------------------------------------------------------------------------
;;	Default triggers for single player
;;		(FIXME: must be combined with game types)

(define (single-player-triggers)
  (add-trigger (lambda () (if-unit 'this '== 0 'all))
    (lambda () (action-defeat)))
  (add-trigger (lambda () (if-opponents 'this '== 0))
    (lambda () (action-victory))) )

;;-----------------------------------------------------------------------------
;;	Tables-Part
;;-----------------------------------------------------------------------------

;;; Uses FreeCraft Library path!
(load "ccl/wc2.ccl" #f #t)

(load "ccl/tilesets.ccl" #f #t)
(load "ccl/icons.ccl" #f #t)
(load "ccl/sound.ccl" #f #t)
(load "ccl/missiles.ccl" #f #t)
(load "ccl/constructions.ccl" #f #t)
(load "ccl/units.ccl" #f #t)
(load "ccl/upgrade.ccl" #f #t)
(load "ccl/fonts.ccl" #f #t)
(load "ccl/buttons.ccl" #f #t)
(load "ccl/ui.ccl" #f #t)
(load "ccl/ai.ccl" #f #t)
(load "ccl/campaigns.ccl" #f #t)
(load "ccl/credits.ccl" #f #t)
(load "ccl/tips.ccl" #f #t)
(load "ccl/ranks.ccl" #f #t)
(load "ccl/menus.ccl" #f #t)

;;-----------------------------------------------------------------------------

;; Test code to create male orc names.
(define orc-first (list "B" "Er" "G" "Gr" "H" "P" "Pr" "R" "V" "Vr"))
(define orc-middle (list "a" "i" "o" "u"))
(define orc-last (list "dash" "dish" "dush" "gar" "gor" "gdush" "lo" "gdish"
    "k" "lg" "nak" "rag" "rbag" "rg" "rk" "ng" "nk" "rt" "ol" "urk" "shnak"))

(define (orc-name)
  (string-append (nth (rand (length orc-first)) orc-first)
    (nth (rand (length orc-middle)) orc-middle)
    (nth (rand (length orc-last)) orc-last)))

;; Test code to create male human names.
(define human-first (list "Au" "Gar" "Bo" "Natha" "Gwë" "Ann" "Ma"
    "Ygd" "Ni" "Lau" "Fra" "O'" "Sul"))
(define human-middle (list "ba" "ga" "ro" "na" "ji" "ria" "da" "li" "re" "va"))
(define human-last (list "nel" "mel" "mir" "ël" "len" "ll" "ril" "van"
    "lin" "lien"))

(define (human-name)
  (string-append (nth (rand (length human-first)) human-first)
    (nth (rand (length human-middle)) human-middle)
    (nth (rand (length human-last)) human-last)))

(define (gen-unit-name ut)
  (orc-name))

;;-----------------------------------------------------------------------------

(writes nil "... ready!\n")
