//   FILE: Ultra Fusion Tetris v7.2DP.tws
// SOURCE: Ultra Fusion Tetris v7.2DP
//   DATE: Wed, Oct 31, 2001  12:38:02 PM


GeneralInfo
{
	PlayfieldColumns 10
	PlayfieldRows 22
	MaxMovementsPerSecond 15
	MaxRotationsPerSecond 5
	GameType Levels
	RemoveFromBagAfterUse
	NextPieceQueueSize 8
}

MinoSticky
{
	NotStickyBetweenPieces
	1: 1
	2: 2
	3: 3
	4: 4
	5: 5
	6: 6
	7: 7
}

Mino
{
	Name "J"
	Tags 0,1
	MutateMino "Solo Blue"
}

Mino
{
	Name "S"
	Tags 0,2
	MutateMino "Solo Green"
}

Mino
{
	Name "O"
	Tags 0,3
	MutateMino "Solo Yellow"
}

Mino
{
	Name "L"
	Tags 0,4
	MutateMino "Solo Orange"
}

Mino
{
	Name "T"
	Tags 0,5
	MutateMino "Solo Cyan"
}

Mino
{
	Name "I"
	Tags 0,6
	MutateMino "Solo Purple"
}

Mino
{
	Name "Z"
	Tags 0,7
	MutateMino "Solo Red"
}

Mino
{
	Name "Gold"
	Tags 0,10
	MutateMino "Red"
	D0 1
	D1 1
}

Mino
{
	Name "Red"
	Tags 0,11
	D0 1
}

Mino
{
	Name "Garbage"
	Antigravity
	Tags 0,31
}

Mino
{
	Name "Solo Blue"
	Tags 0,20
}

Mino
{
	Name "Solo Green"
	Tags 0,21
}

Mino
{
	Name "Solo Yellow"
	Tags 0,22
}

Mino
{
	Name "Solo Orange"
	Tags 0,23
}

Mino
{
	Name "Solo Cyan"
	Tags 0,24
}

Mino
{
	Name "Solo Purple"
	Tags 0,25
}

Mino
{
	Name "Solo Red"
	Tags 0,26
}

