No(Block/Clip)Mask

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: No(Block/Clip)Mask

Re: No(Block/Clip)Mask

by Major Cooke » Fri Mar 06, 2015 6:21 pm

That's fine. Just thought, if anything, well, at least it works. I've done a couple more bug fixes which I've yet to upload but if you don't want this, no biggie.

Re: No(Block/Clip)Mask

by randi » Fri Mar 06, 2015 6:20 pm

Yeah... That's not at all what I had in mind.

Re: No(Block/Clip)Mask

by Major Cooke » Fri Mar 06, 2015 2:42 pm

My obsessive compulsiveness took over and made me finish it. And I was bored. Still doing some more thorough testing but so far, everything seems to be running alright.

I don't care if you do use it, randi. I know you said you'll probably do it yourself. I'm just bringing it up because I was bored, and this felt like a nasty itch that could only be cured by just doing it anyway. Even if it winds up a waste of time, I still learned quite a bit from it. :geek:

There's no pull request yet because I'm still fine-testing as much as I can.

Re: No(Block/Clip)Mask

by Major Cooke » Wed Mar 04, 2015 9:16 pm

Means in short when Randi does this, my previous submission for MTHRUSPECIES flags will be made useless. Except as a reminder that maybe species should be respected on bfg sprays and rail attacks.

Re: No(Block/Clip)Mask

by Xtyfe » Wed Mar 04, 2015 9:14 pm

I understand this will change how these functions work internally, but I'm not sure I understand the end result. How will it be different?

Re: No(Block/Clip)Mask

by Major Cooke » Tue Mar 03, 2015 6:37 pm

None taken. This was proving to be a bit of a mouthful anyway. I have one request though, something to change the masks with a DECORATE function, please.

Do you want what I already have?

Re: No(Block/Clip)Mask

by randi » Tue Mar 03, 2015 6:36 pm

No offence, but I think I'd rather do it myself.

Re: No(Block/Clip)Mask

by Major Cooke » Tue Mar 03, 2015 4:13 pm

Okay, curious. THRUSPECIES and MTHRUSPECIES behaved similarly to what masks are going to do, right?

Code: Select all

	case DEPF_THRUSPECIES:	
	case DEPF_MTHRUSPECIES: //It basically did it just like masks.
		defaults->NoBlockMask |= MASK_Species;
		defaults->NoClipMask |= MASK_Species;
		break;
Is that okay?

Re: No(Block/Clip)Mask

by Major Cooke » Tue Mar 03, 2015 2:16 pm

Yeah. I've got two flag fields, NoBlockMask and NoClipMask. I've figured out the deprecated flag handler, so I believe that should be good. In fact, I'll upload progress as soon as I reach a good stopping point for others to inspect.

About those flags with ghost, I figured making a function to handle things like that would help. Like:

Code: Select all

