Cog Question


[ Follow Ups ] [ Post Followup ] [ The Massassi Temple Message Board ]

Posted by Nightmare on November 21, 1998 at 23:44:30:

This cog is supposed to move the "target" throught it's frames to "lastframe" at the activation of a switch. If it reaches "lastframe" or is damaged, it is supposed to retur to the starting position. My problem is that I can't seem to get the activated message when I have the damage mask set on the "target". waitforstop(target) doesn't work either. Can anyone suggest a remedy?

# Jedi Knight Cog Script
#
# shooting_range.cog
#
# 11/21/98 Nightmare

symbols

message activated
message arrived
message damaged

thing target mask=0x408
thing genpos nolink

template explode

sound flysound
sound click

surface switch

int working=0 local
int currentframe=0 local
int dummy local
int targetsnd local


int lastframe

flex speed

end

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

code

activated:

if(GetSenderRef() == target) return;
{

if(working==1) return;
working=1;

SetWallCel(switch, 1);
PlaySoundPos(click, SurfaceCenter(switch), 1.0, -1, -1, 0);

MoveToFrame(target, 1, speed);

targetsnd = PlaySoundThing(flysound, target, 10.0, -1, -1, 0x41);

return;

}

return;

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

arrived:

if(GetSenderRef() == target)
{
currentframe = GetCurFrame(redtarget);

if(currentframe == 0) return;

if(currentframe == lastframe)
{
SetWallCel(switch, 0);
PlaySoundPos(click, SurfaceCenter(switch), 1.0, -1, -1, 0);
StopSound(targetsnd, 0);
TeleportThing(target, genpos);
SkipToFrame(target, 0, speed);
currentframe=0;
working=0;
return;
}

currentframe=currentframe + 1;
MoveToFrame(target, currentframe, speed);
}

return;


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

damaged:

if(GetSenderRef() == target)
{

if(working == 0) return;

dummy = CreateThing(explode, target);

SetWallCel(switch, 0);
PlaySoundPos(click, SurfaceCenter(switch), 1.0, -1, -1, 0);

StopSound(targetsnd, 0);

TeleportThing(target, genpos);
SkipToFrame(target, 0, speed);

currentframe=0;
working=0;

return;

}

return;

end





Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ The Massassi Temple Message Board ]