
// Create renderer

create D3DRenderer parent root0
link root0 TimeUpdate D3DRenderer TimeUpdate
//subcreate D3DRenderer GlobalEffect script Data\GlobalEffects\X_DepthOfField.txt
//subcreate D3DRenderer GlobalEffect script Data\GlobalEffects\X_MotionBlur.txt


// Create sunlight

subcreate D3DRenderer LightInstance name Light0
set Light0 Colour 0.46 0.48 0.72
set Light0 Intensity 1.3
set Light0 VisInfo 0.0 3.0 2.8 0.0 -0.8 -1.0


// Create scenery

subcreate D3DRenderer RenderInstance name TerrainMesh
set TerrainMesh DataFile Data\Terrain.txt

subcreate D3DRenderer RenderInstance name TownMesh
set TownMesh DataFile Data\Town.txt



subcreate D3DRenderer RenderInstance name Sky
set Sky DataFile Data\SkyBox.txt

// Create input

create DXInput parent root0
link root0 TimeUpdate DXInput TimeUpdate


// Create Audio

create Audio parent root0
link root0 TimeUpdate Audio TimeUpdate


// Create avatar

create Avatar parent root0
set Avatar Position 6.38 2.0 -8.29
set Avatar Look -0.52 -0.16 0.84
set Avatar Up -0.09 0.97 0.14




// Link input to avatar movement

//link DXInput MouseClickLeft Avatar LookMode
link DXInput MouseMove Avatar LookMove
link DXInput Pressed_W Avatar MoveForwards
link DXInput Pressed_S Avatar MoveBackwards
link DXInput Pressed_Q Avatar MoveLeft
link DXInput Pressed_E Avatar MoveRight
link DXInput Pressed_R Avatar MoveUp
link DXInput Pressed_F Avatar MoveDown
link DXInput Pressed_D Avatar StrafeRight
link DXInput Pressed_A Avatar StrafeLeft
link DXInput Hit_C Avatar CameraToggle

// Link avatar outputs

link Avatar Position D3DRenderer CamPos
link Avatar Look D3DRenderer CamLook
link Avatar Up D3DRenderer CamUp

link Avatar Position Audio ListenerPos
link Avatar Look Audio ListenerLook
link Avatar Up Audio ListenerUp



// Create physics engine

create Physics parent root0
link root0 TimeUpdate Physics TimeUpdate

link Avatar Look Physics TargetLook
link Avatar Up Physics TargetUp
set Physics TargetViewAngle 0.95



// Explosion

subcreate D3DRenderer RenderInstance name ExplosionGFX
set ExplosionGFX DataFile Data\Explosion.txt

subcreate Physics PhysicsExplosion
link PhysicsExplosion VisInfo ExplosionGFX VisInfo
link PhysicsExplosion ParticleArray ExplosionGFX ParticleArray
link PhysicsExplosion ShockWaveStrength D3DGlobalEffectExplosion ShockWaveStrength
link PhysicsExplosion ShockWaveSize D3DGlobalEffectExplosion ShockWaveSize 
link PhysicsExplosion GlowStrength D3DGlobalEffectExplosion GlowStrength 
link PhysicsExplosion Position D3DGlobalEffectExplosion Position
link PhysicsExplosion ExplosionAlpha D3DGlobalEffectExplosion ExplosionAlpha
link Avatar Position PhysicsExplosion CameraPosition
link PhysicsExplosion CameraShake D3DRenderer CameraShake




create ExplosionHelper parent root0

set ExplosionHelper TimeModifier 3.0
set ExplosionHelper GasIgnitionRate 40.0
set ExplosionHelper NumGasParticles 13
set ExplosionHelper NumFireParticles 1500
set ExplosionHelper Gravity 0.3
set ExplosionHelper Bouyancy 3.0
set ExplosionHelper SearchRadius 0.2
set ExplosionHelper RestDensity 20.0
set ExplosionHelper PressureK 3.2
set ExplosionHelper TemperatureDiffusion 0.5
set ExplosionHelper VisciousAlpha 0.40
set ExplosionHelper VisciousBeta 0.0

