# Jedi Knight Cog Script
#
# 20_EndLevel.cog
#
# Completion script for level 20.
#
# [IS]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================


symbols

message  startup
message  killed

thing    boc                             mask=0xfff

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

startup:
   player = GetLocalPlayerThing();

   // Prepare Kyle's yellow lightsaber if light path
   if(jkGetChoice() == 1)
   {
		jkSetSaberInfo(player, side_mat, tip_mat, 0.0128, 0.0128, 0.123, tpl_wall, tpl_blood, tpl_saber);
   }
	jkSetFlags(player, 0x81);

   // Setup the goals first string in cogStrings.uni so the UI knows about it.
   SetInv(player, 99, 20000);
   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, 10);

   return;

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

killed:
   SetGoalFlags(player, 0, 2);
   PlaySoundThing(goalsnd, player, 1.0, -1, -1, 0);
   jkPrintUNIString(player, 350);

   Sleep(10.0);

   // Don't end the level if player is dead.
   if (GetThingHealth(player) <= 0)
      return;

   jkEndLevel();
   return;

end