Tetramino
{
	Name "T"
	NumberInBag 1
	ID 1
	MinoList
	{
		"T" (0,1)
		"T" (-1,0)
		"T" (0,0)
		"T" (1,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,0),(1,0),(1,-1),(0,2),(1,2)
	Rot180CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot270CWOffsetList (0,0),(-1,0),(-1,-1),(0,2),(-1,2)
}

Tetramino
{
	Name "J"
	NumberInBag 1
	ID 2
	MinoList
	{
		"J" (-1,1)
		"J" (-1,0)
		"J" (0,0)
		"J" (1,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,0),(1,0),(1,-1),(0,2),(1,2)
	Rot180CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot270CWOffsetList (0,0),(-1,0),(-1,-1),(0,2),(-1,2)
}

Tetramino
{
	Name "L"
	NumberInBag 1
	ID 3
	MinoList
	{
		"L" (1,1)
		"L" (-1,0)
		"L" (0,0)
		"L" (1,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,0),(1,0),(1,-1),(0,2),(1,2)
	Rot180CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot270CWOffsetList (0,0),(-1,0),(-1,-1),(0,2),(-1,2)
}

Tetramino
{
	Name "S"
	NumberInBag 1
	ID 4
	MinoList
	{
		"S" (0,1)
		"S" (1,1)
		"S" (-1,0)
		"S" (0,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,0),(1,0),(1,-1),(0,2),(1,2)
	Rot180CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot270CWOffsetList (0,0),(-1,0),(-1,-1),(0,2),(-1,2)
}

Tetramino
{
	Name "Z"
	NumberInBag 1
	ID 5
	MinoList
	{
		"Z" (-1,1)
		"Z" (0,1)
		"Z" (0,0)
		"Z" (1,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,0),(1,0),(1,-1),(0,2),(1,2)
	Rot180CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot270CWOffsetList (0,0),(-1,0),(-1,-1),(0,2),(-1,2)
}

Tetramino
{
	Name "I"
	NumberInBag 1
	ID 6
	MinoList
	{
		"I" (-1,0)
		"I" (0,0)
		"I" (1,0)
		"I" (2,0)
	}
	Rot0CWOffsetList (0,0),(-1,0),(2,0),(-1,0),(2,0)
	Rot90CWOffsetList (-1,0),(0,0),(0,0),(0,1),(0,-2)
	Rot180CWOffsetList (-1,1),(1,1),(-2,1),(1,0),(-2,0)
	Rot270CWOffsetList (0,1),(0,1),(0,1),(0,-1),(0,2)
}

Tetramino
{
	Name "O"
	NumberInBag 1
	ID 7
	MinoList
	{
		"O" (0,1)
		"O" (1,1)
		"O" (0,0)
		"O" (1,0)
	}
	Rot0CWOffsetList (0,0),(0,0),(0,0),(0,0),(0,0)
	Rot90CWOffsetList (0,-1),(0,-1),(0,-1),(0,-1),(0,-1)
	Rot180CWOffsetList (-1,-1),(-1,-1),(-1,-1),(-1,-1),(-1,-1)
	Rot270CWOffsetList (-1,0),(-1,0),(-1,0),(-1,0),(-1,0)
}

Tetramino
{
	Name "One"
	NumberInBag 3
	ID 8
	MinoList
	{
		"Gold" (0,0)
	}
	Rot0CWOffsetList (0,0)
	Rot90CWOffsetList (0,0)
	Rot180CWOffsetList (0,0)
	Rot270CWOffsetList (0,0)
}

GarbageInfo
{
	NormalMino "Garbage"
	NormalCount 6
}

Shape
{
	Name "tspin1"
	Hotspot (7,8)
	ShapeCoords (6,9),(6,7),(8,7)
}

Shape
{
	Name "tspin2"
	Hotspot (7,8)
	ShapeCoords (6,7),(8,9),(8,7)
}

Pattern
{
	Name "line clear"
	Tags 0
	Method Search
	SearchType Horizontal
	SearchCount 10
	PatternMinoScript
	{
		if mino.d0 = 0
			kill mino
			sound "FX_CLR01"
		else
			set gravity to 1
		line color (136,147,181)
		end
	}
	PatternEndScript
	{
		set st1.d3 to st1.d3 + 1
		set pf.d8 to pf.d8 + 1
		set ph.d0 to 1
	}
}

Pattern
{
	Name "disease"
	Tags 11
	Method Search
	SearchType FloodFill4D
	SearchCount 1
	PatternMinoScript
	{
		pattern "infection" at mino.x, mino.y
	}
}

Pattern
{
	Name "infection"
	Triggered
	Tags 10,11
	Method Search
	SearchType FloodFill4D
	SearchCount 2
	PatternMinoScript
	{
		set st2.d8 to goal
		if mino.d1 = 1
			mutate mino
			sound "FX_FUS02"
		 sound "FX_MTRS4"
			set goal to goal -1
		set st2.d9 to st2.d8 - goal
			set st2.d4 to st2.d4 + 1
			message "Fusion!"
			if level < 6
				sound "VO_FUSION"
			end
			if goal <= 0
				set pf.d0 to 1
			end
		end
	}
}

Pattern
{
	Name "level end"
	Tags 11
	Method Search
	SearchType FloodFill4D
	SearchCount pf.d6 + 1
	PatternMinoScript
	{
	}
	PatternEndScript
	{
		next level
	}
}

Trash
{
	Name "left"
	Height 1
	MinoList
	{
		"Red" (0,0)
		"Garbage" (2,0)
		"Garbage" (4,0)
		"Garbage" (6,0)
		"Garbage" (8,0)
	}
}

Trash
{
	Name "right"
	Height 1
	MinoList
	{
		"Garbage" (1,0)
		"Garbage" (3,0)
		"Garbage" (5,0)
		"Garbage" (7,0)
		"Red" (9,0)
	}
}

Level
{
	Name "Level #1"
}

Level
{
	Name "Level #2"
}

Level
{
	Name "Level #3"
}

Level
{
	Name "Level #4"
}

Level
{
	Name "Level #5"
}

Level
{
	Name "Level #6"
}

Level
{
	Name "Level #7"
}

Level
{
	Name "Level #8"
}

Level
{
	Name "Level #9"
}

Level
{
	Name "Level #10"
}

Level
{
	Name "Level #11"
}

Level
{
	Name "Level #12"
}

Level
{
	Name "Level #13"
}

Level
{
	Name "Level #14"
}

Level
{
	Name "Level #15"
}

GenerationPhase
{
	GenerationTime ((.8-((level-1)*.007))^(level-1))/20
	PieceStartingLocation (4,0)
	GenerationBeginScript
	{
		set pf.d2 to 1
		set pf.d4 to 0
	}
	GenerationEndScript
	{
		set st0.d4 to st0.d4 + 1
		set pf.d9 to 0
	}
}

FallingPhase
{
	FallSpeed (.8-((level-1)*.007))^(level-1)
	SoftDropSpeed ((.8-((level-1)*.007))^(level-1))/20
	HardDropSpeed 0.0001
	MoveTolerance 1
}

LockPhase
{
	MovementRestartsClock
	Duration 0.5
}

PatternPhase
{
	PatternBeginScript
	{
		set pf.d8 to 0
		set pf.d0 to 0
		set ph.d0 to 0
	}
	PatternEndScript
	{
		if ph.d0 = 1
			set pf.d9 to pf.d9 + 1
		end
	}
}

IteratePhase
{
	IterateBeginScript
	{
		set st2.d5 to 0
	}
	SecondaryIterator
	{
		MinoIteratorScript
		{
			if mino.d1 = 1
			 set st2.d5 to st2.d5 + 1
			end
		}
	}
}

EliminatePhase
{
	FallSpeed 0.05
	EliminateBeginScript
	{
		set ph.d0 to pf.d8
	}
	GroupLandedScript
	{
		sound "FX_LNE01"
	}
	EliminateEndScript
	{
		if ph.d0 > st1.d6
			set st1.d6 to ph.d0
		end
		if goal < 0
		 set goal to 0
		end
	}
}

SolidifyPhase
{
}

GravityPhase
{
	FallSpeed 0.05
	GroupLandedScript
	{
		sound "FX_LOCK"
	}
	GravityEndScript
	{
		set gravity to 0
	}
}

CompletionPhase
{
	CompletionBeginScript
	{
			set st1.d4 to st1.d4 + pf.d9
		if st1.d4 > 0
			if pf.d9 > st1.d5
				set st1.d5 to pf.d9
			end
		end
		if pf.d9 > st1.d5
			set st1.d5 to pf.d9
		end
		if pf.d9 = 2
		message "2 Cascades"
		line color (109,0,23)
		end
		if pf.d9 = 3
		message "3 Cascades"
		line color (39,0,87)
		end
		if pf.d9 = 4
		message "4 Cascades"
		line color (39,0,87)
		end
		if pf.d9 = 5
		message "5 Cascades"
		line color (116,55,0)
		end
		if pf.d9 = 6
		message "6 Cascades"
		line color (116,55,0)
		end
		if pf.d9 = 7
		message "7 Cascades"
		line color (0,91,56)
		end
		if pf.d9 = 8
			message "8 Cascades"
		line color (0,91,56)
		end
		if pf.d9 = 9
			message "9 Cascades"
		line color (118,119,0)
		end
		if pf.d9 = 10
			message "10 Cascades"
		line color (118,119,0)
		end
		if pf.d9 >= 11
			message "Super Cascade!!!"
		line color (0,36,154)
		end
		if goal <= 0
			next level
			if level < 15
				sound "FX_LEVEL"
			end
		end
	}
}

EventScripts
{
	GameStartScript
	{
		sound "FX_LEVEL"
		set ghost to 1
		set st2.d4 to 0
		set st2.d5 to 0
		set st0.d4 to 0
		set st0.d5 to 0
		set st0.d7 to 0
		set st0.d8 to 0
		set st1.d3 to 0
		set st1.d4 to 0
		set st1.d5 to 0
		set st1.d6 to 0
		line color (30,30,30)
	}
	LevelStartScript
	{
		mino intensity high
		mixed garbage level
		if ((level/2) - (level\2)) = 0
			trash "left"
		else
			trash "right"
		end
		set pf.d6 to level * 2
		set goal to pf.d6
		set pf.d7 to 0
	}
	LevelEndScript
	{
		if level >= 15
		 sound "VO_EXLNT"
		 win
		end
	}
	MoveSuccessfulScript
	{
		sound "FX_FALL"
		set st0.d5 to st0.d5 + 1
	}
	MoveFailedScript
	{
		sound "FX_LND01"
		set st0.d5 to st0.d5 + 1
	}
	RotateSuccessfulScript
	{
		sound "FX_RTA01"
		set st0.d5 to st0.d5 + 1
	}
	RotateFailedScript
	{
		sound "FX_LND01"
		set st0.d5 to st0.d5 + 1
	}
	HardDropStartScript
	{
		sound "FX_HRDDP"
		set st0.d5 to st0.d5 + 1
		set pf.d2 to 0
	}
	SoftDropStepScript
	{
		sound "FX_FALL"
		set st0.d5 to st0.d5 + 1
	}
	FallStepScript
	{
		sound "FX_FALL"
	}
	TouchdownScript
	{
		if pf.d2
		 sound "FX_LND01"
		end
	}
	LockdownScript
	{
		if pf.d2
		 sound "FX_LCK01"
		end
		if piece.id = 1
			if spin
				shape "T-spin1" at piece.x, piece.y
				if result = 1
		   if level < 6
		    sound "VO_TSPIN"
		   else
		    sound "FX_RWD01"
		   end 
					set pf.d4 to 1
				else
					shape "T-spin2" at piece.x, piece.y
					if result = 1
		    if level < 6
		     sound "VO_TSPIN"
		    else
		     sound "FX_RWD01"
		    end 
						set pf.d4 to 1
					end
				end
			end
		end
	}
	GameSecondScript
	{
		set st0.d8 to game time
	}
	LevelSecondScript
	{
		set st0.d7 to level time
	}
}

CustomEvent
{
	Name "Countdown"
	TriggerType LevelTime 109
	Script
	{
		message "COUNTDOWN!"
	}
}

CustomEvent
{
	Name "10"
	TriggerType LevelTime 110
	Script
	{
		sound "FX_TIC10"
	}
}

CustomEvent
{
	Name "9"
	TriggerType LevelTime 111
	Script
	{
		sound "FX_TIC09"
	}
}

CustomEvent
{
	Name "8"
	TriggerType LevelTime 112
	Script
	{
		sound "FX_TIC08"
	}
}

CustomEvent
{
	Name "7"
	TriggerType LevelTime 113
	Script
	{
		sound "FX_TIC07"
	}
}

CustomEvent
{
	Name "6"
	TriggerType LevelTime 114
	Script
	{
		sound "FX_TIC06"
	}
}

CustomEvent
{
	Name "5"
	TriggerType LevelTime 115
	Script
	{
		sound "FX_TIC05"
	}
}

CustomEvent
{
	Name "4"
	TriggerType LevelTime 116
	Script
	{
		sound "FX_TIC04"
	}
}

CustomEvent
{
	Name "3"
	TriggerType LevelTime 117
	Script
	{
		sound "FX_TIC03"
	}
}

CustomEvent
{
	Name "2"
	TriggerType LevelTime 118
	Script
	{
		sound "FX_TIC02"
	}
}

CustomEvent
{
	Name "1"
	TriggerType LevelTime 119
	Script
	{
		sound "FX_TIC01"
	}
}
