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 → Multiplayet switch
Multiplayet switch
2005-03-23, 12:27 PM #1
I'm having issues converting this cog to multiplayer. This is the cog that controls the moving catwalks inside the core of level 12 (escape with the map)

Here's the problem: only the host can activate the switches. (which require a key) if a client with a key activates it, and the host doesnt have a key, it will print out on the host computer that he needs a key. I 've made slight modifications, but it still doesn't work.

Code:
# Jedi Knight Cog Script
#
# 12_KeyedCatwalk.cog
#
# controls the rotating catwalks
#
# [IS/DB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
#



symbols
	message	startup
	message	activated
	message	arrived
	
	surface	switch0a	linkid=0
	surface	switch0b	linkid=0
   	surface	switch1a	linkid=1
	surface	switch1b	linkid=1
	
  	sound		wav0=Activate02.wav        local
	sound		cwalksnd=df_Door2-2.wav    local
   	sound		doorstop=df_Door2-3.wav		local

	int		itemNum0=46       
	int		itemNum1=48

	int		jkStringsNum0=262 
	int		jkStringsNum1=264

	thing		catwalk	linkid=2
	thing		player			local
	float		moveSpeed=2.0

	int		direction=1		local
	int		startingUp=1	local
   int      channel=-1     local
   int      dummy=0        local

end	

code
startup:
	MoveToFrame(catwalk, 2, 20.0);
	return;
	
activated:

player = GetSourceRef();
	if ((GetSenderId() != 0) && (GetSenderId() != 1)) return;
	if (GetWallCel(GetSenderRef()) == 1) return;
	if (IsThingMoving(catwalk)) return;

	if (GetInv(player, itemNum0[GetSenderId()]) <= 0.0) {
		// print "no key" message
		jkPrintUniString(GetPlayerNum(player), jkStringsNum0[GetSenderId()]);
		return;
	}	

	if (GetSenderId() == 0) {
		if (GetCurFrame(catwalk) == 0) return;
		direction = -1;
	} else if (GetSenderId() == 1) {
		if (GetCurFrame(catwalk) == 4) return;
		direction = 1;	
	}

	dummy=SetWallCel(switch0a, 1);
	dummy=SetWallCel(switch0b, 1);
	dummy=SetWallCel(switch1a, 1);
	dummy=SetWallCel(switch1b, 1);


	dummy=PlaySoundPos(wav0, SurfaceCenter(GetSenderRef()),0.6, 1, 3, 0);

	MoveToFrame(catwalk, GetCurFrame(catwalk)+direction, moveSpeed);

	channel=playsoundthing(cwalksnd, catwalk, 1.5, -1, -1, 1);


	return;
	
arrived:
	// hack to handle starting at frame 2, JumpToFrame(), working on arrived:'s, etc, etc.
	if ((startingUp) && (GetCurFrame(catwalk) == 2)) {
		startingUp = 0;
		return;
	}
		
	if (startingUp) return;

	if ((GetCurFrame(catwalk) == 0) || (GetCurFrame(catwalk) == 4)) {
		dummy=SetWallCel(switch0a, 0);
		dummy=SetWallCel(switch0b, 0);
		dummy=SetWallCel(switch1a, 0);
		dummy=SetWallCel(switch1b, 0);

      if (channel != -1)
         {
         StopSound(channel,0.1);
         channel= -1;
         playsoundthing(doorstop, catwalk, 1.0, -1, -1, 0);
         }

		dummy=PlaySoundPos(wav0, SurfaceCenter(GetSenderRef()), 0.6, 1, 3, 0);
	} else {
		MoveToFrame(catwalk, GetCurFrame(catwalk)+direction, moveSpeed);

   }
	return;
	
end	
Jedi Knight Enhanced
Freelance Illustrator
2005-03-23, 12:42 PM #2
why not just give the everyone in the party a key if one is picked up?
Current Maps | Newest Map
2005-03-23, 12:50 PM #3
becuse the host would still be the only one able to flip the switch.
Jedi Knight Enhanced
Freelance Illustrator
2005-03-23, 8:03 PM #4
If I remember right, this has been a common error with JK. When it looks up the bin for the key, it checks the host computer no matter who activated the switch. Try making a client and server cog setup where the client cog (local) gets the bin value (getting the proper player's bin) then calling the server cog (non-local) to open the door. It's an ugly fix, and there's probably an easier way, but I haven't messed with bins much so someone else might be able to find a single cog solution.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-03-23, 9:10 PM #5
Oh.. well that would make sense, I keep running into this problem with switches.
Jedi Knight Enhanced
Freelance Illustrator
2005-03-24, 8:26 AM #6
I would suggest having a look at one of the CTF COGs where they use Keys to open the red and yellow doors. Just suggesting, so solutions, sorry.
Edward's Cognative Hazards
2005-03-24, 1:55 PM #7
I'd say try adding:
flags=0x40
to the cog.

QM
2005-03-30, 9:44 AM #8
I tested by using flags=0x40 in the above cog.

Everything worked as expected when the host activated the switch (i.e. key worked and catwalk moved).

When the client activated the switch, the key worked, but the catwalk didn't move. (I tested using print statements, so I know the GetInv verb worked properly.)

So, I guess the catwalk is synced differently than the inventory bins.

:)
2005-03-30, 11:45 AM #9
Quote:
Originally posted by Edward
I would suggest having a look at one of the CTF COGs where they use Keys to open the red and yellow doors. Just suggesting, so solutions, sorry.


You have to make new cogs since inventories aren't synched, if I remember right. I made a fully functional & tested MP door keys cogs a while back, dont remember where they are now.. :/
This is retarded, and I mean drooling at the mouth
2005-03-30, 12:00 PM #10
I have also tested using the CTF method for keys, and that works fine, too.

:)

↑ Up to the top!