/*==============================================================================

THE WIZARD (...the real one)

==============================================================================*/

$cd /raid/quake/id1/models/boss2
$origin 0 0 -24
$base base
$skin skin

//==============================================================================
// Animation
//==============================================================================

$frame mesh

$frame idle1 idle2 idle3 idle4 idle5 idle6 idle7 idle8 idle9 idle10 idle11 idle12 idle13 idle14 idle15 idle16 idle17 idle18 idle19 idle20 idle21

$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 walk10 walk11 walk12 walk13 walk14 walk15 walk16 walk17 walk18 walk19

$frame run1 run2 run3 run4 run5 run6 run7 run8 run9 run10 run11

$frame runb1 runb2 runb3 runb4 runb5 runb6 runb7 runb8 runb9 runb10 runb11 runb12 runb13

//frame rangeda11 is duplicate but I'm lazy
$frame rangeda1 rangeda2 rangeda3 rangeda4 rangeda5 rangeda6 rangeda7 rangeda8 rangeda9 rangeda10 rangeda11 rangeda12 rangeda13 rangeda14 rangeda15 rangeda16 rangeda17 rangeda18 rangeda19 rangeda20

$frame rangedb1 rangedb2 rangedb3 rangedb4 rangedb5 rangedb6 rangedb7 rangedb8 rangedb9 rangedb10 rangedb11 rangedb12 rangedb13 rangedb14 rangedb15 rangedb16 rangedb17 rangedb18 rangedb19 rangedb20 rangedb21 rangedb22 rangedb23 rangedb24 rangedb25

$frame rangedc1 rangedc2 rangedc3 rangedc4 rangedc5 rangedc6 rangedc7 rangedc8 rangedc9 rangedc10 rangedc11 rangedc12 rangedc13 rangedc14 rangedc15 rangedc16 rangedc17 rangedc18 rangedc19 rangedc20 rangedc21 rangedc22 rangedc23 rangedc24 rangedc25 rangedc26 rangedc27 rangedc28 rangedc29 rangedc30

$frame spellb1 spellb2 spellb3 spellb4 spellb5 spellb6 spellb7 spellb8 spellb9 spellb10 spellb11 spellb12 spellb13 spellb14 spellb15 spellb16 spellb17 spellb18 spellb19 spellb20 spellb21 spellb22 spellb23 spellb24 spellb25 spellb26 spellb27 spellb28 spellb29 spellb30 spellb31 spellb32 spellb33

//==============================================================================
// Prototypes
//==============================================================================

void() Boss2_Melee;

//==============================================================================
// Definitions
//==============================================================================

//Stand
void() boss2_stand1		=[	$idle1,		boss2_stand2 ]	{ai_stand();};
void() boss2_stand2		=[	$idle2,		boss2_stand3 ]	{ai_stand();};
void() boss2_stand3		=[	$idle3,		boss2_stand4 ]	{ai_stand();};
void() boss2_stand4		=[	$idle4,		boss2_stand5 ]	{ai_stand();};
void() boss2_stand5		=[	$idle5,		boss2_stand6 ]	{ai_stand();};
void() boss2_stand6		=[	$idle6,		boss2_stand7 ]	{ai_stand();};
void() boss2_stand7		=[	$idle7,		boss2_stand8 ]	{ai_stand();};
void() boss2_stand8		=[	$idle8,		boss2_stand9 ]	{ai_stand();};
void() boss2_stand9		=[	$idle9,		boss2_stand10 ]	{ai_stand();};
void() boss2_stand10	=[	$idle10,	boss2_stand11 ]	{ai_stand();};
void() boss2_stand11	=[	$idle11,	boss2_stand12 ]	{ai_stand();};
void() boss2_stand12	=[	$idle12,	boss2_stand13 ]	{ai_stand();};
void() boss2_stand13	=[	$idle13,	boss2_stand14 ]	{ai_stand();};
void() boss2_stand14	=[	$idle14,	boss2_stand15 ]	{ai_stand();};
void() boss2_stand15	=[	$idle15,	boss2_stand16 ]	{ai_stand();};
void() boss2_stand16	=[	$idle16,	boss2_stand17 ]	{ai_stand();};
void() boss2_stand17	=[	$idle17,	boss2_stand18 ]	{ai_stand();};
void() boss2_stand18	=[	$idle18,	boss2_stand19 ]	{ai_stand();};
void() boss2_stand19	=[	$idle19,	boss2_stand20 ]	{ai_stand();};
void() boss2_stand20	=[	$idle20,	boss2_stand21 ]	{ai_stand();};
void() boss2_stand21	=[	$idle21,	boss2_stand1 ]	{ai_stand();};

