title Heroes of Sokoban III: The Bard and The Druid
author Jonah Ostroff
text_color yellow
key_repeat_interval 0.25
run_rules_on_level_start

========
OBJECTS
========

Background
#989898 #C8C8C8
00000
00100
00000
00010
00000

Goal
Brown Yellow
.000.
00000
00010
00000
00000

Wall
Darkgrey #222222
01000
11111
00010
00010
11111

Fighter (Warrior sounds better in-game, but I want different abbreviations for the classes in the editor.)
#FF4444 Pink DarkBrown
.000.
.111.
00000
.000.
.2.2.

Wizard
#2266FF Pink
.000.
.010.
00000
.000.
00000

Thief
#66DD66 Pink DarkBrown
.000.
.010.
00000
.0.0.
.0.0.

Priest
#FFFFAA Pink
.000.
.111.
00000
.000.
00000

Bard
#8800FF #884400 #444444
.222.
.111.
00000
.000.
.0.0.

Druid
#FF8800 Pink DarkBrown
.212.
.111.
00000
.000.
00000

SFighter
#880000 Pink DarkBrown
.000.
.111.
00000
.000.
.2.2.

SWizard
#000088 Pink
.000.
.010.
00000
.000.
00000

SThief
#006600 Pink DarkBrown
.000.
.010.
00000
.0.0.
.0.0.

SPriest
#B8B800 Pink
.000.
.111.
00000
.000.
00000

SBard
#440088 #884400 #444444
.222.
.111.
00000
.000.
.0.0.

SDruid
#884400 Pink DarkBrown
.212.
.111.
00000
.000.
00000

Crate
Orange #552200
.111.
10001
10001
10001
.111.

YellowSwitch
Yellow Black
.....
.111.
.101.
.111.
.....

YellowOpen
Yellow
0...0
.....
.....
.....
0...0

YellowDoor
Yellow #AA7722
01010
10001
00000
10001
01010

PurpleSwitch
#6611CC Black
.....
.111.
.101.
.111.
.....

PurpleDoor
#6611CC #220088
01010
10001
00000
10001
01010

PurpleOpen
#6611CC
0...0
.....
.....
.....
0...0

MonsterDoor
DarkGrey #222222 Red
21002
22122
20212
20012
21112

Warpball
Blue

ShadowDoor
Purple

Goblin
Green DarkBrown DarkGreen
0.2.0
00000
..0..
.111.
.1.1.

Dying
White

Saved
#D8D800
..0..
.000.
..0..
..0..
.....

HasSavedDoor
Yellow
.....
.....
.....
.....
.....

Corpse
#CCC
.000.
.000.
00000
.0.0.
.0.0.

Note
#8800FF
.....
..00.
.00..
.00..
.....

=======
LEGEND
=======

Player = Fighter or Wizard or Thief or Priest or Bard or Druid
SPlayer = Swizard or Sthief or SFighter or SPriest or SBard or SDruid
Hero = Player or Splayer
Healer = Priest or SPriest (Unlike the other heroes, priests must function even when inactive. "Healer" is the generic term for an active or inactive priest.)
ClosedDoor = PurpleDoor or YellowDoor or MonsterDoor
OpenDoor = YellowOpen or PurpleOpen
Switch = PurpleSwitch or YellowSwitch
Monster =  Goblin
Moveable = Crate or SPlayer or Monster
Static = Wall or ClosedDoor
Weighing = Crate or Hero or Monster or Wall
Vulnerable = Hero or Monster
Invulnerable = Crate or Static
. = Background
# = Wall
F = Fighter
W = Wizard
T = Thief
P = Priest
B = Bard
D = Druid
1 = SFighter
2 = SThief
3 = SWizard
4 = SPriest
5 = SBard
6 = SDruid
* = Crate
G = Goal
[ = YellowDoor
] = PurpleDoor
{ = YellowSwitch
} = PurpleSwitch
O = Goblin
M = MonsterDoor

=======
SOUNDS
=======

