Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → getting the green key to work
getting the green key to work
2006-07-13, 4:56 AM #1
i tried the door lock with key cog but it only stated 3 keys red, blue and yellow......no green. Now i need an extra key in my level, hence i either need that key to work, or, i need the wrench to work on the door !!!!!! Help
My Main Objective------ Is to make Jk Real......No i mean Really Real.
2006-07-13, 4:20 PM #2
Post the cog.
And when the moment is right, I'm gonna fly a kite.
2006-07-13, 10:28 PM #3
its in jk.
My Main Objective------ Is to make Jk Real......No i mean Really Real.
2006-07-14, 1:26 AM #4
anyway i'll post it

Code:
# Jedi Knight Cog Script
#
# 00_DOORKEY.COG
#
# Multiple Doors opened with a key
# Use 0 in "key" for the Red Key (default), 1 for Blue and 2 for Yellow
#
# [YB]
#
# 8/28/97 Added clicking sounds [DB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing       door0                            linkid=0 mask=0x405
thing       door1                            linkid=1 mask=0x405
thing       door2                            linkid=2 mask=0x405
thing       door3                            linkid=3 mask=0x405

flex        movespeed=8.0
flex        sleeptime=2.0
flex        lightvalue=0.5
int         key=0

sound       locked_snd=i00ky73t.wav          local
sound       wav0=lvrclik2.wav

sector      doorsector                       local
int         numdoors                         local
int         doorstatus                       local
int         movestatus                       local
int         player                           local

flex        lasttime=-1                      local
flex        curtime=-1                       local

message     startup
message     activated
message     arrived
message     blocked
message     timer

end

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

code

startup:
   if (door0 >= 0) numdoors = numdoors + 1;
   if (door1 >= 0) numdoors = numdoors + 1;
   if (door2 >= 0) numdoors = numdoors + 1;
   if (door3 >= 0) numdoors = numdoors + 1;

   doorsector = GetThingSector(door0);
   SectorAdjoins(doorsector, 0);
   SectorLight(doorsector, lightvalue, 0.0); // add some light to door sector

   Return;

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

activated:
   player = jkGetLocalPlayer();

   if ((GetInv(player, 46 + key) == 1.0) || (GetSourceRef() != player))       // if player has the needed key
   {                                         // or enemy triggers door
      call checkstatus;
      if(movestatus) return;
      if(doorstatus == 0)
      {                                      // all pieces are at frame 0
         SectorAdjoins(doorsector, 1);
         // show the key icon for 2 seconds
         SetInvActivated(player, 46 + key, 1);
         SetTimerEx(2, 1, 0, 0);
         // PlaySoundThing(key_snd, player, 1.0, -1, -1, 0);
         call open_doors;
      }
   }
   else
   {
      PlaySoundThing(wav0, door0, 1.0, -1, -1, 0);
      curtime = GetLevelTime();
      if( (lasttime == -1) || (curtime - lasttime > 3) )
      {
         PlaySoundThing(locked_snd, player, 1.0, -1, -1, 0);
         jkPrintUNIString(-1, 1001);
         lasttime = curtime;
      }
   }

   Return;

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

arrived:
   call checkstatus;
   if(movestatus) return;
   if(doorstatus == numdoors)
   {                                         // all pieces are at frame 1
      sleep(sleeptime);
      call close_doors;
   }
   else if(doorstatus == 0)
   {                                         // all pieces are at frame 0
      sectoradjoins(doorsector, 0);
   }

   Return;

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

blocked:
   call open_doors;

   Return;

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

timer:
   // Remove the key icon
   SetInvActivated(player, 46 + key, 0);
   Return;

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

open_doors:
   MoveToFrame(door0, 1, movespeed);
   if (door1 >= 0) MoveToFrame(door1, 1, movespeed);
   if (door2 >= 0) MoveToFrame(door2, 1, movespeed);
   if (door3 >= 0) MoveToFrame(door3, 1, movespeed);

   Return;


close_doors:
   MoveToFrame(door0, 0, movespeed);
   if (door1 >= 0) MoveToFrame(door1, 0, movespeed);
   if (door2 >= 0) MoveToFrame(door2, 0, movespeed);
   if (door3 >= 0) MoveToFrame(door3, 0, movespeed);

   Return;


checkstatus:
   movestatus = IsThingMoving(door0);
   if (door1 >= 0) movestatus = movestatus + IsThingMoving(door1);
   if (door2 >= 0) movestatus = movestatus + IsThingMoving(door2);
   if (door3 >= 0) movestatus = movestatus + IsThingMoving(door3);

   doorstatus = GetCurFrame(door0);
   if (door1 >= 0) doorstatus = doorstatus + GetCurFrame(door1);
   if (door2 >= 0) doorstatus = doorstatus + GetCurFrame(door2);
   if (door3 >= 0) doorstatus = doorstatus + GetCurFrame(door3);

   Return;

end
My Main Objective------ Is to make Jk Real......No i mean Really Real.
2006-07-14, 10:31 AM #5
Based on the way the cog works (when using an unaltered items.dat), use these values for the "key" symbol:
0 = red key
1 = blue key
2 = yellow key
3 = blue wrench
4 = yellow wrench
5 = green key

:)
2006-07-14, 9:51 PM #6
thnx ;) :) :cool:
My Main Objective------ Is to make Jk Real......No i mean Really Real.

↑ Up to the top!