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 → Changing a premade cog...
Changing a premade cog...
2002-07-31, 1:15 PM #1
Well, I need it modified. I think. Since I'm useless at cogging... I need it to be only openable by space bar interaction (open key) but open and closable by switch.

I.E. Open - hand / switch
Close - switch.

You get the idea?

# Jedi Knight Cog Script
#
# h0_swingdoors2.cog
#
# By Heinz Högel 5/98 for free use in add-on levels
#
# This script controls one or two winged rotating doors. To start open/close
# action, activate one out of two possibly linked switches or send a user0
# message to this cog.
#
# Parameters:
#
# Door0
# Door1 - IDs of door things (one is optional).
#
# Switch0
# Switch1 - Surfaces with switches on. These switches can activate opening
# and closing of the door wings. They are both displayed as activated
# as long as the doors are moving and then return to deactivated state.
# Both are optional (without them you have to send a user0 message to this
# cog to open/close the doors).
#
# Time - How long a complete door swing should last (in seconds). Should be positive
# on startup.
#
# AutoCloseDelay - If greater than 0.0, delay in seconds for automatic re-closing of doors.
#
#
# This file is was not made and is not supported by LucasArts Entertainment Co.
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols
message activated
message arrived
message user0
message timer

thing Door0=-1 linkid=1
thing Door1=-1 nolink // nolink necessary to avoid double arrived messages!!!

surface Switch0=-1 linkid=0
surface Switch1=-1 linkid=0

flex Time=4.0
flex AutoCloseDelay=0.0

int Rotating=0 local
end


## Code Section
code

activated:
if (GetSenderID() != 0) return; // Allow only switches to send activated message
user0:
delayed:
if (Rotating) return; // Rotation already in progress
Rotating = 1;
if (Switch0 >= 0)
SetWallCel(Switch0, 1); // Display first switch as activated
if (Switch1 >= 0)
SetWallCel(Switch1, 0); // Display second switch as activated
if (Door0 >= 0)
RotatePivot(Door0, 1, Time); // Swing (rotate) first door
if (Door1 >= 0)
RotatePivot(Door1, 1, Time); // Swing (rotate) second door
return;

arrived:
if (!Rotating) return; // Rotation already finished
Time = -Time; // Negate time for invers rotation
if (Switch0 >= 0)
SetWallCel(Switch0, 0); // Display first switch as deactivated
if (Switch1 >= 0)
SetWallCel(Switch1, 0); // Display first switch as deactivated
Rotating = 0;
if (AutoCloseDelay > 0.0 && Time < 0)
SetTimer(AutoCloseDelay); // Prepare delayed automatic closing
return;

timer:
call delayed; // Delayed closing
return;

end



------------------
"Yo! Yo! Yo! Yo-yo!"
We're three million years into deep space. Where the smeg did I get a traffic cone?

<font face="Verdana, Arial" size="2">Originally posted by Avenger:
I'm more worried about the waffle intake. That's a lot of waffles.</font>
2002-07-31, 3:38 PM #2
Since I see this is your first post, let me give you a warm welcome greeting to Massassi forums. [humblevoice]Welcome to Massassi![/humblevoice] It seems most people start off with there first post here, runnerup is the showcase forums. Anyway, use the UBB code tag. It helps. Like how the revised version of your cog is displayed.
Code:
# Jedi Knight Cog Script
#
# h0_swingdoors2.cog
#
# By Heinz Högel 5/98 for free use in add-on levels
#
# This script controls one or two winged rotating doors. To start open/close
# action, activate one out of two possibly linked switches or send a user0
# message to this cog.
#
# Parameters:
#
# Door0
# Door1 - IDs of door things (one is optional).
#
# Switch0
# Switch1 - Surfaces with switches on. These switches can activate opening
# and closing of the door wings. They are both displayed as activated
# as long as the doors are moving and then return to deactivated state.
#
# Time - How long a complete door swing should last (in seconds). Should be positive
# on startup.
#
# AutoCloseDelay - If greater than 0, delay in seconds for automatic re-closing of doors.
#
# [DP]
#

symbols
message activated
message arrived
message timer

thing Door0=-1     linkid=1
thing Door1=-1     linkid=2

surface Switch0=-1 linkid=0
surface Switch1=-1 linkid=0

flex Time=4
flex AutoCloseDelay=0

int Rotating=0      local
int open=0          local 
end


## Code Section
code

Activated:
   If(GetSenderID() < 1 && Open) Return; 

Delayed:
   If(Rotating) Return;
   Rotating = 1;
   If(Switch0 >= 0) SetWallCel(Switch0, 1); // Display first switch as activated
   If(Switch1 >= 0) SetWallCel(Switch1, 0); // Display second switch as activated
   If(Door0 >= 0) RotatePivot(Door0, 1, Time); // Swing (rotate) first door
   If(Door1 >= 0) RotatePivot(Door1, 1, Time); // Swing (rotate) second door
   Return;

