# Jedi Knight Cog Script
#
# 17A_ENDLEVEL.COG
#
# [IS]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

symbols
message  killed
message  startup
message  shutdown

thing    sarriss		mask=-1

int      player                          local
sound    goalsnd=Accomplish1.wav         local

material tip_mat=saberyellow0.mat        local
material side_mat=saberyellow1.mat       local

template tpl_wall=+ssparks_wall          local
template tpl_blood=+ssparks_blood        local
template tpl_saber=+ssparks_saber        local

end

# ========================================================================================

code

killed:
   SetGoalFlags(player, 0, 2);
   PlaySoundThing(goalsnd, player, 1.0, -1, -1, 0);
   jkPrintUNIString(player, 350);
   Sleep(6.0);
	
	// Don't end the level if player is dead.
	if (GetThingHealth(player) <= 0)
		return;
	
   jkEndLevel(1);

   Return;

# ........................................................................................

startup:
   player = GetLocalPlayerThing();

   // Remove the light saber
   jkSetFlags(player, 0x8);
   SetInv(player, 10, 0);

   // Prepare Kyle's yellow lightsaber
   jkSetSaberInfo(player, side_mat, tip_mat, 0.0128, 0.0128, 0.123, tpl_wall, tpl_blood, tpl_saber);
//	jkSetFlags(player, 0x1);

   // Setup the goals first string in cogStrings.uni so the UI knows about it.
   SetInv(player, 99, 17000);

   SetGoalFlags(player, 0, 1);

   // When player starts, give him fists, and a bryar.
   SetInv(player, 1, 1.0);
   SetInv(player, 2, 1.0);
   if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);

   // Initialize weapon.
   SetFireWait(player, -1);
   SetMountWait(player, 0);
   SetCurInvWeapon(player, 0);

   SelectWeapon(player, 1);

   Return;

# ........................................................................................

shutdown:
   // Make sure Kyle gets the saber at the end...
   SetInv(player, 10, 1);

   // Set Jedi Level to 7
   SetInv(player, 20, 7);

   // Give 2 stars
   ChangeInv(player, 16, 2);

   Return;

end

