Bring a can of raid


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

Posted by Nightmare on November 23, 1998 at 21:42:11:

Well, I've been working on this cog for some time and I still have a few bugs to work out. I thought maybe someone here could see something I'm missing. Anyway, supposedly, you flip a switch and a little target shows up and starts flying around. When it reaches it's last frame, or it's damaged, it is supposed to return to frame 0 and reset everything so you can do it again. It all works fine the first time around, after that, if you shoot it, it explodes but doesn't drop the powerup. If you let it reach frame 1 without being blown up, it dissappears, but you can still hear it flying around. After a short delay (the time for it to move through the remaining frames to lastframe, I think) it shows up back at frame 0, but doesn't reset the switch or numbers or anything. Weird. I just can't see what's wrong. The target thing use a template based on "flyingcrow, except that the collide is set to 1 (sphere), it uses the sentry droid 3do, and I gave it a .snd (custom one based on an elevator, but with droid-like sounds). If anyone sees what I'm doing wrong, please tell me. I've been looking at this cog for a few days now and I don't see it.

Thanks in advance.

Nightmare


# Jedi Knight Cog Script
#
# target_practice.cog
#
# Runs two objects throught their frames at the activation of a switch, if damaged, they return to their origial positions.
#
# 11/21/98 Nightmare

symbols

message startup
message activated
message arrived
message damaged

thing redtarget mask=-1
thing yellowtarget mask=-1

sector rsector local
sector ysector local

template explode=+firecloud
template powerup=+denergycell

sound click=beep1.wav

surface redswitch linkid=1
surface yellowswitch linkid=2

int rworking=0 local
int yworking=0 local
int rframe=0 local
int yframe=0 local
int dummy local
int rhit=1 local
int yhit=2 local

int lastframe

flex speed=3

end

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

code

startup:

rsector = GetThingSector(redtarget); // get the sectors, used
ysector = GetThingSector(yellowtarget); // in the jumptoframe() statements

return;

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

activated:

// if it's a target, return

if((GetSenderRef() == redtarget) || (GetSenderRef() == yellowtarget)) return;

// if it's the red switch

if(GetSenderID() == 1)
{
if(rworking==1) return; // make sure it's not already in a cycle
rworking=1; // begin a cycle

SetWallCel(redswitch, 1); // mess with the switch
PlaySoundPos(click, SurfaceCenter(redswitch), 1.0, -1, -1, 0);

MoveToFrame(redtarget, lastframe, speed); // move to last frame, since
// this is a movetoframe()
// ststement, the target
// will go through all
// interveaning frames to
// reach lastframe

rhit = 0; // we haven't blown it up yet

return;
}

// the yellow target is the same as for the red target, just a color change

if(GetSenderID() == 2)
{
if(yworking==1) return;
yworking=1;

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

MoveToFrame(yellowtarget, lastframe, speed);

yhit = 0;

return;
}

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

arrived:

if(GetSenderRef() == redtarget) // if it's the red target
{
if(rhit == 1) return;

rframe = GetCurFrame(redtarget); // find the current frame

if(rframe == lastframe) // if this is the last frame
{
rhit = 1; // the target is no longer destructable
SkipToFrame(redtarget, 0, speed); // go to frame zero, where the cycle will end
return;
}

if(rframe == 0)
{
SetWallCel(redswitch, 0); // reset the switch
PlaySoundPos(click, SurfaceCenter(redswitch), 1.0, -1, -1, 0);
rframe=0; // end the cycle
rworking=0;
}

}

if(GetSenderRef() == yellowtarget) // again, same as for the red target
{
if(yhit == 1) return;

yframe = GetCurFrame(yellowtarget);

if(yframe == lastframe)
{
yhit = 1;
SkipToFrame(yellowtarget, 0, speed);
return;
}
if(yframe == 0)
{
SetWallCel(yellowswitch, 0);
PlaySoundPos(click, SurfaceCenter(yellowswitch), 1.0, -1, -1, 0);
yframe=0;
yworking=0;
}

}

return;

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

damaged:

if(GetSenderRef() == redtarget) //if this is the red target
{

if(rhit == 1) return; // make sure it's still alive

if(IsThingMoving(redtarget)) stopthing(redtarget);

rhit = 1; // then make sure it's not
rframe = 0;

dummy = CreateThing(explode, redtarget); // bang! pow!
dummy = CreateThing(powerup, redtarget); // trick or treat

JumpToFrame(redtarget, 0, rsector); // teleport back to the start position

SetWallCel(redswitch, 0); // reset the system
PlaySoundPos(click, SurfaceCenter(redswitch), 1.0, -1, -1, 0);
rframe=0;
rworking=0;
}

if(GetSenderRef() == yellowtarget) // in case you havent guessed, the yellow target works just like the red target
{

if(yhit == 1) return;

if(IsThingMoving(yellowtarget)) stopthing(yellowtarget);

yhit = 1;
yframe = 0;

dummy = CreateThing(explode, yellowtarget);
dummy = CreateThing(powerup, yellowtarget);

JumpToFrame(yellowtarget, 0, ysector);

SetWallCel(yellowswitch, 0);
PlaySoundPos(click, SurfaceCenter(yellowswitch), 1.0, -1, -1, 0);
yframe=0;
yworking=0;

}

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 ]