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 → A special door cog
A special door cog
2005-09-30, 5:05 PM #1
Hi everybody,

I was wondering if someone could cook me up a special door cog that is more or less vital for the completion of my level... It involves a Force-pullable switch.
I know the Carbo-freeze level in MotS features a Force-pullable switch, as well as some of the SP levels, but my understanding of cog is extremely limited. Let me sum up what it should do:

1. It's for multiplayer
2. It's for MotS
3. It needs to handle two doors
4. there should be two (surface) switches, one for each door
5. A third and special switch should be a thing/3do that can be Force-pulled. When this switch is used, both doors should open at the same time. (Ofcourse, this should only be possible when both doors are closed at the time of using the Force-pullable switch).
6. Speed and sleep time of the doors should be controllable in the setup of the cog
ORJ / My Level: ORJ Temple Tournament I
2005-10-07, 1:18 PM #2
:o I hate to bump my own topic, but I really need some help on this...

It's for an almost finished level that (i.m.h.o.) is fun enough to be worth a release. :) I haven't been showcasing it, because I like to keep stuff a surprise.
ORJ / My Level: ORJ Temple Tournament I
2005-10-07, 3:42 PM #3
Well, a showcase could be a good opportunity to catch some attention, no?
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-10-07, 5:57 PM #4
Make the switch an "actor" and in the skill message of its cog open and close the door
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-10-08, 6:37 PM #5
Here are tested cogs and a template that do what you requested.

Usage:
- Replace your existing jed_door_sw.cog with the one here.
- Create a new template with the template given here.
- Insert a new thing with the template just created where you want the pullable switch.
- Go into the Placed Cogs window and find the two door switches that should be "activated" by the new pullable switch. Fill-in the "pullable_switch_thing" parameter with the thing number of the pullable switch thing just inserted.

Template for the pullable switch thing:
Code:
fpullswitch       _powerup           model3d=levr-1.3do cog=switch_force_pullable.cog

The modified jed_door_sw.cog (which replaces your existing one):
Code:
# Jedi Knight Cog Script Generated by CogWriter ver 0.1 beta  1/20/98 10:13:16 AM
#
# jed_door_sw.cog [ver 1.0a]
#
# Generic basic door activated by one or two switches
# This cog will open the door and close it again after the WaitTime specified times out..
# Controls 1 door.
#
# ......Thing Settings
#
# Set Door ThingFlags to 0x408
# Set NumFrames  to  2
# Two frames are used
#
# Switches  Set Surface Flags to  "6"  use a two cell mat such as 00_T_up.mat
#
# [DL]  Jan/98
# Modified by ZeqMacaw 08-Oct-2005  
#   Sends a user0 message with its cog id to the 
#   pullable_switch_thing's class cog.
#	Retrieves a user0 message that opens the door.
#
# THIS LEVEL IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY LUCASARTS ENTERTAINMENT 
# COMPANY.  ELEMENTS TM & (C) LUCASARTS ENTERTAINMENT COMPANY.
#==============================================================================

symbols
	flex        Wait=2.0
	flex        Speed=8.0
	surface     switch0                       linkid=2    # enter as (sector space surface number) in Jed
	surface     switch1                       linkid=2    # optional second switch
	thing       door                          linkid=1    # Door Thing number
	thing       pullable_switch_thing=-1      linkid=4
	flex        Light=0.5                     local
	int         DSector                       local
	sound       locksound=df_door2-3.wav      local
	sound       offSound=lgclick1.wav         local
	sound       onSound=set_hi2.wav           local

	message  activated
	message  arrived
	message  blocked
	message  startup
	message  timer
	message  user0
end

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

code

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

startup:
	DSector = GetThingSector(door);
	SetSectorAdjoins(DSector, 0);
	SetSectorLight(DSector, Light, 0.0);               // add some light to door sector
	if (pullable_switch_thing > -1)
	{
		SendMessageEx(GetThingClassCog(pullable_switch_thing), 
			user0, GetSelfCog(), 0, 0, 0);
	}
	return;

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

activated:
	if (GetSenderId() == 1)
	{
		PlaySoundLocal(locksound, 1, 0, 0);             // play locked sound
	}
	else if (GetSenderId() == 2)
	{
		call open_door;
	}
	return;

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

arrived:
   if(IsThingMoving(door)) Return;

   if(GetCurFrame(door) == 1)
   {
      SetTimer(Wait);
      Return;
   }
   else
   {
      SetSectorAdjoins(DSector, 0);
      PlaySoundThing(offSound, door, 0.6, -1, -1, 0); // play deactivate sound
      SetWallCel(switch0, 0);
      if (switch1 >= 0) SetWallCel(switch1, 0);
      Return;
   }

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

blocked:
   MoveToFrame(door, 1 - GetGoalFrame(door), Speed);
   Return;

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

timer:
   MoveToFrame(door, 0, Speed);
   Return;

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

user0:
   call open_door;
   return;

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

open_door:
    if ( IsThingMoving(door) || (GetCurFrame(door) != 0) )
	{
		return;
	}
    MoveToFrame(door, 1, Speed);
    SetSectorAdjoins(DSector, 1);
    PlaySoundThing(onSound, door, 0.6, -1, -1, 0);  // play activate sound
    SetWallCel(switch0, 1);
    if (switch1 >= 0)
	{
		SetWallCel(switch1, 1);
	}
	return;

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

end

The switch_force_pullable.cog:
Code:
# switch_force_pullable.cog
#
# 
#
# ZeqMacaw 08-Oct-2005
#
# THIS LEVEL IS NOT MADE, DISTRIBUTED, OR SUPPORTED BY LUCASARTS ENTERTAINMENT 
# COMPANY.  ELEMENTS TM & (C) LUCASARTS ENTERTAINMENT COMPANY.
#==============================================================================

symbols
	cog  main_switch_cog1=-1  local
	cog  main_switch_cog2=-1  local

	message  activated
	message  skill
	message  user0
end

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

code

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

activated:
	SendMessageEx(main_switch_cog1, user0, 0, 0, 0, 0);
	SendMessageEx(main_switch_cog2, user0, 0, 0, 0, 0);
	return;

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

skill:
	// Force Pull
	if (GetParam(0) == 24)                            
	{
		SendMessageEx(main_switch_cog1, user0, 0, 0, 0, 0);
		SendMessageEx(main_switch_cog2, user0, 0, 0, 0, 0);
		ReturnEx(0);
		return;
	}

	ReturnEx(-1);
	return;

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

user0:
	if (main_switch_cog1 == -1)
	{
		main_switch_cog1 = GetParam(0);
	}
	else
	{
		main_switch_cog2 = GetParam(0);
	}
	return;

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

end


Enjoy.

:)
2005-10-09, 12:51 PM #6
Awesome Zeq, you're a genius! :)

Just for the record folks, the cogs posted on these boards somehow don't work, because the Massassi forums mess certain characters up somehow. The working versions can be found on the JKHub.

:)
ORJ / My Level: ORJ Temple Tournament I

↑ Up to the top!