// Check if the mask is in noclip of one actor and noblock of the other. Inverse will
	// change clip to block checking on the caller, and vice versa on the other. Can check for
	// the flag as well if noflag is left to false, but just note missile checking won't work
	// properly without it (since it's a non-monster, it'll make it return true).
	inline bool crossCheckMask(AActor *other, int mask, bool noflag = false)
	{
		if (other)
		{
			if (mask == MASK_Ghost && !(noflag))
				return (((flags3 & MF3_GHOST) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Monsters && !(noflag))
				return (((flags3 & MF3_ISMONSTER) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Missiles && !(noflag))
				return (((flags & MF_MISSILE) || (NoClipMask & mask)) && (other->NoBlockMask & mask));

			else if (mask == MASK_Objects && !(noflag)) //Special case: Ensure neither actor is a missile.
				return ((!(flags3 & MF3_ISMONSTER) || (NoClipMask & mask)) && (other->NoBlockMask & mask) && !(flags | other->flags & MF_MISSILE));
			else
			{
				if (mask == MASK_Species && (GetSpecies() != other->GetSpecies()))
					return false; //Only the same species can pass through one another.
				return ((NoClipMask & other->NoBlockMask) & mask);
			}
		}
		return false;
	}

Re: No(Block/Clip)Mask

by Graf Zahl » Tue Mar 03, 2015 1:58 pm

Flag fields would be two actor properties.
But to map the old flags to those new properties you have to use the deprecated flags mechanism, you can't do the reassignments inside the property parser functions themselves.

Another issue is flags that also have another meaning, like 'Ghost'. Some investigation is needed to handle these properly with the new mask fields.

Re: No(Block/Clip)Mask

by Major Cooke » Tue Mar 03, 2015 1:05 pm

Yea, I'm a little nervous about doing this myself, but randi said this is how he wanted it... I think...
randi wrote:I would much rather see two new flags fields: clipmask and blockmask. Clipmask controls what an object is blocked by, and blockmask controls what an object blocks. Some existing flags could be moved into these, and some could be implied by existing flags.

The point is that the blocking check becomes a single bitwise and of the two fields without dozens of lines of nearly identical duplicated code. It also offers more flexibility.

Yes, it will require some more setup code for compatibility, but I think it's worth it
Unless I misinterpreted what he said about "flags fields"?

Re: No(Block/Clip)Mask

by Graf Zahl » Tue Mar 03, 2015 10:38 am

You cannot check for flags in the property parser. They need to be handled as deprecated flags. And you need to OR the flags, not add them.
You also shouldn't implement something too complex. Deprecated flags are not supposed to be used in conjunction with the feature that replaces them.

Be careful, this has a high potential of going wrong as it possibly needs to shuffle around more than a few things.

No(Block/Clip)Mask

by Major Cooke » Tue Mar 03, 2015 9:38 am

I've begun working on NoBlockMask and NoClipMask. I changed it from BlockMask/ClipMask to "No" version because otherwise users would have to keep track of which flags they would need to follow through with, and in relation to THRU flags, it's the same as having the No affixed to it.

Graf/Randi: I've got the property made now, and a function to control it.

Still a WIP, but I wanted to check: I should replace the flag checks where appropriate, and have A_ChangeFlag simply add/subtract the flag from their masks, right? Somewhat like I did here:

Code: Select all

//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(NoClipMask, O, Actor) //O has been set up to parse mask flags
{
	// What doesn't the actor block?
	PROP_INT_PARM(val, 0);

	// [MC] Handle actor flags here.
	// MASK_ALl doesn't combine all of them, because this could break things like bullet 
	// puffs with species. Instead, it'll just take priority like the THRUACTORS flag does.

	if ((defaults->flags2 & MF2_THRUACTORS) && !(val & MASK_All))
		val += MASK_All; 
	if ((defaults->flags2 & MF2_THRUGHOST) && !(val & MASK_Ghost))
		val += MASK_Ghost;
	if ((defaults->flags2 & MF6_THRUSPECIES) && !(val & MASK_Species))
		val += MASK_Species;
	if ((defaults->flags2 & MF6_MTHRUSPECIES) && !(val & MASK_MSpecies))
		val += MASK_MSpecies;

	if (val)
		defaults->NoClipMask = val;
	else
		defaults->NoClipMask = MASK_Default;
}

//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(NoBlockMask, O, Actor)
{
	// What isn't the actor blocked by?
	PROP_INT_PARM(val, 0);

	if ((defaults->flags2 & MF2_THRUACTORS) && !(val & MASK_All))
		val += MASK_All;
	if ((defaults->flags2 & MF2_THRUGHOST) && !(val & MASK_Ghost))
		val += MASK_Ghost;
	if ((defaults->flags2 & MF6_THRUSPECIES) && !(val & MASK_Species))
		val += MASK_Species;
	if ((defaults->flags2 & MF6_MTHRUSPECIES) && !(val & MASK_MSpecies))
		val += MASK_MSpecies;

	if (val)
		defaults->NoBlockMask = val;
	else
		defaults->NoBlockMask = MASK_Default;
}

Top