PDA

View Full Version : Multiplayet switch



Shred18
03-23-2005, 03:27 PM
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.


# 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

Blood Asp
03-23-2005, 03:42 PM
why not just give the everyone in the party a key if one is picked up?

Shred18
03-23-2005, 03:50 PM
becuse the host would still be the only one able to flip the switch.

SG-fan
03-23-2005, 11:03 PM
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.

Shred18
03-24-2005, 12:10 AM
Oh.. well that would make sense, I keep running into this problem with switches.

Edward
03-24-2005, 11:26 AM
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.

Quib Mask
03-24-2005, 04:55 PM
I'd say try adding:
flags=0x40
to the cog.

QM

ZeqMacaw
03-30-2005, 12:44 PM
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.

:)

F-Body
03-30-2005, 02:45 PM
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.. :/

ZeqMacaw
03-30-2005, 03:00 PM
I have also tested using the CTF method for keys, and that works fine, too.

:)