//Walk
void() boss2_walk1	=[	$walk1,  boss2_walk2	]	{ai_walk(8);};  //flat values are shit, fix them
void() boss2_walk2	=[	$walk2,  boss2_walk3	]	{ai_walk(8);};
void() boss2_walk3	=[	$walk3,  boss2_walk4	]	{ai_walk(8);};
void() boss2_walk4	=[	$walk4,  boss2_walk5	]	{ai_walk(8);};
void() boss2_walk5	=[	$walk5,  boss2_walk12	]	{ai_walk(8);};
void() boss2_walk6	=[	$walk6,  boss2_walk7	]	{ai_walk(8);};
void() boss2_walk7	=[	$walk7,  boss2_walk8	]	{ai_walk(8);};
void() boss2_walk8	=[	$walk8,  boss2_walk9	]	{ai_walk(8);};
void() boss2_walk9	=[	$walk9,  boss2_walk10	]	{ai_walk(8);};
void() boss2_walk10	=[	$walk10, boss2_walk11	]	{ai_walk(8);};
void() boss2_walk11	=[	$walk11, boss2_walk12	]	{ai_walk(8);};
void() boss2_walk12	=[	$walk12, boss2_walk13	]	{ai_walk(8);};
void() boss2_walk13	=[	$walk13, boss2_walk14	]	{ai_walk(8);};
void() boss2_walk14	=[	$walk14, boss2_walk15	]	{ai_walk(8);};
void() boss2_walk15	=[	$walk15, boss2_walk16	]	{ai_walk(8);};
void() boss2_walk16	=[	$walk16, boss2_walk17	]	{ai_walk(8);};
void() boss2_walk17	=[	$walk17, boss2_walk18	]	{ai_walk(8);};
void() boss2_walk18	=[	$walk18, boss2_walk19	]	{ai_walk(8);};
void() boss2_walk19	=[	$walk19, boss2_walk1	]	{ai_walk(8);};

// Run
void() boss2_run1	=[	$run1,	boss2_run2		]	{ai_run(16);};
void() boss2_run2	=[	$run2,	boss2_run3		]	{ai_run(16);};
void() boss2_run3	=[	$run3,	boss2_run4		]	{ai_run(16);};
void() boss2_run4	=[	$run4,	boss2_run5		]	{ai_run(16);};
void() boss2_run5	=[	$run5,	boss2_run6		]	{ai_run(16);};
void() boss2_run6	=[	$run6,	boss2_run7		]	{ai_run(16);};
void() boss2_run7	=[	$run7,	boss2_run8		]	{ai_run(16);};
void() boss2_run8	=[	$run8,	boss2_run9		]	{ai_run(16);};
void() boss2_run9	=[	$run9,	boss2_run10		]	{ai_run(16);};
void() boss2_run10	=[	$run10,	boss2_run11		]	{ai_run(16);};
void() boss2_run11	=[	$run11,	boss2_run1		]	{ai_run(16);};

