###############################################################################
#
# finale.txt
# original finale scene for XR7: EarthStrike developed by Drake Analytics, Inc.
# www.xandis.com
#
# This is a really lame finale - just shows a minor graphic of the earth
# witnessing a nice peaceful blue particle effect and then a fullscreen image
# showing the people free once again along with music in the background.
#
###############################################################################

def lighting MainAmbientLight
	color = 255 255 255 255
end

def bounds MainBounds
	min = -10.0 -10.0 -10.0
	max = 10.0 10.0 100.0
end

def projection NormalProjection
	nearplane	= 1.0
	farplane	= 100.0
	fov		= 0.7850
	aspect		= 1.0
end

def camera NormalCamera
	lookat	= 0.0 0.0 0.0
	pos	= 0.0 0.0 -10.0
	up	= 0.0 1.0 0.0
end

################## RENDER STATES ######################
#
def renderstate SpriteRenderState
	id		= 3
	zenable		= f
	specularenable	= f
	fogenable	= f
	alphaenable	= t
	lightenable	= f
	fillmode	= SOLID
	shading		= GOURAUD
	lighting	= 255 255 255
	alphasrc	= SRCALPHA
	alphadest	= INVSRCALPHA
	blendop		= ADD
	cull		= NONE
	clipping	= y
end

def renderstate ParticleRenderState
	id		= 2
	zenable		= f
	specularenable	= f
	fogenable	= f
	alphaenable	= t
	lightenable	= f
	fillmode	= SOLID
	shading		= GOURAUD
	lighting	= 255 255 255
	alphasrc	= ONE
	alphadest	= ONE
	blendop		= ADD
	cull		= NONE
	clipping	= y
end

def renderstate ModelRenderState
	id		= 1
	zenable		= t		# update the z-buffer or not
	specularenable	= f		
	fogenable	= f		# rendering with fog or not
	alphaenable	= f		# alpha blending or not
	lightenable	= t		# lighting or not (requires normals if on)
	fillmode	= SOLID		# SOLID | POINT | WIRE  
	shading		= GOURAUD	# GOURAUD | FLAT
	lighting	= 255 255 255	# R G B  (not used; should have an A too!)
	alphasrc	= SRCCOL
	alphadest	= DESTCOL
	blendop		= ADD
	cull		= CCW		# CCW | CW | NONE
	clipping	= y
end

###################### MODELS #####################
#
def model EarthModel
	source		= models\earth.X
	renderstate	= ModelRenderState
end

###################### ACTORS ######################
#
def actor TheEarth
	model			= EarthModel
	numweapons		= 0		# number of weapons at start
	weaponcapacity		= 0		# total number of weapons actor can have
	deathseq		= 0		# sequence that is started when actor dies
	collisionseq		= 0		# sequence that is started when collision occurs w/o shield
	shieldcollisionseq	= 0		# sequence that is started when collision occurs with shieled
	shieldgoneseq		= 0		# sequence that is started when the shield first goes
	shieldcollisioneffect	= 0		# Effect to other actor when it collides with shield
	collisioneffect		= 0		# Effect to other actor when it collides with actor
	maxonscreen		= 1		# The max number of these particular actors that can be on the screen at ONCE
	type			= NEUTRAL	# NEUTRAL | NEUTRALFIRE | PLAYER | PLAYERFIRE | ENEMY | ENEMYFIRE
	collidewith		= ENEMYFIRE		
	partnerseq		= 0		# (not implemented?)
	bounds			= 0		# Used for 'player' only
	drift			= 0.00 0.0 0.0	# Automatic position drift; often weaponfire is not scripted and just drifts
	rotation		= 0.0 0.1 0.0	# Automatic rotation
	script			= 0		# Script that the actor follows
	input			= DRIFT		# SCRIPT | DRIFT | USER | AI0 | AI1 | DRIFTDIE
	copy			= 0		# (not implemented?)
	bounding		= 0		# 0 for no bounding volumes; -1 for all; 1 for just main sphere
	shield			= 0		# Starting strength of shield
	energy			= 100000	# Starting Life; when zero you die
	maxshield		= 100		# Max strength of shield
	maxenergy		= 100		# Max energy
	rot			= 0.0 0.0 0.0	# Starting rotation 
	scale			= 2.5 2.5 2.5	# Starting scale   (starting vals can be superseded by script)
end

###################### SPRITES #####################
#
def sprite BackImage1
	source		= sprites\finale-back-1.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

def sprite BackImage2
	source		= sprites\finale-back-2.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

def sprite BackImage3
	source		= sprites\finale-back-3.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

def sprite BackImage4
	source		= sprites\finale-back-4.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

def sprite BackImage5
	source		= sprites\finale-back-5.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

