
// ATTWAR.CON

// define MSPAWNER 5300

action TROOPSPAWNER -3620 1 5 1 1
action OCTASPAWNER    -3480   3   5   1   15
action BEASTSPAWNER -690   2  5  1  40
action PIGSPAWNER -3270 1 5 1 1
action COMMSPAWNER -3380  3  5  1  40
action LIZSPAWNER -3160   2  5  1  40
action TANKSPAWNER  -3325 1 7 1 1
action RECONSPAWNER  -3340 1 7 1 1
action BOSS1SPAWNER -2670  1  5  1  1
action BOSS2SPAWNER -2590 0  1  5  1
action BOSS3SPAWNER -2540  1  5  1  1
action BOSS3MINISPAWNER -2540  1  5  1  1
action BOSS4SPAWNER -510 3  5  1  1
action BOTALLYSPAWNER -3895   1   5   1  1
action MECH2SPAWNER -180    1    8    1    1
action DRONESPAWNER    -3420   1   7   1   1

state boss2set
sizeat 46 46
action BOSS2SPAWNER
ends

state boss3set
sizeat 64 64
action BOSS3SPAWNER
ends

state boss3miniset
sizeat 48 42
action BOSS3MINISPAWNER
ends

state boss4set
sizeat 41 40
action BOSS4SPAWNER
ends

state mech2set
sizeat 38 36
action MECH2SPAWNER

ends

state botallyset
sizeat 42 36
action BOTALLYSPAWNER
ends

state troopset
sizeat 41 40
action TROOPSPAWNER
ends

state droneset
sizeat 41 40
action DRONESPAWNER
ends

state octaset
sizeat 40 40
action OCTASPAWNER
ends

state beastset
sizeat 40 40
action BEASTSPAWNER
ends

state commset
sizeat 41 40
action COMMSPAWNER
ends

state lizset
sizeat 41 40
action LIZSPAWNER
ends

state pigset
sizeat 41 40
action PIGSPAWNER
ends

state reconset
sizeat 48 48
action RECONSPAWNER
ends

state tankset
sizeat 60 60
action TANKSPAWNER
ends

state boss1set
sizeat 40 40
action BOSS1SPAWNER
ends

state spawnmonster

//sound TELEPORTER
//spawn TRANSPORTERSTAR

randvar mtype 100

switch wave
case 0 case 1 case 15
state troopset
break

case 2
ifvarl mtype 80 state troopset else
state octaset
break

case 3
ifvarl mtype 50 state troopset else
ifvarl mtype 80 state octaset else
state beastset
break

case 4
state lizset
break

case 5
ifvarl mtype 65 state droneset else
state commset
break

case 6
case 19
ifvarl mtype 65 state pigset else
ifgapzl 96 state pigset else
ifvarl mtype 85 state reconset else
state tankset
break

case 7
ifgapzl 96 setvar peractor1 0 else
state boss1set
break

case 8
state droneset
break

case 9
case 18
state botallyset
break

case 10
ifgapzl 96 setvar peractor1 0 else // cancel spawn
state boss4set
break

case 11
ifvarl mtype 90 state troopset else // 80
// ifvarl mtype 90 state reconset else
else state boss3miniset
break

case 12
ifgapzl 96 setvar peractor1 0 else // cancel spawn
state boss2set
break

case 13
ifvarl mtype 50 state octaset else
ifvarl mtype 90 state beastset else
state boss4set
break

case 14
ifgapzl 96 setvar peractor1 0 else // cancel spawn
state mech2set
break

case 16
ifvarl mtype 40 state lizset else
ifvarl mtype 60 state commset else
ifvarl mtype 80 state droneset else
ifvarl mtype 90 state boss3miniset else
ifgapzl 96 state boss1set else
state botallyset
break

case 17
ifvarl mtype 80 state beastset else
ifgapzl 128 state beastset else
state reconset
break

case 20
ifvarl mtype 80 state commset else
ifgapzl 96 state commset else
ifvarl mtype 90
state boss1set else
state boss3set
break