// Injured Run
void() boss2_runb1	=[	$runb1,		boss2_runb2			]	{ai_run(8);};	//ijed Waiting for new ai_escape function
void() boss2_runb2	=[	$runb2,		boss2_runb3			]	{ai_run(8);};
void() boss2_runb3	=[	$runb3,		boss2_runb4			]	{ai_run(8);};
void() boss2_runb4	=[	$runb4,		boss2_runb5			]	{ai_run(8);};
void() boss2_runb5	=[	$runb5,		boss2_runb6			]	{ai_run(8);};
void() boss2_runb6	=[	$runb6,		boss2_runb7			]	{ai_run(8);};
void() boss2_runb7	=[	$runb7,		boss2_runb8			]	{ai_run(8);};
void() boss2_runb8	=[	$runb8,		boss2_runb9			]	{ai_run(8);};
void() boss2_runb9	=[	$runb9,		boss2_runb10		]	{ai_run(8);};
void() boss2_runb10	=[	$runb10,	boss2_runb11		]	{ai_run(8);};
void() boss2_runb11	=[	$runb11,	boss2_runb12		]	{ai_run(8);};
void() boss2_runb12	=[	$runb12,	boss2_runb13		]	{ai_run(8);};
void() boss2_runb13	=[	$runb13,	boss2_runb1			]	{ai_run(8);};

//Melee #1 Right Handed Claw Swipe
void() boss2_meleea1	=[	$rangeda1,	boss2_meleea2		]	{};
void() boss2_meleea2	=[	$rangeda2,	boss2_meleea3		]	{};
void() boss2_meleea3	=[	$rangeda3,	boss2_meleea4		]	{};
void() boss2_meleea4	=[	$rangeda4,	boss2_meleea5		]	{ai_charge(0);};
void() boss2_meleea5	=[	$rangeda5,	boss2_meleea6		]	{ai_charge(3);};
void() boss2_meleea6	=[	$rangeda6,	boss2_meleea7		]	{ai_charge(4);};
void() boss2_meleea7	=[	$rangeda7,	boss2_meleea8		]	{ai_charge(5); Boss2_Melee();};
void() boss2_meleea8	=[	$rangeda8,	boss2_meleea9		]	{ai_charge(6);};
void() boss2_meleea9	=[	$rangeda9,	boss2_meleea10		]	{ai_charge(3);};
void() boss2_meleea10	=[	$rangeda10,	boss2_runb11		]	{ai_charge(1);};

//Melee #2 Left Handed Claw Swipe
void() boss2_meleeb1	=[	$rangeda12,	boss2_meleeb2		]	{};
void() boss2_meleeb2	=[	$rangeda13,	boss2_meleeb3		]	{};
void() boss2_meleeb3	=[	$rangeda14,	boss2_meleeb4		]	{};
void() boss2_meleeb4	=[	$rangeda15,	boss2_meleeb5		]	{ai_charge(3);};
void() boss2_meleeb5	=[	$rangeda16,	boss2_meleeb6		]	{ai_charge(4);};
void() boss2_meleeb6	=[	$rangeda17,	boss2_meleeb7		]	{ai_charge(5); Boss2_Melee();};
void() boss2_meleeb7	=[	$rangeda18,	boss2_meleeb8		]	{ai_charge(6);};
void() boss2_meleeb8	=[	$rangeda19,	boss2_meleeb9		]	{ai_charge(3);};
void() boss2_meleeb9	=[	$rangeda20,	boss2_runb11		]	{ai_charge(1);};

//Ranged Attack #1
void() boss2_rangeda1	=[	$rangeda1,	boss2_rangeda2 ]	{ai_face();};
void() boss2_rangeda2	=[	$rangeda2,	boss2_rangeda3 ]	{ai_face();};
void() boss2_rangeda3	=[	$rangeda3,	boss2_rangeda4 ]	{ai_face();};
void() boss2_rangeda4	=[	$rangeda4,	boss2_rangeda5 ]	{ai_face();};
void() boss2_rangeda5	=[	$rangeda5,	boss2_rangeda6 ]	{ai_face();};
void() boss2_rangeda6	=[	$rangeda6,	boss2_rangeda7 ]	{ai_face();};
void() boss2_rangeda7	=[	$rangeda7,	boss2_rangeda8 ]	{ai_face(); M_FireGrenade('0 0 0');};
void() boss2_rangeda8	=[	$rangeda8,	boss2_rangeda9 ]	{ai_face();};
void() boss2_rangeda9	=[	$rangeda9,	boss2_rangeda10 ]	{ai_face();};
void() boss2_rangeda10	=[	$rangeda10,	boss2_rangeda11 ]	{ai_face();};
void() boss2_rangeda11	=[	$rangeda11,	boss2_rangeda12 ]	{ai_face();};
void() boss2_rangeda12	=[	$rangeda12,	boss2_rangeda13 ]	{ai_face();};
void() boss2_rangeda13	=[	$rangeda13,	boss2_rangeda14 ]	{ai_face();};
void() boss2_rangeda14	=[	$rangeda14,	boss2_rangeda15 ]	{ai_face();};
void() boss2_rangeda15	=[	$rangeda15,	boss2_rangeda16 ]	{ai_face();};
void() boss2_rangeda16	=[	$rangeda16,	boss2_rangeda17 ]	{ai_face();};
void() boss2_rangeda17	=[	$rangeda17,	boss2_rangeda18 ]	{ai_face(); M_FireGrenade('0 0 0');};
void() boss2_rangeda18	=[	$rangeda18,	boss2_rangeda19 ]	{ai_face();};
void() boss2_rangeda19	=[	$rangeda19,	boss2_rangeda20 ]	{ai_face();};
void() boss2_rangeda20	=[	$rangeda20,	boss2_run1		]	{ai_face();};

