title Explod
author CHz
homepage quiteajolt.com

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

Background 
Green  

Goal 
DarkBlue Black
.111.
10001
10001
10001
10001

Wall 
DarkBrown DarkGray
00000
01110
01110
01110
00000

LivePlayer 
PINK
..0..
..0..
.000.
..0..
.0.0.

DeadPlayer
RED
.....
.....
0.0..
.0000
0.0..

Water
Blue

MovementCheck
Black
.....
.....
.....
.....
.....

ExplodingCheck
Black
.....
.....
.....
.....
.....

UnlitBomb3
Black Gray Brown
...22
..2..
.101.
.000.
.101.

UnlitBomb2
Black Gray Brown
...2.
..2..
.101.
.000.
.101.

UnlitBomb1
Black Gray Brown
.....
..2..
.101.
.000.
.101.

(internal)
LitBomb4
BLACK

LitBomb3
Black Gray Brown Yellow
...23
..2..
.101.
.000.
.101.

LitBomb2
Black Gray Brown Yellow
...3.
..2..
.101.
.000.
.101.

LitBomb1
Black Gray Brown Yellow
.....
..3..
.101.
.000.
.101.

Explosion
Red Orange Yellow
0.0.0
.010.
01210
.010.
0.0.0

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

. = Background
# = Wall
P = LivePlayer
G = Goal
W = Water
3 = UnlitBomb3
2 = UnlitBomb2
1 = UnlitBomb1

Player = LivePlayer or DeadPlayer
Bomb = UnlitBomb3 or UnlitBomb2 or UnlitBomb1 or LitBomb4 or LitBomb3 or LitBomb2 or LitBomb1

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

showmessage 89095700
endlevel 83499103
SFX0 93522108 (explosion)
SFX1 7122702 (dead)
SFX2 60043507 (push)
SFX3 57545505 (lighting a bomb)
SFX4 47357104 (douse)
SFX5 10248707 (tick)

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

Background
MovementCheck, ExplodingCheck
Goal, Water
Player, Wall, Bomb
Explosion

======
RULES     
======

(don't let a dead player move)
[ MOVING DeadPlayer ] -> [ STATIONARY DeadPlayer ]

(require movement to tick: set flag under player)
[ Player ] -> [ Player MovementCheck ]

(if this is the 2nd explosion animation frame, we'll say the player moved so the animation isn't cancelled)
[ ExplodingCheck ] [ Player MovementCheck ] -> [ ExplodingCheck ] [ Player no MovementCheck ]

(shove bombs)
[ > LivePlayer | Bomb ] -> [ > LivePlayer | > Bomb ] SFX2

(light bombs that aren't on water; a tick will occur later on this turn, so when we light a bomb we add 1 to its fuse)
[ Action LivePlayer | UnlitBomb3 No Water ] -> [ Action LivePlayer | LitBomb4 No Water ] SFX3
[ Action LivePlayer | UnlitBomb2 No Water ] -> [ Action LivePlayer | LitBomb3 No Water ] SFX3
[ Action LivePlayer | UnlitBomb1 No Water ] -> [ Action LivePlayer | LitBomb2 No Water ] SFX3

(hitting X counts as movement, so clear the movement flag)
[ Action LivePlayer MovementCheck ] -> [ Action LivePlayer ]


(the ticking and movement rules here are fairly order-sensitive 〔ﾟ～ﾟ〕 )

(douse bombs)
late [ LitBomb3 Water ] -> [ UnlitBomb3 Water ] SFX4
late [ LitBomb2 Water ] -> [ UnlitBomb2 Water ] SFX4
late [ LitBomb1 Water ] -> [ UnlitBomb1 Water ] SFX4

(draw/clear explosions)
late [ Explosion ] -> [ ]
late [ ExplodingCheck ] -> [ ]
late [ LitBomb1 ] [ Bomb ] -> [ LitBomb1 ] [ Bomb ExplodingCheck ]
late [ LitBomb1 no Explosion ] -> [ LitBomb1 Explosion ] again
late [ LitBomb1 | no Explosion ] -> [ LitBomb1 | Explosion ]

(explosions blow things up)
late [ LitBomb1 | LivePlayer ] -> [ LitBomb1 | DeadPlayer ] SFX1
late [ LitBomb1 | Wall ] -> [ LitBomb1 | ]
late [ LitBomb1 | UnlitBomb3 ] -> [ LitBomb1 | LitBomb4 ] SFX3
late [ LitBomb1 | UnlitBomb2 ] -> [ LitBomb1 | LitBomb3 ] SFX3
late [ LitBomb1 | UnlitBomb1 ] -> [ LitBomb1 | LitBomb2 ] SFX3
late [ LitBomb1 ] -> [ ] SFX0

(fuse ticking; if ExplodingCheck is set anywhere, then a bomb exploded this frame, so we'll hold off ticking until the next frame so we don't double tick)
late [ LitBomb2 no ExplodingCheck ] -> [ LitBomb1 no ExplodingCheck ] SFX5
late [ LitBomb3 no ExplodingCheck ] -> [ LitBomb2 no ExplodingCheck ] SFX5
late [ LitBomb4 no ExplodingCheck ] -> [ LitBomb3 no ExplodingCheck ]

(require movement to tick: check if the player didn't move and cancel the move if so)
late [ Player MovementCheck ] -> CANCEL
late [ MovementCheck ] -> [ ]

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

some LivePlayer on Goal     

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

message X lights bombs.

.#...#.
.#..1#.
.#...#.
G#.P2#.
.#...#.
.#..3#.
.#...#.

G#....
.#.33.
.#.33.
.#...P

message X causes time to pass too.

3333333.#.
3333333.#.
3.3P3.3.#G
3333333.#.
3333333.#.

..G..
#####
#####
#####
.3P3.
3#3#3
.###.
3###3
.#3#.
.###.

P#...
.332.
###2.
###2.
G#.3.

.3.3.3#######
3.3.3.#######
P3.3.3######G
3.3.3.#######
.3.3.3#######

message Water douses lit fuses.

.#.33WP
.#.33W.
.#.33W.
G#.33W.

.3###G###3.
.3#######3.
.3WWWWWWW3.
.3#######3.
.3#.3P3.#3.

G#W3#
##W3#
W.W3.
..W3.
P.W3.

........P
...WWWWW.
...W333W.
...W333W.
#..W333W.
##.WWWWW.
###......
####.....
G####....

message You are an excellent bomb exploder!