Moveable move 82056307
Sfx0 21221308 (teleport)
Endlevel 36315908
Sfx1 66399906 (switch player)
Sfx2 92172900 (close door)
Sfx3 15129100 (open door)
Sfx4 69860105 (saved)
Sfx5 63194902 (kill enemy)
Sfx6 81996702 (dying player)
Sfx7 20187909 (Bard leading)
Sfx8 93615108 (Transmutation)
EndGame 86793500

================
COLLISIONLAYERS
================

Background
Warpball, Dying
Goal, Switch, OpenDoor, ShadowDoor, HasSavedDoor
ClosedDoor, Hero, Crate, Wall, Monster, Corpse
Saved
Note

======
RULES
======
[Saved] [Goal] -> [] [HasSavedDoor] (Remembering whether we saved someone last round by temporarily changing some door to a HasSavedDoor. This is purely for sound effects purposes.)

[Corpse] -> Restart

[ >  Fighter | Moveable ] -> [  >  Fighter | > Moveable  ]
[ > Moveable | Moveable ] [ Fighter] -> [ > Moveable | > Moveable ] [ Fighter] (Fighters push.)

[ < Thief | Moveable ] -> [ < Thief | < Moveable ] (Thieves pull.)

[ > Wizard ] -> [ Wizard > Warpball]
[ > Warpball | no Moveable no Static] -> [ | > Warpball]
[ > Warpball | Static] [Wizard] -> [ | Static ] [> Wizard]
[ > Warpball | Moveable ] [Wizard] -> [ | Wizard Sfx0] [Moveable]
[ > Warpball] [Wizard] -> [] [> Wizard]
(Wizards telexport. What they really do is shoot a "warpball", which causes them to move normally if it hits a wall or the edge of the screen and warp if it hits something they can warp with.)

