I'm working on a cog to launch a squadron of fighters from a hanger. The fighters must move to a "ready" position, a "launch" position, and then takes off. When the first fighter reaches the launch position the second fighter begins to move to the ready position, etc.
When the switch is activated, the the cog sends a message to the baydoor cog which returns if the doors are opened or closed.
The variable "shipsready" is the number of ships already in the ready position.
My problem is that the cog is not recieving the "activated" message from the switch.
[This message has been edited by force_dude (edited August 17, 2002).]
When the switch is activated, the the cog sends a message to the baydoor cog which returns if the doors are opened or closed.
The variable "shipsready" is the number of ships already in the ready position.
My problem is that the cog is not recieving the "activated" message from the switch.
Code:
# Jedi Knight Cog Script
#
# fd_ship.COG
#
# Launches a squadron of fighters
#
#
# This Cog is Not supported by LucasArts Entertainment Co
#==============================================================#
symbols
thing ship0 linkid=0
thing ship1 linkid=0
thing ship2 linkid=0
thing ship3 linkid=0
thing ship4 linkid=0
thing ship5 linkid=0
thing ship6 linkid=0
thing ship7 linkid=0
thing ship8 linkid=0
thing ship9 linkid=0
thing tempship local
surface switch linkid=1
int closedstring
int launchstring
int shipsready
int readyframe
int launchframe
int numframes
int numships local
int launching=0 local
int curship local
int inreadypos local
int endframe local
int closed local
int dummy local
sound activated=set_hi2.wav local
sound blocked=lgclick1.wav local
sound doorclosed=00alarmloop01.wav local
flex readydeley=0.25 local
flex launchdeley=0.5 local
flex readyspeed=2 local
flex launchspeed=4 local
flex movespeed=8 local
flex soundlen local
cog baydoor
message startup
message activated
message arrived
message timer
end
#==============================================================#
code
#------------------------------------------------------
startup:
Sleep(1);
for(curship = 0; ship0[curship] >= 0 && curship < 10; curship = curship + 1)
{
numships = numships + 1;
}
endframe = numframes - 1;
Return;
#------------------------------------------------------
activated:
if(GetSenderID() == 0) Return;
if(launching)
{
PlaySoundLocal(blocked, 1.0, 0, 0);
Return;
}
launching = 1;
SetWallCel(switch, 1);
PlaySoundLocal(activated, 1.0, 0, 0);
closed = SendMessageEx(baydoor, user0, 1, -1, -1, -1); // Check baydoor status
if(closed) // if doors are closed
{
soundlen = GetSoundLen(doorclosed);
soundlen = soundlen * 3;
dummy = PlaySoundLocal(doorclosed, 1.0, 0, 0x5);
jkPrintUNIString(-1, closedstring);
SetTimerEx(soundlen, 3, -1, -1);
SetWallCel(switch, 1);
launching = 0;
Return;
}
curship = 0;
inreadypos = shipsready;
jkPrintUNIString(-1, launchstring);
call launch;
Return;
#------------------------------------------------------
arrived:
tempship = GetSenderRef();
if(GetCurFrame(tempship) == readyframe)
{
SetTimerEx(readydeley, 1, tempship, -1);
}
else if(GetCurFrame(tempship) == launchframe)
{
SetTimerEx(launchdeley, 2, tempship, -1);
call launch;
}
else if(GetCurFrame(tempship) == endframe)
{
DestroyThing(tempship);
}
Return;
#------------------------------------------------------
timer:
tempship = GetParam(0);
if(GetSenderId() == 1)
{
call launch;
}
else if(GetSenderId() == 2)
{
MoveToFrame(tempship, endframe, movespeed);
}
else if(GetSenderId() == 3)
{
StopSound(dummy, 1);
}
Return;
#------------------------------------------------------
launch:
if(curship == numships)
{
SetWallCel(switch, 0);
SendMessageEx(baydoor, user0, 0, -1, -1, -1);
Return;
}
else if(curship == inreadypos)
{
MoveToFrame(ship0[curship], readyframe, readyspeed);
inreadypos = inreadypos + 1;
}
else if(curship < numships)
{
MoveToFrame(ship0[curship], launchframe, launchspeed);
curship = curship + 1;
}
Return;
#------------------------------------------------------
end[This message has been edited by force_dude (edited August 17, 2002).]
) use it all the time to check our syntax. Other then that... Here's something to help/solve your problems.
Now try it. ![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
As for the () I know all about them (except how to spell it correctly
), and what they do. I was talking about the middle parameter in the For loop for force_dude. (There's a tongue twister