Help with moving forcefields

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Help with moving forcefields

Postby stevet1 » Mon May 31, 2021 2:21 am

I'm trying to build a forcefield (well several eventually) that moves along a corridor and back again so that you have to time it correctly to avoid it. I have started to make this this by having lines every 4 map units and using the following acs code to "move" the forcefield by switching line properties on and off of adjacent lines -
while (vForceFieldOn)
{
for ( int Lineid = 75; Lineid <= 154; Lineid++ )
{

Line_SetBlocking(lineID, 32, 0);
SetLineTexture(lineID, SIDE_FRONT, TEXTURE_MIDDLE, "N_FFLD1A");
SetLineTexture(lineID, SIDE_BACK, TEXTURE_MIDDLE, "N_FFLD1A");

Line_SetBlocking(vOldLineID, 0, 32);
SetLineTexture(vOldLineID, SIDE_FRONT, TEXTURE_MIDDLE, "-");
SetLineTexture(vOldLineID, SIDE_BACK, TEXTURE_MIDDLE, "-");

vOldLineID = Lineid;

delay(2);

}

for ( int Lineid2 = 153; Lineid2 >= 74; Lineid2-- )
{

Line_SetBlocking(Lineid2, 32, 0);
SetLineTexture(Lineid2, SIDE_FRONT, TEXTURE_MIDDLE, "N_FFLD1A");
SetLineTexture(Lineid2, SIDE_BACK, TEXTURE_MIDDLE, "N_FFLD1A");

Line_SetBlocking(vOldLineID, 0, 32);
SetLineTexture(vOldLineID, SIDE_FRONT, TEXTURE_MIDDLE, "-");
SetLineTexture(vOldLineID, SIDE_BACK, TEXTURE_MIDDLE, "-");

vOldLineID = Lineid2;

delay(2);

}
}

Each line has an activation tag for when the player bumps which calls another script
if ( vForceFieldOn )
{
ThrustThing(random(160, 224), 64);
DamageThing(random(5, 25));

}
This makes the forcefield appear to move sucessfully, and if the player walks into the line works correctly, but my problem is that if the player stands still the forcefield just moves over them as the player hasn't technically bumped into the line. Does anyone have any suggestions how to get around this, or a better method?
Thanks.
stevet1
 
Joined: 28 Jan 2021

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests