Support Bits2 field and fix docs

To maximize forwards compatiblity in case the flags in Bits/Bits2
got shifted around in different ports, both Bits and Bits2 will
accept any of the flags when using mnemonics, and they will set
their values in the corresponding bits.

However, "Bits" will only unset (set to zero) the bits in the lower
32 bits, and "Bits2" will only unset (set zero) the second 32 bits
set. This is to prevent dehacked files that only manipulate the
first 32 bits from affecting the default values from "Bits2", which
would have otherwise held hardcoded behavior expected from Doom.
This commit is contained in:
Fernando Carmona Varo 2019-10-08 20:06:22 +02:00
parent 87b7373c54
commit a2e2897684
2 changed files with 78 additions and 56 deletions

View File

@ -143,40 +143,49 @@ translucent)
Color 1 (gray/red)
TRANSLATION2, 0x08000000 - second bit for selecting translation table
Color 2 (brown/red)
TRANSLATION, 0x04000000 - for compatibility, same as TRANSLATION1
UNUSED1, 0x08000000 - undefined or same as TRANSLATION2
UNUSED2, 0x10000000 - undefined
UNUSED3, 0x20000000 - undefined
UNUSED4, 0x40000000 - undefined
TOUCHY, 0x10000000 - dies on contact with solid objects (MBF)
BOUNCES, 0x20000000 - bounces off floors, ceilings and maybe walls (MBF)
FRIEND, 0x40000000 - a friend of the player(s) (MBF)
TRANSLUCENT, 0x80000000 - apply translucency to sprite (BOOM)
The previous table pertains to the first (lower) byte, as used in
vanilla Doom with some Boom extensions.
However, many ports have extended this bit mask doubling its size,
which means there's space to have potetially up to 32 new flags.
Many of the most common flags have been adopted in this PrBoom port.
TRANSLATION, 0x04000000 - for compatibility, same as TRANSLATION1
UNUSED1, 0x08000000 - for compatibility, same as TRANSLATION2
UNUSED2, 0x10000000 - for compatibility, same as TOUCHY
UNUSED3, 0x20000000 - for compatibility, same as BOUNCES
UNUSED4, 0x40000000 - for compatibility, same as FRIEND
The previous table pertains to the first (lower) 32 bits, as used in
vanilla Doom with some popular extensions.
In addition to the flags above, the field was expanded so that it's
possible to have additional flags to have finer control of behavior
that was previously hardcoded to some specific enemies, such as the
way the cyberdemon is immune to splash damage from explosions.
Because these flags are not common between ports, it's recomended
to use in this case always the mnemonics to ensure that they are
properly ignored in ports that don't support it.
If a monster has already had any of these flags set, you won't be
able to unset it by using the "Bits" field, you'll need to use the
"Bits2" field, this is so it's possible to keep compatibility.
For example:
Bits2 = ISMONSTER+MISSILEMORE+NOTARGET
If a number was to be given instead (which is not recomended), the
bits will be shifted so only the extended flags are affected.
One important note, however, is that in order to keep compatibility
it'd be much preferable to use the mnemonics rather than the actual
bit numbers since this way engines that do not support it will simply
ignore them, or those that do support it but use an incompatible bit
mask sequence will interpret it correctly.
Mnemonic Bit(2) mask Meaning
----------------------------------------------------------------------------
TOUCHY, 0x00000001 - dies on contact with solid objects
BOUNCES, 0x00000002 - bounces off floors, ceilings and maybe walls
FRIEND, 0x00000004 - a friend of the player(s)
NOTARGET, 0x00000100 - won't be targetted even on accidental infight
MISSILEMORE, 0x00000400 - shoots missiles more often from far away
FULLVOLSIGHT, 0x00000800 - plays its alert sound at full volume
FULLVOLDEATH, 0x00001000 - plays its death sound at full volume
NORADIUSDMG, 0x00002000 - radius (explosive) damage doesnt harm it
QUICKTORETALIATE, 0x00004000 - immediately switch target if attacked
ISMONSTER, 0x00008000 - for all monsters, even if don't count in kill%
DONTFALL, 0x00010000 - don't fall down after killed (like Lost Soul)
NOTARGET, 0x00000001 - won't be targetted even on accidental infight
MISSILEMORE, 0x00000002 - shoots missiles more often from far away
FULLVOLSIGHT, 0x00000004 - plays its alert sound at full volume
FULLVOLDEATH, 0x00000008 - plays its death sound at full volume
NORADIUSDMG, 0x00000010 - radius (explosive) damage doesnt harm it
QUICKTORETALIATE, 0x00000020 - immediately switch target if attacked
ISMONSTER, 0x00000040 - for all monsters, even if don't count in kill%
DONTFALL, 0x00000080 - don't fall down after killed (like Lost Soul)
----------------------------CODE POINTERS-------------------------
@ -2163,19 +2172,19 @@ the two Things for PUSH and PULL wind sources at the end.
SOLID+SHOOTABLE+DROPOFF+PICKUP+NOTDMATCH
2 POSSESSED
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
3 SHOTGUY
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
4 VILE
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER+NOTARGET+QUICKTORETALIATE
5 FIRE
NOBLOCKMAP+NOGRAVITY+TRANSLUCENT
6 UNDEAD
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
7 TRACER
NOBLOCKMAP+MISSILE+DROPOFF+NOGRAVITY
@ -2184,55 +2193,55 @@ the two Things for PUSH and PULL wind sources at the end.
NOBLOCKMAP+NOGRAVITY+TRANSLUCENT
9 FATSO
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
10 FATSHOT
NOBLOCKMAP+MISSILE+DROPOFF+NOGRAVITY+TRANSLUCENT
11 CHAINGUY
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
12 TROOP
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
13 SERGEANT
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
14 SHADOWS
SOLID+SHOOTABLE+SHADOW+COUNTKILL
SOLID+SHOOTABLE+SHADOW+COUNTKILL+ISMONSTER
15 HEAD
SOLID+SHOOTABLE+FLOAT+NOGRAVITY+COUNTKILL
SOLID+SHOOTABLE+FLOAT+NOGRAVITY+COUNTKILL+ISMONSTER
16 BRUISER
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
17 BRUISERSHOT
NOBLOCKMAP+MISSILE+DROPOFF+NOGRAVITY+TRANSLUCENT
18 KNIGHT
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
19 SKULL
SOLID+SHOOTABLE+FLOAT+NOGRAVITY
SOLID+SHOOTABLE+FLOAT+NOGRAVITY+ISMONSTER+MISSILEMORE
20 SPIDER
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER+MISSILEMORE+FULLVOLSIGHT+FULLVOLDEATH+NORADIUSDMG
21 BABY
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
22 CYBORG
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER+MISSILEMORE+FULLVOLSIGHT+FULLVOLDEATH+NORADIUSDMG
23 PAIN
SOLID+SHOOTABLE+FLOAT+NOGRAVITY+COUNTKILL
SOLID+SHOOTABLE+FLOAT+NOGRAVITY+COUNTKILL+ISMONSTER
24 WOLFSS
SOLID+SHOOTABLE+COUNTKILL
SOLID+SHOOTABLE+COUNTKILL+ISMONSTER
25 KEEN
SOLID+SPAWNCEILING+NOGRAVITY+SHOOTABLE+COUNTKILL
SOLID+SPAWNCEILING+NOGRAVITY+SHOOTABLE+COUNTKILL+ISMONSTER
26 BOSSBRAIN
SOLID+SHOOTABLE

