PDA

View Full Version : A Simple Trap Cog Request



Daft_Vader
11-21-2005, 01:13 PM
I would like a thrust trap for Multi-player Deathmatch. When one of four pressure plates is trod on, a sound is played (so that everyone in the game can hear it), the forcefield is deactivated, and any player in one of 5 designated sectors is shot upwards at a very high speed.

Because the forcefield is deactivated, they shoot past it, and are killed by the impact of a ceiling above them. Keep in mind that AS LONG AS one or more players are standing on any or all of the four pressure plates, the reactor is shooting upwards, the sound is playing, and the forcefield is deactivated. As soon as the players move off the surface(s) the forcefield is reactivated and everything returns to normal.

This trap needs to work for Multiplayer, so I suppose I need both a client and server cog? Thanks. :)

ORJ_JoS
11-21-2005, 02:00 PM
m4_reactorthrust.cog does most of this. It works with switches instead of pressure plates and doors instead of forcefields. You may want to adapt that one. Also, it's for MP. (It's the Bespin Mining Station thrust trap) It also plays an alarm sound and has a light-effect for warning.

Hope this helps :)

Daft_Vader
11-21-2005, 02:23 PM
Thanks JoS, I did know of that cog, but I really need the pressure plates, and a forcefield instead of the doors. I don't know enough about cog to modify it myself, so I'm still dependent on some kind cogging soul, I'm afraid... :(

ORJ_JoS
11-22-2005, 09:18 AM
Well, I'm no cogger either, but as far as I know, for pressure-plates, you simply need to change the 'activated' message to 'touched' for the switch surface(s).

I'm sure someone will want to implement your forcefields... it's much less work to adapt that existing cog than to make a new cog from scratch. (I think - but I'm no cogger).

I'm sure someone will want to help you, it shouldn't be too hard for a 'real' cogger. :)

Daft_Vader
11-23-2005, 12:51 AM
No worries everyone, PhantomCoder has kindly made me the cog. You can see it in action in my hub contest level soon. ;)

ORJ_JoS
11-23-2005, 08:55 AM
Don't forget to post it here when it's done! :D

Daft_Vader
11-23-2005, 11:57 AM
Thanks for reminding me JoS. Here's the cog. It's free for public use, just remember to credit PhantomCoder for making it:


# JK Trap

symbols

flex ThrustSpeed desc=Thrust_Speed
surface Plate desc=Plate0
surface Plate1 desc=Plate1
surface Plate2 desc=Plate2
surface Plate3 desc=Plate3

surface ForceField desc=ForceField_Surf

sector ThrustSec desc=Thrust_Sector0
sector ThrustSec1 desc=Thrust_Sector1
sector ThrustSec2 desc=Thrust_Sector2
sector ThrustSec3 desc=Thrust_Sector3
sector ThrustSec4 desc=Thrust_Sector4

sound LoopSound desc=Loop_Sound
sound OnPlate desc=On_Plate_Sound
sound OffPlate desc=Off_Plate_Sound

int InCount=0 local
int TrapOn=0 local

message startup
message entered
message exited


end

code

startup:

InCount=0;
TrapOn=0;

ClearAdjoinFlags(ForceField, 0x2);

return;

entered:

if(GetSenderType() != 6) return;

InCount=InCount+1;

PlaySoundPos(OnPlate, SurfaceCenter(GetSenderRef()), 1, -1, -1, 0);

if(InCount > 0 && TrapOn == 0)
{
//Play Sound
Channel=PlaySoundGlobal(LoopSound, 1, 0, 0x101);

//Deactivate Field
SetAdjoinFlags(ForceField, 0x2);
SetFaceGeoMode(ForceField, 0);

//Thrust Sectors Upwards
// unattach all players in sectors
for(x=0; x<5; x=x+1)
{
SetSectorThrust(ThrustSec[x], '0 0 1', ThrustSpeed);
currentThing = FirstThingInSector(ThrustSec[x]);
while (currentThing != -1)
{
call reactorpull;
currentThing = NextThingInSector(currentThing);
}
}
TrapOn=1;
}

return;

exited:

if(GetSenderType() != 6) return;

InCount=InCount-1;

PlaySoundPos(OffPlate, SurfaceCenter(GetSenderRef()), 1, -1, -1, 0);

if(InCount == 0 && TrapOn)
{
//Stop Sound
StopSound(Channel, 0);
//Activate Field
ClearAdjoinFlags(ForceField, 0x2);
SetFaceGeoMode(ForceField, 4);
//Stop Thrust Sectors
for(x=0; x<5; x=x+1)
{SetSectorThrust(ThrustSec[x], '0 0 1', 0);}

TrapOn=0;
}

return;

reactorpull:

if (GetThingType(currentThing) == 10)
{
DetachThing(currentThing);
playerVec = GetThingVel(currentThing);
playerVec = VectorAdd(vec0, playerVec);
SetThingVel(currentThing, playerVec);
}
return;

end