REM ********************************************
REM  Ancient Keeper campaign for KeeperFX
REM  Script for Level 20
REM  Version 1.00
REM ********************************************

SET_GENERATE_SPEED(400)

START_MONEY(PLAYER0,30000)

SET_FLAG(PLAYER0,FLAG0,0)

MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,1,1)

DISPLAY_OBJECTIVE(2,PLAYER0)
DISPLAY_INFORMATION(120,PLAYER0)
DISPLAY_INFORMATION(3,PLAYER0)

IF(PLAYER0,WORKSHOP>0)
  DISPLAY_INFORMATION(4,PLAYER0)
ENDIF

IF(PLAYER0,PRISON > 0)
  DISPLAY_INFORMATION(116,PLAYER0)
ENDIF

DOOR_AVAILABLE(PLAYER0,MAGIC,1,0)

IF(PLAYER0,IMP >= 1)
  MAGIC_AVAILABLE(PLAYER0,POWER_DESTROY_WALLS,0,0)
ENDIF

IF(PLAYER0,FLAG0 == 0)
  IF(PLAYER_GOOD,HORNY == 0)
    SET_FLAG(PLAYER0,FLAG0,1)
    SET_TIMER(PLAYER0,TIMER0)
  ENDIF
ENDIF

CREATE_PARTY(DRAGONS)
  ADD_TO_PARTY(DRAGONS,DRAGON,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(DRAGONS,DRAGON,10,3000,ATTACK_ENEMIES,0)

IF(PLAYER0,FLAG0 == 1)
  IF(PLAYER0,TIMER0 >= 3000)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DRAGONS,1,DUNGEON,1,10,100)
    ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,DRAGONS,2,DUNGEON,1,10,100)
  ENDIF
ENDIF

CREATE_PARTY(NINJAS)
  ADD_TO_PARTY(NINJAS,SAMURAI,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(NINJAS,SAMURAI,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(NINJAS,SAMURAI,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(NINJAS,SAMURAI,10,3000,ATTACK_ENEMIES,0)

IF(PLAYER0,GUARD_POST >= 1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NINJAS,3,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NINJAS,3,1)
ENDIF

IF(PLAYER0,FLAG0 == 1)
  IF_ACTION_POINT(4,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,2)
    SET_TIMER(PLAYER0,TIMER0)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 == 1)
  IF_ACTION_POINT(5,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,2)
    SET_TIMER(PLAYER0,TIMER0)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 == 2)
  IF(PLAYER0,TIMER0 >= 1000)
    SET_FLAG(PLAYER0,FLAG0,3)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 <= 2)
  IF(PLAYER0,AVATAR >= 1)
    SET_FLAG(PLAYER0,FLAG0,3)
  ENDIF
ENDIF

