Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Nash on May 21, 2011, 08:02:26 pm

Title: no pierce shields
Post by: Nash on May 21, 2011, 08:02:26 pm
The "no pierce shields" flag when added to beam weapons in weapons table file is not working properly. Beam hits shield causing shield to glow but always continues through shield and hits hull anyway doing no damage to shield along the way.

Has anybody else had this problem?
Solution to make flag work properly?

Tried flag fsopen 3.6.10 and 3.6.12

Thanks in advance! Nash
Title: Re: no pierce shields
Post by: Nash on May 22, 2011, 06:47:25 pm
Found Problem with "no pierce shields" !!!

The "no pierce shields" flag must be placed last after "beam" as shown below. Works properly now. (Example given below.)


$Flags: ("in tech database" "player allowed" "beam" "no pierce shields" )
Title: Re: no pierce shields
Post by: General Battuta on May 22, 2011, 07:26:29 pm
Weird, and good to know. We should document that on the wiki (i should do it right now but i :effort:)
Title: Re: no pierce shields
Post by: karajorma on May 22, 2011, 08:06:12 pm
I can see exactly why that's the case just looking at the code.

Code: [Select]
else if (!stricmp(NOX("beam"), weapon_strings[i]))
{
weaponp->wi_flags |= WIF_BEAM;

// IMPORTANT: beams pierce shields by default :rolleyes: :p - Goober5000
weaponp->wi_flags2 |= WIF2_PIERCE_SHIELDS;
}

......


else if (!stricmp(NOX("pierce shields"), weapon_strings[i]))
weaponp->wi_flags2 |= WIF2_PIERCE_SHIELDS;
else if (!stricmp(NOX("no pierce shields"), weapon_strings[i])) // only for beams
weaponp->wi_flags2 &= ~WIF2_PIERCE_SHIELDS;

In simple terms, the beam flag resets the pierce shields flag ignoring whatever was set before. Theoretically you could just swap the internal logic around and make the WIF2_PIERCE_SHIELDS flag into WIF2_DON'T_PIERCE_SHIELDS and then remove the line after Goober's comment but the code is probably peppered with assumptions that beams do pierce by default and you'd probably screw up a bunch of stuff.

Which may mean that simply putting a note in the wiki is the simplest solution.
Title: Re: no pierce shields
Post by: Goober5000 on May 25, 2011, 03:41:28 am
Actually I'm pretty sure I put that there when the shield piercing logic was changed to check for the WIF2_PIERCE_SHIELDS constant rather than the WIF_BEAM constant.  Whoever made that change in the code forgot to initially set that internal flag when the weapon was actually parsed.

So the solution would be to either always make sure the "no pierce shields" string appears last in the tbl, or to add some sort of code logic that applies pierce/no-pierce after all flags have been parsed.
Title: Re: no pierce shields
Post by: FUBAR-BDHR on May 25, 2011, 01:18:48 pm
A better solution might be to check during parse if the beam flag is set or not.  If not store to a temp variable.  When you hit the beam one and the temp variable is already set turn it on and set the temp variable to false.  Get to the end of parsing and the temp variable is still true toss a "hey idiot your trying to set a beam flag on a non beam weapon" warning in debug builds.
Title: Re: no pierce shields
Post by: Goober5000 on May 25, 2011, 02:25:38 pm
That's kind of what I said, but backwards, and unnecessarily restrictive.
Title: Re: no pierce shields
Post by: Goober5000 on May 25, 2011, 10:40:29 pm
Reported as Mantis #2442 and fixed.
Title: Re: no pierce shields
Post by: General Battuta on May 25, 2011, 10:43:01 pm
Tomorrow on Mantis: beams deal no damage, shield meshes are inverted and block only shots from the inside, all briefing icons are rendered as GTNB Pharos
Title: Re: no pierce shields
Post by: Goober5000 on May 27, 2011, 03:22:37 pm
NO U