# Jedi Knight Cog Script
#
# 19a_Endlevel cog
#
# Endlevel script for level 19A.
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================


symbols

message     startup
message     user0
message     shutdown

thing       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);
   }

   // This is the master COG, so register it.
   SetMasterCOG(GetSelfCOG());

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

   // Setup the first goal as SECRET
   SetGoalFlags(player, 0, 4);

   // Setup the second goal as DISPLAYED
   SetGoalFlags(player, 1, 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, AutoSelectWeapon(player, 1));

   Return;

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

user0:
   PlaySoundThing(goalsnd, player, 1.0, -1, -1, 0);
   jkPrintUNIString(player, 350);

   if(GetParam(0) == 0)
   {
      SetGoalFlags(player, 0, 2);
      SetGoalFlags(player, 0, 1);
      Return;
   }

   if(GetParam(0) == 1)
   {
      SetGoalFlags(player, 1, 2);
      SetGoalFlags(player, 2, 1);
      Return;
   }

   if(GetParam(0) == 2)
   {
      SetGoalFlags(player, 2, 2);
      SetGoalFlags(player, 3, 1);
      Return;
   }

   if(GetParam(0) == 3)
   {
      SetGoalFlags(player, 3, 2);
      SetGoalFlags(player, 4, 1);
      Return;
   }

   if(GetParam(0) == 4)
   {
      SetGoalFlags(player, 4, 2);
      jkEndLevel(1);
      Return;
   }

   Return;

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

shutdown:
   // Set Jedi Level to 8
   SetInv(player, 20, 8);

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

   // Give a force star if the player finds all the secrets
   if((GetInv(player, 71) != 0) && (GetInv(player, 70) == GetInv(player, 71)))
      ChangeInv(player, 16, 1);

   Return;

end

