PDA

View Full Version : May the Forcefield be with you...



Electro
01-24-2001, 01:44 PM
Hi, i just edited this forcefield cog from an LEC cog, i am not that good at programming it so i took my best shot, the problem is, when the level starts, the forcefields are turned on, i want it so the forcefields are off when the level starts, and they can be turned on by the switch, can anyone point out how to do this, the cog follows:

# Jedi Knight Cog Script
#
# Multifieldswitch.cog
#
# This script operates up to 10 forcefield surfaces that damages
# the player and can be turned on/off by a switch. Very handy for security system type things
# It also sets this surface to be nomove and translucent.
#
# [EL3CTRO]
#
# 24/01/2001
#
# (C) 2001 EL3CTROPROSE Software. All Rights Reserved
# ================================================== ======================================

symbols

message startup
message damaged
message activated
message touched
message timer

sound poweroff=activate04.wav local
sound poweron=activate01.wav local
sound hitsurf=ForceFieldHit01.wav local

surface switch linkid=1
surface switch1 linkid=1
surface damsurf0 linkid=3 mask=0x448
surface damsurf1 linkid=3 mask=0x448
surface damsurf2 linkid=3 mask=0x448
surface damsurf3 linkid=3 mask=0x448
surface damsurf4 linkid=3 mask=0x448
surface damsurf5 linkid=3 mask=0x448
surface damsurf6 linkid=3 mask=0x448
surface damsurf7 linkid=3 mask=0x448
surface damsurf8 linkid=3 mask=0x448
surface damsurf9 linkid=3 mask=0x448

flex maxdamage=10.0
flex mindamage=5.0
flex damage=0.0 local
flex interval=0.25 local

int damaging=1 local
int garbage=0 local
int garbage2=0 local

thing victim local

template sparks=+heavysmoke local

end

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

code

startup:
SetWallCel(switch,0); //on
ClearAdjoinFlags(damsurf0,2); //no move
ClearAdjoinFlags(damsurf1,2);
ClearAdjoinFlags(damsurf2,2);
ClearAdjoinFlags(damsurf3,2);
ClearAdjoinFlags(damsurf4,2);
ClearAdjoinFlags(damsurf5,2);
ClearAdjoinFlags(damsurf6,2);
ClearAdjoinFlags(damsurf7,2);
ClearAdjoinFlags(damsurf8,2);
ClearAdjoinFlags(damsurf9,2);
SetFaceGeoMode(damsurf0,0); //translucent
SetFaceGeoMode(damsurf1,0);
SetFaceGeoMode(damsurf2,0);
SetFaceGeoMode(damsurf3,0);
SetFaceGeoMode(damsurf4,0);
SetFaceGeoMode(damsurf5,0);
SetFaceGeoMode(damsurf6,0);
SetFaceGeoMode(damsurf7,0);
SetFaceGeoMode(damsurf8,0);
SetFaceGeoMode(damsurf9,0);
SetSurfaceFlags(damsurf0,16384); //magsealed
SetSurfaceFlags(damsurf1,16384);
SetSurfaceFlags(damsurf2,16384);
SetSurfaceFlags(damsurf3,16384);
SetSurfaceFlags(damsurf4,16384);
SetSurfaceFlags(damsurf5,16384);
SetSurfaceFlags(damsurf6,16384);
SetSurfaceFlags(damsurf7,16384);
SetSurfaceFlags(damsurf8,16384);
SetSurfaceFlags(damsurf9,16384);
SurfaceLightAnim(damsurf0, 0.4, 1.0, 0.5); // animate surface
SurfaceLightAnim(damsurf1, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf2, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf3, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf4, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf5, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf6, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf7, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf8, 0.4, 1.0, 0.5);
SurfaceLightAnim(damsurf9, 0.4, 1.0, 0.5);
return;

# .................................................. ......................................

