
// hitscan actors
kActor@ Dummy1, Dummy2;

int  PowerBoostTick;    // player tick when power boost began
int  PowerBoostBeep;    // how many expiration warning beeps have played
bool bPowerBoostEffect; // power boost actorfx is applied to current weapon

void jkPreBeginLevel()
{
	bool bNewGame;
	if ( GameVariables.GetBool( "g_newgame", bNewGame ) && bNewGame )
		SetSaberColor( jk_Saber_Green );
	else
		GameVariables.GetInt( "jkSaberColor", SaberColor, jk_Saber_Green );
	// if Turok+ is installed, tell it we don't have the GL, so enemies will drop thermal detonators on Hard and Hardcore
	int bits;
	if ( !GameVariables.GetInt("Smoke39Flags",bits) ) return;
	bits &= ~( 1 << 2 );
	GameVariables.SetValue( "Smoke39Flags", ""+bits );
}

void jkPostBeginLevel()
{
	@Dummy1 = ActorFactory.Spawn( -1, Player.Actor().Origin().x, Player.Actor().Origin().y, Player.Actor().Origin().z, Player.Actor().SectorIndex() );
	@Dummy2 = ActorFactory.Spawn( -1, Player.Actor().Origin().x, Player.Actor().Origin().y, Player.Actor().Origin().z, Player.Actor().SectorIndex() );
	Dummy1.Height() = Dummy1.Radius() = Dummy2.Height() = Dummy2.Radius() = 0;
	PowerBoostTick = -2000;
	bPowerBoostEffect = false;
}

//==============================================================================
//
//    Pickups
//

class PowerBoost : ScriptObject
{
	PowerBoost( kActor@ A ) {}

	// actor was removed, which means it was picked up
	// (or level end, in which case it will be undone by jkInit())
	~PowerBoost()
	{
		PowerBoostTick = Player.Actor().GameTicks();
		PowerBoostBeep = 0;
	}

	void OnSpawn() {}
	void OnTick() {}
}

class jkArmorPickup : ScriptObject
{
	kActor@ self;
	jkArmorPickup( kActor@ a ) { @self = a; }
	void OnSpawn() {}
	// cap to 50 displayed armor after being picked up (and level end, which is redundant but fine)
	~jkArmorPickup()
	{
		if ( Player.Armor() > 150 ) Player.Armor() = 150;
	}
	// only allow picking up if displayed armor is < 50
	void OnTick()
	{
		if ( Player.Armor() <= 147 ) self.Flags() |=  AF_CANBETOUCHED;
		else                         self.Flags() &= ~AF_CANBETOUCHED;
	}
}

//==============================================================================
//
//    Debug Cheats
//

void red5()
{
	Game.PrintLine( "All Weapons", 0 );
	Player.GiveWeapon( jk_Weapon_DL44, 100 );
	Player.GiveWeapon( jk_Weapon_STRifle, 100 );
	Player.GiveWeapon( jk_Weapon_Bowcaster, 100 );
	Player.GiveWeapon( jk_Weapon_Sniper, 100 );
	Player.GiveWeapon( jk_Weapon_Repeater, 100 );
	Player.GiveWeapon( jk_Weapon_ConcRifle, 100 );
	Player.GiveWeapon( jk_Weapon_Sequencers, 100 );
	Player.GiveWeapon( jk_Weapon_ThermalDetonator, 100 );
	Player.GiveWeapon( jk_Weapon_RailDetonator, 100 );
	Player.GiveWeapon( jk_Weapon_Carbonite, 100 );
	Player.GiveWeapon( jk_Weapon_Lightsaber, 0 );
}

void jkbls()
{
	Game.PrintLine( "DL-44 Pistol", 0 );
	Player.GiveWeapon( jk_Weapon_DL44, 100 );
}
void jkstr()
{
	Game.PrintLine( "E-11 Rifle", 0 );
	Player.GiveWeapon( jk_Weapon_STRifle, 100 );
}
void jkbow()
{
	Game.PrintLine( "Bowcaster", 0 );
	Player.GiveWeapon( jk_Weapon_Bowcaster, 100 );
}
void jkrep()
{
	Game.PrintLine( "Precision Blaster Rifle", 0 );
	Player.GiveWeapon( jk_Weapon_Sniper, 100 );
}
void jkrpt()
{
	Game.PrintLine( "Repeater Rifle", 0 );
	Player.GiveWeapon( jk_Weapon_Repeater, 100 );
}
void jkcon()
{
	Game.PrintLine( "Concussion Rifle", 0 );
	Player.GiveWeapon( jk_Weapon_ConcRifle, 100 );
}
void jkseq()
{
	Game.PrintLine( "Sequencer Charges", 0 );
	Player.GiveWeapon( jk_Weapon_Sequencers, 100 );
}
void jkdet()
{
	Game.PrintLine( "Thermal Detonator", 0 );
	Player.GiveWeapon( jk_Weapon_ThermalDetonator, 100 );
}
void jkrld()
{
	Game.PrintLine( "Rail Detonator", 0 );
	Player.GiveWeapon( jk_Weapon_RailDetonator, 100 );
}
void jkcbn()
{
	Game.PrintLine( "Carbonite Gun", 0 );
	Player.GiveWeapon( jk_Weapon_Carbonite, 100 );
}
void jksab()
{
	Game.PrintLine( "Lightsaber", 0 );
	Player.GiveWeapon( jk_Weapon_Lightsaber, 0 );
}

void jkboost()
{
	PowerBoostTick = Player.Actor().GameTicks();
	PowerBoostBeep = 0;
}