(Druid does his thing. Warpball gets reused as a placeholder here. That's gonna happen a lot.)
[> Druid | Crate] -> [Druid | Wall Sfx8]
[> Druid | Monster] -> [Druid | Wall Sfx8]
[> Druid | Wall] -> [Druid | Crate Sfx8]
[> Druid | Healer] -> [Druid | Healer Saved]
[> Druid | Hero] -> [Druid | Hero Warpball]
[Warpball | Healer] -> [Saved | Healer]
[Warpball Hero] -> [Wall Sfx8]
(What strategic purpose could it serve for healers to protect against petrification? None, but it's fun.)

(I mean, theoretically you could write some horrid dragon breath timing puzzle where the ability to delay an extra turn without moving or switching characters is necessary in order to let you move someone else at the correct moment, but even if dragons still existed, that sounds like a really gross level.)

(Bard moves stuff. Reusing "WarpBall" for totally different purpose, so we can cancel the move if he doesn't move.)
[> Bard no Note] -> [> Note > Bard WarpBall]
[> Note] [Note] -> [> Note] [> Note]
[> Note Moveable | no Static no Moveable no Bard] -> [| Moveable Sfx7]
+[> Note Bard WarpBall| no Static no Moveable no Bard] -> [| Bard]

(Why are we doing this pseudo-movement instead of using the built-in version? Because using movement directions makes the note-adding stuff way easier below, and you can't use movement directions in the LATE phase, so the actual moving has to be done before then.)

[WarpBall] -> Cancel
[Note] -> []

(The following mess is for changing characters. But at least it's less messy than before. Thanks to Stephen for spotting my silly redundancies.)
[ Action Fighter] [SThief] -> [SFighter] [Thief Sfx1]
[ Action Thief] [SWizard] -> [SThief] [Wizard Sfx1]
[ Action Wizard] [SPriest] -> [SWizard] [Priest Sfx1]
[ Action Priest] [SBard] -> [SPriest] [Bard Sfx1]
[ Action Bard] [SDruid] -> [SBard] [Druid Sfx1]
[ Action Druid] [SFighter] -> [SDruid] [Fighter Sfx1]

[ Action Fighter] [SWizard] -> [SFighter] [Wizard Sfx1]
[ Action Thief] [SPriest] -> [SThief] [Priest Sfx1]
[ Action Wizard] [SBard] -> [SWizard] [Bard Sfx1]
[ Action Priest] [SDruid] -> [SPriest] [Druid Sfx1]
[ Action Bard] [SFighter] -> [SBard] [Fighter Sfx1]
[ Action Druid] [SThief] -> [SDruid] [Thief Sfx1]

[ Action Fighter] [SPriest] -> [SFighter] [Priest Sfx1]
[ Action Thief] [SBard] -> [SThief] [Bard Sfx1]
[ Action Wizard] [SDruid] -> [SWizard] [Druid Sfx1]
[ Action Priest] [SFighter] -> [SPriest] [Fighter Sfx1]
[ Action Bard] [SThief] -> [SBard] [Thief Sfx1]
[ Action Druid] [SWizard] -> [SDruid] [Wizard Sfx1]

[ Action Fighter] [SBard] -> [SFighter] [Bard Sfx1]
[ Action Thief] [SDruid] -> [SThief] [Druid Sfx1]
[ Action Wizard] [SFighter] -> [SWizard] [Fighter Sfx1]
[ Action Priest] [SThief] -> [SPriest] [Thief Sfx1]
[ Action Bard] [SWizard] -> [SBard] [Wizard Sfx1]
[ Action Druid] [SPriest] -> [SDruid] [Priest Sfx1]

[ Action Fighter] [SDruid] -> [SFighter] [Druid Sfx1]
[ Action Thief] [SFighter] -> [SThief] [Fighter Sfx1]
[ Action Wizard] [SThief] -> [SWizard] [Thief Sfx1]
[ Action Priest] [SWizard] -> [SPriest] [Wizard Sfx1]
[ Action Bard] [SPriest] -> [SBard] [Priest Sfx1]
[ Action Druid] [SBard] -> [SDruid] [Bard Sfx1]

(Bard plays music. This is my favorite part of the code, btw. Yes, you can make square area effects with just one object!)
[no Note | no Note | Bard] -> [^ Note | ^ Note | Bard]
[no Note | Bard] -> [^ Note | Bard]
[> Note | no Note | no Note] -> [Note | Note | Note]
[> Note | no Note] -> [Note | Note]
[> Note] -> [Note]

(Now enemies attack. Yeah, there's only one kind of enemy now.)

Late [Goblin | Vulnerable] -> [Goblin | Dying Vulnerable]

(Vulnerable objects that are attacked are designated as "Dying", but heroes can be saved by the Priest. Then the stuff that didn't get saved dies.)

Late [Dying Healer] -> [Saved Healer]
Late [Healer | Dying Hero] -> [Healer | Saved Hero]
Late [Dying Monster] -> [Sfx5]
Late [Dying Hero] -> [Corpse Sfx6]

(Doors opening.)

late [Weighing  YellowSwitch] [YellowDoor] -> [Weighing  YellowSwitch] [ShadowDoor]
late [YellowSwitch no Weighing] [YellowOpen] -> [YellowSwitch] [YellowDoor sfx2]
late [YellowSwitch no Weighing] [ShadowDoor] -> [YellowSwitch] [YellowDoor]
late [ShadowDoor] -> [YellowOpen sfx3]

late [Weighing PurpleSwitch] [PurpleDoor] -> [Weighing PurpleSwitch] [ShadowDoor]
late [PurpleSwitch no Weighing] [PurpleOpen] -> [PurpleSwitch] [PurpleDoor sfx2]
late [PurpleSwitch no Weighing] [ShadowDoor] -> [PurpleSwitch] [PurpleDoor]
late [ShadowDoor] -> [PurpleOpen sfx3]

late [MonsterDoor] -> [ShadowDoor]
late [ShadowDoor] [Monster] -> [MonsterDoor] [Monster]
late [ShadowDoor] -> [sfx3]

(Looks for a HasSavedDoor and, if there is one, puts a warpball on the Priest. Then, if someone was saved this turn, plays the sound only if the Priest doesn't have the warpball. Finally, cleans that up.)

late [HasSavedDoor] [Healer] -> [Goal] [Healer WarpBall]
late [Saved] [Healer no WarpBall] -> [Saved sfx4] [Healer]
late [HasSavedDoor] -> [Goal]
late [WarpBall] -> []

late [Note no Moveable] -> []

==============
WINCONDITIONS
==============

All Hero on Goal
All Goal on Hero

=======
LEVELS
=======

Message Many years have passed since the events of Heroes of Sokoban II.

Message Dragons have vanished from the realm, never to be seen again.

Message And new heroes have cropped up, as if there were only room for so many beings in one world.

###################
#.F.#.........#**G#
#***#...*****.#..*#
#.G.#...*...*.#2..#
#####...*...*.#####
#.......*...*.....#
#.......*...*.....#
#####..**..**.#####
#*..#.***.***.#..G#
#*G*#..*...*..#.O.#
#3.*#.........#4..#
###################

Message Purple bard charms nearby crates.

#############
#{#....{#...#
#.#.*#B.[.G.#
#*#.....#...#
#############

###############
#..############
#.B..****.....#
#..######.#####
#########G#####
###############

Message Monsters may also be charmed.

#############
#.......#...#
#...#...#...#
#O..B..OM.G.#
#...#...#...#
#.......#...#
#############

Message No one can resist the bard's music.

############
#G#.F.{..O.#
#.[........#
#G#.5.{..O.#
############

############
##[[[[[[[###
##[#####[###
##[##[[[[{*#
#...#[######
#.T.#......#
#...#.5.G.G#
############

########
#*G{####
###.####
#...[W##
###.#.5#
#*G*####
########

#########
#....G#G#
#.#*..#[#
#.**....#
#.......#
#.{4{B{.#
#...{...#
#########

############
#*.{..{.**{#
############
#B21.......#
##########[#
#.G..G..G..#
############

Message Orange druid turns stone into wood, wood into stone.

#############
#.[.{.2.#.D.#
#.#########.#
#....G.G..#.#
#############

#############
#...#####{{{#
#.D.##...{{{#
#...##.##{{{#
#############
#...#..######
#.1.#..##G.G#
#...#..#[...#
#############

#############
#O*....{...3#
##.####.#####
##.###O.O##G#
##.####.###.#
##D[....###G#
#############

Message Living things may also be turned into stone.

Message Try not to think about the moral implications, and don't do it any more than necessary.

#############
####.4..##G.#
#O..F..OM#.G#
####.6..##G.#
#############

###############
#.............#
#.5.}}}.]]]]].#
#...}}}.]G.G].#
#.D.}}}.]]]]].#
#.............#
###############

#########
#G#####W#
#########
#G#####6#
#########

#############
#......O.G.G#
#.###########
#.###########
#...#########
#B.6#########
#############

################
#...#...########
#.G.#.}.....{[O#
#...#.F.########
#...#...########
#.G.].4.########
#...#...########
#...#.5.########
#.G.#.}.....{[O#
#...#...########
################

#####M########
#G.GM#F.2###O#
#...#M.......#
#G.GM#3.6###O#
#####M########

############
#6######B###
#........###
############
#.#######.4#
#.......##1#
#G.G.G.G##O#
############

###############
#....#O.O#...G#
#..##W...1##..#
#..#O..O..O#.G#
#4.#..OGO..#..#
#..#O..O..O#.G#
#..##2...6##..#
#....#O.O#...G#
###############

Message Get ready.

#######################
#.F.*....#G.G#....*.4.#
#...#....#...#....#...#
#######.........#######
#####.#####O#####.#####
#..##O#..#...#..#O##..#
#.2.*....#G.G#....*.5.#
#..##O#..*...#..#O##..#
#####.####...####.#####
#######..#..*O.*#######
#...###.#######...#...#
#.3.###.##G.G##...#.6.#
#######################

################
#..............#
#.1.4......G.G.#
#..............#
#.2.B......G.G.#
#..............#
#.3.6......G.G.#
#..............#
################

Message Thanks for playing!