def sprite BackImage6
	source		= sprites\finale-back-6.bmp
	transformed	= y
	maxonscreen	= 1
	size		= 1.0
	renderstate	= SpriteRenderState
end

###################### BACK IMAGE #####################
#
def backimage BackImage
	numimages	= 6
	image1		= BackImage1
	image2		= BackImage2
	image3		= BackImage3
	image4		= BackImage4
	image5		= BackImage5
	image6		= BackImage6
	pos1		= 16.0	44.0	0.0
	pos2		= 272.0	44.0	0.0
	pos3		= 528.0	44.0	0.0
	pos4		= 16.0	300.0	0.0
	pos5		= 272.0 300.0	0.0
	pos6		= 528.0 300.0	0.0
end

################# PARTICLE #################
#
def particle BlueWave
	texture		= sprites\particle-intro.dds
	renderstate	= ParticleRenderState
	numparticles	= 256
	life		= 256
	startcolor	= 0.0 0.0 1.0 1.0
	coloradjmin	= -0.01  -0.01 -0.01 -0.07
	coloradjmax	= 0.00  -0.01 0.0  0.0
	repeat		= f
	maxonscreen	= 5		# max of these systems on screen not max particles on screen
	size		= 64.0
	posadjmin	=  -0.125  0.0  -0.125
	posadjmax	=   0.125  0.25  0.125
end
	
def particle BlueParticleBlast
	texture		= sprites\particle-intro.dds
	renderstate	= ParticleRenderState
	numparticles	= 256
	life		= 128
	startcolor	= 0.0 0.0 1.0 1.0
	coloradjmin	= -0.01  -0.01 -0.01 -0.07
	coloradjmax	= 0.00  -0.01 0.0  0.0
	repeat		= t
	maxonscreen	= 6		# max of these systems on screen not max particles on screen
	size		= 32.0
	posadjmin	=  -0.25  0.0  -0.25
	posadjmax	=   0.25  0.5  0.25
end

def particle RedParticleBlast
	texture		= sprites\particle-intro.dds
	renderstate	= ParticleRenderState
	numparticles	= 256
	life		= 128
	startcolor	= 1.0 0.0 0.0 1.0
	coloradjmin	= -0.01  -0.01 -0.01 -0.07
	coloradjmax	= 0.00  -0.01 0.0  0.0
	repeat		= t
	maxonscreen	= 6		# max of these systems on screen not max particles on screen
	size		= 32.0
	posadjmin	=  -0.25  0.0  -0.25
	posadjmax	=   0.25  0.5  0.25
end

################# MUSIC AND WAVES #################
#
def music FinaleSceneMusic
	source	= audio\music\classica.mid
	repeats = 1000
end

######## SEQUENCES #########
#
def sequence FinalSeq
	setbackimage		= BackImage
	startparticlehere	= 1.0 -2.0 0.0 RedParticleBlast
	startparticlehere	= -2.0 -3.0 0.0 BlueParticleBlast
	startparticlehere	= 2.0 -2.0 0.0 RedParticleBlast
	startparticlehere	= 0.0 0.0 0.0 BlueParticleBlast
	waitframes			= 30
	startparticlehere	= -2.0 -2.0 0.0 RedParticleBlast
	startparticlehere	= 2.0 -3.0 0.0 BlueParticleBlast
	startparticlehere	= 2.5 -1.0 0.0 RedParticleBlast
	startparticlehere	= -2.5 -1.5 0.0 BlueParticleBlast
	startparticlehere	= 2.0 -2.0 0.0 RedParticleBlast
	waitframes			= 30
	startparticlehere	= -2.0 -3.0 0.0 BlueParticleBlast
	startparticlehere	= -2.0 0.0 0.0 RedParticleBlast
	startparticlehere	= 2.0 -1.0 0.0 BlueParticleBlast
end

########################### SCENE ############################
#
def scene main
	playmusic		= FinaleSceneMusic
	setcamera		= NormalCamera
	setprojection		= NormalProjection
	setambientlight		= MainAmbientLight
	setbackcolor		= 0 0 0			# R G B
	setrenderstate		= SpriteRenderState  	# start off with any old render state
	setbounds		= MainBounds

	startactorhere		= 0.0 0.0 0.0 TheEarth

	startparticlehere	= 0.0 0.0 0.0 BlueWave
	startparticlehere	= 1.0 1.0 0.0 BlueWave
	startparticlehere	= 1.0 -1.0 0.0 BlueWave
	startparticlehere	= -1.0 -1.0 0.0 BlueWave
	startparticlehere	= -1.0 1.0 0.0 BlueWave

	waitframes		= 180
	setbackcolor		= 255 255 255
	killactor		= TheEarth
	startsequence		= FinalSeq
	waitframes		= 40
	waituntilinput
	eos				
end

### END OF SCENE

