# Jedi Knight Cog Script
#
# 18_endelev.cog
#
# cross an adjoin and end the level
#
# [SXC]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

symbols

message     startup
message     activated
message     user0
message     shutdown

thing       elevator
surface     switch0

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:
   // This is the master COG, so register it.
   SetMasterCOG(GetSelfCOG());

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

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

   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, AutoSelectWeapon(player, 1));

   return;

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

activated:
   if (GetSenderRef() == switch0)
      {
      MoveToFrame(elevator, 1, 5);
      Sleep(2);
      jkEndLevel();
      }
      return;

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

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

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

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

      SetGoalFlags(player, 2, 1);
      SetGoalFlags(player, 3, 1);
      Return;
   }

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

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

   Return;

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

shutdown:
   // 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