case 21
ifgapzl 96 setvar peractor1 0 else // cancel spawn
ifvarl mpoints 2 state mech2set else
ifvarl mpoints 4 state boss4set else
ifvarl mpoints 6 state boss2set else
ifvarl mpoints 7 state boss3set else
state boss1set
break

case 22
state octaset
break

case 23
ifvarl mtype 30 state troopset else
ifvarl mtype 40 state pigset else
ifvarl mtype 50 state lizset else
ifvarl mtype 58 state octaset else
ifvarl mtype 62 { ifgapzl 96 state commset else state tankset } else
ifvarl mtype 70 state droneset else
ifvarl mtype 78 state beastset else
ifvarl mtype 85 { ifgapzl 128 state botallyset else state reconset } else
ifvarl mtype 90 state botallyset else
ifgapzl 96 state botallyset else
ifvarl mtype 96 state boss2set else
state mech2set
break

case 24

ifvarl mtype 35 state droneset else
ifgapzl 128 setvar peractor1 0 else
ifvarl mtype 60 state tankset else
ifvarl mtype 85 state reconset else
state boss1set
break

case 25
ifgapzl 96 state boss3miniset else
ifvarl mtype 60 state boss3miniset else
state boss3set
break

case 26
ifvarl mtype 50 state beastset else
state lizset
break

case 27
ifvarl mpoints 2 state mech2set else
state botallyset
break

case 28
ifvarl mpoints 4
{
	ifgapzl 128 setvar peractor1 0 else
	state boss1set
}
else
ifvarl mtype 30 state troopset else
ifvarl mtype 55 state pigset else
ifvarl mtype 80 state lizset else
state commset
break

case 30
ifvarl mpoints 2 state boss3set else
ifvarl mpoints 6 state mech2set else
ifvarl mpoints 12 state botallyset else
ifvarl mpoints 20 state commset else
state troopset

break

// case 29
default
ifvarl mtype 30 state troopset else
ifvarl mtype 40 state pigset else
ifvarl mtype 50 state lizset else
ifvarl mtype 58 state octaset else
ifvarl mtype 62 { ifgapzl 96 state commset else state tankset } else
ifvarl mtype 70 state droneset else
ifvarl mtype 78 state beastset else
ifvarl mtype 85 { ifgapzl 128 state botallyset else state reconset } else
ifvarl mtype 89 state commset else
ifvarl mtype 93 state botallyset else
ifvarl mtype 95 { ifgapzl 96 state boss3miniset else state boss1set } else
ifvarl mtype 97 { ifgapzl 96 state boss3miniset else state boss2set } else
ifvarl mtype 98 state boss3set else
{ ifgapzl 128 state boss3miniset else state mech2set }
break
endswitch

ifaction ANULLACTION break

subvar mpoints 1
ifvare mpoints 0 // check for strays
{
	setvar A 0
	headspritestat spriteid 1
	whilevarn spriteid -1
	{
		ifvarg actorvar[spriteid].mval 0 addvar A 1 // monster still in the map
		ifvare sprite[spriteid].picnum MSPAWNER
		ifvarn actorvar[spriteid].peractor1 0 addvar A 1 // monster gonna spawn
		nextspritestat spriteid spriteid
	}
	ifvarvarl A mdeaths { setvarvar temp mdeaths subvarvar temp A setvarvar mpoints temp }
}

setvar countvarb 0
cstat 512
spritepal 121

spawn GROUNDWARP
setvar position 56384 // to make it look like it's coming out of the ground

ends

useractor notenemy MSPAWNER 0

// sleeptime 30000
ifvarg position 40000 subvar position 109

ifmove 0
{
	move INIT
	action ANULLACTION
	randvar countvar 1200
	setactor[THISACTOR].mdflags 17
}

