So, cogging is not my strong point. I just want to make sure that this abomination will work for both client and server. I don't want it updated or renovated unless it has to be. I conjured up this beast on a whim, and I'd like to just stick with things that I know work, since testers are hard to find.
Yes, it's ugly, but will it work for all parties involved?
Yes, it's ugly, but will it work for all parties involved?
Code:
# Jedi Knight Cog Script
#
# What the hell have I done?
#
# This should allow 2 switches to control a sector which can both heal and damage a player.
#
# Modified from 00_sectordamage.cog
flags=0x240
symbols
message startup
message activate
message pulse
sector deltaSector # the life/death sector
flex damageInterval=1.0 # damage applied in seconds
flex damage=4.0 # how much damage is applied
flex heal=4.0 # how much health is applied
thing victim local # actors and players affected.
surface switch0
surface switch1
int type local
int toggle=0 local
sound switchon=forcefieldon01.wav local
sound switchoff=forcefieldoff01.wav local
end
# Code Section
code
startup:
if (GetWallCel(switch0) == 0)
{
SetWallCel(switch0, 0);
SetWallCel(switch1, 0);
toggle = 1;
}
else
{
SetWallCel(switch0, 1);
SetWallCel(switch1, 1);
toggle = 0;
}
if(deltaSector > -1) SetPulse(damageInterval);
return;
activate:
if (GetWallCel(switch0) == 1)
{
PlaySoundPos(switchoff, SurfaceCenter(switch0), 1, -1, -1, 0);
PlaySoundPos(switchoff, SurfaceCenter(switch1), 1, -1, -1, 0);
SetWallCel(switch0, 0);
SetWallCel(switch1, 0);
toggle = 1;
}
else if (GetWallCel(switch0) == 0)
{
PlaySoundPos(switchon, SurfaceCenter(switch0), 1, -1, -1, 0);
PlaySoundPos(switchon, SurfaceCenter(switch1), 1, -1, -1, 0);
SetWallCel(switch0, 1);
SetWallCel(switch1, 1);
toggle = 0;
}
return;
pulse:
victim = FirstThingInSector(deltaSector);
while (victim != -1)
{
type = GetThingType(victim);
// If we have an actor (2) or a player (10)
if ((type==2) || (type==10))
{
// Do the damage or healing.
if (toggle > 0)
{
DamageThing(victim, damage, 0x1, victim);
}
else
{
HealThing(victim, heal);
}
}
victim = NextThingInSector(victim);
}
return;
end