CREATE_PARTY(HORNIES)
  ADD_TO_PARTY(HORNIES,HORNY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(HORNIES,HORNY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(HORNIES,HORNY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(HORNIES,HORNY,10,3000,ATTACK_ENEMIES,0)

IF(PLAYER0,FLAG0 == 3)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,HORNIES,3,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,HORNIES,4,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,HORNIES,5,1)
ENDIF

CREATE_PARTY(SPIDERS)
  ADD_TO_PARTY(SPIDERS,SPIDER,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(SPIDERS,SPIDER,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(SPIDERS,SPIDER,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(SPIDERS,SPIDER,10,3000,ATTACK_ENEMIES,0)

CREATE_PARTY(BARBARIANS)
  ADD_TO_PARTY(BARBARIANS,BARBARIAN,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(BARBARIANS,BARBARIAN,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(BARBARIANS,BARBARIAN,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(BARBARIANS,BARBARIAN,10,3000,ATTACK_ENEMIES,0)

IF_ACTION_POINT(6,PLAYER0)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,SPIDERS,7,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,BARBARIANS,7,1)
ENDIF

CREATE_PARTY(TENTACLES)
  ADD_TO_PARTY(TENTACLES,TENTACLE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(TENTACLES,TENTACLE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(TENTACLES,TENTACLE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(TENTACLES,TENTACLE,10,3000,ATTACK_ENEMIES,0)

CREATE_PARTY(GIANTS)
  ADD_TO_PARTY(GIANTS,GIANT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(GIANTS,GIANT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(GIANTS,GIANT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(GIANTS,GIANT,10,3000,ATTACK_ENEMIES,0)

IF_ACTION_POINT(8,PLAYER0)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,TENTACLES,9,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,GIANTS,9,1)
ENDIF

CREATE_PARTY(FAIRIES)
  ADD_TO_PARTY(FAIRIES,FAIRY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(FAIRIES,FAIRY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(FAIRIES,FAIRY,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(FAIRIES,FAIRY,10,3000,ATTACK_ENEMIES,0)

IF_ACTION_POINT(10,PLAYER0)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,NINJAS,11,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,FAIRIES,11,1)
ENDIF

CREATE_PARTY(WIZARDS)
  ADD_TO_PARTY(WIZARDS,WIZARD,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(WIZARDS,WIZARD,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(WIZARDS,WIZARD,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(WIZARDS,WIZARD,10,3000,ATTACK_ENEMIES,0)

IF_ACTION_POINT(12,PLAYER0)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,WIZARDS,13,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,HORNIES,13,1)
ENDIF

CREATE_PARTY(VAMPIRES)
  ADD_TO_PARTY(VAMPIRES,VAMPIRE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(VAMPIRES,VAMPIRE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(VAMPIRES,VAMPIRE,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(VAMPIRES,VAMPIRE,10,3000,ATTACK_ENEMIES,0)

CREATE_PARTY(KNIGHTS)
  ADD_TO_PARTY(KNIGHTS,KNIGHT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(KNIGHTS,KNIGHT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(KNIGHTS,KNIGHT,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(KNIGHTS,KNIGHT,10,3000,ATTACK_ENEMIES,0)

IF_ACTION_POINT(14,PLAYER0)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,VAMPIRES,15,1)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHTS,15,1)
ENDIF

IF(PLAYER0,FLAG0 <= 3)
  IF_ACTION_POINT(16,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,4)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 <= 3)
  IF_ACTION_POINT(17,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,4)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 <= 3)
  IF_ACTION_POINT(18,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,4)
  ENDIF
ENDIF

IF(PLAYER0,FLAG0 <= 3)
  IF_ACTION_POINT(19,PLAYER0)
    SET_FLAG(PLAYER0,FLAG0,4)
  ENDIF
ENDIF

CREATE_PARTY(DEFENDERS)
  ADD_TO_PARTY(DEFENDERS,AVATAR,10,30000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(DEFENDERS,BUG,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(DEFENDERS,BUG,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(DEFENDERS,BUG,10,3000,ATTACK_ENEMIES,0)
  ADD_TO_PARTY(DEFENDERS,BUG,10,3000,ATTACK_ENEMIES,0)

IF(PLAYER0,FLAG0 == 4)
  ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DEFENDERS,20,1)
ENDIF

CREATE_PARTY(REVENGE)
  ADD_TO_PARTY(REVENGE,AVATAR,10,30000,ATTACK_ENEMIES,0)

IF(PLAYER_GOOD,DUNGEON_DESTROYED == 1)
  SET_FLAG(PLAYER0,FLAG0,5)
  ROOM_AVAILABLE(PLAYER0,BRIDGE,1,1)
  ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,REVENGE,21,DUNGEON,1,9,100)
  ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,REVENGE,21,DUNGEON,1,9,100)
  ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,REVENGE,21,DUNGEON,1,9,100)
  ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,REVENGE,21,DUNGEON,1,9,100)
  DISPLAY_OBJECTIVE(123,PLAYER0)
  DISPLAY_INFORMATION(119,PLAYER0)
ENDIF

IF(PLAYER0,GUARD_POST > 0)
  DISPLAY_INFORMATION(117,PLAYER0)
ENDIF

IF(PLAYER0,AVATAR>0)
  DISPLAY_INFORMATION(118,PLAYER0)
ENDIF

IF(PLAYER0,TOTAL_CREATURES<1)
  DISPLAY_OBJECTIVE(124,PLAYER0)
  LOSE_GAME
ENDIF

IF(PLAYER0,FLAG0 == 5)
  IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
    DISPLAY_OBJECTIVE(121,PLAYER0)
    DISPLAY_INFORMATION(122,PLAYER0)
    WIN_GAME
  ENDIF
ENDIF