//Ranged Attack #2
void() boss2_rangedb1	=[	$rangedb1,	boss2_rangedb2 ]	{};
void() boss2_rangedb2	=[	$rangedb2,	boss2_rangedb3 ]	{}; 
void() boss2_rangedb3	=[	$rangedb3,	boss2_rangedb4 ]	{};
void() boss2_rangedb4	=[	$rangedb4,	boss2_rangedb5 ]	{};
void() boss2_rangedb5	=[	$rangedb5,	boss2_rangedb6 ]	{};
void() boss2_rangedb6	=[	$rangedb6,	boss2_rangedb7 ]	{};
void() boss2_rangedb7	=[	$rangedb7,	boss2_rangedb8 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb8	=[	$rangedb8,	boss2_rangedb9 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb9	=[	$rangedb9,	boss2_rangedb10 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb10	=[	$rangedb10,	boss2_rangedb11 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb11	=[	$rangedb11,	boss2_rangedb12 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb12	=[	$rangedb12,	boss2_rangedb13 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb13	=[	$rangedb13,	boss2_rangedb14 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb14	=[	$rangedb14,	boss2_rangedb15 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb15	=[	$rangedb15,	boss2_rangedb16 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb16	=[	$rangedb16,	boss2_rangedb17 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb17	=[	$rangedb17,	boss2_rangedb18 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb18	=[	$rangedb18,	boss2_rangedb19 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb19	=[	$rangedb19,	boss2_rangedb20 ]	{HomingMissile(DEATHORB);};
void() boss2_rangedb20	=[	$rangedb20,	boss2_rangedb21 ]	{};
void() boss2_rangedb21	=[	$rangedb21,	boss2_rangedb22 ]	{};
void() boss2_rangedb22	=[	$rangedb22,	boss2_rangedb23 ]	{};
void() boss2_rangedb23	=[	$rangedb23,	boss2_rangedb24 ]	{};
void() boss2_rangedb24	=[	$rangedb24,	boss2_rangedb25 ]	{};
void() boss2_rangedb25	=[	$rangedb25,	boss2_run1		]	{};

//Ranged3 DeathStrike 
void() boss2_rangedc1	=[	$rangedc1,	boss2_rangedc2	]	{};
void() boss2_rangedc2	=[	$rangedc2,	boss2_rangedc3	]	{}; 
void() boss2_rangedc3	=[	$rangedc3,	boss2_rangedc4	]	{};
void() boss2_rangedc4	=[	$rangedc4,	boss2_rangedc5	]	{};
void() boss2_rangedc5	=[	$rangedc5,	boss2_rangedc6	]	{};
void() boss2_rangedc6	=[	$rangedc6,	boss2_rangedc7	]	{};
void() boss2_rangedc7	=[	$rangedc7,	boss2_rangedc8 	]	{};
void() boss2_rangedc8	=[	$rangedc8,	boss2_rangedc9 	]	{};
void() boss2_rangedc9	=[	$rangedc9,	boss2_rangedc10	]	{};
void() boss2_rangedc10	=[	$rangedc10,	boss2_rangedc11	]	{};
void() boss2_rangedc11	=[	$rangedc11,	boss2_rangedc12	]	{};
void() boss2_rangedc12	=[	$rangedc12,	boss2_rangedc13	]	{};
void() boss2_rangedc13	=[	$rangedc13,	boss2_rangedc14	]	{};
void() boss2_rangedc14	=[	$rangedc14,	boss2_rangedc15	]	{};
void() boss2_rangedc15	=[	$rangedc15,	boss2_rangedc16	]	{};
void() boss2_rangedc16	=[	$rangedc16,	boss2_rangedc17	]	{};
void() boss2_rangedc17	=[	$rangedc17,	boss2_rangedc18	]	{};
void() boss2_rangedc18	=[	$rangedc18,	boss2_rangedc19	]	{};
void() boss2_rangedc19	=[	$rangedc19,	boss2_rangedc20	]	{};
void() boss2_rangedc20	=[	$rangedc20,	boss2_rangedc21	]	{};	
void() boss2_rangedc21	=[	$rangedc21,	boss2_rangedc22	]	{};
void() boss2_rangedc22	=[	$rangedc22,	boss2_rangedc23	]	{};
void() boss2_rangedc23	=[	$rangedc23,	boss2_rangedc24	]	{};
void() boss2_rangedc24	=[	$rangedc24,	boss2_rangedc25	]	{};
void() boss2_rangedc25	=[	$rangedc25,	boss2_rangedc26	]	{};	
void() boss2_rangedc26	=[	$rangedc26,	boss2_rangedc27	]	{};
void() boss2_rangedc27	=[	$rangedc27,	boss2_rangedc28	]	{};
void() boss2_rangedc28	=[	$rangedc28,	boss2_rangedc29	]	{};
void() boss2_rangedc29	=[	$rangedc29,	boss2_rangedc30	]	{};
void() boss2_rangedc30	=[	$rangedc30,	boss2_run1		]	{};

//Spell2 Regeneration (called from pain)
void() boss2_regenerate1	=[	$spellb1,	boss2_regenerate2	]	{};
void() boss2_regenerate2	=[	$spellb2,	boss2_regenerate3	]	{}; 
void() boss2_regenerate3	=[	$spellb3,	boss2_regenerate4	]	{};
void() boss2_regenerate4	=[	$spellb4,	boss2_regenerate5	]	{};
void() boss2_regenerate5	=[	$spellb5,	boss2_regenerate6	]	{};
void() boss2_regenerate6	=[	$spellb6,	boss2_regenerate7	]	{};
void() boss2_regenerate7	=[	$spellb7,	boss2_regenerate8 	]	{};
void() boss2_regenerate8	=[	$spellb8,	boss2_regenerate9 	]	{};
void() boss2_regenerate9	=[	$spellb9,	boss2_regenerate10	]	{};
void() boss2_regenerate10	=[	$spellb10,	boss2_regenerate11	]	{};
void() boss2_regenerate11	=[	$spellb11,	boss2_regenerate12	]	{SPL_HealSelf(10);};
void() boss2_regenerate12	=[	$spellb12,	boss2_regenerate13	]	{SPL_HealSelf(10);};
void() boss2_regenerate13	=[	$spellb13,	boss2_regenerate14	]	{SPL_HealSelf(10);};
void() boss2_regenerate14	=[	$spellb14,	boss2_regenerate15	]	{SPL_HealSelf(10);};
void() boss2_regenerate15	=[	$spellb15,	boss2_regenerate16	]	{SPL_HealSelf(10);};
void() boss2_regenerate16	=[	$spellb16,	boss2_regenerate17	]	{SPL_HealSelf(10);};
void() boss2_regenerate17	=[	$spellb17,	boss2_regenerate18	]	{SPL_HealSelf(10);};
void() boss2_regenerate18	=[	$spellb18,	boss2_regenerate19	]	{SPL_HealSelf(10);};
void() boss2_regenerate19	=[	$spellb19,	boss2_regenerate20	]	{SPL_HealSelf(10);};
void() boss2_regenerate20	=[	$spellb20,	boss2_regenerate21	]	{SPL_HealSelf(10);};	//FIXME This should be an infinite loop until the player does enough damage to cause pain
void() boss2_regenerate21	=[	$spellb21,	boss2_regenerate22	]	{SPL_HealSelf(10);};
void() boss2_regenerate22	=[	$spellb22,	boss2_regenerate23	]	{SPL_HealSelf(10);};
void() boss2_regenerate23	=[	$spellb23,	boss2_regenerate24	]	{};
void() boss2_regenerate24	=[	$spellb24,	boss2_regenerate25	]	{};
void() boss2_regenerate25	=[	$spellb25,	boss2_regenerate26	]	{};
void() boss2_regenerate26	=[	$spellb26,	boss2_regenerate27	]	{};
void() boss2_regenerate27	=[	$spellb27,	boss2_regenerate28	]	{};
void() boss2_regenerate28	=[	$spellb28,	boss2_regenerate29	]	{};
void() boss2_regenerate29	=[	$spellb29,	boss2_regenerate30	]	{};
void() boss2_regenerate30	=[	$spellb30,	boss2_regenerate31	]	{};
void() boss2_regenerate31	=[	$spellb31,	boss2_regenerate32	]	{};
void() boss2_regenerate32	=[	$spellb32,	boss2_regenerate33	]	{};
void() boss2_regenerate33	=[	$spellb33,	boss2_run1			]	{};

//Spell3 Summoning -> Fiends or Mirror Images
void() boss2_summon1	=[	$rangedc1,	boss2_summon2	]	{};
void() boss2_summon2	=[	$rangedc2,	boss2_summon3	]	{}; 
void() boss2_summon3	=[	$rangedc3,	boss2_summon4	]	{};
void() boss2_summon4	=[	$rangedc4,	boss2_summon5	]	{};
void() boss2_summon5	=[	$rangedc5,	boss2_summon6	]	{SPL_Summon(0);};
void() boss2_summon6	=[	$rangedc6,	boss2_summon7	]	{};
void() boss2_summon7	=[	$rangedc7,	boss2_summon8 	]	{SPL_Summon(0);};
void() boss2_summon8	=[	$rangedc8,	boss2_summon9 	]	{};
void() boss2_summon9	=[	$rangedc9,	boss2_summon10	]	{SPL_Summon(0);};
void() boss2_summon10	=[	$rangedc10,	boss2_summon11	]	{};
void() boss2_summon11	=[	$rangedc27,	boss2_summon12	]	{};
void() boss2_summon12	=[	$rangedc28,	boss2_summon13	]	{};
void() boss2_summon13	=[	$rangedc29,	boss2_summon14	]	{};
void() boss2_summon14	=[	$rangedc30,	boss2_run1		]	{};

//==============================================================================
// Abilities
//==============================================================================

void()	Boss2_Melee =
{
	local vector	ShoveDir;
	local	float	ldmg;
	local vector	delta, enemyorg;

	ai_face ();
	walkmove (self.ideal_yaw, 12);	// allow a little closing

	// Supa, take breakables into account
	if (self.enemy.solid == SOLID_BSP)	enemyorg = (self.enemy.absmin + self.enemy.absmax) * 0.5;
	else								enemyorg = self.enemy.origin;
	
	delta = enemyorg - self.origin;

// DRAGONS /- - - -
//    if (vlen(delta) > 100)
    if (!InMeleeRange (100))    // Needed for fat dragons.
        return;
//- - - - - - - - -
	if (!CanDamage (self.enemy, self))
		return;

    //sound (self, CHAN_WEAPON, "demon/dhit2.wav", 1, ATTN_NORM);
	ldmg = 20 + 10*random();
	T_Damage (self.enemy, self, self, ldmg, DTH_FIEND_CLAW, FALSE, 3);
	
	ShoveDir = aim (self, 1000);
	
	self.enemy.velocity = self.enemy.velocity + (ShoveDir * 1000) + '0 0 100';	//Shoves the player in the direction that the boss is looking
};


//==============================================================================
// Thinking
//==============================================================================

void() boss2_SelectAttack = 
{
	if (self.classname == "monster_boss2_mirror")	//A cheap copy, knows no tricks
		boss2_rangeda1();
	
	local float AttType;
	local float AttStyle;
	local float Aggression;
	
	if (self.health < 500) 
		Aggression = 3;
	else if (self.health < 1000) 
		Aggression = 2; 
	else if (self.health < 1500) 
		Aggression = 1;
	else
		Aggression = 0;
	
	AttType=random()*skill+Aggression;  //ijed This is a value from 0-6 based on health loss and skill setting
	AttStyle=random();
	
	if (AttType > 4)			//desperate
	{
		if (AttStyle > 0.6)
			boss2_rangeda1();
		else if (AttStyle > 0.3)
			boss2_rangedb1();
		else
			boss2_rangedc1();
	}
	else if (AttType > 2)		//enraged
	{
		if (AttStyle > 0.6)
			boss2_rangeda1();
		else if (AttStyle > 0.3)
			boss2_rangedb1();
		else
			boss2_rangedc1();
	}
	else						//lazy
	{
		if (AttStyle > 0.6)
			boss2_rangeda1();
		else if (AttStyle > 0.3)
			boss2_rangedb1();
		else
			boss2_rangedc1();
	}
};

void() boss2_Pain =	//limping and escape to be called from here
{
};

void() Boss2_SelectMelee =	//This is supposed to kick the player across the room if it connects
{
	if (random() > 0.5)
		boss2_meleea1();
	else
		boss2_meleeb1();
};

void() boss2_die1 =	//Placeholder
{
	self.think = SUB_Remove;
	self.nextthink = time + 0.1;
	if (self.classname == "monster_boss2_mirror") //ijed All mirrors should be destroyed if the original is.  Need to figure out how.
		bprint ("Boss2 Mirror Image Destroyed\n");
	else
		bprint ("Boss2 Destroyed\n");
};


//==============================================================================

void() monster_boss2_go =
{
	self.solid = SOLID_SLIDEBOX;
	self.movetype = MOVETYPE_STEP;

	setmodel (self, "progs/boss2.mdl");

	setsize (self, '-64 -64 -0', '64 64 128');
	//setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
	if (self.classname == "monster_boss2_mirror")
		self.health = 500;
	else
		self.health = 4000;

	self.th_stand		=	boss2_stand1;
	self.th_walk		=	boss2_walk1;
	self.th_run			=	boss2_run1;
	self.th_missile		=	boss2_SelectAttack;
	self.th_melee		=	Boss2_SelectMelee;
	//self.th_pain		=	boss2_Pain;
	self.th_die			=	boss2_die1;
	
	Gyro_Object_Activate (self, 65000);

	walkmonster_start ();
};

//QUAKED monster_boss2 (1 0 0) (-64 -64 -0) (64 64 128) Ambush Inert
void() monster_boss2 =
{
	if (deathmatch)
	{
		remove(self);
		return;
	}
	precache_model ("progs/boss2.mdl");
	
	precache_model ("progs/firebolt.mdl");
	precache_model ("progs/v_spike.mdl");	//Need to change this for a unique DEATHORB model
	
	//precache_sound ("boss2/sight1.wav");
	//precache_sound ("boss2/idle1.wav");
	//precache_sound ("boss2/attack1.wav");
	//precache_sound ("boss2/death1.wav");
		
	//precache_model ("progs/gib_boss21.mdl");

	//precache_model ("progs/fireball1.spr");

	//Summons fiends, so here are the precache's
	precache_model ("progs/demon.mdl");
	precache_model ("progs/h_demon.mdl");

	precache_sound ("demon/ddeath.wav");
	precache_sound ("demon/dhit2.wav");
	precache_sound ("demon/djump.wav");
	precache_sound ("demon/dpain1.wav");
	precache_sound ("demon/idle1.wav");
	precache_sound ("demon/sight2.wav");
	precache_sound ("magic/bigboom.wav");

	self.go = monster_boss2_go;
	if(!CheckGroup()) self.go();
};

void() monster_boss2_mirror =	//this should only exist if there's a real boss2 around and therefore use the same precaches
{
	self.go = monster_boss2_go;	
};