link ExplosionHelper TimeModifier PhysicsExplosion TimeModifier
link ExplosionHelper GasIgnitionRate PhysicsExplosion GasIgnitionRate
link ExplosionHelper NumGasParticles PhysicsExplosion NumGasParticles
link ExplosionHelper NumFireParticles PhysicsExplosion NumFireParticles
link ExplosionHelper Gravity PhysicsExplosion Gravity
link ExplosionHelper Bouyancy PhysicsExplosion Bouyancy
link ExplosionHelper SearchRadius PhysicsExplosion SearchRadius
link ExplosionHelper RestDensity PhysicsExplosion RestDensity
link ExplosionHelper PressureK PhysicsExplosion PressureK
link ExplosionHelper TemperatureDiffusion PhysicsExplosion TemperatureDiffusion
link ExplosionHelper VisciousAlpha PhysicsExplosion VisciousAlpha
link ExplosionHelper VisciousBeta PhysicsExplosion VisciousBeta


subcreate D3DRenderer LightInstance name ExplosionLight
set ExplosionLight Colour 0.9 0.8 0.1
set ExplosionLight Attenuation 1.0 0.6 0.0
set ExplosionLight Intensity 1.3
set ExplosionLight VisInfo 0.0 0.5 00.0 0.0 0.0 1.0
set ExplosionLight Shadows false


subcreate D3DRenderer RenderInstance name BulletMesh
set BulletMesh DataFile Data\Projectile.txt

subcreate Physics PhysicsProjectile
link PhysicsProjectile ProjectilePosition PhysicsExplosion ExplodePosition
link PhysicsProjectile VisInfo BulletMesh VisInfo

subcreate D3DRenderer RenderInstance name ArtilleryBase
set ArtilleryBase DataFile Data\ArtilleryBase.txt
subcreate D3DRenderer RenderInstance name ArtilleryFrame
set ArtilleryFrame DataFile Data\ArtilleryFrame.txt
subcreate D3DRenderer RenderInstance name ArtilleryBarrel
set ArtilleryBarrel DataFile Data\ArtilleryBarrel.txt


create ArtilleryLauncher name Artillery
link Artillery Trigger PhysicsProjectile Trigger
link Artillery AimPosition PhysicsProjectile AimPosition
link Artillery AimDirection PhysicsProjectile AimDirection
link Artillery AimPower PhysicsProjectile AimPower
link Artillery BaseVisInfo ArtilleryBase VisInfo
link Artillery FrameVisInfo ArtilleryFrame VisInfo
link Artillery BarrelVisInfo ArtilleryBarrel VisInfo

link root0 TimeUpdate Artillery TimeUpdate
link DXInput MouseClickLeft Artillery Fire
link DXInput Pressed_Left Artillery RotateLeft
link DXInput Pressed_Right Artillery RotateRight
link DXInput Pressed_Up Artillery TiltUp
link DXInput Pressed_Down Artillery TiltDown


// Create Intro UI

subcreate D3DRenderer RenderEntity2D name IntroPic1
set IntroPic1 Scale 0.5 0.2 0.0
set IntroPic1 Position 0.3 0.2 0.0
set IntroPic1 Texture Data\Textures\shell_intro1.tga

subcreate D3DRenderer RenderEntity2D name IntroPic2
set IntroPic2 Scale 0.6 0.12 0.0
set IntroPic2 Texture Data\Textures\shell_intro2.tga

create IntroUI
link root0 TimeUpdate IntroUI TimeUpdate
link IntroUI Position IntroPic2 Position
link IntroUI Alpha1 IntroPic1 Alpha
link IntroUI Alpha2 IntroPic2 Alpha


// Create quit UI

subcreate D3DRenderer RenderEntity2D name QuitImage
set QuitImage Scale 0.4 0.12 0.0
set QuitImage Position 0.5 0.5 0.0
set QuitImage Texture Data\Textures\exit.tga

create QuitUI
link root0 TimeUpdate QuitUI TimeUpdate
link QuitUI DialogAlpha QuitImage Alpha
link DXInput Hit_Escape QuitUI Quit
link DXInput Hit_Y QuitUI Yes
link DXInput Hit_N QuitUI No
link DXInput Hit_Enter QuitUI Enter


// Create artillery UI