activated:
if ((GetWallCel(switch) == 0) && (GetSenderId() == 1))
{
PlaySoundPos(poweroff, SurfaceCenter(switch), 1.0, -1, -1, 0 );
PlaySoundPos(poweroff, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch,1);
SetWallCel(switch1,1); //off
SetAdjoinFlags(damsurf0,2); //move
SetAdjoinFlags(damsurf1,2);
SetAdjoinFlags(damsurf2,2);
SetAdjoinFlags(damsurf3,2);
SetAdjoinFlags(damsurf4,2);
SetAdjoinFlags(damsurf5,2);
SetAdjoinFlags(damsurf6,2);
SetAdjoinFlags(damsurf7,2);
SetAdjoinFlags(damsurf8,2);
SetAdjoinFlags(damsurf9,2);
}
else if ((GetWallCel(switch) == 1) && (GetSenderId() == 1))
{
PlaySoundPos(poweron, SurfaceCenter(switch), 1.0, -1, -1, 0 );
PlaySoundPos(poweron, SurfaceCenter(switch1), 1.0, -1, -1, 0);
SetWallCel(switch,0);
SetWallCel(switch1,0); //on
ClearAdjoinFlags(damsurf0,2); //no move
ClearAdjoinFlags(damsurf1,2);
ClearAdjoinFlags(damsurf2,2);
ClearAdjoinFlags(damsurf3,2);
ClearAdjoinFlags(damsurf4,2);
ClearAdjoinFlags(damsurf5,2);
ClearAdjoinFlags(damsurf6,2);
ClearAdjoinFlags(damsurf7,2);
ClearAdjoinFlags(damsurf8,2);
ClearAdjoinFlags(damsurf9,2);
}
return;

# .................................................. ......................................

touched:
if ((GetSenderID() == 3) && (damaging == 1))
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
victim = GetSourceRef();
damage = (Rand()*(maxdamage - mindamage))+mindamage;
DamageThing(victim,damage,0x2,victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
damaging=0;
SetTimerEx(interval, 1, 0, 0);
}
else return;

# .................................................. ......................................

damaged:
victim = GetThingParent(GetSourceRef());

if((GetParam(1) == 1) && (GetThingType(victim) == 10))
{
damage = (Rand()*(maxdamage - mindamage))+mindamage;
DamageThing(victim, damage, 0x1, victim);
if(!IsMulti()) CreateThing(sparks, GetSourceRef());
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
SetFaceGeoMode(damsurf0,3);
SetFaceGeoMode(damsurf1,3);
SetFaceGeoMode(damsurf2,3);
SetFaceGeoMode(damsurf3,3);
SetFaceGeoMode(damsurf4,3);
SetFaceGeoMode(damsurf5,3);
SetFaceGeoMode(damsurf6,3);
SetFaceGeoMode(damsurf7,3);
SetFaceGeoMode(damsurf8,3);
SetFaceGeoMode(damsurf9,3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}
else
{
PlaySoundPos(hitsurf, SurfaceCenter(damsurf), 1.0, -1, -1, 0 );
SetFaceGeoMode(damsurf0,3);
SetFaceGeoMode(damsurf1,3);
SetFaceGeoMode(damsurf2,3);
SetFaceGeoMode(damsurf3,3);
SetFaceGeoMode(damsurf4,3);
SetFaceGeoMode(damsurf5,3);
SetFaceGeoMode(damsurf6,3);
SetFaceGeoMode(damsurf7,3);
SetFaceGeoMode(damsurf8,3);
SetFaceGeoMode(damsurf9,3);
KillTimerEx(2);
SetTimerEx(0.5, 2, 0, 0);
}

return;

# .................................................. ......................................

timer:
if(GetSenderId() == 1)
{
damaging=1;
}

if(GetSenderId() == 2)
{
SetFaceGeoMode(damsurf0,0);
SetFaceGeoMode(damsurf1,0);
SetFaceGeoMode(damsurf2,0);
SetFaceGeoMode(damsurf3,0);
SetFaceGeoMode(damsurf4,0);
SetFaceGeoMode(damsurf5,0);
SetFaceGeoMode(damsurf6,0);
SetFaceGeoMode(damsurf7,0);
SetFaceGeoMode(damsurf8,0);
SetFaceGeoMode(damsurf9,0);
}

return;

end

------------------
Generating Electro Vibes™ for the masses on Massassi
Go To: HERE (http://electroprose.clanpages.com)

LoA_Anxious_Bob
01-24-2001, 04:43 PM
I too had that problem, but the cog that i did wasn't that complicated, it only had 2 damage surfs. Anyway, what i did is copy everything from the activated message and put it at the end of the startup section. That way it will be like activating after it does all the startup stuff.

Hideki
01-25-2001, 08:12 AM
Delete all lines in startup and put the
"if ((GetWallCel(switch) == 0) && (GetSenderId() == 1))"
statement lines in the activated message to the startup.

------------------
http://millennium.massassi.net/ - Millennium