Bitfield and building mask issues
Moderator: Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Bitfield and building mask issues
Normal Ground has a mask value of 1.
I have a field (control points) that I need only certain units to be able to be built upon this ground, but units also need to be able to build on regular ground as well.
So it would appear that if I set a unitdef building mask to 5, that unit should be able to be built on regular ground, because 5 intersects with 1.
So if I set control points to 4, then units with a mask of 5 should be able to build in control points and on regular ground. Unfortunately this isn't the case. Units with a mask of 5 cannot be built on regular ground.
Can someone please explain this to me?
https://springrts.com/wiki/Shield_Interception_Tag_Use
Re: Bitfield and building mask issues
Can you post a truth table I.e. units vs terrain matrix and 1/0 on whether or not it should be allowed for construction.
Otherwise I can't really get what is what from your post. Sry.
Otherwise I can't really get what is what from your post. Sry.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Bitfield and building mask issues
• 1 = 001
• 4 = 100
• 5 = 101
Unit(5) should be buildable both on normal ground(1), AND in the control point area(4). This is because 5 intersects with 4 and 1.
Additionally, normal units(1), should not be buildable in control point areas(4) because 4 does not intersect with 1.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Bitfield and building mask issues
After talking with it over anarchid, we have found the issue.
This bitfield logic only allows for 0's over 1's, NEVER 1's over 0's, which is exactly opposite of how shields work.
This bitfield logic only allows for 0's over 1's, NEVER 1's over 0's, which is exactly opposite of how shields work.
Last edited by Forboding Angel on 03 Mar 2017, 11:46, edited 1 time in total.
Re: Bitfield and building mask issues
Much clearer. So you have a normal (U1) and privileged (U5) units. Normals should only be built on "normal" ground, and privileged - on both "normal" and "special" ones. Ok.
Here is the answer:
normal tile Mask (NTM) = 11 (3)
special tile Mask (STM) = 10 (2)
normal unit Value (NUV) = 01 (1)
special unit Value (SUV) = 10 (2)
Check:
NUV on NTM: 11 AND 01 = 01, construction allowed
SUV on NTM: 11 AND 10 = 10, construction allowed
NUV on STM: 10 AND 01 = 00, construction not allowed
SUV on STM: 10 AND 10 = 10, construction allowed
Practically, in the gadget, you will need to go thru every map tile and set them all to "3", except for the special areas, there you put "2". Next in the unitdefs or in unitdefs_post, you will mark "special" units with "2" value.
Haven't slept well last night, so hopefully I'm not messing things up.
Here is the answer:
normal tile Mask (NTM) = 11 (3)
special tile Mask (STM) = 10 (2)
normal unit Value (NUV) = 01 (1)
special unit Value (SUV) = 10 (2)
Check:
NUV on NTM: 11 AND 01 = 01, construction allowed
SUV on NTM: 11 AND 10 = 10, construction allowed
NUV on STM: 10 AND 01 = 00, construction not allowed
SUV on STM: 10 AND 10 = 10, construction allowed
Practically, in the gadget, you will need to go thru every map tile and set them all to "3", except for the special areas, there you put "2". Next in the unitdefs or in unitdefs_post, you will mark "special" units with "2" value.
Haven't slept well last night, so hopefully I'm not messing things up.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Bitfield and building mask issues
You haven't. That's the same conclusion we came to. Thank you. I wish it worked like shields :-/
Re: Bitfield and building mask issues
As far as I see in the spring sources shield interception is a simple test of whether or not InterceptedByShieldType AND interceptedType is equal to zero (have at least one common bit set to 1). It's certainly simpler to understand, but I thought mask would give better flexibility.