subcreate D3DRenderer RenderEntity2D name RotateBar
set RotateBar Position 0.80 0.94 0.0
set RotateBar Scale 0.2 0.04 0.0
set RotateBar Colour 1.0 1.0 0.0
set RotateBar Texture Data\Textures\rotatebar.tga
set RotateBar Alpha 0.5

subcreate D3DRenderer RenderEntity2D name RotateTick
set RotateTick Position 0.80 0.94 0.0
set RotateTick Scale 0.02 0.04 0.0
set RotateTick Colour 1.0 1.0 0.0
set RotateTick Texture Data\Textures\horiztick.tga
set RotateTick Alpha 0.5

subcreate D3DRenderer RenderEntity2D name TiltBar
set TiltBar Position 0.95 0.83 0.0
set TiltBar Scale 0.04 0.2 0.0
set TiltBar Colour 1.0 1.0 0.0
set TiltBar Texture Data\Textures\tiltbar.tga
set TiltBar Alpha 0.5

subcreate D3DRenderer RenderEntity2D name TiltTick
set TiltTick Position 0.95 0.83 0.0
set TiltTick Scale 0.04 0.02 0.0
set TiltTick Colour 1.0 1.0 0.0
set TiltTick Texture Data\Textures\verttick.tga
set TiltTick Alpha 0.5

subcreate D3DRenderer RenderEntity2D name PowerBar
set PowerBar Position 0.95 0.52 0.0
set PowerBar Scale 0.04 0.2 0.0
set PowerBar Colour 1.0 1.0 0.0
set PowerBar Texture Data\Textures\powerbar.tga
set PowerBar Alpha 0.5

subcreate D3DRenderer RenderEntity2D name PowerTick
set PowerTick Position 0.95 0.52 0.0
set PowerTick Scale 0.04 0.02 0.0
set PowerTick Colour 1.0 1.0 0.0
set PowerTick Texture Data\Textures\verttick.tga
set PowerTick Alpha 0.5

link Artillery RotateTickPos RotateTick Position
link Artillery TiltTickPos TiltTick Position
link Artillery PowerTickPos PowerTick Position


//link DXInput Hit_Space PhysicsExplosion Trigger
//link Avatar Position PhysicsExplosion AimPosition
//link Avatar Look PhysicsExplosion AimDirection

link PhysicsExplosion LightVisInfo ExplosionLight VisInfo
link PhysicsExplosion LightColour ExplosionLight Colour

subcreate Audio SFX name ExplosionSFX script Data\Audio\Explosion.txt
link PhysicsExplosion SoundEvent ExplosionSFX Play


// Debris

subcreate D3DRenderer RenderInstance name Particles
set Particles DataFile Data\Particles.txt

subcreate Physics PhysicsDebris
link PhysicsDebris SmokeParticles Particles ParticleArray
link PhysicsExplosion Position PhysicsDebris DebrisSource




// Ground physics

subcreate Physics PhysicsEntity name TerrainPhysics
set TerrainPhysics AddMaterial Data\PhysicsMaterials\Stone.txt
set TerrainPhysics Density 0.0
set TerrainPhysics AddMesh Data\Meshes\terrain.x
set TerrainPhysics Enable true

subcreate Physics PhysicsEntity name TownPhysics
set TownPhysics AddMaterial Data\PhysicsMaterials\Stone.txt
set TownPhysics Density 0.0
set TownPhysics AddMesh Data\Meshes\town.x
set TownPhysics Enable true

//subcreate Physics PhysicsEntity name TestPhysics
//set TestPhysics AddMaterial Data\PhysicsMaterials\Stone.txt
//set TestPhysics Density 0.0
//set TestPhysics AddShapePos 0.0 0.3 0.0
//set TestPhysics AddBox 20.0 0.1 20.0
//set TestPhysics Enable true




// Load english language by default

open Data\Language\English.txt


create HelpNode parent root0
link HelpNode TextDisplay D3DRenderer TextDisplay
link DXInput Hit_F1 HelpNode Active



open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt
open Data\AddBox.txt

//open Data\AddCar.txt

//create RunScript parent root0 name Run2
//set Run2 ScriptFile Data\AddBox.txt
//link DXInput Hit_G Run2 Execute
