From f5f012ccb9c9ff8d58bf6aea6abcaf65e0b0044f Mon Sep 17 00:00:00 2001 From: Grind Core Date: Mon, 7 Oct 2019 22:29:52 +0300 Subject: [PATCH] - Added names for statnums - Added names for system RX/TX channels - Detect if map requires new features to work properly via special TX and command - Effect Gen update # Conflicts: # source/blood/src/actor.cpp # source/blood/src/eventq.h # source/blood/src/triggers.cpp # source/blood/src/triggers.h --- source/blood/src/actor.cpp | 192 ++++++------ source/blood/src/actor.h | 2 +- source/blood/src/ai.cpp | 10 +- source/blood/src/aibeast.cpp | 6 +- source/blood/src/aicerber.cpp | 4 +- source/blood/src/aicult.cpp | 2 +- source/blood/src/aigarg.cpp | 2 +- source/blood/src/aighost.cpp | 2 +- source/blood/src/aitchern.cpp | 4 +- source/blood/src/aiunicult.cpp | 40 +-- source/blood/src/asound.cpp | 4 +- source/blood/src/blood.cpp | 4 +- source/blood/src/callback.cpp | 10 +- source/blood/src/common_game.h | 22 +- source/blood/src/db.cpp | 25 +- source/blood/src/db.h | 2 + source/blood/src/endgame.cpp | 6 +- source/blood/src/eventq.cpp | 135 ++++----- source/blood/src/eventq.h | 29 ++ source/blood/src/fx.cpp | 4 +- source/blood/src/levels.cpp | 1 + source/blood/src/messages.h | 3 +- source/blood/src/mirrors.cpp | 4 +- source/blood/src/player.cpp | 10 +- source/blood/src/triggers.cpp | 529 +++++++++++++++++---------------- source/blood/src/triggers.h | 3 + source/blood/src/view.cpp | 31 +- source/blood/src/view.h | 2 +- source/blood/src/weapon.cpp | 12 +- 29 files changed, 585 insertions(+), 515 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 604188af1..96c583354 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -2543,7 +2543,7 @@ short gPhysSpritesCount; // current count void actInit(bool bSaveLoad) { // by NoOne: init code for all my stuff - if (!VanillaMode()) { + if (gModernMap) { // reset counters gProxySpritesCount = gSightSpritesCount = gPhysSpritesCount = 0; @@ -2561,12 +2561,12 @@ void actInit(bool bSaveLoad) { switch (pSprite->type) { // add statnum for faster dude searching case kGDXDudeTargetChanger: - changespritestat(i, kStatGDXDudeTargetChanger); + changespritestat(i, kStatModernDudeTargetChanger); break; // remove kStatItem status from random item generators case 40: // Random weapon case 80: // Random ammo - changespritestat(i, 0); + changespritestat(i, kStatDecoration); break; case kCustomDude: case kCustomDudeBurning: @@ -2585,7 +2585,7 @@ void actInit(bool bSaveLoad) { if (pXSprite->data3 != pXSprite->sysData1) { switch (pSprite->statnum) { - case 6: + case kStatDude: switch (pSprite->type) { case kCustomDude: case kCustomDudeBurning: @@ -2601,21 +2601,21 @@ void actInit(bool bSaveLoad) { if (pXSprite->Proximity && gProxySpritesCount < kMaxSuperXSprites) { switch (pSprite->statnum) { // exceptions - case 4: // things already treated in their functions - case 6: // enemies already treated in their functions + case kStatThing: // things already treated in their functions + case kStatDude: // enemies already treated in their functions // senseless to have sight and proximity together if (pXSprite->Sight && pXSprite->DudeLockout) pXSprite->Proximity = false; break; - case 1: // effects - case 2: // explosions - case 3: // items - case 9: // purgeable sprites - case 13: // ??? - case 14: // burning flares stuck - case 7: // inactive enemies + case kStatFX: // effects + case kStatExplosion: // explosions + case kStatItem: // items + case kStatPurge: // purgeable sprites + case kStatSpares: // ??? + case kStatFlare: // burning flares stuck + case kStatInactive: // inactive enemies case kStatFree: // removed sprites case kStatMarker: // markers - case 16: // path markers + case kStatPathMarker: // path markers break; default: // senseless to have sight and proximity together @@ -2633,16 +2633,16 @@ void actInit(bool bSaveLoad) { if (pXSprite->Sight && gSightSpritesCount < kMaxSuperXSprites) { switch (pSprite->statnum) { // exceptions - case 1: // effects - case 2: // explosions - case 3: // items - case 9: // purgeable sprites - case 13: // ??? - case 14: // burning flares stuck - case 7: // inactive enemies + case kStatFX: // effects + case kStatExplosion: // explosions + case kStatItem: // items + case kStatPurge: // purgeable sprites + case kStatSpares: // ??? + case kStatFlare: // burning flares stuck + case kStatInactive: // inactive enemies case kStatFree: // removed sprites case kStatMarker: // markers - case 16: // path markers + case kStatPathMarker: // path markers break; default: gSightSpritesList[gSightSpritesCount++] = pSprite->xvel; @@ -2654,14 +2654,14 @@ void actInit(bool bSaveLoad) { } } - for (int nSprite = headspritestat[3]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatItem]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->type == 44) // Voodoo doll (ammo) pSprite->type = 70; // Voodoo doll (weapon) } - for (int nSprite = headspritestat[11]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatTraps]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; int nXSprite = pSprite->extra; @@ -2676,7 +2676,7 @@ void actInit(bool bSaveLoad) { pSprite->cstat |= 32768; } } - for (int nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; int nXSprite = pSprite->extra; @@ -2717,16 +2717,16 @@ void actInit(bool bSaveLoad) { if (gGameOptions.nMonsterSettings == 0) { gKillMgr.SetCount(0); - while (headspritestat[6] >= 0) + while (headspritestat[kStatDude] >= 0) { - spritetype *pSprite = &sprite[headspritestat[6]]; + spritetype *pSprite = &sprite[headspritestat[kStatDude]]; int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); XSPRITE *pXSprite = &xsprite[nXSprite]; // Drop Key if (pXSprite->key > 0) actDropObject(pSprite, 99 + pXSprite->key); - DeleteSprite(headspritestat[6]); + DeleteSprite(headspritestat[kStatDude]); } } else @@ -2735,7 +2735,7 @@ void actInit(bool bSaveLoad) { /////////////// char unk[kDudeMax-kDudeBase]; memset(unk, 0, sizeof(unk)); - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) @@ -2750,7 +2750,7 @@ void actInit(bool bSaveLoad) { for (int j = 0; j < 7; j++) dudeInfo[i].at70[j] = mulscale8(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j]); - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); @@ -2879,7 +2879,7 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, nDist <<= 4; if (a10 & 2) { - for (int i = headspritestat[6]; i >= 0; i = nextspritestat[i]) + for (int i = headspritestat[kStatDude]; i >= 0; i = nextspritestat[i]) { if (i != nSprite || (a10 & 1)) { @@ -2912,7 +2912,7 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, } if (a10 & 4) { - for (int i = headspritestat[4]; i >= 0; i = nextspritestat[i]) + for (int i = headspritestat[kStatThing]; i >= 0; i = nextspritestat[i]) { spritetype *pSprite2 = &sprite[i]; if (pSprite2->flags&0x20) @@ -2944,7 +2944,7 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, void sub_2AA94(spritetype *pSprite, XSPRITE *pXSprite) { int nSprite = actOwnerIdToSpriteId(pSprite->owner); - actPostSprite(pSprite->index, 0); + actPostSprite(pSprite->index, kStatDecoration); seqSpawn(9, 3, pSprite->extra); if (Chance(0x8000)) pSprite->cstat |= 4; @@ -3250,7 +3250,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType, else { if (gGameOptions.nGameType == 1 && IsPlayerSprite(pKillerSprite) - && pSprite->statnum == 6 && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) + && pSprite->statnum == kStatDude && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) { PLAYER *pKillerPlayer = &gPlayer[pKillerSprite->type-kDudePlayer1]; pKillerPlayer->at2c6++; @@ -3344,7 +3344,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType, { seqKill(3, nXSprite); gKillMgr.AddKill(pSprite); - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); return; } @@ -3695,7 +3695,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType, gKillMgr.AddKill(pSprite); actCheckRespawn(pSprite); pSprite->type = 426; - actPostSprite(pSprite->index, 4); + actPostSprite(pSprite->index, kStatThing); } int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, int damage) @@ -3709,7 +3709,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in dassert(nXSprite > 0 && nXSprite < kMaxXSprites); XSPRITE *pXSprite = &xsprite[nXSprite]; dassert(pXSprite->reference == pSprite->index); - if ((pXSprite->health == 0 && pSprite->statnum != 6) || pXSprite->locked) + if ((pXSprite->health == 0 && pSprite->statnum != kStatDude) || pXSprite->locked) return 0; if (nSource == -1) nSource = pSprite->index; @@ -3720,7 +3720,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in return 0; switch (pSprite->statnum) { - case 6: + case kStatDude: { if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) { @@ -3754,7 +3754,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in } break; } - case 4: + case kStatThing: dassert(pSprite->type >= kThingBase && pSprite->type < kThingMax); int nType = pSprite->type-kThingBase; int nDamageFactor = thingInfo[nType].at17[damageType]; @@ -3815,7 +3815,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in case -1: GibSprite(pSprite, GIBTYPE_14, NULL, NULL); sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 312, pSprite->sectnum); - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); break; case 0: seqSpawn(25, 3, pSprite->extra, nTreeToGibClient); @@ -3917,12 +3917,12 @@ void actImpactMissile(spritetype *pMissile, int a2) DUDEINFO *pDudeInfo = NULL; if (a2 == 3 && pSpriteHit) { - if (pSpriteHit->statnum == 4) + if (pSpriteHit->statnum == kStatThing) { dassert(pXSpriteHit != NULL); pThingInfo = &thingInfo[pSpriteHit->type-kThingBase]; } - else if (pSpriteHit->statnum == 6) + else if (pSpriteHit->statnum == kStatDude) { dassert(pXSpriteHit != NULL); pDudeInfo = &dudeInfo[pSpriteHit->type-kDudeBase]; @@ -3951,7 +3951,7 @@ void actImpactMissile(spritetype *pMissile, int a2) } if (pMissile->extra > 0) { - actPostSprite(pMissile->index, 0); + actPostSprite(pMissile->index, kStatDecoration); if (pMissile->ang == 1024) sfxPlay3DSound(pMissile, 307, -1, 0); pMissile->type = 0; @@ -3959,7 +3959,7 @@ void actImpactMissile(spritetype *pMissile, int a2) } else { - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); } break; case 302: @@ -3971,7 +3971,7 @@ void actImpactMissile(spritetype *pMissile, int a2) pFX->ang = (GetWallAngle(nWallHit)+512)&2047; } GibSprite(pMissile, GIBTYPE_24, NULL, NULL); - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); break; case 309: seqKill(3, nXMissile); @@ -3981,7 +3981,7 @@ void actImpactMissile(spritetype *pMissile, int a2) int nDamage = (15+Random(7))<<4; actDamageSprite(nOwner, pSpriteHit, DAMAGE_TYPE_2, nDamage); } - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); break; case 311: sfxKill3DSound(pMissile, -1, -1); @@ -3993,7 +3993,7 @@ void actImpactMissile(spritetype *pMissile, int a2) int nDamage = (25+Random(20))<<4; actDamageSprite(nOwner, pSpriteHit, DAMAGE_TYPE_5, nDamage); } - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); break; case 316: case 317: @@ -4011,7 +4011,7 @@ void actImpactMissile(spritetype *pMissile, int a2) int nDamage = (nDmgMul+Random(nDmgMul))<<4; actDamageSprite(nOwner, pSpriteHit, DAMAGE_TYPE_5, nDamage); } - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); break; case 305: case 312: @@ -4061,14 +4061,14 @@ void actImpactMissile(spritetype *pMissile, int a2) pXMissile->targetZ = pMissile->z-pSpriteHit->z; pXMissile->goalAng = getangle(pMissile->x-pSpriteHit->x, pMissile->y-pSpriteHit->y)-pSpriteHit->ang; pXMissile->state = 1; - actPostSprite(pMissile->index, 14); + actPostSprite(pMissile->index, kStatFlare); pMissile->cstat &= ~257; break; } } } GibSprite(pMissile, GIBTYPE_17, NULL, NULL); - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); break; case 304: case 308: @@ -4080,7 +4080,7 @@ void actImpactMissile(spritetype *pMissile, int a2) if (pObject->extra > 0) { XSPRITE *pXObject = &xsprite[pObject->extra]; - if ((pObject->statnum == 4 || pObject->statnum == 6) && pXObject->burnTime == 0) + if ((pObject->statnum == kStatThing || pObject->statnum == kStatDude) && pXObject->burnTime == 0) evPost(nObject, 3, 0, CALLBACK_ID_0); int nOwner = actSpriteOwnerToSpriteId(pMissile); actBurnSprite(pMissile->owner, pXObject, (4+gGameOptions.nDifficulty)<<2); @@ -4098,7 +4098,7 @@ void actImpactMissile(spritetype *pMissile, int a2) if (pObject->extra > 0) { XSPRITE *pXObject = &xsprite[pObject->extra]; - if ((pObject->statnum == 4 || pObject->statnum == 6) && pXObject->burnTime == 0) + if ((pObject->statnum == kStatThing || pObject->statnum == kStatDude) && pXObject->burnTime == 0) evPost(nObject, 3, 0, CALLBACK_ID_0); int nOwner = actSpriteOwnerToSpriteId(pMissile); actBurnSprite(pMissile->owner, pXObject, (4+gGameOptions.nDifficulty)<<2); @@ -4119,7 +4119,7 @@ void actImpactMissile(spritetype *pMissile, int a2) if (pObject->extra > 0) { XSPRITE *pXObject = &xsprite[pObject->extra]; - if ((pObject->statnum == 4 || pObject->statnum == 6) && pXObject->burnTime == 0) + if ((pObject->statnum == kStatThing || pObject->statnum == kStatDude) && pXObject->burnTime == 0) evPost(nObject, 3, 0, CALLBACK_ID_0); int nOwner = actSpriteOwnerToSpriteId(pMissile); actBurnSprite(pMissile->owner, pXObject, 32); @@ -4133,14 +4133,14 @@ void actImpactMissile(spritetype *pMissile, int a2) case 307: sfxKill3DSound(pMissile, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 522, pMissile->sectnum); - actPostSprite(pMissile->index, 15); + actPostSprite(pMissile->index, kStatDebris); seqSpawn(20, 3, pMissile->extra, -1); if (a2 == 3) { int nObject = gHitInfo.hitsprite; dassert(nObject >= 0 && nObject < kMaxSprites); spritetype *pObject = &sprite[nObject]; - if (pObject->statnum == 6) + if (pObject->statnum == kStatDude) { int nOwner = actSpriteOwnerToSpriteId(pMissile); int nDamage = (25+Random(10))<<4; @@ -4149,7 +4149,7 @@ void actImpactMissile(spritetype *pMissile, int a2) } break; case 300: - actPostSprite(pMissile->index, 15); + actPostSprite(pMissile->index, kStatDebris); pMissile->cstat &= ~16; pMissile->type = 0; seqSpawn(20, 3, pMissile->extra, -1); @@ -4158,7 +4158,7 @@ void actImpactMissile(spritetype *pMissile, int a2) int nObject = gHitInfo.hitsprite; dassert(nObject >= 0 && nObject < kMaxSprites); spritetype *pObject = &sprite[nObject]; - if (pObject->statnum == 6) + if (pObject->statnum == kStatDude) { int nOwner = actSpriteOwnerToSpriteId(pMissile); int nDamage = (10+Random(10))<<4; @@ -4177,7 +4177,7 @@ void actImpactMissile(spritetype *pMissile, int a2) GibSprite(pMissile, (a2 == 2) ? GIBTYPE_23 : GIBTYPE_22, NULL, NULL); evKill(pMissile->index, 3); seqKill(3, nXMissile); - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); if (a2 == 3) { int nObject = gHitInfo.hitsprite; @@ -4191,7 +4191,7 @@ void actImpactMissile(spritetype *pMissile, int a2) case 310: default: seqKill(3, nXMissile); - actPostSprite(pMissile->index, 1024); + actPostSprite(pMissile->index, kStatFree); if (a2 == 3) { int nObject = gHitInfo.hitsprite; @@ -4265,9 +4265,9 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) { spritetype *pSprite2 = &sprite[nHitSprite]; XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; - if ((pSprite2->statnum == 4 || pSprite2->statnum == 6) && (xvel[nSprite] != 0 || yvel[nSprite] != 0 || zvel[nSprite] != 0)) + if ((pSprite2->statnum == kStatThing || pSprite2->statnum == kStatDude) && (xvel[nSprite] != 0 || yvel[nSprite] != 0 || zvel[nSprite] != 0)) { - if (pSprite2->statnum == 4) + if (pSprite2->statnum == kStatThing) { int nType = pSprite2->type-kThingBase; THINGINFO *pThingInfo = &thingInfo[nType]; @@ -4817,7 +4817,7 @@ void MoveDude(spritetype *pSprite) if (nSector == -1) { nSector = pSprite->sectnum; - if (pSprite->statnum == 6 || pSprite->statnum == 4) + if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing) actDamageSprite(pSprite->index, pSprite, DAMAGE_TYPE_0, 1000<<4); } if (sector[nSector].type >= 612 && sector[nSector].type <= 617) @@ -4842,7 +4842,7 @@ void MoveDude(spritetype *pSprite) if (pSprite->extra > 0) pHitXSprite = &xsprite[pHitSprite->extra]; int nOwner = actSpriteOwnerToSpriteId(pHitSprite); - if (pHitSprite->statnum == 5 && !(pHitSprite->flags&32) && pSprite->index != nOwner) + if (pHitSprite->statnum == kStatProjectile && !(pHitSprite->flags&32) && pSprite->index != nOwner) { HITINFO hitInfo = gHitInfo; gHitInfo.hitsprite = nSprite; @@ -5338,7 +5338,7 @@ int MoveMissile(spritetype *pSprite) pXTarget = &xsprite[pTarget->extra]; else pXTarget = NULL; - if (pTarget->statnum == 6 && pXTarget && pXTarget->health > 0) + if (pTarget->statnum == kStatDude && pXTarget && pXTarget->health > 0) { int nTargetAngle = getangle(-(pTarget->y-pSprite->y), pTarget->x-pSprite->x); int UNUSED(nAngle) = getangle(xvel[nSprite]>>12,yvel[nSprite]>>12); @@ -5476,7 +5476,7 @@ void actExplodeSprite(spritetype *pSprite) int nXSprite = pSprite->extra; if (nXSprite <= 0 || nXSprite >= kMaxXSprites) return; - if (pSprite->statnum == 2) + if (pSprite->statnum == kStatExplosion) return; sfxKill3DSound(pSprite, -1, -1); evKill(pSprite->index, 3); @@ -5544,7 +5544,7 @@ void actExplodeSprite(spritetype *pSprite) pXSprite->health = thingInfo[0].at0<<4; } else - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); nType = 2; nXSprite = pSprite2->extra; seqSpawn(4, 3, nXSprite, -1); @@ -5603,7 +5603,7 @@ void actExplodeSprite(spritetype *pSprite) } int nSprite = pSprite->index; xvel[nSprite] = yvel[nSprite] = zvel[nSprite] = 0; - actPostSprite(nSprite, 2); + actPostSprite(nSprite, kStatExplosion); pSprite->xrepeat = pSprite->yrepeat = explodeInfo[nType].at0; pSprite->flags &= ~3; pSprite->type = nType; @@ -5632,7 +5632,7 @@ void actActivateGibObject(spritetype *pSprite, XSPRITE *pXSprite) if (v8 > 0) actDropObject(pSprite, v8); if (!(pSprite->cstat&32768) && !(pSprite->flags&16)) - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); } bool IsUnderWater(spritetype *pSprite) @@ -5669,7 +5669,7 @@ void actProcessSprites(void) if (!pXProxSpr->DudeLockout) { - for (int nAffected = headspritestat[6]; nAffected >= 0; nAffected = nextspritestat[nAffected]) { + for (int nAffected = headspritestat[kStatDude]; nAffected >= 0; nAffected = nextspritestat[nAffected]) { if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue; else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) { trTriggerSprite(index, pXProxSpr, 35); @@ -5775,7 +5775,7 @@ void actProcessSprites(void) } } - for (nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags&32) @@ -5795,7 +5795,7 @@ void actProcessSprites(void) // by NoOne: don't process locked or 1-shot things for proximity if (pXSprite->Proximity && (VanillaMode() || (pXSprite->locked != 1 && pXSprite->isTriggered != true))) { if (pSprite->type == 431) pXSprite->target = -1; - for (int nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nNextSprite) + for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nNextSprite) { nNextSprite = nextspritestat[nSprite2]; @@ -5851,7 +5851,7 @@ void actProcessSprites(void) } } } - for (nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) @@ -5977,7 +5977,7 @@ void actProcessSprites(void) } } } - for (nSprite = headspritestat[5]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatProjectile]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) @@ -5987,7 +5987,7 @@ void actProcessSprites(void) if (hit >= 0) actImpactMissile(pSprite, hit); } - for (nSprite = headspritestat[2]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatExplosion]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { char v24c[(kMaxSectors+7)>>3]; spritetype *pSprite = &sprite[nSprite]; @@ -6024,7 +6024,7 @@ void actProcessSprites(void) trTriggerWall(nWall, pXWall, 51); } - for (int nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pDude = &sprite[nSprite2]; if (pDude->flags & 32) @@ -6052,7 +6052,7 @@ void actProcessSprites(void) } } - for (int nSprite2 = headspritestat[4]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (int nSprite2 = headspritestat[kStatThing]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pThing = &sprite[nSprite2]; if (pThing->flags & 32) @@ -6112,10 +6112,10 @@ void actProcessSprites(void) } if (pXSprite->data1 == 0 && pXSprite->data2 == 0 && pXSprite->data3 == 0 && seqGetStatus(3, nXSprite) < 0) - actPostSprite(nSprite, 1024); + actPostSprite(nSprite, kStatFree); } - for (nSprite = headspritestat[11]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (nSprite = headspritestat[kStatTraps]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) continue; @@ -6156,7 +6156,7 @@ void actProcessSprites(void) break; } } - for (nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) @@ -6222,7 +6222,7 @@ void actProcessSprites(void) short oldData2 = pXSprite->data2; pXSprite->data2 = pXIncarnation->data2; // seq new seqId and save old one. // if incarnation is active dude, it's sndStartId will be stored in sysData1, otherwise it will be data3 - if (pIncarnation->statnum == 6 && pIncarnation->type == kCustomDude) pXSprite->sysData1 = pXIncarnation->sysData1; + if (pIncarnation->statnum == kStatDude && pIncarnation->type == kCustomDude) pXSprite->sysData1 = pXIncarnation->sysData1; else pXIncarnation->data3; pXSprite->data4 = pXIncarnation->data4; @@ -6306,7 +6306,7 @@ void actProcessSprites(void) } if (pXSprite->Proximity && !pXSprite->isTriggered) { - for (int nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nNextSprite) + for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nNextSprite) { nNextSprite = nextspritestat[nSprite2]; spritetype *pSprite2 = &sprite[nSprite2]; @@ -6362,7 +6362,7 @@ void actProcessSprites(void) ProcessTouchObjects(pSprite, nXSprite); } } - for (nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) @@ -6409,7 +6409,7 @@ void actProcessSprites(void) velFloor[pSprite->sectnum] || velCeil[pSprite->sectnum]) MoveDude(pSprite); } - for (nSprite = headspritestat[14]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatFlare]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags & 32) @@ -6425,7 +6425,7 @@ void actProcessSprites(void) if (pTarget->statnum == kMaxStatus) { GibSprite(pSprite, GIBTYPE_17, NULL, NULL); - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); } if (pTarget->extra > 0 && xsprite[pTarget->extra].health > 0) { @@ -6441,7 +6441,7 @@ void actProcessSprites(void) else { GibSprite(pSprite, GIBTYPE_17, NULL, NULL); - actPostSprite(pSprite->index, 1024); + actPostSprite(pSprite->index, kStatFree); } } aiProcessDudes(); @@ -6455,7 +6455,7 @@ spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6 sprite[nSprite].extra = -1; else { - nSprite = headspritestat[9]; + nSprite = headspritestat[kStatPurge]; dassert(nSprite >= 0); dassert(nSector >= 0 && nSector < kMaxSectors); ChangeSpriteSect(nSprite, nSector); @@ -6541,7 +6541,7 @@ spritetype * actSpawnSprite(spritetype *pSource, int nStat) int nSprite = InsertSprite(pSource->sectnum, nStat); if (nSprite < 0) { - nSprite = headspritestat[9]; + nSprite = headspritestat[kStatPurge]; dassert(nSprite >= 0); dassert(pSource->sectnum >= 0 && pSource->sectnum < kMaxSectors); ChangeSpriteSect(nSprite, pSource->sectnum); @@ -6878,7 +6878,7 @@ bool actCheckRespawn(spritetype *pSprite) if (pXSprite->respawnPending == 1) nRespawnTime = mulscale16(nRespawnTime, 0xa000); pSprite->owner = pSprite->statnum; - actPostSprite(pSprite->index, 8); + actPostSprite(pSprite->index, kStatRespawn); pSprite->flags |= 16; if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { @@ -7025,7 +7025,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, if (pXSprite->Vector) trTriggerSprite(nSprite, pXSprite, 31); } - if (pSprite->statnum == 4) + if (pSprite->statnum == kStatThing) { int t = thingInfo[pSprite->type-kThingBase].at2; if (t > 0 && pVectorData->at5) @@ -7043,7 +7043,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, actBurnSprite(actSpriteIdToOwnerId(nShooter), pXSprite, pVectorData->at11); } } - if (pSprite->statnum == 6) + if (pSprite->statnum == kStatDude) { int t = pSprite->type == 426 ? 0 : dudeInfo[pSprite->type-kDudeBase].mass; @@ -7126,8 +7126,8 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, } if (pSprite->type >= kThingBase && pSprite->type < kThingMax) - changespritestat(pSprite->index, 4); - //actPostSprite(pSprite->index, 4); // if it was a thing, return it's statnum back + changespritestat(pSprite->index, kStatThing); + //actPostSprite(pSprite->index, kStatThing); // if it was a thing, return it's statnum back } } @@ -7743,8 +7743,8 @@ void debrisConcuss(int nOwner, int listIndex, int x, int y, int z, int dmg) { if (pSprite->type >= kThingBase && pSprite->type < kThingMax) - //actPostSprite(pSprite->index, 4); // !!! (does not working here) if it was a thing, return it's statnum back - changespritestat(pSprite->index, 4); + //actPostSprite(pSprite->index, kStatThing); // !!! (does not working here) if it was a thing, return it's statnum back + changespritestat(pSprite->index, kStatThing); } @@ -7927,8 +7927,8 @@ void debrisMove(int listIndex) { if (pSprite->type >= kThingBase && pSprite->type < kThingMax) // if thing was turned in debris, change it's stat back so it will do on impact what it supposed to do... - //actPostSprite(nSprite, 4); // !!!! not working here for some reason - changespritestat(nSprite, 4); + //actPostSprite(nSprite, kStatThing); // !!!! not working here for some reason + changespritestat(nSprite, kStatThing); if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, COMMAND_ID_0); else trTriggerSprite(pSprite->xvel, pXDebris, COMMAND_ID_1); diff --git a/source/blood/src/actor.h b/source/blood/src/actor.h index 92e9a796f..94cf5c067 100644 --- a/source/blood/src/actor.h +++ b/source/blood/src/actor.h @@ -208,7 +208,7 @@ inline bool IsDudeSprite(spritetype *pSprite) inline void actBurnSprite(int nSource, XSPRITE *pXSprite, int nTime) { - pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == 6 ? 2400 : 1200); + pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); pXSprite->burnSource = nSource; } diff --git a/source/blood/src/ai.cpp b/source/blood/src/ai.cpp index b7f463ae3..90902d489 100644 --- a/source/blood/src/ai.cpp +++ b/source/blood/src/ai.cpp @@ -83,7 +83,7 @@ void aiSetGenIdleState(spritetype* pSprite, XSPRITE* pXSprite) { bool sub_5BDA8(spritetype *pSprite, int nSeq) { - if (pSprite->statnum == 6 && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) + if (pSprite->statnum == kStatDude && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) { DUDEINFO *pDudeInfo = &dudeInfo[pSprite->type-kDudeBase]; if (seqGetID(3, pSprite->extra) == pDudeInfo->seqStartID + nSeq && seqGetStatus(3, pSprite->extra) >= 0) @@ -1152,7 +1152,7 @@ void RecoilDude(spritetype *pSprite, XSPRITE *pXSprite) { char v4 = Chance(0x8000); DUDEEXTRA *pDudeExtra = &gDudeExtra[pSprite->extra]; - if (pSprite->statnum == 6 && (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) + if (pSprite->statnum == kStatDude && (pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) { DUDEINFO *pDudeInfo = &dudeInfo[pSprite->type-kDudeBase]; switch (pSprite->type) @@ -1470,7 +1470,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite) gAffectedSectors[0] = 0; gAffectedXWalls[0] = 0; GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, gAffectedSectors, va4, gAffectedXWalls); - for (int nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; int dx = pSprite2->x-pSprite->x; @@ -1493,7 +1493,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite) void aiProcessDudes(void) { - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags&32) @@ -1528,7 +1528,7 @@ void aiProcessDudes(void) void aiInit(void) { - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { aiInitSprite(&sprite[nSprite]); } diff --git a/source/blood/src/aibeast.cpp b/source/blood/src/aibeast.cpp index b9cfe5db5..2ab701a64 100644 --- a/source/blood/src/aibeast.cpp +++ b/source/blood/src/aibeast.cpp @@ -123,11 +123,11 @@ static void StompSeqCallback(int, int nXSprite) actHitcodeToData(hit, &gHitInfo, &v34, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (hit == 3 && v34 >= 0) { - if (sprite[v34].statnum == 6) + if (sprite[v34].statnum == kStatDude) v4 = 0; } vc <<= 4; - for (int nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { if (nSprite != nSprite2 || v4) { @@ -163,7 +163,7 @@ static void StompSeqCallback(int, int nXSprite) } } } - for (int nSprite2 = headspritestat[4]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (int nSprite2 = headspritestat[kStatThing]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite2->flags&32) diff --git a/source/blood/src/aicerber.cpp b/source/blood/src/aicerber.cpp index dfeeb1f0c..12db78cd5 100644 --- a/source/blood/src/aicerber.cpp +++ b/source/blood/src/aicerber.cpp @@ -114,7 +114,7 @@ static void BurnSeqCallback(int, int nXSprite) aim.dy = Sin(pSprite->ang)>>16; aim.dz = gDudeSlope[nXSprite]; int nClosest = 0x7fffffff; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) @@ -197,7 +197,7 @@ static void BurnSeqCallback2(int, int nXSprite) aim.dz = gDudeSlope[nXSprite]; az = 0; int nClosest = 0x7fffffff; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) diff --git a/source/blood/src/aicult.cpp b/source/blood/src/aicult.cpp index 63cd1b8fe..b5d9a024a 100644 --- a/source/blood/src/aicult.cpp +++ b/source/blood/src/aicult.cpp @@ -222,7 +222,7 @@ static char TargetNearExplosion(spritetype *pSprite) { for (short nSprite = headspritesect[pSprite->sectnum]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { - if (sprite[nSprite].type == 418 || sprite[nSprite].statnum == 2) + if (sprite[nSprite].type == 418 || sprite[nSprite].statnum == kStatExplosion) return 1; } return 0; diff --git a/source/blood/src/aigarg.cpp b/source/blood/src/aigarg.cpp index a949daaa6..de8994aec 100644 --- a/source/blood/src/aigarg.cpp +++ b/source/blood/src/aigarg.cpp @@ -149,7 +149,7 @@ static void BlastSSeqCallback(int, int nXSprite) aim.dy = Sin(pSprite->ang)>>16; aim.dz = gDudeSlope[nXSprite]; int nClosest = 0x7fffffff; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) diff --git a/source/blood/src/aighost.cpp b/source/blood/src/aighost.cpp index 13feedf47..d95244d16 100644 --- a/source/blood/src/aighost.cpp +++ b/source/blood/src/aighost.cpp @@ -132,7 +132,7 @@ static void BlastSeqCallback(int, int nXSprite) aim.dy = Sin(pSprite->ang)>>16; aim.dz = gDudeSlope[nXSprite]; int nClosest = 0x7fffffff; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) diff --git a/source/blood/src/aitchern.cpp b/source/blood/src/aitchern.cpp index e1f72db0b..5ff0de1a8 100644 --- a/source/blood/src/aitchern.cpp +++ b/source/blood/src/aitchern.cpp @@ -101,7 +101,7 @@ static void sub_71BD4(int, int nXSprite) aim.dy = Sin(pSprite->ang)>>16; aim.dz = gDudeSlope[nXSprite]; int nClosest = 0x7fffffff; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) @@ -177,7 +177,7 @@ static void sub_720AC(int, int nXSprite) aim.dz = gDudeSlope[nXSprite]; int nClosest = 0x7fffffff; az = 0; - for (short nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) + for (short nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) { spritetype *pSprite2 = &sprite[nSprite2]; if (pSprite == pSprite2 || !(pSprite2->flags&8)) diff --git a/source/blood/src/aiunicult.cpp b/source/blood/src/aiunicult.cpp index 8b7e543c0..24749ed52 100644 --- a/source/blood/src/aiunicult.cpp +++ b/source/blood/src/aiunicult.cpp @@ -722,35 +722,11 @@ int checkAttackState(spritetype* pSprite, XSPRITE* pXSprite) { return 0; } -/*bool sub_5BDA8(spritetype* pSprite, int nSeq) -{ - if (pSprite->statnum == 6 && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) - { - DUDEINFO* pDudeInfo = &dudeInfo[pSprite->type - kDudeBase]; - if (seqGetID(3, pSprite->extra) == pDudeInfo->seqStartID + nSeq && seqGetStatus(3, pSprite->extra) >= 0) - return true; - } - return false; -} - -bool sub_57901(spritetype* pSprite, int nSeqID) { - if ( pSprite->statnum == 6 ) - { - if ( IsDudeSprite(pSprite) ) - { - SEQINST* pSeqInst = GetInstance(3, pSprite->extra); Seq* pSeq = pSeqInst->pSequence; - if ( pSeq == pSEQs.get(xsprite[pSprite->extra].data2 + nSeqID) && seqGetStatus(3, pSprite->extra) >= 0 ) - return true; - } - } - return false; -}*/ - bool TargetNearThing(spritetype* pSprite, int thingType) { for ( int nSprite = headspritesect[pSprite->sectnum]; nSprite >= 0; nSprite = nextspritesect[nSprite] ) { // check for required things or explosions in the same sector as the target - if ( sprite[nSprite].type == thingType || sprite[nSprite].statnum == 2 ) + if ( sprite[nSprite].type == thingType || sprite[nSprite].statnum == kStatExplosion ) return true; // indicate danger } return false; @@ -866,7 +842,7 @@ bool spriteIsUnderwater(spritetype* pSprite,bool oldWay) { } spritetype* leechIsDropped(spritetype* pSprite) { - for (int nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (sprite[nSprite].type == kGDXThingCustomDudeLifeLeech && sprite[nSprite].owner == pSprite->xvel) return &sprite[nSprite]; } @@ -876,7 +852,7 @@ spritetype* leechIsDropped(spritetype* pSprite) { } void removeDudeStuff(spritetype* pSprite) { - for (short nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (short nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (sprite[nSprite].owner != pSprite->xvel) continue; switch (sprite[nSprite].type) { case 401: @@ -891,7 +867,7 @@ void removeDudeStuff(spritetype* pSprite) { } } - for (short nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (short nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (sprite[nSprite].owner != pSprite->xvel) continue; actDamageSprite(sprite[nSprite].owner, &sprite[nSprite], (DAMAGE_TYPE) 0, 65535); } @@ -928,8 +904,8 @@ XSPRITE* getNextIncarnation(XSPRITE* pXSprite) { continue; switch (sprite[rxBucket[i].index].statnum) { - case 6: - case 7: // inactive (ambush) dudes + case kStatDude: + case kStatInactive: // inactive (ambush) dudes if (xsprite[sprite[rxBucket[i].index].extra].health > 0) return &xsprite[sprite[rxBucket[i].index].extra]; } @@ -1009,7 +985,7 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT a3) int nTarget = pXSprite->target; if (nTarget >= 0 && nTarget < kMaxSprites) { spritetype* pTarget = &sprite[nTarget]; - if (pTarget->statnum == 6 && !(pTarget->flags & 32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites && !pXSprite->stateTimer) + if (pTarget->statnum == kStatDude && !(pTarget->flags & 32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites && !pXSprite->stateTimer) { int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -1087,7 +1063,7 @@ bool doExplosion(spritetype* pSprite, int nType) { void updateTargetOfSlaves(spritetype* pSprite) { - for (short nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (short nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (sprite[nSprite].owner != pSprite->xvel || sprite[nSprite].extra < 0 || !IsDudeSprite(&sprite[nSprite])) continue; else if (xsprite[pSprite->extra].target != xsprite[sprite[nSprite].extra].target && IsDudeSprite(&sprite[xsprite[pSprite->extra].target])) { diff --git a/source/blood/src/asound.cpp b/source/blood/src/asound.cpp index 12a8a9863..33160bb68 100644 --- a/source/blood/src/asound.cpp +++ b/source/blood/src/asound.cpp @@ -55,7 +55,7 @@ void ambProcess(void) { if (!SoundToggle) return; - for (int nSprite = headspritestat[12]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatAmbience]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->owner < 0 || pSprite->owner >= kMaxAmbChannel) @@ -116,7 +116,7 @@ void ambInit(void) { ambKillAll(); memset(ambChannels, 0, sizeof(ambChannels)); - for (int nSprite = headspritestat[12]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatAmbience]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; int nXSprite = pSprite->extra; diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index fb88e3e5b..24d075650 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -357,10 +357,10 @@ void PreloadTiles(void) spritetype *pSprite = &sprite[i]; switch (pSprite->statnum) { - case 6: + case kStatDude: PrecacheDude(pSprite); break; - case 4: + case kStatThing: PrecacheThing(pSprite); break; default: diff --git a/source/blood/src/callback.cpp b/source/blood/src/callback.cpp index d5ebaa3a6..98fe055b2 100644 --- a/source/blood/src/callback.cpp +++ b/source/blood/src/callback.cpp @@ -51,14 +51,14 @@ BEGIN_BLD_NS void makeMissileBlocking(int nSprite) // 23 { dassert(nSprite >= 0 && nSprite < kMaxSprites); - if (sprite[nSprite].statnum != 5) return; + if (sprite[nSprite].statnum != kStatProjectile) return; sprite[nSprite].cstat |= CSTAT_SPRITE_BLOCK; } void UniMissileBurst(int nSprite) // 22 { dassert(nSprite >= 0 && nSprite < kMaxSprites); - if (sprite[nSprite].statnum != 5) return; + if (sprite[nSprite].statnum != kStatProjectile) return; spritetype * pSprite = &sprite[nSprite]; int nAngle = getangle(xvel[nSprite], yvel[nSprite]); int nRadius = 0x55555; @@ -306,7 +306,7 @@ void Respawn(int nSprite) // 9 int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); XSPRITE *pXSprite = &xsprite[nXSprite]; - if (pSprite->statnum != 8 && pSprite->statnum != 4) + if (pSprite->statnum != kStatRespawn && pSprite->statnum != kStatThing) ThrowError("Sprite %d is not on Respawn or Thing list\n", nSprite); if (!(pSprite->flags&16)) ThrowError("Sprite %d does not have the respawn attribute\n", nSprite); @@ -622,7 +622,7 @@ void sub_768E8(int nSprite) // 18 void sub_769B4(int nSprite) // 19 { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 4 && !(pSprite->flags & 32)) { + if (pSprite->statnum == kStatThing && !(pSprite->flags & 32)) { switch (pSprite->type) { case 431: case kGDXThingCustomDudeLifeLeech: @@ -683,7 +683,7 @@ void sub_76B78(int nSprite) return; } int nSprite2, nNextSprite; - for (nSprite2 = headspritestat[6]; nSprite2 >= 0; nSprite2 = nNextSprite) + for (nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nNextSprite) { nNextSprite = nextspritestat[nSprite2]; if (nOwner == nSprite2) diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index a72234eed..f6329c59d 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS extern int g_useCwd; - #ifndef APPNAME #define APPNAME "NBlood" #endif @@ -89,9 +88,25 @@ void QuitGame(void); #define kMaxPowerUps 51 +#define kStatNothing -1 +#define kStatDecoration 0 +#define kStatFX 1 +#define kStatExplosion 2 +#define kStatItem 3 +#define kStatThing 4 +#define kStatProjectile 5 +#define kStatDude 6 +#define kStatInactive 7 // inactive (ambush) dudes #define kStatRespawn 8 +#define kStatPurge 9 #define kStatMarker 10 -#define kStatGDXDudeTargetChanger 20 +#define kStatTraps 11 +#define kStatAmbience 12 +#define kStatSpares 13 +#define kStatFlare 14 +#define kStatDebris 15 +#define kStatPathMarker 16 +#define kStatModernDudeTargetChanger 20 #define kStatFree 1024 #define kLensSize 80 @@ -185,9 +200,6 @@ void QuitGame(void); // projectile types #define kProjectileEctoSkull 307 -// custom level end -#define kGDXChannelEndLevelCustom 6 - // GDX types #define kGDXTypeBase 24 #define kGDXCustomDudeSpawn 24 diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 86351617c..d8f681b48 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "globals.h" #include "db.h" #include "iob.h" +#include "eventq.h" BEGIN_BLD_NS @@ -48,7 +49,7 @@ int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites]; char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors]; int gVisibility; - +bool gModernMap = false; const char *gItemText[] = { "Skull Key", "Eye Key", @@ -236,7 +237,7 @@ void RemoveSpriteStat(int nSprite) { headspritestat[nStat] = nextspritestat[nSprite]; } - sprite[nSprite].statnum = -1; + sprite[nSprite].statnum = kStatNothing; gStatCount[nStat]--; } @@ -599,7 +600,7 @@ void dbInit(void) void PropagateMarkerReferences(void) { int nSprite, nNextSprite; - for (nSprite = headspritestat[10]; nSprite != -1; nSprite = nNextSprite) + for (nSprite = headspritestat[kStatMarker]; nSprite != -1; nSprite = nNextSprite) { nNextSprite = nextspritestat[nSprite]; switch (sprite[nSprite].type) @@ -1008,6 +1009,11 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSector->bobRotate = bitReader.readUnsigned(1); xsector[sector[i].extra].reference = i; xsector[sector[i].extra].busy = xsector[sector[i].extra].state<<16; + + // by NoOne: indicate if the map requires modern features to work properly + // for maps wich created in different editors (include vanilla MAPEDIT) or in PMAPEDIT version below than BETA13 + if (pXSector->rxID == kChannelMapExtended && pXSector->rxID == pXSector->txID && pXSector->command == kCommandMapExtend) + gModernMap = true; } } for (int i = 0; i < numwalls; i++) @@ -1082,6 +1088,11 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXWall->at14_0 = bitReader.readUnsigned(32); xwall[wall[i].extra].reference = i; xwall[wall[i].extra].busy = xwall[wall[i].extra].state << 16; + + // by NoOne: indicate if the map requires modern features to work properly + // for maps wich created in different editors (include vanilla MAPEDIT) or in PMAPEDIT version below than BETA13 + if (pXWall->rxID == kChannelMapExtended && pXWall->rxID == pXWall->txID && pXWall->command == kCommandMapExtend) + gModernMap = true; } } initspritelists(); @@ -1198,10 +1209,14 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short bitReader.skipBits(32); xsprite[sprite[i].extra].reference = i; xsprite[sprite[i].extra].busy = xsprite[sprite[i].extra].state << 16; - if (!byte_1A76C8) - { + if (!byte_1A76C8) { xsprite[sprite[i].extra].lT |= xsprite[sprite[i].extra].lB; } + + // by NoOne: indicate if the map requires modern features to work properly + // for maps wich created in different editors (include vanilla MAPEDIT) or in PMAPEDIT version below than BETA13 + if (pXSprite->rxID == kChannelMapExtended && pXSprite->rxID == pXSprite->txID && pXSprite->command == kCommandMapExtend) + gModernMap = true; } if ((sprite[i].cstat & 0x30) == 0x30) { diff --git a/source/blood/src/db.h b/source/blood/src/db.h index b68bf8d99..2709d60a1 100644 --- a/source/blood/src/db.h +++ b/source/blood/src/db.h @@ -31,6 +31,8 @@ BEGIN_BLD_NS // by NoOne additional non-thing proximity, sight and physics sprites #define kMaxSuperXSprites 128 +extern bool gModernMap; + #pragma pack(push, 1) struct AISTATE; diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index 735abb2d3..c66b72908 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -140,19 +140,19 @@ void CKillMgr::sub_263E0(int nCount) void CKillMgr::AddKill(spritetype *pSprite) { - if (pSprite->statnum == 6 && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) + if (pSprite->statnum == kStatDude && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) at4++; } void CKillMgr::sub_2641C(void) { at0 = 0; - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) ThrowError("Non-enemy sprite (%d) in the enemy sprite list.", nSprite); - if (pSprite->statnum == 6 && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) + if (pSprite->statnum == kStatDude && pSprite->type != 219 && pSprite->type != 220 && pSprite->type != 245 && pSprite->type != 239) at0++; } } diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index 33d545dc7..94a86be4f 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "loadsave.h" #include "pqueue.h" #include "triggers.h" +#include "view.h" BEGIN_BLD_NS @@ -360,55 +361,50 @@ char evGetSourceState(int nType, int nIndex) void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) { - if (command == COMMAND_ID_2) - command = evGetSourceState(nType, nIndex) ? COMMAND_ID_1 : COMMAND_ID_0; - else if (command == COMMAND_ID_4) - command = evGetSourceState(nType, nIndex) ? COMMAND_ID_0 : COMMAND_ID_1; - EVENT evn; - evn.index = nIndex; - evn.type = nType; - evn.cmd = command; - if (rxId > 0) - { - switch (rxId) - { - case 7: - case 10: + EVENT event; event.index = nIndex; event.type = nType; event.cmd = command; + + switch (command) { + case COMMAND_ID_2: + command = evGetSourceState(nType, nIndex) ? COMMAND_ID_1 : COMMAND_ID_0; break; - case 3: - if (command < COMMAND_ID_64) - ThrowError("Invalid TextOver command by xobject %d(type %d)", nIndex, nType); - trTextOver(command-COMMAND_ID_64); + case COMMAND_ID_4: + command = evGetSourceState(nType, nIndex) ? COMMAND_ID_0 : COMMAND_ID_1; + break; + } + + switch (rxId) { + case kChannelTextOver: + if (command >= COMMAND_ID_64) trTextOver(command - COMMAND_ID_64); + else viewSetSystemMessage("Invalid TextOver command by xobject #%d (object type %d)", nIndex, nType); return; - case 4: + case kChannelLevelExitNormal: levelEndLevel(0); return; - case 5: + case kChannelLevelExitSecret: levelEndLevel(1); return; // By NoOne: finished level and load custom level ¹ via numbered command. - case kGDXChannelEndLevelCustom: - levelEndLevelCustom(command - 64); + case kChannelModernEndLevelCustom: + if (command >= COMMAND_ID_64) levelEndLevelCustom(command - COMMAND_ID_64); + else viewSetSystemMessage("Invalid Level-Exit# command by xobject #%d (object type %d)", nIndex, nType); return; - case 1: - if (command < COMMAND_ID_64) - ThrowError("Invalid SetupSecret command by xobject %d(type %d)", nIndex, nType); - levelSetupSecret(command - COMMAND_ID_64); + case kChannelSetTotalSecrets: + if (command >= COMMAND_ID_64) levelSetupSecret(command - COMMAND_ID_64); + else viewSetSystemMessage("Invalid Total-Secrets command by xobject #%d (object type %d)", nIndex, nType); break; - case 2: - if (command < COMMAND_ID_64) - ThrowError("Invalid Secret command by xobject %d(type %d)", nIndex, nType); - levelTriggerSecret(command - COMMAND_ID_64); + case kChannelSecretFound: + if (command >= COMMAND_ID_64) levelTriggerSecret(command - COMMAND_ID_64); + else viewSetSystemMessage("Invalid Trigger-Secret command by xobject #%d (object type %d)", nIndex, nType); break; - case 90: - case 91: - case 92: - case 93: - case 94: - case 95: - case 96: - case 97: - for (int nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + case kChannelRemoteBomb0: + case kChannelRemoteBomb1: + case kChannelRemoteBomb2: + case kChannelRemoteBomb3: + case kChannelRemoteBomb4: + case kChannelRemoteBomb5: + case kChannelRemoteBomb6: + case kChannelRemoteBomb7: + for (int nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags&32) @@ -418,13 +414,13 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->rxID == rxId) - trMessageSprite(nSprite, evn); + trMessageSprite(nSprite, event); } } return; - case 80: - case 81: - for (int nSprite = headspritestat[3]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + case kChannelTeamAFlagCaptured: + case kChannelTeamBFlagCaptured: + for (int nSprite = headspritestat[kStatItem]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags&32) @@ -434,39 +430,38 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->rxID == rxId) - trMessageSprite(nSprite, evn); + trMessageSprite(nSprite, event); } } return; - } + default: + break; } - for (int i = bucketHead[rxId]; i < bucketHead[rxId+1]; i++) - { - if (evn.type != rxBucket[i].type || evn.index != rxBucket[i].index) - { - switch (rxBucket[i].type) - { - case 6: - trMessageSector(rxBucket[i].index, evn); - break; - case 0: - trMessageWall(rxBucket[i].index, evn); - break; - case 3: - { - int nSprite = rxBucket[i].index; - spritetype *pSprite = &sprite[nSprite]; - if (pSprite->flags&32) - continue; - int nXSprite = pSprite->extra; - if (nXSprite > 0) + + for (int i = bucketHead[rxId]; i < bucketHead[rxId+1]; i++) { + if (event.type != rxBucket[i].type || event.index != rxBucket[i].index) { + switch (rxBucket[i].type) { + case 6: + trMessageSector(rxBucket[i].index, event); + break; + case 0: + trMessageWall(rxBucket[i].index, event); + break; + case 3: { - XSPRITE *pXSprite = &xsprite[nXSprite]; - if (pXSprite->rxID > 0) - trMessageSprite(nSprite, evn); + int nSprite = rxBucket[i].index; + spritetype *pSprite = &sprite[nSprite]; + if (pSprite->flags&32) + continue; + int nXSprite = pSprite->extra; + if (nXSprite > 0) + { + XSPRITE *pXSprite = &xsprite[nXSprite]; + if (pXSprite->rxID > 0) + trMessageSprite(nSprite, event); + } + break; } - break; - } } } } diff --git a/source/blood/src/eventq.h b/source/blood/src/eventq.h index cc8a5940b..1a36c3202 100644 --- a/source/blood/src/eventq.h +++ b/source/blood/src/eventq.h @@ -25,6 +25,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS + +enum { + kChannelZero = 0, + kChannelSetTotalSecrets, + kChannelSecretFound, + kChannelTextOver, + kChannelLevelExitNormal, + kChannelLevelExitSecret, + kChannelModernEndLevelCustom, // // custom level end + kChannelLevelStartSinglePlayer, + kChannelLevelStartMatch, // DM and TEAMS + kChannelLevelStartCoop, + kChannelLevelStartTeamsOnly, + kChannelPlayerDeathTeamA = 15, + kChannelPlayerDeathTeamB, + kChannelMapExtended = 60, // map requires modern features to work properly + kChannelTeamAFlagCaptured = 80, + kChannelTeamBFlagCaptured, + kChannelRemoteBomb0 = 90, + kChannelRemoteBomb1, + kChannelRemoteBomb2, + kChannelRemoteBomb3, + kChannelRemoteBomb4, + kChannelRemoteBomb5, + kChannelRemoteBomb6, + kChannelRemoteBomb7, +}; + #define kMaxChannels 4096 struct RXBUCKET @@ -51,6 +79,7 @@ enum COMMAND_ID { COMMAND_ID_21, kGDXCommandPaste = 53, // used by some new GDX types COMMAND_ID_64 = 64, + kCommandMapExtend = 100 }; struct EVENT { diff --git a/source/blood/src/fx.cpp b/source/blood/src/fx.cpp index bfe48f43d..7ec464a55 100644 --- a/source/blood/src/fx.cpp +++ b/source/blood/src/fx.cpp @@ -169,7 +169,7 @@ spritetype * CFX::fxSpawn(FX_ID nFx, int nSector, int x, int y, int z, unsigned FXDATA *pFX = &gFXData[nFx]; if (gStatCount[1] == 512) { - int nSprite = headspritestat[1];; + int nSprite = headspritestat[kStatFX];; while ((sprite[nSprite].flags & 32) && nSprite != -1) nSprite = nextspritestat[nSprite]; if (nSprite == -1) @@ -205,7 +205,7 @@ spritetype * CFX::fxSpawn(FX_ID nFx, int nSector, int x, int y, int z, unsigned void CFX::fxProcess(void) { - for (int nSprite = headspritestat[1]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatFX]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; viewBackupSpriteLoc(nSprite, pSprite); diff --git a/source/blood/src/levels.cpp b/source/blood/src/levels.cpp index 82a42bd97..cd609417f 100644 --- a/source/blood/src/levels.cpp +++ b/source/blood/src/levels.cpp @@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "sound.h" #include "sfx.h" #include "view.h" +#include "eventq.h" BEGIN_BLD_NS diff --git a/source/blood/src/messages.h b/source/blood/src/messages.h index b6bd95342..9eccd4831 100644 --- a/source/blood/src/messages.h +++ b/source/blood/src/messages.h @@ -35,7 +35,8 @@ enum MESSAGE_PRIORITY { MESSAGE_PRIORITY_PICKUP = -10, MESSAGE_PRIORITY_NORMAL = 0, MESSAGE_PRIORITY_SECRET = 10, - MESSAGE_PRIORITY_INI = 20 + MESSAGE_PRIORITY_INI = 20, + MESSAGE_PRIORITY_SYSTEM = 100 }; class CGameMessageMgr diff --git a/source/blood/src/mirrors.cpp b/source/blood/src/mirrors.cpp index fed130586..1699e306d 100644 --- a/source/blood/src/mirrors.cpp +++ b/source/blood/src/mirrors.cpp @@ -258,7 +258,7 @@ void sub_557C4(int x, int y, int interpolation) GetSpriteExtents(pSprite, &top, &bottom); int zCeil, zFloor; getzsofslope(nSector, pSprite->x, pSprite->y, &zCeil, &zFloor); - if (pSprite->statnum == 6 && (top < zCeil || bottom > zFloor)) + if (pSprite->statnum == kStatDude && (top < zCeil || bottom > zFloor)) { int j = i; if (mirror[i].at0 == 2) @@ -285,7 +285,7 @@ void sub_557C4(int x, int y, int interpolation) pTSprite->xoffset = pSprite->xoffset; pTSprite->yoffset = pSprite->yoffset; pTSprite->cstat = pSprite->cstat; - pTSprite->statnum = 0; + pTSprite->statnum = kStatDecoration; pTSprite->owner = pSprite->index; pTSprite->extra = pSprite->extra; pTSprite->flags = pSprite->hitag|0x200; diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index bcf031a94..270a1caec 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1056,7 +1056,7 @@ void playerInit(int nPlayer, unsigned int a2) char sub_3A158(PLAYER *a1, spritetype *a2) { - for (int nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (a2 && a2->index == nSprite) continue; @@ -1392,7 +1392,7 @@ void CheckPickUp(PLAYER *pPlayer) int z = pSprite->z; int nSector = pSprite->sectnum; int nNextSprite; - for (int nSprite = headspritestat[3]; nSprite >= 0; nSprite = nNextSprite) + for (int nSprite = headspritestat[kStatItem]; nSprite >= 0; nSprite = nNextSprite) { spritetype *pItem = &sprite[nSprite]; nNextSprite = nextspritestat[nSprite]; @@ -1440,7 +1440,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3) case 3: *a2 = gHitInfo.hitsprite; *a3 = sprite[*a2].extra; - if (*a3 > 0 && sprite[*a2].statnum == 4) + if (*a3 > 0 && sprite[*a2].statnum == kStatThing) { spritetype *pSprite = &sprite[*a2]; XSPRITE *pXSprite = &xsprite[*a3]; @@ -1454,7 +1454,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3) } if (*a3 > 0 && xsprite[*a3].Push) return 3; - if (sprite[*a2].statnum == 6) + if (sprite[*a2].statnum == kStatDude) { spritetype *pSprite = &sprite[*a2]; XSPRITE *pXSprite = &xsprite[*a3]; @@ -1542,7 +1542,7 @@ void ProcessInput(PLAYER *pPlayer) { if (pPlayer->pSprite) pPlayer->pSprite->type = 426; - actPostSprite(pPlayer->at5b, 4); + actPostSprite(pPlayer->at5b, kStatThing); seqSpawn(pPlayer->pDudeInfo->seqStartID+15, 3, pPlayer->pSprite->extra, -1); playerReset(pPlayer); if (gGameOptions.nGameType == 0 && numplayers == 1) diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index c96f30cf0..4b1ba27ea 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -315,7 +315,7 @@ void sub_43CF8(spritetype *pSprite, XSPRITE *pXSprite, EVENT a3) if (!pXSprite->stateTimer) { spritetype *pTarget = &sprite[nTarget]; - if (pTarget->statnum == 6 && !(pTarget->flags&32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites) + if (pTarget->statnum == kStatDude && !(pTarget->flags&32) && pTarget->extra > 0 && pTarget->extra < kMaxXSprites) { int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -389,7 +389,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT a3) } return; } - if (pSprite->statnum == 6 && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) + if (pSprite->statnum == kStatDude && pSprite->type >= kDudeBase && pSprite->type < kDudeMax) { switch (a3.cmd) { @@ -658,6 +658,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT a3) modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); break; case kGDXObjPropertiesChanger: + if (pXSprite->txID <= 0) { + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) + usePropertiesChanger(pXSprite, -1, -1); + break; + } + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + break; case kGDXObjPicnumChanger: case kGDXObjSizeChanger: case kGDXSectorFXChanger: @@ -878,7 +885,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT a3) break; case 402: - if (pSprite->statnum == 8) + if (pSprite->statnum == kStatRespawn) break; if (a3.cmd != 1) actExplodeSprite(pSprite); @@ -890,7 +897,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT a3) break; case 401: case kGDXThingTNTProx: - if (pSprite->statnum == 8) + if (pSprite->statnum == kStatRespawn) break; switch (a3.cmd) { @@ -1208,6 +1215,241 @@ void useConcussSprite(XSPRITE* pXSource, spritetype* pSprite) { //debrisConcuss(pXSource->reference, nIndex, pSprite->x - 100, pSprite->y - 100, pSprite->z - 100, pXSource->data1); } +void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex) { + + switch (objType) { + + // for walls + case 0: { + walltype* pWall = &wall[objIndex]; int old = -1; + + // data3 = set wall hitag + if (valueIsBetween(pXSource->data3, -1, 32767)) + pWall->hitag = pXSource->data3; + + // data4 = set wall cstat + if (valueIsBetween(pXSource->data4, -1, 65535)) { + old = pWall->cstat; + pWall->cstat = pXSource->data4; // set new cstat + + // and hanlde exceptions + if ((old & 0x2) && !(pWall->cstat & 0x2)) pWall->cstat |= 0x2; // kWallBottomSwap + if ((old & 0x4) && !(pWall->cstat & 0x4)) pWall->cstat |= 0x4; // kWallBottomOrg, kWallOutsideOrg + if ((old & 0x20) && !(pWall->cstat & 0x20)) pWall->cstat |= 0x20; // kWallOneWay + + if (old & 0xc000) { + + if (!(pWall->cstat & 0xc000)) + pWall->cstat |= 0xc000; // kWallMoveMask + + if ((old & 0x0) && !(pWall->cstat & 0x0)) pWall->cstat |= 0x0; // kWallMoveNone + else if ((old & 0x4000) && !(pWall->cstat & 0x4000)) pWall->cstat |= 0x4000; // kWallMoveForward + else if ((old & 0x8000) && !(pWall->cstat & 0x8000)) pWall->cstat |= 0x8000; // kWallMoveBackward + + } + } + + break; + } + + // for sprites + case 3: { + spritetype* pSprite = &sprite[objIndex]; bool thing2debris = false; + XSPRITE* pXSprite = &xsprite[pSprite->extra]; int old = -1; + + // data3 = set sprite hitag + if (valueIsBetween(pXSource->data3, -1, 32767)) { + old = pSprite->hitag; pSprite->hitag = pXSource->data3; // set new hitag + + // and handle exceptions + if ((old & kHitagFree) && !(pSprite->hitag & kHitagFree)) pSprite->hitag |= kHitagFree; + if ((old & kHitagRespawn) && !(pSprite->hitag & kHitagRespawn)) pSprite->hitag |= kHitagRespawn; + + // prepare things for different (debris) physics. + if (pSprite->statnum == kStatThing && debrisGetFreeIndex() >= 0) thing2debris = true; + + } + + // data2 = sprite physics settings + if ((pXSource->data2 >= 0 && pXSource->data3 <= 33) || thing2debris) { + switch (pSprite->statnum) { + case kStatDude: // dudes already treating in game + case kStatFree: + case kStatMarker: + case kStatPathMarker: // path marker + break; + default: + // store physics attributes in xsprite to avoid setting hitag for modern types! + int flags = (pXSprite->physAttr != 0) ? pXSprite->physAttr : 0; + + if (thing2debris) { + + // converting thing to debris + if ((pSprite->hitag & kPhysMove) != 0) flags |= kPhysMove; + else flags &= ~kPhysMove; + + if ((pSprite->hitag & kPhysGravity) != 0) flags |= (kPhysGravity | kPhysFalling); + else flags &= ~(kPhysGravity | kPhysFalling); + + pSprite->hitag &= ~(kPhysMove | kPhysGravity | kPhysFalling); + xvel[objIndex] = yvel[objIndex] = zvel[objIndex] = 0; pXSprite->restState = pXSprite->state; + + } else { + + // first digit of data2: set main physics attributes + switch (pXSource->data2) { + case 0: + flags &= ~kPhysMove; + flags &= ~(kPhysGravity | kPhysFalling); + break; + + case 1: case 10: case 11: case 12: case 13: + flags |= kPhysMove; + flags &= ~(kPhysGravity | kPhysFalling); + break; + + case 2: case 20: case 21: case 22: case 23: + flags &= ~kPhysMove; + flags |= (kPhysGravity | kPhysFalling); + break; + + case 3: case 30: case 31: case 32: case 33: + flags |= kPhysMove; + flags |= (kPhysGravity | kPhysFalling); + break; + } + + // second digit of data2: set physics flags + switch (pXSource->data2) { + case 0: case 1: case 2: case 3: + case 10: case 20: case 30: + flags &= ~kPhysDebrisVector; + flags &= ~kPhysDebrisExplode; + break; + + case 11: case 21: case 31: + flags |= kPhysDebrisVector; + flags &= ~kPhysDebrisExplode; + break; + + case 12: case 22: case 32: + flags &= ~kPhysDebrisVector; + flags |= kPhysDebrisExplode; + break; + + case 13: case 23: case 33: + flags |= kPhysDebrisVector; + flags |= kPhysDebrisExplode; + break; + } + + } + + int nIndex = isDebris(objIndex); // check if there is no sprite in list + + // adding physics sprite in list + if ((flags & kPhysGravity) != 0 || (flags & kPhysMove) != 0) { + + if (nIndex != -1) pXSprite->physAttr = flags; // just update physics attributes + else if ((nIndex = debrisGetFreeIndex()) < 0) + showWarning("Max (%d) Physics affected sprites reached!", kMaxSuperXSprites); + else { + + pXSprite->physAttr = flags; // update physics attributes + + // allow things to became debris, so they use different physics... + if (pSprite->statnum == kStatThing) changespritestat(objIndex, 0); + //actPostSprite(nDest, kStatDecoration); // !!!! not working here for some reason + + gPhysSpritesList[nIndex] = objIndex; + if (nIndex >= gPhysSpritesCount) gPhysSpritesCount++; + getSpriteMassBySize(pSprite); // create physics cache + + } + + // removing physics from sprite in list (don't remove sprite from list) + } else if (nIndex != -1) { + + pXSprite->physAttr = flags; + xvel[objIndex] = yvel[objIndex] = zvel[objIndex] = 0; + if (pSprite->lotag >= kThingBase && pSprite->lotag < kThingMax) + changespritestat(objIndex, kStatThing); // if it was a thing - restore statnum + + } + + break; + } + } + + // data4 = sprite cstat + if (valueIsBetween(pXSource->data4, -1, 65535)) { + + old = pSprite->cstat; + pSprite->cstat = pXSource->data4; // set new cstat + + // and handle exceptions + if ((old & 0x1000) && !(pSprite->cstat & 0x1000)) pSprite->cstat |= 0x1000; //kSpritePushable + if ((old & 0x80) && !(pSprite->cstat & 0x80)) pSprite->cstat |= 0x80; // kSpriteOriginAlign + + if (old & 0x6000) { + + if (!(pSprite->cstat & 0x6000)) + pSprite->cstat |= 0x6000; // kSpriteMoveMask + + if ((old & 0x0) && !(pSprite->cstat & 0x0)) pSprite->cstat |= 0x0; // kSpriteMoveNone + else if ((old & 0x2000) && !(pSprite->cstat & 0x2000)) pSprite->cstat |= 0x2000; // kSpriteMoveForward, kSpriteMoveFloor + else if ((old & 0x4000) && !(pSprite->cstat & 0x4000)) pSprite->cstat |= 0x4000; // kSpriteMoveReverse, kSpriteMoveCeiling + + } + + } + + break; + } + + // for sectors + case 6: { + + XSECTOR* pXSector = &xsector[sector[objIndex].extra]; + + // data1 = sector underwater status and depth level + if (pXSource->data1 == 0) pXSector->Underwater = false; + else if (pXSource->data1 == 1) pXSector->Underwater = true; + else if (pXSource->data1 > 9) pXSector->Depth = 7; + else if (pXSource->data1 > 1) pXSector->Depth = pXSource->data1 - 2; + + + // data2 = sector visibility + if (valueIsBetween(pXSource->data2, -1, 32767)) { + if (pXSource->data2 > 234) sector[objIndex].visibility = 234; + else sector[objIndex].visibility = pXSource->data2; + } + + // data3 = sector ceil cstat + if (valueIsBetween(pXSource->data3, -1, 32767)) + sector[objIndex].ceilingstat = pXSource->data3; + + // data4 = sector floor cstat + if (valueIsBetween(pXSource->data4, -1, 65535)) + sector[objIndex].floorstat = pXSource->data4; + + break; + + } + + // no TX id + case -1: { + + // data2 = global visibility + if (valueIsBetween(pXSource->data2, -1, 32767)) + gVisibility = ClipRange(pXSource->data2, 0, 4096); + } + + break; + } + +} + void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite) { spritetype* pSource = &sprite[pXSource->reference]; XSECTOR* pXSector = (sector[pSource->sectnum].extra >= 0) ? &xsector[sector[pSource->sectnum].extra] : NULL; @@ -1270,21 +1512,14 @@ void useEffectGen(XSPRITE * pXSource, spritetype * pSprite) { if (pSprite == NULL) pSprite = &sprite[pXSource->reference]; if (pSprite->extra < 0) return; + int fxId = pXSource->data2 + Random(pXSource->data3); int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); spritetype * pEffect = NULL; - int dx = 0, dy = 0; int cnt = (pXSource->data4 > 32) ? 32 : pXSource->data4; - - while (cnt-- >= 0) { - if (cnt > 0) { - int dx = Random3(250); - int dy = Random3(150); - } - - pEffect = gFX.fxSpawn((FX_ID)pXSource->data2, pSprite->sectnum, pSprite->x + dx, pSprite->y + dy, top, 0); - if (pEffect != NULL) { + if (fxId > 0 && fxId < 57 && (pEffect = gFX.fxSpawn((FX_ID) fxId, pSprite->sectnum, pSprite->x, pSprite->y, top, 0)) != NULL) { if ((pEffect->cstat & CSTAT_SPRITE_ALIGNMENT_WALL) && (pEffect->cstat & CSTAT_SPRITE_ONE_SIDED)) pEffect->cstat &= ~CSTAT_SPRITE_ONE_SIDED; + if (pSprite->flags & kModernTypeFlag1) { if (pEffect->pal <= 0) pEffect->pal = pSprite->pal; if (pEffect->xrepeat <= 0) pEffect->xrepeat = pSprite->xrepeat; if (pEffect->yrepeat <= 0) pEffect->yrepeat = pSprite->yrepeat; @@ -1292,8 +1527,9 @@ void useEffectGen(XSPRITE * pXSource, spritetype * pSprite) { } } - if (pXSource->data3 > 0) - sfxPlay3DSound(pSprite, pXSource->data3, -1, 0); + if (pXSource->data4 > 0) + sfxPlay3DSound(pSprite, pXSource->data4, -1, 0); + // kModernTypeFlag = 2: kill the sound before play again } @@ -1590,7 +1826,7 @@ void SectorStartSound(int nSector, int nState) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 0 && pSprite->type == 709) + if (pSprite->statnum == kStatDecoration && pSprite->type == 709) { int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); @@ -1614,7 +1850,7 @@ void SectorEndSound(int nSector, int nState) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 0 && pSprite->type == 709) + if (pSprite->statnum == kStatDecoration && pSprite->type == 709) { int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); @@ -1638,7 +1874,7 @@ void PathSound(int nSector, int nSound) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 0 && pSprite->type == 709) + if (pSprite->statnum == kStatDecoration && pSprite->type == 709) sfxPlay3DSound(pSprite, nSound, 0, 0); } } @@ -1751,7 +1987,7 @@ void TranslateSector(int nSector, int a2, int a3, int a4, int a5, int a6, int a7 { spritetype *pSprite = &sprite[nSprite]; // By NoOne: allow to move markers by sector movements in game if flags 1 is added in editor. - if (pSprite->statnum == 10 || pSprite->statnum == 16) { + if (pSprite->statnum == kStatMarker || pSprite->statnum == kStatPathMarker) { if (!(pSprite->flags & kModernTypeFlag1)) continue; } x = baseSprite[nSprite].x; @@ -1805,7 +2041,7 @@ void ZTranslateSector(int nSector, XSECTOR *pXSector, int a3, int a4) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 10 || pSprite->statnum == 16) + if (pSprite->statnum == kStatMarker || pSprite->statnum == kStatPathMarker) continue; int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -1832,7 +2068,7 @@ void ZTranslateSector(int nSector, XSECTOR *pXSector, int a3, int a4) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 10 || pSprite->statnum == 16) + if (pSprite->statnum == kStatMarker || pSprite->statnum == kStatPathMarker) continue; if (pSprite->cstat&16384) { @@ -1849,7 +2085,7 @@ int GetHighestSprite(int nSector, int nStatus, int *a3) int v8 = -1; for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { - if (sprite[nSprite].statnum == nStatus || nStatus == 1024) + if (sprite[nSprite].statnum == nStatus || nStatus == kStatFree) { spritetype *pSprite = &sprite[nSprite]; int top, bottom; @@ -1874,7 +2110,7 @@ int GetCrushedSpriteExtents(unsigned int nSector, int *pzTop, int *pzBot) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 6 || pSprite->statnum == 4) + if (pSprite->statnum == kStatDude || pSprite->statnum == kStatThing) { int top, bottom; GetSpriteExtents(pSprite, &top, &bottom); @@ -2261,7 +2497,7 @@ char SectorContainsDudes(int nSector) { for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { - if (sprite[nSprite].statnum == 6) + if (sprite[nSprite].statnum == kStatDude) return 1; } return 0; @@ -2272,9 +2508,9 @@ void TeleFrag(int nKiller, int nSector) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 6) + if (pSprite->statnum == kStatDude) actDamageSprite(nKiller, pSprite, DAMAGE_TYPE_3, 4000); - else if (pSprite->statnum == 4) + else if (pSprite->statnum == kStatThing) actDamageSprite(nKiller, pSprite, DAMAGE_TYPE_3, 4000); } } @@ -2291,7 +2527,7 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector) for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { spritetype *pSprite = &sprite[nSprite]; - if (pSprite->statnum == 6) + if (pSprite->statnum == kStatDude) { PLAYER *pPlayer; char bPlayer = IsPlayerSprite(pSprite); @@ -2331,10 +2567,10 @@ void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT a3) spritetype *pSprite2 = &sprite[pXSector->at2c_0]; XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; int nId = pXSprite2->data2; - for (nSprite = headspritestat[16]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatPathMarker]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pSprite = &sprite[nSprite]; - if (pSprite->type == 15) + if (pSprite->type == kMarkerPath) { pXSprite = &xsprite[pSprite->extra]; if (pXSprite->data1 == nId) @@ -2472,10 +2708,10 @@ void InitPath(unsigned int nSector, XSECTOR *pXSector) XSPRITE *pXSprite; dassert(nSector < (unsigned int)numsectors); int nId = pXSector->data; - for (nSprite = headspritestat[16]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatPathMarker]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pSprite = &sprite[nSprite]; - if (pSprite->type == 15) + if (pSprite->type == kMarkerPath) { pXSprite = &xsprite[pSprite->extra]; if (pXSprite->data1 == nId) @@ -3041,7 +3277,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { /* 4: follow player(s) when no targets in sight, attack targets if any in sight - */ if (type != 3) return; - else if (!IsDudeSprite(&sprite[nDest]) && sprite[nDest].statnum != 6 && xsprite[sprite[nDest].extra].data3 != 0) { + else if (!IsDudeSprite(&sprite[nDest]) && sprite[nDest].statnum != kStatDude && xsprite[sprite[nDest].extra].data3 != 0) { switch (sprite[nDest].type) { // can be dead dude turned in gib // make current target and all other dudes not attack this dude anymore case 425: @@ -3082,7 +3318,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { // dude is dead? if (pXSprite->health <= 0) { - pSprite->type = 426; actPostSprite(pSprite->xvel, 4); // turn it in gib + pSprite->type = 426; actPostSprite(pSprite->xvel, kStatThing); // turn it in gib return; } @@ -3226,7 +3462,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { if ((pXSprite->target < 0 || pPlayer != NULL) && ((int)gFrameClock & 32) != 0) { // try find first target that dude can see - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pTarget = &sprite[nSprite]; pXTarget = &xsprite[pTarget->extra]; if (pXTarget->target == pSprite->xvel) { @@ -3419,218 +3655,9 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { } } else if (pSource->type == kGDXObjPropertiesChanger) { - - /* - properties changer can change various properties of sprite/wall/sector via TX ID - */ - /* - data1 = sector underwater status - */ - /* - data2 = sector visibility - */ - /* - data3 = sector ceiling cstat / sprite / wall flags - */ - /* - data4 = sector floor / sprite / wall cstat - */ - int old = -1; - switch (type) { - - // for sectors - case 6: { - XSECTOR* pXSector = &xsector[sector[nDest].extra]; - - if (pXSource->data1 == 0) pXSector->Underwater = false; - else if (pXSource->data1 == 1) pXSector->Underwater = true; - else if (pXSource->data1 > 9) pXSector->Depth = 7; - else if (pXSource->data1 > 1) pXSector->Depth = pXSource->data1 - 2; - - if (valueIsBetween(pXSource->data2, -1, 32767)) { - if (pXSource->data2 > 234) sector[nDest].visibility = 234; - else sector[nDest].visibility = pXSource->data2; + /* - properties changer can change various properties - */ + usePropertiesChanger(pXSource, type, nDest); } - - if (valueIsBetween(pXSource->data3, -1, 32767)) - sector[nDest].ceilingstat = pXSource->data3; - - if (valueIsBetween(pXSource->data4, -1, 65535)) - sector[nDest].floorstat = pXSource->data4; - } - break; - - // for sprites - case 3: { - - spritetype* pSprite = &sprite[nDest]; bool thing2debris = false; - XSPRITE* pXSprite = &xsprite[pSprite->extra]; - - if (valueIsBetween(pXSource->data3, -1, 32767)) { - old = pSprite->flags; pSprite->flags = pXSource->data3; // set new flags - - // and handle exceptions - if ((old & kHitagFree) && !(pSprite->flags & kHitagFree)) pSprite->flags |= kHitagFree; - if ((old & kHitagRespawn) && !(pSprite->flags & kHitagRespawn)) pSprite->flags |= kHitagRespawn; - - // prepare things for different (debris) physics. - if (pSprite->statnum == 4 && debrisGetFreeIndex() >= 0) thing2debris = true; - - } - - if ((pXSource->data2 >= 0 && pXSource->data3 <= 33) || thing2debris) { - switch (pSprite->statnum) { - case 6: // dudes already treating in game - case kStatFree: - case kStatMarker: - case 16: // path marker - break; - default: - // store physics attributes in xsprite to avoid setting flags for modern types! - int flags = (pXSprite->physAttr != 0) ? pXSprite->physAttr : 0; - - if (thing2debris) { - - // converting thing to debris - if ((pSprite->flags & kPhysMove) != 0) flags |= kPhysMove; - else flags &= ~kPhysMove; - - if ((pSprite->flags & kPhysGravity) != 0) flags |= (kPhysGravity | kPhysFalling); - else flags &= ~(kPhysGravity | kPhysFalling); - - pSprite->flags &= ~(kPhysMove | kPhysGravity | kPhysFalling); - xvel[nDest] = yvel[nDest] = zvel[nDest] = 0; pXSprite->restState = pXSprite->state; - - } else { - - // first digit of data2: set main physics attributes first - switch (pXSource->data2) { - case 0: - flags &= ~kPhysMove; - flags &= ~(kPhysGravity | kPhysFalling); - break; - - case 1: case 10: case 11: case 12: case 13: - flags |= kPhysMove; - flags &= ~(kPhysGravity | kPhysFalling); - break; - - case 2: case 20: case 21: case 22: case 23: - flags &= ~kPhysMove; - flags |= (kPhysGravity | kPhysFalling); - break; - - case 3: case 30: case 31: case 32: case 33: - flags |= kPhysMove; - flags |= (kPhysGravity | kPhysFalling); - break; - } - - // second digit of data2: then set physics flags - switch (pXSource->data2) { - case 0: case 1: case 2: case 3: - case 10: case 20: case 30: - flags &= ~kPhysDebrisVector; - flags &= ~kPhysDebrisExplode; - break; - - case 11: case 21: case 31: - flags |= kPhysDebrisVector; - flags &= ~kPhysDebrisExplode; - break; - - case 12: case 22: case 32: - flags &= ~kPhysDebrisVector; - flags |= kPhysDebrisExplode; - break; - - case 13: case 23: case 33: - flags |= kPhysDebrisVector; - flags |= kPhysDebrisExplode; - break; - } - - } - - int nIndex = isDebris(nDest); // check if there is no sprite in list - - // adding physics sprite in list - if ((flags & kPhysGravity) != 0 || (flags & kPhysMove) != 0) { - if (nIndex != -1) pXSprite->physAttr = flags; // just update physics attributes - else if ((nIndex = debrisGetFreeIndex()) < 0) - ;// showWarning("Max (%d) Physics affected sprites reached!", kMaxSuperXSprites); - else { - - pXSprite->physAttr = flags; // update physics attributes - - // allow things to became debris, so they use different physics... - if (pSprite->statnum == 4) changespritestat(nDest, 0); - //actPostSprite(nDest, 0); // !!!! not working here for some reason - - gPhysSpritesList[nIndex] = nDest; - if (nIndex >= gPhysSpritesCount) gPhysSpritesCount++; - getSpriteMassBySize(pSprite); // create physics cache - - } - // removing physics from sprite in list (don't remove sprite from list) - } else if (nIndex != -1) { - pXSprite->physAttr = flags; - xvel[nDest] = yvel[nDest] = zvel[nDest] = 0; - if (pSprite->type >= kThingBase && pSprite->type < kThingMax) - changespritestat(nDest, 4); // if it was a thing - restore statnum - } - - break; - } - } - - if (valueIsBetween(pXSource->data4, -1, 65535)) { - - old = pSprite->cstat; - pSprite->cstat = pXSource->data4; // set new cstat - - // and handle exceptions - if ((old & 0x1000) && !(pSprite->cstat & 0x1000)) pSprite->cstat |= 0x1000; //kSpritePushable - if ((old & 0x80) && !(pSprite->cstat & 0x80)) pSprite->cstat |= 0x80; // kSpriteOriginAlign - - if (old & 0x6000) { - - if (!(pSprite->cstat & 0x6000)) - pSprite->cstat |= 0x6000; // kSpriteMoveMask - - if ((old & 0x0) && !(pSprite->cstat & 0x0)) pSprite->cstat |= 0x0; // kSpriteMoveNone - else if ((old & 0x2000) && !(pSprite->cstat & 0x2000)) pSprite->cstat |= 0x2000; // kSpriteMoveForward, kSpriteMoveFloor - else if ((old & 0x4000) && !(pSprite->cstat & 0x4000)) pSprite->cstat |= 0x4000; // kSpriteMoveReverse, kSpriteMoveCeiling - - } - - } - - } - break; - - // for walls - case 0: { - walltype* pWall = &wall[nDest]; - if (valueIsBetween(pXSource->data3, -1, 32767)) - pWall->hitag = pXSource->data3; - - if (valueIsBetween(pXSource->data4, -1, 65535)) { - old = pWall->cstat; - pWall->cstat = pXSource->data4; // set new cstat - - // and hanlde exceptions - if ((old & 0x2) && !(pWall->cstat & 0x2)) pWall->cstat |= 0x2; // kWallBottomSwap - if ((old & 0x4) && !(pWall->cstat & 0x4)) pWall->cstat |= 0x4; // kWallBottomOrg, kWallOutsideOrg - if ((old & 0x20) && !(pWall->cstat & 0x20)) pWall->cstat |= 0x20; // kWallOneWay - - if (old & 0xc000) { - - if (!(pWall->cstat & 0xc000)) - pWall->cstat |= 0xc000; // kWallMoveMask - - if ((old & 0x0) && !(pWall->cstat & 0x0)) pWall->cstat |= 0x0; // kWallMoveNone - else if ((old & 0x4000) && !(pWall->cstat & 0x4000)) pWall->cstat |= 0x4000; // kWallMoveForward - else if ((old & 0x8000) && !(pWall->cstat & 0x8000)) pWall->cstat |= 0x8000; // kWallMoveBackward - - } - - } - } - break; - - } - } } // By NoOne: the following functions required for kGDXDudeTargetChanger @@ -3638,7 +3665,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { spritetype* getTargetInRange(spritetype* pSprite, int minDist, int maxDist, short data, short teamMode) { DUDEINFO* pDudeInfo = &dudeInfo[pSprite->type - kDudeBase]; XSPRITE* pXSprite = &xsprite[pSprite->extra]; spritetype* pTarget = NULL; XSPRITE* pXTarget = NULL; spritetype* cTarget = NULL; - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pTarget = &sprite[nSprite]; pXTarget = &xsprite[pTarget->extra]; if (!dudeCanSeeTarget(pXSprite, pDudeInfo, pTarget)) continue; @@ -3775,7 +3802,7 @@ void activateDudes(int rx) { // by NoOne: this function sets target to -1 for all dudes that hunting for nSprite void freeTargets(int nSprite) { - for (int nTarget = headspritestat[6]; nTarget >= 0; nTarget = nextspritestat[nTarget]) { + for (int nTarget = headspritestat[kStatDude]; nTarget >= 0; nTarget = nextspritestat[nTarget]) { if (!IsDudeSprite(&sprite[nTarget]) || sprite[nTarget].extra < 0) continue; else if (xsprite[sprite[nTarget].extra].target == nSprite) aiSetTarget(&xsprite[sprite[nTarget].extra], sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z); @@ -3797,7 +3824,7 @@ void freeAllTargets(XSPRITE* pXSource) { bool affectedByTargetChg(XSPRITE* pXDude) { if (pXDude->rxID <= 0 || pXDude->locked == 1) return false; - for (int nSprite = headspritestat[kStatGDXDudeTargetChanger]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatModernDudeTargetChanger]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { XSPRITE* pXSprite = (sprite[nSprite].extra >= 0) ? &xsprite[sprite[nSprite].extra] : NULL; if (pXSprite == NULL || pXSprite->txID <= 0 || pXSprite->state != 1) continue; for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) { @@ -3910,7 +3937,7 @@ void disturbDudesInSight(spritetype* pSprite, int max) { spritetype* pDude = NULL; XSPRITE* pXDude = NULL; XSPRITE* pXSprite = &xsprite[pSprite->extra]; DUDEINFO* pDudeInfo = &dudeInfo[pSprite->type - kDudeBase]; - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pDude = &sprite[nSprite]; if (pDude->xvel == pSprite->xvel || !IsDudeSprite(pDude) || pDude->extra < 0) continue; @@ -4415,7 +4442,7 @@ void ActivateGenerator(int nSprite) case 80: { // Random ammo // let's first search for previously dropped items and remove it if (pXSprite->dropMsg > 0) { - for (short nItem = headspritestat[3]; nItem >= 0; nItem = nextspritestat[nItem]) { + for (short nItem = headspritestat[kStatItem]; nItem >= 0; nItem = nextspritestat[nItem]) { spritetype* pItem = &sprite[nItem]; if (pItem->type == pXSprite->dropMsg && pItem->x == pSprite->x && pItem->y == pSprite->y && pItem->z == pSprite->z) { gFX.fxSpawn((FX_ID)29, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0); diff --git a/source/blood/src/triggers.h b/source/blood/src/triggers.h index 7c7329b41..14a6acef1 100644 --- a/source/blood/src/triggers.h +++ b/source/blood/src/triggers.h @@ -75,7 +75,10 @@ void useEffectGen(XSPRITE* pXSource, spritetype* pSprite); void useSeqSpawnerGen(XSPRITE* pXSource, int objType, int index); void useSpriteDamager(XSPRITE* pXSource, spritetype* pSprite); void useTeleportTarget(XSPRITE* pXSource, spritetype* pSprite); +void usePropertiesChanger(XSPRITE* pXSource, short objType, int objIndex); void TeleFrag(int nKiller, int nSector); +bool valueIsBetween(int val, int min, int max); + // ------------------------------------------------------- END_BLD_NS diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index df65ee724..f3f4c3a24 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -817,7 +817,7 @@ void fakeActAirDrag(spritetype *pSprite, int num) void fakeActProcessSprites(void) { spritetype *pSprite = gMe->pSprite; - if (pSprite->statnum == 6) + if (pSprite->statnum == kStatDude) { int nXSprite = pSprite->extra; dassert(nXSprite > 0 && nXSprite < kMaxXSprites); @@ -1995,7 +1995,7 @@ uspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect) pNSprite->shade = -128; pNSprite->z = pTSprite->z; pNSprite->picnum = 908; - pNSprite->statnum = 0; + pNSprite->statnum = kStatDecoration; pNSprite->xrepeat = pNSprite->yrepeat = (tilesiz[pTSprite->picnum].x*pTSprite->xrepeat)/64; break; } @@ -2364,7 +2364,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } switch (pTSprite->statnum) { - case 0: + case kStatDecoration: { switch (pTSprite->type) { @@ -2415,7 +2415,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } break; } - case 3: + case kStatItem: { switch (pTSprite->type) { @@ -2454,7 +2454,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } break; } - case 5: + case kStatProjectile: { switch (pTSprite->type) { @@ -2470,7 +2470,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t break; case 301: case 303: - if (pTSprite->statnum == 14) + if (pTSprite->statnum == kStatFlare) { dassert(pTXSprite != NULL); if (pTXSprite->target == gView->at5b) @@ -2498,7 +2498,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } break; } - case 6: + case kStatDude: { if (pTSprite->type == 212 && pTXSprite->aiState == &hand13A3B4) { @@ -2585,7 +2585,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } break; } - case 11: + case kStatTraps: { if (pTSprite->type == 454) { @@ -2614,7 +2614,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t } break; } - case 4: + case kStatThing: { if (pXSector && pXSector->color) { @@ -2805,6 +2805,15 @@ void viewBurnTime(int gScale) } } +// by NoOne: show warning msgs in game instead of throwing errors (in some cases) +void viewSetSystemMessage(const char* pMessage, ...) { + char buffer[256]; va_list args; va_start(args, pMessage); + vsprintf(buffer, pMessage, args); + + OSD_Printf("%s\n", buffer); + gGameMessageMgr.Add(buffer, 15, 7, MESSAGE_PRIORITY_SYSTEM); +} + void viewSetMessage(const char *pMessage, const int pal, const MESSAGE_PRIORITY priority) { OSD_Printf("%s\n", pMessage); @@ -3340,7 +3349,7 @@ RORHACKOTHER: deliriumTurn = 0; deliriumPitch = 0; } - int nSprite = headspritestat[2]; + int nSprite = headspritestat[kStatExplosion]; int unk = 0; while (nSprite >= 0) { @@ -3354,7 +3363,7 @@ RORHACKOTHER: } nSprite = nextspritestat[nSprite]; } - nSprite = headspritestat[5]; + nSprite = headspritestat[kStatProjectile]; while (nSprite >= 0) { spritetype *pSprite = &sprite[nSprite]; diff --git a/source/blood/src/view.h b/source/blood/src/view.h index d4eeda282..cf33cf7af 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -160,7 +160,7 @@ void viewUpdateShake(void); void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b); void viewResetCrosshairToDefault(void); void viewPrintFPS(void); - +void viewSetSystemMessage(const char* pMessage, ...); inline void viewInterpolateSector(int nSector, sectortype *pSector) { diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index 85f105022..3aa34825f 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -320,7 +320,7 @@ void UpdateAimVector(PLAYER * pPlayer) if (gProfile[pPlayer->at57].nAutoAim == 1 || (gProfile[pPlayer->at57].nAutoAim == 2 && !pWeaponTrack->bIsProjectile) || pPlayer->atbd == 10 || pPlayer->atbd == 9) { int nClosest = 0x7fffffff; - for (nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pSprite = &sprite[nSprite]; if (pSprite == pPSprite) @@ -378,7 +378,7 @@ void UpdateAimVector(PLAYER * pPlayer) } if (pWeaponTrack->atc > 0) { - for (nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pSprite = &sprite[nSprite]; if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pSprite)) @@ -2251,7 +2251,7 @@ void WeaponProcess(PLAYER *pPlayer) { } pPlayer->voodooTarget = pPlayer->at1d6; - if (pPlayer->voodooTarget == -1 || sprite[pPlayer->voodooTarget].statnum != 6) + if (pPlayer->voodooTarget == -1 || sprite[pPlayer->voodooTarget].statnum != kStatDude) i = 4; StartQAV(pPlayer,103+i, nClientFireVoodoo, 0); return; @@ -2462,9 +2462,9 @@ void sub_51340(spritetype *pMissile, int a2) char v4 = 1; int v24 = -1; actHitcodeToData(a2, &gHitInfo, &v24, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if (a2 == 3 && v24 >= 0 && sprite[v24].statnum == 6) + if (a2 == 3 && v24 >= 0 && sprite[v24].statnum == kStatDude) v4 = 0; - for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { if (nSprite != nOwner || v4) { @@ -2482,7 +2482,7 @@ void sub_51340(spritetype *pMissile, int a2) } } } - for (int nSprite = headspritestat[4]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + for (int nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { spritetype *pSprite = &sprite[nSprite]; if (pSprite->flags&32)