Hi!
Sorry if I asked you guys to make a sentry gun COG for me... I made a class cog and it doesn't seem to work... Help?
In the while I test to see if the thing is moving cause I want it to NOT unfold if it's falling. I want it to unfold when it has come to a complete stop and has attached itself to a surface.
BUT, non of the keys seem to respond. It plays the sound but it doesn't unfold, nor does it target me and fire. OK not fire, but play the sound of fireing. Doesn't move at all. I've given it this template:
Oh, and it keeps sliding off the walls when I want it to stick! And I don't collide into it!
Keys will come...
Sorry if I asked you guys to make a sentry gun COG for me... I made a class cog and it doesn't seem to work... Help?
Code:
# Sentry Gun Class COG
#
# By Edward
symbols
message created
message pulse
thing sentry local
template boom=+grenade_exp local
template proj=+stlaser local
keyframe opening=Sentry_Open.key local
keyframe idle=Sentry_Idle.key local
keyframe over=Sentry_Down.key local
sound open=Ed_Sadar_Ready.wav local
sound going=scalarm.wav local
sound empty=pistout1.wav local
sound moving=weegeemove01.wav local
sound firy=SentryGun_Fire.wav local
int ammo local
int thekey=-1 local
int chan=1 local
flex dot local
flex maxdot=0 local
model xeno=alien.3do local
thing victim=-1 local
int potential=-1 local
end
#
code
created:
sentry=GetSenderRef();
thekey=PlayKey(sentry,opening,1,0x1);
ammo=500;
sleep(0.2);
while(IsThingMoving(sentry))
{
sleep(0.1);
}
StopKey(sentry,thekey,0.1);
PlaySoundThing(open,sentry,1,-1,10,0xC0);
thekey=PlayKey(sentry,opening,1,0x4);
sleep(1);
StopKey(sentry,thekey,0.1);
thekey=PlayKey(sentry,idle,1,0x0);
SetPulse(.1);
return;
pulse:
victim=-1;
maxdot=0;
potential=FirstThingInView(sentry,90,1,0x404);
while(potential!=-1)
{
if(HasLOS(sentry,potential) && (potential!=sentry) && (VectorDist(GetThingPos(sentry), GetThingPos(potential)) <= 1) && !(GetThingFlags(potential) & 0x200) && !((jkGetFlags(potential) & 0x20) && !IsInvActivated(sentry, 23)))
{
dot=ThingViewDot(sentry,potential);
if(dot>maxdot)
{
victim=potential;
maxdot=dot;
PlaySoundThing(firy,sentry,1,-1,10,0xC0);
}
}
Potential=NextThingInView();
}
############################################################################
if(ammo<=0)
{
PlaySoundThing(empty,sentry,1,-1,10,0xC0);
SetPulse(0);
StopKey(sentry,thekey,1);
thekey=PlayKey(sentry,over,1,0x4);
chan=PlaySoundThing(moving,sentry,1,-1,10,0xC0);
ChangeSoundPitch(chan,.1,1);
sleep(1);
PlaySoundThing(going,sentry,1,-1,10,0xC0);
Sleep(GetSoundLen(going) + 0.25);
PlaySoundThing(going,sentry,1,-1,10,0xC0);
Sleep(GetSoundLen(going) + 0.25);
CreateThing(boom,sentry);
DestroyThing(sentry);
}
return;
endIn the while I test to see if the thing is moving cause I want it to NOT unfold if it's falling. I want it to unfold when it has come to a complete stop and has attached itself to a surface.
BUT, non of the keys seem to respond. It plays the sound but it doesn't unfold, nor does it target me and fire. OK not fire, but play the sound of fireing. Doesn't move at all. I've given it this template:
Code:
sentrygun _weapon timer=86400 size=0.04 movesize=0.04 model3d=Sentry.3DO vel=(0/.1/0) physflags=0x429B typeflags=0x00A81 explode=+grenade_exp fleshhit=+sequencer_exp cog=class_sentrygun.cog soundclass=sentry.snd surfdrag=100.000000 airdrag=10.000000 collide=1 pup=sentry.pup mass=5
Oh, and it keeps sliding off the walls when I want it to stick! And I don't collide into it!
Keys will come...
That lost a few hairs on my head back in the day. ![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)
![http://forums.massassi.net/html/tongue.gif [http://forums.massassi.net/html/tongue.gif]](http://forums.massassi.net/html/tongue.gif)