; can_build: buildings that the unit can build
; can_research: abilities that the unit can research
; can_train: units that the building can train
; can_use: abilities that the unit can use and upgrades by which the unit is affected
; requirements: objects (units, upgrades) required by the object to be acquired (unit or building) or used (ability)


; races (this part is not ready yet)

def human_race
class race

;def orc_race
;class race
;townhall great_hall
;farm pig_farm
;peasant peon
;easy orc_easy
;aggressive orc_aggressive


; misc parameters

def parameters
nb_of_resource_types 2 ; gold and wood


; resource deposits

def goldmine
class deposit
resource_type 0 ; gold
extraction_time 3
extraction_qty 1

def wood
class deposit
resource_type 1 ; wood
extraction_time 20
extraction_qty 2


; abilities (passive or active)

def a_teleportation
class ability
requirements u_teleportation
mana_cost 150
effect teleportation
effect_target ask
effect_range anywhere
universal_notification 1

def a_recall
class ability
requirements u_recall
mana_cost 150
effect recall
effect_target ask
effect_range anywhere
universal_notification 1

def a_conversion
class ability
requirements u_conversion
mana_cost 150
effect conversion
effect_target ask

def a_summon_dragon
class ability
requirements u_summon_dragon
mana_cost 150
effect summon 120 2 dragon

def a_holy_vision
class ability
mana_cost 30
effect summon 10 holy_vision
effect_target ask
effect_range anywhere

def a_exorcism
class ability
requirements u_exorcism
mana_cost 150
effect summon 15 exorcism
effect_target ask
effect_range nearby

def a_deadly_fog
class ability
requirements u_deadly_fog
mana_cost 150
effect summon 15 deadly_fog
effect_target ask
effect_range nearby

def a_meteors
class ability
requirements u_meteors
mana_cost 150
effect summon 15 meteors
effect_target ask
effect_range nearby

def a_resurrection
class ability
requirements u_resurrection
mana_cost 150
effect resurrection 6

def a_raise_dead
class ability
mana_cost 50
effect raise_dead 600 zombie skeleton zombie skeleton zombie skeleton zombie skeleton zombie skeleton

;def a_improved_wood_gathering
;effect bonus stored_wood --
;requirements lumbermill


; upgrades (research)

def superhealer
class upgrade
cost 80 0
time_cost 120
effect bonus heal_level 9
requirements castle

def u_teleportation
class upgrade
cost 50 0
time_cost 120

def u_recall
class upgrade
cost 50 0
time_cost 120

def u_meteors
class upgrade
cost 50 0
time_cost 120

def u_deadly_fog
class upgrade
cost 50 0
time_cost 120

def u_conversion
class upgrade
cost 50 0
time_cost 120
requirements castle

def u_summon_dragon
class upgrade
cost 50 0
time_cost 120

def u_exorcism
class upgrade
cost 50 0
time_cost 120

def u_resurrection
class upgrade
cost 50 0
time_cost 120
requirements castle

def melee_weapon
class upgrade
cost 8 10
time_cost 60
effect apply_bonus damage

def melee_armor
class upgrade
cost 8 10
time_cost 60
effect apply_bonus armor

def archer_weapon
class upgrade
cost 8 10
time_cost 60
effect bonus damage 1.5

def archer_armor
class upgrade
cost 8 10
time_cost 60
effect bonus armor 0.5

def archer_range
class upgrade
cost 8 10
time_cost 60
effect bonus range 1

def horse_speed
class upgrade
cost 15 5
time_cost 60
effect bonus speed 2.5


; units

def peasant
class worker
cost 4 0
food_cost 1
time_cost 10
hp_max 4
speed 1.5
can_build farm barracks lumbermill blacksmith scouttower townhall stables workshop dragonslair magestower temple necropolis
;can_use a_improved_wood_gathering
range 0.8
cooldown 1
damage 1.5

def footman
class soldier
cost 6 0
food_cost 1
time_cost 12
hp_max 15
speed 1.5
can_use melee_weapon melee_armor
armor 0.5
armor_bonus 1
range 1
cooldown 1.5
damage 3.5
damage_bonus 2.5

def zombie
class soldier
food_cost 0
hp_max 23
speed 1
can_use melee_weapon melee_armor
armor 0.5
armor_bonus 1
range 1
cooldown 3
damage 5
damage_bonus 2.5
corpse 0
is_healable 0
is_undead 1

def archer
class soldier
cost 5 1
food_cost 1
time_cost 15
hp_max 10
speed 1.5
requirements lumbermill
can_use archer_weapon archer_armor archer_range
armor 0
cooldown 1.5
target_types ground air
range 3
damage 2.5
can_upgrade_to darkarcher

def darkarcher
class soldier
cost 10 5 ; this is the total cost
food_cost 1
time_cost 75 ; this is the total cost
hp_max 12
speed 1.5
requirements lumbermill magestower
can_use archer_weapon archer_armor archer_range
armor 0
cooldown 3
target_types ground air
range 5
damage 10
is_invisible 1

def skeleton
class soldier
food_cost 0
hp_max 15
speed 1.5
can_use archer_weapon archer_armor archer_range
armor 0
cooldown 1.5
target_types ground air
range 3
damage 2.5
corpse 0
is_healable 0
is_undead 1

def knight
class soldier
cost 15 0
food_cost 2
time_cost 20
hp_max 45
requirements stables
can_use melee_weapon melee_armor horse_speed
speed 2.5
armor 1
armor_bonus 1.5
range 1
cooldown 1.5
damage 6
damage_bonus 6
transport_volume 2