ifaction ANULLACTION nullop else
{
	ifspritepal 121 spritepal 0 else
	ifspritepal 0 spritepal 4 else
	spritepal 121
	
	getactor[THISACTOR].cstat temp
	ifvarl countvarb 50
	{
		ifvare temp 512 setvar temp -1 else setvar temp 512
	}
	else
	ifvarl countvarb 100
	{
		ifvare temp 512 setvar temp 2 else setvar temp 512
	}
	else
	{
		ifvare temp 512 setvar temp 2
		ifvare temp 2 setvar temp 0 else setvar temp 2
	}
	setactor[THISACTOR].cstat temp
	
	addvar countvarb 1
	ifvarg countvarb 149
	{
		ifaction TROOPSPAWNER { espawn LIZTROOP ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction LIZSPAWNER { espawn LIZMAN ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction PIGSPAWNER { espawn PIGCOP ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction BEASTSPAWNER espawn NEWBEAST else
		ifaction TANKSPAWNER { espawn TANK ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction OCTASPAWNER espawn OCTABRAIN else
		ifaction RECONSPAWNER espawn RECONDP else
		ifaction BOSS1SPAWNER { espawn BOSS1 ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction BOSS2SPAWNER { espawn BOSS2PALRESPAWN ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction BOSS3SPAWNER
		{
			ifvare wave 30 // final wave
			{
				espawn BOSS3
				setactor[RETURN].pal 0
				setactorvar[RETURN].pal 0
				setactorvar[RETURN].monstflags 18800
				setactorvar[RETURN].mtype 1
			}
			else
			espawn BOSS3PALRESPAWN 
	    }
	    else
		ifaction BOSS3MINISPAWNER 
		{ 
			espawn BOSS3PALRESPAWN
			getactorvar[RETURN].monstflags temp 
			orvar temp 288
			setactorvar[RETURN].monstflags temp
		} else
		ifaction BOSS4SPAWNER 
		{
			espawn BOSS4
			getactorvar[RETURN].monstflags temp 
			ifvare wave 10
			orvar temp 16384
			ifvare wave 21
			orvar temp 16384
			setactorvar[RETURN].monstflags temp
		}
		else
		ifaction COMMSPAWNER { espawn COMMANDER ifrnd 32 setactor[RETURN].htactorstayput sprite[THISACTOR].sectnum } else
		ifaction DRONESPAWNER espawn DRONE else
		ifaction MECH2SPAWNER
		{
			 espawn MECH2
			 ifvare wave 27
			 {
				 setactorvar[RETURN].monstflags 2056
				 setactor[RETURN].pal 57
			 }
			 ifvare wave 30
			 {
				 setactorvar[RETURN].monstflags 2056
				 setactor[RETURN].pal 57
			 }
		}
		else
		ifaction BOTALLYSPAWNER espawn BOTALLY
			
		cstat 32768
		spritepal 0
		setvar peractor1 0
		action ANULLACTION
	}
	break
}

ifvare peractor1 1
{
	setvar peractor1 2
	state spawnmonster
}

enda

useractor notenemy GROUNDWARP 0

ifmove 0
{
	cstat 32
	move INIT
	sizeat 16 16
	setvar tempd 2
	setvar intensity 4096
	setvar pal 17
	state spawnpointlight
}

getactor[THISACTOR].ang angvar
addvar angvar 91
setactor[THISACTOR].ang angvar

ifspritepal 121 spritepal 2 else
ifspritepal 2 spritepal 4 else
spritepal 121

ifcount 111 nullop else
ifcount 110 sound PORTIN
ifcount 150 killit

enda

useractor notenemy RAGESPRITE 0

ifmove 0
{
	move INIT
	sizeat 8 8
	getactor[THISACTOR].z z
	subvar z 6144
	setactor[THISACTOR].z z
	cstat 16
}

getactor[THISACTOR].ang angvar
addvar angvar 48
setactor[THISACTOR].ang angvar

setvar peractor4 0
state moveitem

ifp pshrunk nullop
    else
      ifp palive
        ifpdistl RETRIEVEDISTANCE
          ifcount 6
              ifcanseetarget
                ifvare rage 0
	    {
		    globalsound GETATOMICHEALTH
		    palfrom 50 40
		    setvar ftq 1057 setvar fta 130
		    setvar rage FULLRAGE
		    killit
	    }

enda