Arrived:
   If(GetSenderID != 1) Return; // Only called for the first door
   If(!Rotating) return; // Rotation already finished
   Time = -Time; // Negate time for invers rotation
   open = 1 - open;
   If(Switch0 >= 0) SetWallCel(Switch0, 0); // Display first switch as deactivated
   If(Switch1 >= 0) SetWallCel(Switch1, 0); // Display first switch as deactivated
   Rotating = 0;
   If(AutoCloseDelay > 0 && Time < 0)
   SetTimer(AutoCloseDelay); // Prepare delayed automatic closing
   Return;

   Timer:
   call delayed; // Delayed closing
   Return;

end
And doesn't that look nice too. [http://forums.massassi.net/html/wink.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited July 31, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-01, 2:28 AM #3
Thanks... but that wasn't REALLY my first post. My first post was yonks ago when... hmm... i think GBK wasn't a Moderator, and I was under BigMadTony. But i changed email address and lost it... oh well...

------------------
"Yo! Yo! Yo! Yo-yo!"
We're three million years into deep space. Where the smeg did I get a traffic cone?

<font face="Verdana, Arial" size="2">Originally posted by Avenger:
I'm more worried about the waffle intake. That's a lot of waffles.</font>
2002-08-01, 6:44 AM #4
Well how am I to know that? I can't keep track of everybody. I would think people keep the same name or just have a few mods to it... [http://forums.massassi.net/html/redface.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited August 01, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-01, 2:30 PM #5
Code:
# Jedi Knight Cog Script
#
# h0_swingdoors2.cog
#
# By Heinz Högel 5/98 for free use in add-on levels
#
# This script controls one or two winged rotating doors. To start open/close
# action, activate one out of two possibly linked switches or send a user0
# message to this cog.
#
# Parameters:
#
# Door0
# Door1 - IDs of door things (one is optional).
#
# Switch0
# Switch1 - Surfaces with switches on. These switches can activate opening
# and closing of the door wings. They are both displayed as activated
# as long as the doors are moving and then return to deactivated state.
# Both are optional (without them you have to send a user0 message to this
# cog to open/close the doors).
#
# Time - How long a complete door swing should last (in seconds). Should be positive
# on startup.
#
# AutoCloseDelay - If greater than 0.0, delay in seconds for automatic re-closing of doors.
#
#
# This file is was not made and is not supported by LucasArts Entertainment Co.
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
#==============================================================#
symbols

message   activated
message   arrived
message   user0
message   timer

thing     Door0=-1             linkid=1
thing     Door1=-1             linkid=1

surface   Switch0=-1           linkid=0
surface   Switch1=-1           linkid=0

flex      Time=4.0
flex      AutoCloseDelay=0.0

int       Rotating=0           local

end
#==============================================================#
## Code Section
code
#------------------------------------------------------
activated:
	// Return if activated was not called by a switch or a door when closed.
	if(GetSenderID() != 0 && !(GetSenderID() == 1 && Time > 0)) Return;
	user0:
	delayed:
	if(Rotating) Return;	// Rotation already in progress
	Rotating = 1;
	if(Switch0 >= 0) SetWallCel(Switch0, 1);	// Display first switch as activated
	if(Switch1 >= 0) SetWallCel(Switch1, 1);	// Display second switch as activated
	if(Door0 >= 0) RotatePivot(Door0, 1, Time);	// Swing (rotate) first door
	if(Door1 >= 0) RotatePivot(Door1, 1, Time);	// Swing (rotate) second door

Return;
#------------------------------------------------------
arrived:
	if(!Rotating) Return;	// Rotation already finished
	Rotating = 0;
	Time = -Time;	// Negate time for invers rotation
	if(Switch0 >= 0) SetWallCel(Switch0, 0);	// Display first switch as deactivated
	if(Switch1 >= 0) SetWallCel(Switch1, 0);	// Display first switch as deactivated
	// Prepare delayed automatic closing
	if(AutoCloseDelay > 0.0 && Time < 0) SetTimer(AutoCloseDelay);

Return;
#------------------------------------------------------
timer:
	call delayed;	// Delayed closing

Return;
#------------------------------------------------------
end


Both doors now have a linkid of 1. The author thought that would cause a problem with the arrived message, but I think the if(!Rotating) Return; condition will stop the second arrived message.

The new condition in the activated message will allow the following code to run if the player nudged either door when it was closed.

It appears that the author mistakenly set one of the switches to cel 0 in the activated message. In the above cog, both switches are set to cel 1 for activated.

Well, it should work fine now. Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 01, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!