def catapult
class soldier
cost 15 10
food_cost 2
time_cost 30
hp_max 30
speed 0.75
sight_range 1 ; can see the adjacent squares
special_range 1 ; can attack the adjacent squares
cooldown 4
damage 8
damage_radius 0.25
splash 1
is_repairable 1
is_healable 0
transport_volume 4
corpse 0

def dragon
class soldier
cost 15 10
food_cost 3
time_cost 15
airground_type air
hp_max 30
speed 1.75
sight_range 1 ; can see the adjacent squares
range 3
cooldown 4
damage 4
target_types ground air
damage_radius 1
splash 1
transport_volume 99
corpse 0

def mage
class soldier
cost 20 10
food_cost 3
time_cost 30
hp_max 30
mana_max 200
mana_regen 1 ; mana / second
speed 1
can_use a_recall a_summon_dragon a_meteors
range 4.5
cooldown 1.5
damage 8
target_types ground air
transport_volume 2

def necromancer
class soldier
cost 20 10
food_cost 3
time_cost 30
hp_max 30
mana_max 200
mana_regen 1 ; mana / second
speed 1
can_use a_raise_dead a_deadly_fog
range 4.5
cooldown 1.5
damage 8
target_types ground air
transport_volume 2

def priest
class soldier
cost 15 7
food_cost 2
time_cost 20
hp_max 30
mana_max 200
mana_regen 1
speed 1
can_use superhealer a_holy_vision a_exorcism a_conversion a_resurrection
heal_level 1
transport_volume 2

def new_flyingmachine
class soldier
cost 5 5
food_cost 1
time_cost 10
airground_type air
hp_max 30
speed 1.5
sight_range 1 ; can see the adjacent squares
is_repairable 1
is_healable 0
transport_capacity 8
transport_volume 99
is_a_detector 1
corpse 0

def flyingmachine
class soldier
cost 20 10
food_cost 3
time_cost 30
airground_type air
hp_max 30
speed 1.5
requirements magestower
sight_range 1 ; can see the adjacent squares
range 4.5
cooldown 1.5
damage 8
target_types ground air
is_repairable 1
is_healable 0
transport_volume 99
corpse 0

; buildings

def farm
class building
cost 5 5
food_provided 8; 4 * 2
hp_max 133.3;  400/3
time_cost 45
requirements townhall

def lumbermill
class building
cost 6 9
food_provided 0
hp_max 200;  600/3
time_cost 68
requirements townhall
storable_resource_types 1
can_research archer_weapon archer_armor archer_range
storage_bonus 0 1 ; gold bonus is +0, wood bonus is +1

def barracks
class building
cost 7 9
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements townhall
can_train footman archer knight

def townhall
class building
cost 12 16
food_provided 1
hp_max 400;  1200/3
time_cost 135
heal_level 1
storable_resource_types 0 1
can_train peasant
can_upgrade_to keep

def keep
class building
cost 22 31 ; this is the total cost
time_cost 315 ; this is the total cost
hp_max 800
heal_level 2
requirements barracks
can_upgrade_to castle
is_a townhall

def castle
class building
cost 42 61 ; this is the total cost
time_cost 675 ; this is the total cost
hp_max 1600
heal_level 4
requirements barracks lumbermill blacksmith stables
can_upgrade_to
is_a keep

def blacksmith
class building
cost 8 10
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements townhall
can_research melee_weapon melee_armor

def stables
class building
cost 10 15
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements keep
can_research horse_speed

def workshop
class building
cost 10 15
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements keep
can_train catapult new_flyingmachine flyingmachine

def dragonslair
class building
cost 15 20
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements castle
can_train dragon

def magestower
class building
cost 15 20
food_provided 0
hp_max 266.7;  800/3
time_cost 90
requirements castle
can_train mage
can_research u_recall u_summon_dragon u_meteors

def temple
class building
cost 10 30
food_provided 0
hp_max 300
time_cost 90
requirements keep
can_train priest
can_research superhealer u_exorcism u_conversion u_resurrection

def necropolis
class building
cost 10 30
food_provided 0
hp_max 300
time_cost 90
requirements castle
can_train necromancer
can_research u_deadly_fog

def scouttower
class building
cost 6 2
hp_max 33;  100/3
time_cost 60
sight_range 1 ; can see the adjacent squares
can_upgrade_to guardtower cannontower
is_buildable_anywhere 1

def guardtower
class building
cost 11 4
requirements lumbermill
hp_max 43;  130/3
time_cost 140
sight_range 1 ; can see the adjacent squares
range 5
cooldown 1.5
damage 6 ; 6-16
target_types ground air
armor 1 ; armor 20
can_use archer_weapon archer_range
is_buildable_anywhere 1

def cannontower
class building
cost 16 5
requirements blacksmith
hp_max 53;  160/3
time_cost 190
sight_range 1 ; can see the adjacent squares
range 6
cooldown 4
damage 8 ; 10-50
target_types ground
damage_radius 1
splash 1
armor 1 ; armor 20
is_buildable_anywhere 1

; other units

def instant_death ; used by some maps to create dead units
class effect
harm_level 10000
harm_target_type
decay 1

def meteors ; or blizzard
class effect
harm_level 1
harm_target_type

def deadly_fog
class effect
harm_level 1
harm_target_type healable

def earthquake
class effect
harm_level 1
harm_target_type building

def quicksand ; or surface
class effect
harm_level 1
harm_target_type ground unit

def holy_vision
class soldier
presence 0 ; casting holy vision on a square doesn't trigger "player has entered the square"
food_cost 0
corpse 0
is_vulnerable 0
is_invisible 1
is_a_detector 1

def exorcism
class effect
harm_level 2
harm_target_type undead