View File

@ -1655,7 +1655,7 @@ static void deh_procBexCodePointers(DEHFILE *fpin, FILE* fpout, char *line)
// to prboom types - POPE
//---------------------------------------------------------------------------
static uint64_t getConvertedDEHBits(uint64_t bits) {
static const uint64_t bitMap[32] = {
static const uint64_t bitMap[40] = {
/* cf linuxdoom-1.10 p_mobj.h */
MF_SPECIAL, // 0 Can be picked up - When touched the thing can be picked up.
MF_SOLID, // 1 Obstacle - The thing is solid and will not let you (or others) pass through it
@ -1690,12 +1690,22 @@ static uint64_t getConvertedDEHBits(uint64_t bits) {
MF_TOUCHY, // 28 - explodes on contact (MBF)
MF_BOUNCES, // 29 - bounces off walls and floors (MBF)
MF_FRIEND, // 30 - friendly monster helps players (MBF)
MF_TRANSLUCENT // e6y: Translucency via dehacked/bex doesn't work without it
MF_TRANSLUCENT, // 31 - e6y: Translucency via dehacked/bex doesn't work without it
// Bits2 fields below
MF_NOTARGET, // 32 - won't be targetted even on accidental infight
MF_MISSILEMORE, // 33 - shoots missiles more often from far away
MF_FULLVOLSIGHT, // 34 - plays its alert sound at full volume
MF_FULLVOLDEATH, // 35 - plays its death sound at full volume
MF_NORADIUSDMG, // 36 - radius (explosive) damage doesnt harm it
MF_QUICKTORETALIATE, // 37 - immediately switch target if attacked
MF_ISMONSTER, // 38 - for all monsters, even if don't count in kill%
MF_DONTFALL, // 39 - don't fall down after killed (like Lost Soul)
};
int i;
uint64_t shiftBits = bits;
uint64_t convertedBits = 0;
for (i=0; i<32; i++) {
for (i=0; i<40; i++) {
if (shiftBits & 0x1) convertedBits |= bitMap[i];
shiftBits >>= 1;
}
@ -1732,8 +1742,8 @@ static void setMobjInfoValue(int mobjInfoIndex, int keyIndex, uint64_t value) {
case 19: mi->mass = (int)value; return;
case 20: mi->damage = (int)value; return;
case 21: mi->activesound = (int)value; return;
case 22: mi->flags = value; return;
case 23: return; // "Bits2", unused
case 22: mi->flags = (mi->flags & 0xFFFFFFFF00000000)|value; return; // Bits
case 23: mi->flags = (mi->flags & 0x00000000FFFFFFFF)|value; return; // Bits2
case 24: mi->raisestate = (int)value; return;
case 25: mi->meleethreshold = (int)value; return;
case 26: mi->maxattackrange = (int)value; return;
@ -1809,7 +1819,7 @@ static void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
for (ix=0; ix<DEH_MOBJINFOMAX; ix++) {
if (strcasecmp(key,deh_mobjinfo[ix])) continue;
if (strcasecmp(key,"bits")) {
if (strcasecmp(key,"bits") && strcasecmp(key,"bits2")) {
// standard value set
// The old code here was the cause of a DEH-related bug in prboom.
@ -1826,8 +1836,11 @@ static void deh_procThing(DEHFILE *fpin, FILE* fpout, char *line)
// bit set
// e6y: Correction of wrong processing of Bits parameter if its value is equal to zero
// No more desync on HACX demos.
if (bGetData==1) { // proff
value = getConvertedDEHBits(value);
if (bGetData==1) {
// shift flags if we are using 'Bits2'
if (key[3] == '2')
value = value << 32;
value = getConvertedDEHBits(value);
mobjinfo[indexnum].flags = value;
}
else {