diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 2e6cbc4e3..3f54469b8 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -2430,9 +2430,9 @@ void DudeToGibCallback1(int, int); void DudeToGibCallback2(int, int); int nFireballClient = seqRegisterClient(FireballSeqCallback); -int dword_2192D8 = seqRegisterClient(sub_38938); +int dword_2192D8 = seqRegisterClient(sub_38938); // fireball smoke int nNapalmClient = seqRegisterClient(NapalmSeqCallback); -int dword_2192E0 = seqRegisterClient(sub_3888C); +int dword_2192E0 = seqRegisterClient(sub_3888C); // flame lick int nTreeToGibClient = seqRegisterClient(TreeToGibCallback); int nDudeToGibClient1 = seqRegisterClient(DudeToGibCallback1); int nDudeToGibClient2 = seqRegisterClient(DudeToGibCallback2); @@ -2540,6 +2540,7 @@ short gSightSpritesCount; // current count short gPhysSpritesList[]; // by NoOne: list of additional sprites which can be affected by physics short gPhysSpritesCount; // current count + short gQavPlayerIndex = -1; // by NoOne: index of sprite which currently activated to play qav void actInit(bool bSaveLoad) { @@ -2551,7 +2552,10 @@ void actInit(bool bSaveLoad) { gProxySpritesCount = gSightSpritesCount = gPhysSpritesCount = 0; // reset qav player index - gQavPlayerIndex = -1; + for (int i = 0; i < kMaxPlayers; i++) { + gQavScene[i].index = -1; + gQavScene[i].qavId = NULL; + } // fill arrays with negative values to avoid xvel 0 situation memset(gSightSpritesList, -1, sizeof(gSightSpritesList)); @@ -3217,7 +3221,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType, gPlayer[p].fraggerId = -1; } if (pSprite->type != kDudeCultistBeast) - trTriggerSprite(pSprite->index, pXSprite, kCmdOff); + trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nKillerSprite); pSprite->flags |= 7; if (VanillaMode()) { @@ -3733,7 +3737,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in break; } - trTriggerSprite(pSprite->index, pXSprite, kCmdOff); + trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nSource); switch (pSprite->type) { case kThingObjectGib: @@ -4351,8 +4355,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) break; } nHitSprite = pSpriteHit->florhit & 0x3fff; - switch (pSpriteHit->florhit&0xc000) - { + switch (pSpriteHit->florhit & 0xc000) { case 0x8000: break; case 0x4000: @@ -4487,7 +4490,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) if (nHSprite >= 0 && sprite[nHSprite].extra >= 0) { XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra]; if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite))) - trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch); + trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch, nSprite); } // Touch walls @@ -4779,13 +4782,13 @@ void MoveDude(spritetype *pSprite) // by NoOne: do not check state (so, things can work with touch too) and allow dudelockout if ((gModernMap) && (!pHitXSprite->DudeLockout || IsPlayerSprite(pSprite))) - trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch); + trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch, nSprite); else if (!pHitXSprite->state) // or check like vanilla do - trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch); + trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch, nSprite); } if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer) - trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush); + trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush, nSprite); break; } @@ -4804,7 +4807,7 @@ void MoveDude(spritetype *pSprite) XSECTOR *pHitXSector = NULL; if (pHitSector->extra > 0) pHitXSector = &xsector[pHitSector->extra]; - if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->at37_7 && !pHitXSector->state && !pHitXSector->busy && !pPlayer) + if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer) trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush); if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) { @@ -4830,13 +4833,13 @@ void MoveDude(spritetype *pSprite) pXSector = &xsector[nXSector]; else pXSector = NULL; - if (pXSector && pXSector->Exit && (pPlayer || !pXSector->at37_7)) + if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout)) trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit); ChangeSpriteSect(nSprite, nSector); nXSector = sector[nSector].extra; pXSector = (nXSector > 0) ? pXSector = &xsector[nXSector] : NULL; - if (pXSector && pXSector->Enter && (pPlayer || !pXSector->at37_7)) { + if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout)) { if (sector[nSector].type == kSectorTeleport) pXSector->data = pPlayer ? nSprite : -1; @@ -4934,9 +4937,9 @@ void MoveDude(spritetype *pSprite) if (pPlayer) { pPlayer->posture = 0; pPlayer->bubbleTime = 0; - if (!pPlayer->canJump && pPlayer->input.buttonFlags.jump) { + if (!pPlayer->cantJump && pPlayer->input.buttonFlags.jump) { zvel[nSprite] = -0x6aaaa; - pPlayer->canJump = 1; + pPlayer->cantJump = 1; } sfxPlay3DSound(pSprite, 721, -1, 0); } else { @@ -5607,7 +5610,7 @@ void actProcessSprites(void) 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, kCmdSpriteProximity); + trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, nAffected); break; } } @@ -5616,7 +5619,7 @@ void actProcessSprites(void) for (int a = connecthead; a >= 0; a = connectpoint2[a]) { if (gPlayer[a].pXSprite->health > 0 && CheckProximity(gPlayer[a].pSprite, x, y, z, sectnum, 96)) { - trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity); + trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, gPlayer[a].pSprite->index); break; } } @@ -5641,7 +5644,7 @@ void actProcessSprites(void) for (int a = connecthead; a >= 0; a = connectpoint2[a]) { spritetype* pPlaySprite = gPlayer[a].pSprite; if (gPlayer[a].pXSprite->health > 0 && cansee(x, y, z, sectnum, pPlaySprite->x, pPlaySprite->y, pPlaySprite->z, pPlaySprite->sectnum)) { - trTriggerSprite(index, pXSightSpr, kCmdSpriteSight); + trTriggerSprite(index, pXSightSpr, kCmdSpriteSight, pPlaySprite->index); break; } } @@ -5709,20 +5712,6 @@ void actProcessSprites(void) } } - - // process playing 3-rd side qavs for player(s) - if (gQavPlayerIndex > -1) { - if (sprite[gQavPlayerIndex].extra >= 0) { - XSPRITE* pXSprite = &xsprite[sprite[gQavPlayerIndex].extra]; PLAYER* pPlayer = getPlayerById(pXSprite->data1); - if (pPlayer->curWeapon != 0) pPlayer->curWeapon = 0; - if (((int)gFrameClock & pXSprite->busyTime) == 0) { - if (pXSprite->waitTime <= 0 || pXSprite->sysData1-- > 0) StartQAV(pPlayer, kFreeQAVEntry); - else evPost(gQavPlayerIndex, 3, 0, kCmdOff); - } - } else { - gQavPlayerIndex = -1; - } - } } for (nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite]) @@ -5803,7 +5792,7 @@ void actProcessSprites(void) break; } if (pSprite->owner == -1) actPropagateSpriteOwner(pSprite, pSprite2); - trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity); + trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); } } } @@ -5879,9 +5868,8 @@ void actProcessSprites(void) { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->Impact) - trTriggerSprite(nSprite, pXSprite, kCmdOff); - switch (pSprite->type) - { + trTriggerSprite(nSprite, pXSprite, kCmdOff, -1); + switch (pSprite->type) { case kThingDripWater: case kThingDripBlood: MakeSplash(pSprite, pXSprite); @@ -6168,7 +6156,7 @@ void actProcessSprites(void) pXIncarnation->triggerOff = false; // trigger dude death before transform - trTriggerSprite(nSprite, pXSprite, kCmdOff); + trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); pSprite->type = pIncarnation->type; @@ -6260,7 +6248,7 @@ void actProcessSprites(void) } else { // just trigger dude death - trTriggerSprite(nSprite, pXSprite, kCmdOff); + trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); } } @@ -6286,12 +6274,9 @@ void actProcessSprites(void) if (pSprite2->flags&32) continue; XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; - if ((unsigned int)pXSprite2->health > 0 && IsPlayerSprite(pSprite2)) - { + if ((unsigned int)pXSprite2->health > 0 && IsPlayerSprite(pSprite2)) { if (CheckProximity(pSprite2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128)) - { - trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity); - } + trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); } } } @@ -6989,7 +6974,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, { XSPRITE *pXSprite = &xsprite[nXSprite]; if (pXSprite->Vector) - trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact); + trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact, nShooter); } if (pSprite->statnum == kStatThing) { @@ -7899,8 +7884,9 @@ void debrisMove(int listIndex) { //actPostSprite(nSprite, kStatThing); // !!!! not working here for some reason changespritestat(nSprite, kStatThing); - if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff); - else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn); + + if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff, -1); + else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn, -1); } } diff --git a/source/blood/src/actor.h b/source/blood/src/actor.h index 5a71b7293..df20f107b 100644 --- a/source/blood/src/actor.h +++ b/source/blood/src/actor.h @@ -180,6 +180,7 @@ struct SPRITEMASS { int fraction; // mainly needs for moving debris }; + extern AMMOITEMDATA gAmmoItemData[]; extern WEAPONITEMDATA gWeaponItemData[]; extern ITEMDATA gItemData[]; @@ -287,6 +288,4 @@ extern short gPhysSpritesList[kMaxSuperXSprites]; extern short gProxySpritesCount; extern short gSightSpritesCount; extern short gPhysSpritesCount; -extern short gQavPlayerIndex; - -END_BLD_NS +//extern short gQavPlayerIndex; diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 9ae2af268..f71032c3e 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -596,6 +596,12 @@ void StartLevel(GAMEOPTIONS *gameOptions) break; } + // very quick fix for floor sprites with Touch trigger flag if their Z is equals sector floorz / ceilgz + if ((pSprite->cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) && pSprite->sectnum >= 0 && pSprite->extra >= 0 && xsprite[pSprite->extra].Touch) { + if (pSprite->z == sector[pSprite->sectnum].floorz) pSprite->z--; + else if (pSprite->z == sector[pSprite->sectnum].ceilingz) pSprite->z++; + } + } else { switch (pSprite->type) { diff --git a/source/blood/src/callback.cpp b/source/blood/src/callback.cpp index 6012f8eb1..723653b06 100644 --- a/source/blood/src/callback.cpp +++ b/source/blood/src/callback.cpp @@ -486,13 +486,13 @@ void returnFlagToBase(int nSprite) // 17 XSPRITE* pXOwner = &xsprite[pOwner->extra]; switch (pSprite->type) { case kItemFlagA: - trTriggerSprite(pOwner->index, pXOwner, kCmdOn); + trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); sndStartSample(8003, 255, 2, 0); gBlueFlagDropped = false; viewSetMessage("Blue Flag returned to base."); break; case kItemFlagB: - trTriggerSprite(pOwner->index, pXOwner, kCmdOn); + trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); sndStartSample(8002, 255, 2, 0); gRedFlagDropped = false; viewSetMessage("Red Flag returned to base."); diff --git a/source/blood/src/callback.h b/source/blood/src/callback.h index d007190a6..d01f95fd8 100644 --- a/source/blood/src/callback.h +++ b/source/blood/src/callback.h @@ -51,7 +51,7 @@ enum CALLBACK_ID { kCallbackDropVoodoo = 21, // unused kCallbackMissileBurst = 22, // by NoOne kCallbackMissileSpriteBlock = 23, // by NoOne - kCallbackMax = 24, + kCallbackMax, }; extern void (*gCallback[kCallbackMax])(int); diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index 6dc7fdd7f..1ae528b8a 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -189,7 +189,7 @@ enum { kModernEffectSpawner = 38, kModernWindGenerator = 39, kModernConcussSprite = 712, /// WIP - kModernPlayerControl = 713, /// WIP + kModernPlayerControl = 500, /// WIP // decorations kDecorationTorch = 30, diff --git a/source/blood/src/db.cpp b/source/blood/src/db.cpp index 51eaaee0b..7ba34751f 100644 --- a/source/blood/src/db.cpp +++ b/source/blood/src/db.cpp @@ -906,20 +906,20 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSector->busy = bitReader.readUnsigned(17); pXSector->data = bitReader.readUnsigned(16); pXSector->txID = bitReader.readUnsigned(10); - pXSector->at7_2 = bitReader.readUnsigned(3); - pXSector->at7_5 = bitReader.readUnsigned(3); + pXSector->busyWaveA = bitReader.readUnsigned(3); + pXSector->busyWaveB = bitReader.readUnsigned(3); pXSector->rxID = bitReader.readUnsigned(10); pXSector->command = bitReader.readUnsigned(8); pXSector->triggerOn = bitReader.readUnsigned(1); pXSector->triggerOff = bitReader.readUnsigned(1); pXSector->busyTimeA = bitReader.readUnsigned(12); pXSector->waitTimeA = bitReader.readUnsigned(12); - pXSector->atd_4 = bitReader.readUnsigned(1); + pXSector->restState = bitReader.readUnsigned(1); pXSector->interruptable = bitReader.readUnsigned(1); pXSector->amplitude = bitReader.readSigned(8); pXSector->freq = bitReader.readUnsigned(8); - pXSector->atf_6 = bitReader.readUnsigned(1); - pXSector->atf_7 = bitReader.readUnsigned(1); + pXSector->reTriggerA = bitReader.readUnsigned(1); + pXSector->reTriggerB = bitReader.readUnsigned(1); pXSector->phase = bitReader.readUnsigned(8); pXSector->wave = bitReader.readUnsigned(4); pXSector->shadeAlways = bitReader.readUnsigned(1); @@ -935,7 +935,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSector->Depth = bitReader.readUnsigned(3); pXSector->panVel = bitReader.readUnsigned(8); pXSector->panAngle = bitReader.readUnsigned(11); - pXSector->at16_3 = bitReader.readUnsigned(1); + pXSector->unused1 = bitReader.readUnsigned(1); pXSector->decoupled = bitReader.readUnsigned(1); pXSector->triggerOnce = bitReader.readUnsigned(1); pXSector->isTriggered = bitReader.readUnsigned(1); @@ -947,30 +947,30 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSector->Exit = bitReader.readUnsigned(1); pXSector->Wallpush = bitReader.readUnsigned(1); pXSector->color = bitReader.readUnsigned(1); - pXSector->at18_1 = bitReader.readUnsigned(1); + pXSector->unused2 = bitReader.readUnsigned(1); pXSector->busyTimeB = bitReader.readUnsigned(12); pXSector->waitTimeB = bitReader.readUnsigned(12); pXSector->stopOn = bitReader.readUnsigned(1); pXSector->stopOff = bitReader.readUnsigned(1); pXSector->ceilpal = bitReader.readUnsigned(4); - pXSector->at1c_0 = bitReader.readSigned(32); - pXSector->at20_0 = bitReader.readSigned(32); - pXSector->at24_0 = bitReader.readSigned(32); - pXSector->at28_0 = bitReader.readSigned(32); + pXSector->offCeilZ = bitReader.readSigned(32); + pXSector->onCeilZ = bitReader.readSigned(32); + pXSector->offFloorZ = bitReader.readSigned(32); + pXSector->onFloorZ = bitReader.readSigned(32); pXSector->marker0 = bitReader.readUnsigned(16); pXSector->marker1 = bitReader.readUnsigned(16); pXSector->Crush = bitReader.readUnsigned(1); - pXSector->at30_1 = bitReader.readUnsigned(8); - pXSector->at31_1 = bitReader.readUnsigned(8); - pXSector->at32_1 = bitReader.readUnsigned(8); + pXSector->ceilXPanFrac = bitReader.readUnsigned(8); + pXSector->ceilYPanFrac = bitReader.readUnsigned(8); + pXSector->floorXPanFrac = bitReader.readUnsigned(8); pXSector->damageType = bitReader.readUnsigned(3); pXSector->floorpal = bitReader.readUnsigned(4); - pXSector->at34_0 = bitReader.readUnsigned(8); + pXSector->floorYPanFrac = bitReader.readUnsigned(8); pXSector->locked = bitReader.readUnsigned(1); pXSector->windVel = bitReader.readUnsigned(10); pXSector->windAng = bitReader.readUnsigned(11); pXSector->windAlways = bitReader.readUnsigned(1); - pXSector->at37_7 = bitReader.readUnsigned(1); + pXSector->dudeLockout = bitReader.readUnsigned(1); pXSector->bobTheta = bitReader.readUnsigned(11); pXSector->bobZRange = bitReader.readUnsigned(5); pXSector->bobSpeed = bitReader.readSigned(12); @@ -1031,7 +1031,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXWall->busy = bitReader.readUnsigned(17); pXWall->data = bitReader.readSigned(16); pXWall->txID = bitReader.readUnsigned(10); - pXWall->at7_2 = bitReader.readUnsigned(6); + pXWall->unused1 = bitReader.readUnsigned(6); pXWall->rxID = bitReader.readUnsigned(10); pXWall->command = bitReader.readUnsigned(8); pXWall->triggerOn = bitReader.readUnsigned(1); @@ -1050,13 +1050,13 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXWall->triggerPush = bitReader.readUnsigned(1); pXWall->triggerVector = bitReader.readUnsigned(1); pXWall->triggerTouch = bitReader.readUnsigned(1); - pXWall->at11_0 = bitReader.readUnsigned(2); + pXWall->unused2 = bitReader.readUnsigned(2); pXWall->xpanFrac = bitReader.readUnsigned(8); pXWall->ypanFrac = bitReader.readUnsigned(8); pXWall->locked = bitReader.readUnsigned(1); pXWall->dudeLockout = bitReader.readUnsigned(1); - pXWall->at13_4 = bitReader.readUnsigned(4); - pXWall->at14_0 = bitReader.readUnsigned(32); + pXWall->unused3 = bitReader.readUnsigned(4); + pXWall->unused4 = bitReader.readUnsigned(32); xwall[wall[i].extra].reference = i; xwall[wall[i].extra].busy = xwall[wall[i].extra].state << 16; @@ -1130,9 +1130,9 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSprite->waitTime = bitReader.readUnsigned(12); pXSprite->restState = bitReader.readUnsigned(1); pXSprite->Interrutable = bitReader.readUnsigned(1); - pXSprite->atb_2 = bitReader.readUnsigned(2); + pXSprite->unused1 = bitReader.readUnsigned(2); pXSprite->respawnPending = bitReader.readUnsigned(2); - pXSprite->atb_6 = bitReader.readUnsigned(1); + pXSprite->unused2 = bitReader.readUnsigned(1); pXSprite->lT = bitReader.readUnsigned(1); pXSprite->dropMsg = bitReader.readUnsigned(8); pXSprite->Decoupled = bitReader.readUnsigned(1); @@ -1146,7 +1146,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSprite->Touch = bitReader.readUnsigned(1); pXSprite->Sight = bitReader.readUnsigned(1); pXSprite->Proximity = bitReader.readUnsigned(1); - pXSprite->ate_5 = bitReader.readUnsigned(2); + pXSprite->unused3 = bitReader.readUnsigned(2); pXSprite->lSkill = bitReader.readUnsigned(5); pXSprite->lS = bitReader.readUnsigned(1); pXSprite->lB = bitReader.readUnsigned(1); @@ -1161,7 +1161,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSprite->medium = bitReader.readUnsigned(2); pXSprite->respawn = bitReader.readUnsigned(2); pXSprite->data4 = bitReader.readUnsigned(16); - pXSprite->at1a_2 = bitReader.readUnsigned(6); + pXSprite->unused4 = bitReader.readUnsigned(6); pXSprite->lockMsg = bitReader.readUnsigned(8); pXSprite->health = bitReader.readUnsigned(12); pXSprite->dudeDeaf = bitReader.readUnsigned(1); @@ -1252,15 +1252,15 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short pXSector->busyTimeB = pXSector->busyTimeA; if (pXSector->busyTimeA > 0) { - if (!pXSector->atd_4) + if (!pXSector->restState) { - pXSector->atf_6 = 1; + pXSector->reTriggerA = 1; } else { pXSector->waitTimeB = pXSector->busyTimeA; pXSector->waitTimeA = 0; - pXSector->atf_7 = 1; + pXSector->reTriggerB = 1; } } } @@ -1425,20 +1425,20 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSector->busy, 17); bitWriter.write(pXSector->data, 16); bitWriter.write(pXSector->txID, 10); - bitWriter.write(pXSector->at7_2, 3); - bitWriter.write(pXSector->at7_5, 3); + bitWriter.write(pXSector->busyWaveA, 3); + bitWriter.write(pXSector->busyWaveB, 3); bitWriter.write(pXSector->rxID, 10); bitWriter.write(pXSector->command, 8); bitWriter.write(pXSector->triggerOn, 1); bitWriter.write(pXSector->triggerOff, 1); bitWriter.write(pXSector->busyTimeA, 12); bitWriter.write(pXSector->waitTimeA, 12); - bitWriter.write(pXSector->atd_4, 1); + bitWriter.write(pXSector->restState, 1); bitWriter.write(pXSector->interruptable, 1); bitWriter.write(pXSector->amplitude, 8); bitWriter.write(pXSector->freq, 8); - bitWriter.write(pXSector->atf_6, 1); - bitWriter.write(pXSector->atf_7, 1); + bitWriter.write(pXSector->reTriggerA, 1); + bitWriter.write(pXSector->reTriggerB, 1); bitWriter.write(pXSector->phase, 8); bitWriter.write(pXSector->wave, 4); bitWriter.write(pXSector->shadeAlways, 1); @@ -1454,7 +1454,7 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSector->Depth, 3); bitWriter.write(pXSector->panVel, 8); bitWriter.write(pXSector->panAngle, 11); - bitWriter.write(pXSector->at16_3, 1); + bitWriter.write(pXSector->unused1, 1); bitWriter.write(pXSector->decoupled, 1); bitWriter.write(pXSector->triggerOnce, 1); bitWriter.write(pXSector->isTriggered, 1); @@ -1466,30 +1466,30 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSector->Exit, 1); bitWriter.write(pXSector->Wallpush, 1); bitWriter.write(pXSector->color, 1); - bitWriter.write(pXSector->at18_1, 1); + bitWriter.write(pXSector->unused2, 1); bitWriter.write(pXSector->busyTimeB, 12); bitWriter.write(pXSector->waitTimeB, 12); bitWriter.write(pXSector->stopOn, 1); bitWriter.write(pXSector->stopOff, 1); bitWriter.write(pXSector->ceilpal, 4); - bitWriter.write(pXSector->at1c_0, 32); - bitWriter.write(pXSector->at20_0, 32); - bitWriter.write(pXSector->at24_0, 32); - bitWriter.write(pXSector->at28_0, 32); + bitWriter.write(pXSector->offCeilZ, 32); + bitWriter.write(pXSector->onCeilZ, 32); + bitWriter.write(pXSector->offFloorZ, 32); + bitWriter.write(pXSector->onFloorZ, 32); bitWriter.write(pXSector->marker0, 16); bitWriter.write(pXSector->marker1, 16); bitWriter.write(pXSector->Crush, 1); - bitWriter.write(pXSector->at30_1, 8); - bitWriter.write(pXSector->at31_1, 8); - bitWriter.write(pXSector->at32_1, 8); + bitWriter.write(pXSector->ceilXPanFrac, 8); + bitWriter.write(pXSector->ceilYPanFrac, 8); + bitWriter.write(pXSector->floorXPanFrac, 8); bitWriter.write(pXSector->damageType, 3); bitWriter.write(pXSector->floorpal, 4); - bitWriter.write(pXSector->at34_0, 8); + bitWriter.write(pXSector->floorYPanFrac, 8); bitWriter.write(pXSector->locked, 1); bitWriter.write(pXSector->windVel, 10); bitWriter.write(pXSector->windAng, 11); bitWriter.write(pXSector->windAlways, 1); - bitWriter.write(pXSector->at37_7, 1); + bitWriter.write(pXSector->dudeLockout, 1); bitWriter.write(pXSector->bobTheta, 11); bitWriter.write(pXSector->bobZRange, 5); bitWriter.write(pXSector->bobSpeed, 12); @@ -1521,7 +1521,7 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXWall->busy, 17); bitWriter.write(pXWall->data, 16); bitWriter.write(pXWall->txID, 10); - bitWriter.write(pXWall->at7_2, 6); + bitWriter.write(pXWall->unused1, 6); bitWriter.write(pXWall->rxID, 10); bitWriter.write(pXWall->command, 8); bitWriter.write(pXWall->triggerOn, 1); @@ -1540,13 +1540,13 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXWall->triggerPush, 1); bitWriter.write(pXWall->triggerVector, 1); bitWriter.write(pXWall->triggerTouch, 1); - bitWriter.write(pXWall->at11_0, 2); + bitWriter.write(pXWall->unused2, 2); bitWriter.write(pXWall->xpanFrac, 8); bitWriter.write(pXWall->ypanFrac, 8); bitWriter.write(pXWall->locked, 1); bitWriter.write(pXWall->dudeLockout, 1); - bitWriter.write(pXWall->at13_4, 4); - bitWriter.write(pXWall->at14_0, 32); + bitWriter.write(pXWall->unused3, 4); + bitWriter.write(pXWall->unused4, 32); IOBuffer1.Write(pBuffer, nXWallSize); } } @@ -1581,9 +1581,9 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSprite->waitTime, 12); bitWriter.write(pXSprite->restState, 1); bitWriter.write(pXSprite->Interrutable, 1); - bitWriter.write(pXSprite->atb_2, 2); + bitWriter.write(pXSprite->unused1, 2); bitWriter.write(pXSprite->respawnPending, 2); - bitWriter.write(pXSprite->atb_6, 1); + bitWriter.write(pXSprite->unused2, 1); bitWriter.write(pXSprite->lT, 1); bitWriter.write(pXSprite->dropMsg, 8); bitWriter.write(pXSprite->Decoupled, 1); @@ -1597,7 +1597,7 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSprite->Touch, 1); bitWriter.write(pXSprite->Sight, 1); bitWriter.write(pXSprite->Proximity, 1); - bitWriter.write(pXSprite->ate_5, 2); + bitWriter.write(pXSprite->unused3, 2); bitWriter.write(pXSprite->lSkill, 5); bitWriter.write(pXSprite->lS, 1); bitWriter.write(pXSprite->lB, 1); @@ -1612,7 +1612,7 @@ int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSe bitWriter.write(pXSprite->medium, 2); bitWriter.write(pXSprite->respawn, 2); bitWriter.write(pXSprite->data4, 16); - bitWriter.write(pXSprite->at1a_2, 6); + bitWriter.write(pXSprite->unused4, 6); bitWriter.write(pXSprite->lockMsg, 8); bitWriter.write(pXSprite->health, 12); bitWriter.write(pXSprite->dudeDeaf, 1); diff --git a/source/blood/src/db.h b/source/blood/src/db.h index 32f2ff398..23f15f426 100644 --- a/source/blood/src/db.h +++ b/source/blood/src/db.h @@ -38,191 +38,190 @@ extern bool gModernMap; struct AISTATE; struct XSPRITE { - //int isActive; - unsigned int atb_2 : 2; // unused // - unsigned int atb_6 : 1; // unused // let's use these to add more data - unsigned int ate_5 : 2; // unused // fields in the future? must be signed also - unsigned int at1a_2 : 6; // unused // + unsigned int unused1 : 2; // unused + unsigned int unused2 : 1; // unused + unsigned int unused3 : 2; // unused + unsigned int unused4 : 6; // unused - signed int reference : 15; // at0_0 - unsigned int state : 1; // State 0 + signed int reference : 15; + unsigned int state : 1; // State 0 unsigned int busy : 17; - unsigned int txID : 10; // TX ID - unsigned int rxID : 10; // RX ID - unsigned int command : 8; // Cmd - unsigned int triggerOn : 1; // going ON - unsigned int triggerOff : 1; // going OFF - unsigned int busyTime : 12; // busyTime - unsigned int waitTime : 12; // waitTime - unsigned int restState : 1; // restState - unsigned int Interrutable : 1; // Interruptable + unsigned int txID : 10; // TX ID + unsigned int rxID : 10; // RX ID + unsigned int command : 8; // Cmd + unsigned int triggerOn : 1; // going ON + unsigned int triggerOff : 1; // going OFF + unsigned int busyTime : 12; // busyTime + unsigned int waitTime : 12; // waitTime + unsigned int restState : 1; // restState + unsigned int Interrutable : 1; // Interruptable - unsigned int respawnPending : 2; // respawnPending + unsigned int respawnPending : 2; // respawnPending - signed int dropMsg : 8; // Drop Item - unsigned int Decoupled : 1; // Decoupled - unsigned int triggerOnce : 1; // 1-shot - unsigned int isTriggered : 1; // works in case if triggerOnce selected + signed int dropMsg : 8; // Drop Item + unsigned int Decoupled : 1; // Decoupled + unsigned int triggerOnce : 1; // 1-shot + unsigned int isTriggered : 1; // works in case if triggerOnce selected - unsigned int key : 3; // Key - unsigned int wave : 2; // Wave - unsigned int Push : 1; // Push - unsigned int Vector : 1; // Vector - unsigned int Impact : 1; // Impact - unsigned int Pickup : 1; // Pickup - unsigned int Touch : 1; // Touch - unsigned int Sight : 1; // Sight - unsigned int Proximity : 1; // Proximity - unsigned int lSkill : 5; // Launch 12345 - unsigned int lS : 1; // Single - unsigned int lB : 1; // Bloodbath - unsigned int lT : 1; // Launch Team - unsigned int lC : 1; // Coop - unsigned int DudeLockout : 1; // DudeLockout - signed int data1 : 16; // Data 1 - signed int data2 : 16; // Data 2 - signed int data3 : 16; // Data 3 - unsigned int data4 : 16; // Data 4 - unsigned int locked : 1; // Locked - unsigned int medium : 2; // medium - unsigned int respawn : 2; // Respawn option - unsigned int lockMsg : 8; // Lock msg - unsigned int health : 20; // 1c_0 - unsigned int dudeDeaf : 1; // dudeDeaf - unsigned int dudeAmbush : 1; // dudeAmbush - unsigned int dudeGuard : 1; // dudeGuard - unsigned int dudeFlag4 : 1; // DF reserved - signed int target : 16; // target sprite - signed int targetX : 32; // target x - signed int targetY : 32; // target y - signed int targetZ : 32; // target z - unsigned int goalAng : 11; // Dude goal ang - signed int dodgeDir : 2; // Dude dodge direction + unsigned int key : 3; // Key + unsigned int wave : 2; // Wave + unsigned int Push : 1; // Push + unsigned int Vector : 1; // Vector + unsigned int Impact : 1; // Impact + unsigned int Pickup : 1; // Pickup + unsigned int Touch : 1; // Touch + unsigned int Sight : 1; // Sight + unsigned int Proximity : 1; // Proximity + unsigned int lSkill : 5; // Launch 12345 + unsigned int lS : 1; // Single + unsigned int lB : 1; // Bloodbath + unsigned int lT : 1; // Launch Team + unsigned int lC : 1; // Coop + unsigned int DudeLockout : 1; // DudeLockout + signed int data1 : 16; // Data 1 + signed int data2 : 16; // Data 2 + signed int data3 : 16; // Data 3 + unsigned int data4 : 16; // Data 4 + unsigned int locked : 1; // Locked + unsigned int medium : 2; // medium + unsigned int respawn : 2; // Respawn option + unsigned int lockMsg : 8; // Lock msg + unsigned int health : 20; + unsigned int dudeDeaf : 1; // dudeDeaf + unsigned int dudeAmbush : 1; // dudeAmbush + unsigned int dudeGuard : 1; // dudeGuard + unsigned int dudeFlag4 : 1; // unused + signed int target : 16; // target sprite + signed int targetX : 32; // target x + signed int targetY : 32; // target y + signed int targetZ : 32; // target z + unsigned int goalAng : 11; // Dude goal ang + signed int dodgeDir : 2; // Dude dodge direction unsigned int burnTime : 16; signed int burnSource : 16; unsigned int height : 16; - unsigned int stateTimer : 16; // ai timer - AISTATE* aiState; // ai - signed int sysData1 : 16; // used to keep here various system data, so user can't change it in map editor - unsigned int physAttr : 12; // currently used by additional physics sprites to keep it's attributes. - signed int scale; // used for scaling SEQ size on sprites + unsigned int stateTimer : 16; // ai timer + AISTATE* aiState; // ai + signed int sysData1 : 16; // used to keep here various system data, so user can't change it in map editor + unsigned int physAttr : 12; // currently used by additional physics sprites to keep it's attributes. + signed int scale; // used for scaling SEQ size on sprites }; struct XSECTOR { signed int reference : 14; - unsigned int state : 1; // State + unsigned int state : 1; // State unsigned int busy : 17; - unsigned int data : 16; // Data - unsigned int txID : 10; // TX ID - unsigned int rxID : 10; // RX ID - unsigned int at7_2 : 3; // OFF->ON wave - unsigned int at7_5 : 3; // ON->OFF wave + unsigned int data : 16; // Data + unsigned int txID : 10; // TX ID + unsigned int rxID : 10; // RX ID + unsigned int busyWaveA : 3; // OFF->ON wave + unsigned int busyWaveB : 3; // ON->OFF wave - unsigned int command : 8; // Cmd - unsigned int triggerOn : 1; // Send at ON - unsigned int triggerOff : 1; // Send at OFF - unsigned int busyTimeA : 12; // OFF->ON busyTime - unsigned int waitTimeA : 12; // OFF->ON waitTime - unsigned int atd_4 : 1; - unsigned int interruptable : 1; // Interruptable + unsigned int command : 8; // Cmd + unsigned int triggerOn : 1; // Send at ON + unsigned int triggerOff : 1; // Send at OFF + unsigned int busyTimeA : 12; // OFF->ON busyTime + unsigned int waitTimeA : 12; // OFF->ON waitTime + unsigned int restState : 1; + unsigned int interruptable : 1; // Interruptable - unsigned int atf_6 : 1; // OFF->ON wait - unsigned int atf_7 : 1; // ON->OFF wait - signed int amplitude : 8; // Lighting amplitude - unsigned int freq : 8; // Lighting freq - unsigned int phase : 8; // Lighting phase - unsigned int wave : 4; // Lighting wave - unsigned int shadeAlways : 1; // Lighting shadeAlways - unsigned int shadeFloor : 1; // Lighting floor - unsigned int shadeCeiling : 1; // Lighting ceiling - unsigned int shadeWalls : 1; // Lighting walls - signed int shade : 8; // Lighting value - unsigned int panAlways : 1; // Pan always - unsigned int panFloor : 1; // Pan floor - unsigned int panCeiling : 1; // Pan ceiling - unsigned int Drag : 1; // Pan drag - unsigned int panVel : 8; // Motion speed - unsigned int panAngle : 11; // Motion angle - unsigned int Underwater : 1; // Underwater - unsigned int Depth : 3; // Depth - unsigned int at16_3 : 1; - unsigned int decoupled : 1; // Decoupled - unsigned int triggerOnce : 1; // 1-shot + unsigned int reTriggerA : 1; // OFF->ON wait + unsigned int reTriggerB : 1; // ON->OFF wait + signed int amplitude : 8; // Lighting amplitude + unsigned int freq : 8; // Lighting freq + unsigned int phase : 8; // Lighting phase + unsigned int wave : 4; // Lighting wave + unsigned int shadeAlways : 1; // Lighting shadeAlways + unsigned int shadeFloor : 1; // Lighting floor + unsigned int shadeCeiling : 1; // Lighting ceiling + unsigned int shadeWalls : 1; // Lighting walls + signed int shade : 8; // Lighting value + unsigned int panAlways : 1; // Pan always + unsigned int panFloor : 1; // Pan floor + unsigned int panCeiling : 1; // Pan ceiling + unsigned int Drag : 1; // Pan drag + unsigned int panVel : 8; // Motion speed + unsigned int panAngle : 11; // Motion angle + unsigned int Underwater : 1; // Underwater + unsigned int Depth : 3; // Depth + unsigned int unused1 : 1; + unsigned int decoupled : 1; // Decoupled + unsigned int triggerOnce : 1; // 1-shot unsigned int isTriggered : 1; - unsigned int Key : 3; // Key - unsigned int Push : 1; // Push - unsigned int Vector : 1; // Vector - unsigned int Reserved : 1; // Reserved - unsigned int Enter : 1; // Enter - unsigned int Exit : 1; // Exit - unsigned int Wallpush : 1; // WallPush - unsigned int color : 1; // Color Lights - unsigned int at18_1 : 1; - unsigned int busyTimeB : 12; // ON->OFF busyTime - unsigned int waitTimeB : 12; // ON->OFF waitTime + unsigned int Key : 3; // Key + unsigned int Push : 1; // Push + unsigned int Vector : 1; // Vector + unsigned int Reserved : 1; // Reserved + unsigned int Enter : 1; // Enter + unsigned int Exit : 1; // Exit + unsigned int Wallpush : 1; // WallPush + unsigned int color : 1; // Color Lights + unsigned int unused2 : 1; + unsigned int busyTimeB : 12; // ON->OFF busyTime + unsigned int waitTimeB : 12; // ON->OFF waitTime unsigned int stopOn : 1; unsigned int stopOff : 1; - unsigned int ceilpal : 4; // Ceil pal2 - signed int at1c_0 : 32; - signed int at20_0 : 32; - signed int at24_0 : 32; - signed int at28_0 : 32; + unsigned int ceilpal : 4; // Ceil pal2 + signed int offCeilZ : 32; + signed int onCeilZ : 32; + signed int offFloorZ : 32; + signed int onFloorZ : 32; unsigned int marker0 : 16; unsigned int marker1 : 16; - unsigned int Crush : 1; // Crush - unsigned int at30_1 : 8; // Ceiling x panning frac - unsigned int at31_1 : 8; // Ceiling y panning frac - unsigned int at32_1 : 8; // Floor x panning frac - unsigned int damageType : 3; // DamageType - unsigned int floorpal : 4; // Floor pal2 - unsigned int at34_0 : 8; // Floor y panning frac - unsigned int locked : 1; // Locked - unsigned int windVel; // Wind vel (by NoOne: changed from 10 bit to use higher velocity values) - unsigned int windAng : 11; // Wind ang - unsigned int windAlways : 1; // Wind always - unsigned int at37_7 : 1; - unsigned int bobTheta : 11; // Motion Theta - unsigned int bobZRange : 5; // Motion Z range - signed int bobSpeed : 12; // Motion speed - unsigned int bobAlways : 1; // Motion always - unsigned int bobFloor : 1; // Motion bob floor - unsigned int bobCeiling : 1; // Motion bob ceiling - unsigned int bobRotate : 1; // Motion rotate -}; // 60(0x3c) bytes + unsigned int Crush : 1; // Crush + unsigned int ceilXPanFrac : 8; // Ceiling x panning frac + unsigned int ceilYPanFrac : 8; // Ceiling y panning frac + unsigned int floorXPanFrac : 8; // Floor x panning frac + unsigned int damageType : 3; // DamageType + unsigned int floorpal : 4; // Floor pal2 + unsigned int floorYPanFrac : 8; // Floor y panning frac + unsigned int locked : 1; // Locked + unsigned int windVel : 32; // Wind vel (by NoOne: changed from 10 bit to use higher velocity values) + unsigned int windAng : 11; // Wind ang + unsigned int windAlways : 1; // Wind always + unsigned int dudeLockout : 1; + unsigned int bobTheta : 11; // Motion Theta + unsigned int bobZRange : 5; // Motion Z range + signed int bobSpeed : 12; // Motion speed + unsigned int bobAlways : 1; // Motion always + unsigned int bobFloor : 1; // Motion bob floor + unsigned int bobCeiling : 1; // Motion bob ceiling + unsigned int bobRotate : 1; // Motion rotate +}; struct XWALL { signed int reference : 15; - unsigned int state : 1; // State + unsigned int state : 1; // State unsigned int busy : 17; - signed int data : 16; // Data - unsigned int txID : 10; // TX ID - unsigned int at7_2 : 6; // unused - unsigned int rxID : 10; // RX ID - unsigned int command : 8; // Cmd - unsigned int triggerOn : 1; // going ON - unsigned int triggerOff : 1; // going OFF - unsigned int busyTime : 12; // busyTime - unsigned int waitTime : 12; // waitTime - unsigned int restState : 1; // restState - unsigned int interruptable : 1; // Interruptable - unsigned int panAlways : 1; // panAlways - signed int panXVel : 8; // panX - signed int panYVel : 8; // panY - unsigned int decoupled : 1; // Decoupled - unsigned int triggerOnce : 1; // 1-shot + signed int data : 16; // Data + unsigned int txID : 10; // TX ID + unsigned int unused1 : 6; // unused + unsigned int rxID : 10; // RX ID + unsigned int command : 8; // Cmd + unsigned int triggerOn : 1; // going ON + unsigned int triggerOff : 1; // going OFF + unsigned int busyTime : 12; // busyTime + unsigned int waitTime : 12; // waitTime + unsigned int restState : 1; // restState + unsigned int interruptable : 1; // Interruptable + unsigned int panAlways : 1; // panAlways + signed int panXVel : 8; // panX + signed int panYVel : 8; // panY + unsigned int decoupled : 1; // Decoupled + unsigned int triggerOnce : 1; // 1-shot unsigned int isTriggered : 1; - unsigned int key : 3; // Key - unsigned int triggerPush : 1; // Push - unsigned int triggerVector : 1; // Vector - unsigned int triggerTouch : 1; // by NoOne: renamed from Reserved to Touch as it works with Touch now. - unsigned int at11_0 : 2; // unused - unsigned int xpanFrac : 8; // x panning frac - unsigned int ypanFrac : 8; // y panning frac - unsigned int locked : 1; // Locked - unsigned int dudeLockout : 1; // DudeLockout - unsigned int at13_4 : 4; // unused; - unsigned int at14_0 : 32; // unused -}; // 24(0x18) bytes + unsigned int key : 3; // Key + unsigned int triggerPush : 1; // Push + unsigned int triggerVector : 1; // Vector + unsigned int triggerTouch : 1; // by NoOne: renamed from Reserved to Touch as it works with Touch now. + unsigned int unused2 : 2; // unused + unsigned int xpanFrac : 8; // x panning frac + unsigned int ypanFrac : 8; // y panning frac + unsigned int locked : 1; // Locked + unsigned int dudeLockout : 1; // DudeLockout + unsigned int unused3 : 4; // unused; + unsigned int unused4 : 32; // unused +}; struct MAPSIGNATURE { char signature[4]; diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index ccb7e0ed6..a97e1b8ba 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -72,13 +72,7 @@ void EventQueue::Kill(int a1, int a2, CALLBACK_ID a3) PQueue->Kill([=](EVENT nItem)->bool {return !memcmp(&nItem, &evn, sizeof(EVENT)); }); } -//struct RXBUCKET -//{ -// unsigned int at0_0 : 13; -// unsigned int at1_5 : 3; -//}; - -RXBUCKET rxBucket[kMaxChannels+1]; +RXBUCKET rxBucket[kChannelMax+1]; int GetBucketChannel(const RXBUCKET *pRX) { @@ -280,7 +274,7 @@ void evInit(void) ThrowError("Invalid xsector reference in sector %d", i); if (nXSector > 0 && xsector[nXSector].rxID > 0) { - dassert(nCount < kMaxChannels); + dassert(nCount < kChannelMax); rxBucket[nCount].type = 6; rxBucket[nCount].index = i; nCount++; @@ -293,7 +287,7 @@ void evInit(void) ThrowError("Invalid xwall reference in wall %d", i); if (nXWall > 0 && xwall[nXWall].rxID > 0) { - dassert(nCount < kMaxChannels); + dassert(nCount < kChannelMax); rxBucket[nCount].type = 0; rxBucket[nCount].index = i; nCount++; @@ -308,7 +302,7 @@ void evInit(void) ThrowError("Invalid xsprite reference in sprite %d", i); if (nXSprite > 0 && xsprite[nXSprite].rxID > 0) { - dassert(nCount < kMaxChannels); + dassert(nCount < kChannelMax); rxBucket[nCount].type = 3; rxBucket[nCount].index = i; nCount++; @@ -352,9 +346,9 @@ char evGetSourceState(int nType, int nIndex) return 0; } -void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) +void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) { - EVENT event; event.index = nIndex; event.type = nType; event.cmd = command; + EVENT event; event.index = nIndex; event.type = nType; event.cmd = command; event.causedBy = causedBy; switch (command) { case kCmdState: @@ -460,28 +454,25 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command) } } -void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command) -{ +void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy) { dassert(command != kCmdCallback); - if (command == kCmdState) - command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; - else if (command == kCmdNotState) - command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn; + if (command == kCmdState) command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; + else if (command == kCmdNotState) command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn; EVENT evn = {}; evn.index = nIndex; evn.type = nType; evn.cmd = command; - // Inlined? + evn.causedBy = causedBy; eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } -void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID a4) -{ +void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy) { EVENT evn = {}; evn.index = nIndex; evn.type = nType; evn.cmd = kCmdCallback; - evn.funcID = a4; + evn.funcID = callback; + evn.causedBy = causedBy; eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } diff --git a/source/blood/src/eventq.h b/source/blood/src/eventq.h index bb649668d..6c87c3927 100644 --- a/source/blood/src/eventq.h +++ b/source/blood/src/eventq.h @@ -34,7 +34,7 @@ enum { kChannelLevelExitNormal, kChannelLevelExitSecret, kChannelModernEndLevelCustom, // // custom level end - kChannelLevelStartSinglePlayer, + kChannelLevelStart, kChannelLevelStartMatch, // DM and TEAMS kChannelLevelStartCoop, kChannelLevelStartTeamsOnly, @@ -51,10 +51,10 @@ enum { kChannelRemoteBomb5, kChannelRemoteBomb6, kChannelRemoteBomb7, + kChannelUser = 100, + kChannelMax = 4096, }; -#define kMaxChannels 4096 - struct RXBUCKET { unsigned int index : 13; @@ -105,17 +105,18 @@ enum COMMAND_ID { }; struct EVENT { - unsigned int index : 14; // index - unsigned int type : 3; // type - unsigned int cmd : 8; // cmd - unsigned int funcID : 8; // callback + unsigned int index: 14; // index + unsigned int type: 3; // type + unsigned int cmd: 8; // cmd + unsigned int funcID: 8; // callback + signed int causedBy: 14; // by NoOne: spritenum of object which initiated this event (-1 == initiated by the game) }; void evInit(void); char evGetSourceState(int nType, int nIndex); -void evSend(int nIndex, int nType, int rxId, COMMAND_ID command); -void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command); -void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID a4); +void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy = -1); +void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy = -1); +void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy = -1); void evProcess(unsigned int nTime); void evKill(int a1, int a2); void evKill(int a1, int a2, CALLBACK_ID a3); diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 9f1cdaddb..aa895dbe3 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -104,13 +104,13 @@ void SetAmmo(bool stat) if (stat) { for (int i = 0; i < 12; i++) - gMe->ammCount[i] = gAmmoInfo[i].max; + gMe->ammoCount[i] = gAmmoInfo[i].max; viewSetMessage("You have full ammo."); } else { for (int i = 0; i < 12; i++) - gMe->ammCount[i] = 0; + gMe->ammoCount[i] = 0; viewSetMessage("You have no ammo."); } } diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 805b46911..f870260a3 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -435,6 +435,29 @@ DAMAGEINFO damageInfo[7] = { { 0, 0, 0, 0, 0, 0, 0 } }; + +QAVSCENE gQavScene[kMaxPlayers]; + +void playQavScene(PLAYER* pPlayer) { + dassert(pPlayer != NULL); + if (pPlayer->weaponQav == -1) + return; + QAV * pQAV = gQavScene[pPlayer->nPlayer].qavId; + pQAV->nSprite = pPlayer->pSprite->index; + int nTicks = pQAV->at10 - pPlayer->weaponTimer; + pQAV->Play(nTicks - 4, nTicks, pPlayer->qavCallback, pPlayer); +} + +void startQavScene(PLAYER * pPlayer, int qavId, int a3, char a4) { + pPlayer->weaponQav = qavId; + pPlayer->weaponTimer = gQavScene[pPlayer->nPlayer].qavId->at10; + pPlayer->qavCallback = a3; + pPlayer->qavLoop = a4; + gQavScene[pPlayer->nPlayer].qavId->Preload(); + playQavScene(pPlayer); + pPlayer->weaponTimer -= 4; +} + int powerupCheck(PLAYER *pPlayer, int nPowerUp) { dassert(pPlayer != NULL); @@ -1037,9 +1060,9 @@ void playerReset(PLAYER *pPlayer) for (int i = 0; i < 12; i++) { if (gInfiniteAmmo) - pPlayer->ammCount[i] = gAmmoInfo[i].max; + pPlayer->ammoCount[i] = gAmmoInfo[i].max; else - pPlayer->ammCount[i] = 0; + pPlayer->ammoCount[i] = 0; } for (int i = 0; i < 3; i++) pPlayer->armor[i] = 0; @@ -1126,7 +1149,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) { pPlayer->hasFlag |= 1; pPlayer->used2[0] = pItem->index; - trTriggerSprite(pItem->index, pXItem, kCmdOff); + trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); sprintf(buffer, "%s stole Blue Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8007, 255, 2, 0); viewSetMessage(buffer); @@ -1138,7 +1161,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) { pPlayer->hasFlag &= ~1; pPlayer->used2[0] = -1; - trTriggerSprite(pItem->index, pXItem, kCmdOn); + trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); sprintf(buffer, "%s returned Blue Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8003, 255, 2, 0); viewSetMessage(buffer); @@ -1170,7 +1193,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) { pPlayer->hasFlag |= 2; pPlayer->used2[1] = pItem->index; - trTriggerSprite(pItem->index, pXItem, kCmdOff); + trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); sprintf(buffer, "%s stole Red Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8006, 255, 2, 0); viewSetMessage(buffer); @@ -1182,7 +1205,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) { { pPlayer->hasFlag &= ~2; pPlayer->used2[1] = -1; - trTriggerSprite(pItem->index, pXItem, kCmdOn); + trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); sprintf(buffer, "%s returned Red Flag", gProfile[pPlayer->nPlayer].name); sndStartSample(8002, 255, 2, 0); viewSetMessage(buffer); @@ -1293,12 +1316,12 @@ char PickupAmmo(PLAYER* pPlayer, spritetype* pAmmo) { AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[pAmmo->type - kItemAmmoBase]; int nAmmoType = pAmmoItemData->type; - if (pPlayer->ammCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; + if (pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; else if (!gModernMap || pAmmo->extra < 0 || xsprite[pAmmo->extra].data1 <= 0) - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType]+pAmmoItemData->count, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType]+pAmmoItemData->count, gAmmoInfo[nAmmoType].max); // by NoOne: allow custom amount for item else - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType] + xsprite[pAmmo->extra].data1, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + xsprite[pAmmo->extra].data1, gAmmoInfo[nAmmoType].max); if (pAmmoItemData->weaponType) pPlayer->hasWeapon[pAmmoItemData->weaponType] = 1; sfxPlay3DSound(pPlayer->pSprite, 782, -1, 0); @@ -1316,9 +1339,9 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) { if (nAmmoType == -1) return 0; // By NoOne: allow to set custom ammo count for weapon pickups if (!gModernMap || pWeapon->extra < 0 || xsprite[pWeapon->extra].data1 <= 0) - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType] + pWeaponItemData->count, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + pWeaponItemData->count, gAmmoInfo[nAmmoType].max); else - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max); int nNewWeapon = WeaponUpgrade(pPlayer, nWeaponType); if (nNewWeapon != pPlayer->curWeapon) { @@ -1329,11 +1352,11 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) { return 1; } - if (!actGetRespawnTime(pWeapon) || nAmmoType == -1 || pPlayer->ammCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; + if (!actGetRespawnTime(pWeapon) || nAmmoType == -1 || pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; else if (!gModernMap || pWeapon->extra < 0 || xsprite[pWeapon->extra].data1 <= 0) - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType]+pWeaponItemData->count, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType]+pWeaponItemData->count, gAmmoInfo[nAmmoType].max); else - pPlayer->ammCount[nAmmoType] = ClipHigh(pPlayer->ammCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max); + pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max); sfxPlay3DSound(pPlayer->pSprite, 777, -1, 0); return 1; @@ -1369,7 +1392,7 @@ void PickUp(PLAYER *pPlayer, spritetype *pSprite) else if (pSprite->extra > 0) { XSPRITE *pXSprite = &xsprite[pSprite->extra]; if (pXSprite->Pickup) - trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup); + trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup, pPlayer->nSprite); } if (!actCheckRespawn(pSprite)) @@ -1464,7 +1487,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3) zvel[*a2] += mulscale16(z, t2); } if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered) - trTriggerSprite(*a2, pXSprite, kCmdSpritePush); + trTriggerSprite(*a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); } break; case 0: @@ -1627,7 +1650,7 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff; pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang); if (!pInput->buttonFlags.jump) - pPlayer->canJump = 0; + pPlayer->cantJump = 0; switch (pPlayer->posture) { @@ -1642,7 +1665,7 @@ void ProcessInput(PLAYER *pPlayer) pPlayer->posture = 0; break; default: - if (!pPlayer->canJump && pInput->buttonFlags.jump && pXSprite->height == 0) + if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) { sfxPlay3DSound(pSprite, 700, 0, 0); if (packItemActive(pPlayer, 4)) @@ -1654,7 +1677,7 @@ void ProcessInput(PLAYER *pPlayer) if (isShrinked(pPlayer->pSprite)) zvel[nSprite] -= -200000; else if (isGrown(pPlayer->pSprite)) zvel[nSprite] += -250000; - pPlayer->canJump = 1; + pPlayer->cantJump = 1; } @@ -1712,7 +1735,7 @@ void ProcessInput(PLAYER *pPlayer) if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg) trTextOver(pXSprite->lockMsg); if (!key || pPlayer->hasKey[key]) - trTriggerSprite(a2, pXSprite, kCmdSpritePush); + trTriggerSprite(a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); else if (pPlayer == gMe) { viewSetMessage("That requires a key."); @@ -2283,7 +2306,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in gPlayer[p].fraggerId = -1; } FragPlayer(pPlayer, nSource); - trTriggerSprite(nSprite, pXSprite, kCmdOff); + trTriggerSprite(nSprite, pXSprite, kCmdOff, nSource); } dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL); seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer); @@ -2296,8 +2319,8 @@ int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec) return 9999; if (nAmmoType == -1) return 9999; - pPlayer->ammCount[nAmmoType] = ClipLow(pPlayer->ammCount[nAmmoType]-nDec, 0); - return pPlayer->ammCount[nAmmoType]; + pPlayer->ammoCount[nAmmoType] = ClipLow(pPlayer->ammoCount[nAmmoType]-nDec, 0); + return pPlayer->ammoCount[nAmmoType]; } void sub_41250(PLAYER *pPlayer) diff --git a/source/blood/src/player.h b/source/blood/src/player.h index e33ef73f7..492ce5196 100644 --- a/source/blood/src/player.h +++ b/source/blood/src/player.h @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "db.h" #include "dude.h" #include "levels.h" +#include "qav.h" BEGIN_BLD_NS @@ -106,12 +107,12 @@ struct PLAYER { char nextWeapon; int weaponTimer; int weaponState; - int weaponAmmo; + int weaponAmmo; //rename bool hasWeapon[14]; int weaponMode[14]; int weaponOrder[2][14]; //int at149[14]; - int ammCount[12]; + int ammoCount[12]; bool qavLoop; int fuseTime; int throwTime; @@ -143,7 +144,7 @@ struct PLAYER { int spin; // turning around bool godMode; bool fallScream; - bool canJump; + bool cantJump; int packItemTime; // pack timer int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots @@ -209,6 +210,13 @@ struct POWERUPINFO { int maxTime; }; + +struct QAVSCENE { + short index; + QAV* qavId; +}; +extern QAVSCENE gQavScene[kMaxPlayers]; + extern PLAYER gPlayer[kMaxPlayers]; extern PLAYER *gMe, *gView; @@ -302,5 +310,7 @@ bool growPlayerSize(PLAYER* pPlayer, int multiplier); bool resetPlayerSize(PLAYER* pPlayer); void deactivateSizeShrooms(PLAYER* pPlayer); PLAYER* getPlayerById(short id); +void startQavScene(PLAYER* pPlayer, int qavId, int a3, char a4); +void playQavScene(PLAYER* pPlayer); END_BLD_NS diff --git a/source/blood/src/sectorfx.cpp b/source/blood/src/sectorfx.cpp index c593e3b06..b948f41cc 100644 --- a/source/blood/src/sectorfx.cpp +++ b/source/blood/src/sectorfx.cpp @@ -281,8 +281,8 @@ void DoSectorPanning(void) if (pXSector->panFloor) // Floor { int nTile = pSector->floorpicnum; - int px = (pSector->floorxpanning<<8)+pXSector->at32_1; - int py = (pSector->floorypanning<<8)+pXSector->at34_0; + int px = (pSector->floorxpanning<<8)+pXSector->floorXPanFrac; + int py = (pSector->floorypanning<<8)+pXSector->floorYPanFrac; if (pSector->floorstat&64) angle -= 512; int xBits = (picsiz[nTile]&15)-((pSector->floorstat&8)!=0); @@ -291,14 +291,14 @@ void DoSectorPanning(void) py -= mulscale30(speed<<2, Sin(angle))>>yBits; pSector->floorxpanning = px>>8; pSector->floorypanning = py>>8; - pXSector->at32_1 = px&255; - pXSector->at34_0 = py&255; + pXSector->floorXPanFrac = px&255; + pXSector->floorYPanFrac = py&255; } if (pXSector->panCeiling) // Ceiling { int nTile = pSector->ceilingpicnum; - int px = (pSector->ceilingxpanning<<8)+pXSector->at30_1; - int py = (pSector->ceilingypanning<<8)+pXSector->at31_1; + int px = (pSector->ceilingxpanning<<8)+pXSector->ceilXPanFrac; + int py = (pSector->ceilingypanning<<8)+pXSector->ceilYPanFrac; if (pSector->ceilingstat&64) angle -= 512; int xBits = (picsiz[nTile]&15)-((pSector->ceilingstat&8)!=0); @@ -307,8 +307,8 @@ void DoSectorPanning(void) py -= mulscale30(speed<<2, Sin(angle))>>yBits; pSector->ceilingxpanning = px>>8; pSector->ceilingypanning = py>>8; - pXSector->at30_1 = px&255; - pXSector->at31_1 = py&255; + pXSector->ceilXPanFrac = px&255; + pXSector->ceilYPanFrac = py&255; } } } diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 930c5b317..aaf3b745f 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -53,7 +53,7 @@ int soundRates[13] = { 44100, 44100, }; -#define kMaxChannels 32 +#define kChannelMax 32 int sndGetRate(int format) { @@ -62,11 +62,11 @@ int sndGetRate(int format) return 11025; } -SAMPLE2D Channel[kMaxChannels]; +SAMPLE2D Channel[kChannelMax]; SAMPLE2D * FindChannel(void) { - for (int i = kMaxChannels - 1; i >= 0; i--) + for (int i = kChannelMax - 1; i >= 0; i--) if (Channel[i].at5 == 0) return &Channel[i]; consoleSysMsg("No free channel available for sample"); //ThrowError("No free channel available for sample"); @@ -249,7 +249,7 @@ void sndStartSample(const char *pzSound, int nVolume, int nChannel) return; if (!strlen(pzSound)) return; - dassert(nChannel >= -1 && nChannel < kMaxChannels); + dassert(nChannel >= -1 && nChannel < kChannelMax); SAMPLE2D *pChannel; if (nChannel == -1) pChannel = FindChannel(); @@ -269,7 +269,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop) { if (!snd_enabled) return; - dassert(nChannel >= -1 && nChannel < kMaxChannels); + dassert(nChannel >= -1 && nChannel < kChannelMax); DICTNODE *hSfx = gSoundRes.Lookup(nSound, "SFX"); if (!hSfx) return; @@ -313,7 +313,7 @@ void sndStartWavID(unsigned int nSound, int nVolume, int nChannel) { if (!snd_enabled) return; - dassert(nChannel >= -1 && nChannel < kMaxChannels); + dassert(nChannel >= -1 && nChannel < kChannelMax); SAMPLE2D *pChannel; if (nChannel == -1) pChannel = FindChannel(); @@ -340,7 +340,7 @@ void sndKillSound(SAMPLE2D *pChannel) void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel) { - dassert(nChannel >= -1 && nChannel < kMaxChannels); + dassert(nChannel >= -1 && nChannel < kChannelMax); SAMPLE2D *pChannel; if (nChannel == -1) pChannel = FindChannel(); @@ -365,7 +365,7 @@ void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel) void sndKillAllSounds(void) { - for (int i = 0; i < kMaxChannels; i++) + for (int i = 0; i < kChannelMax; i++) { SAMPLE2D *pChannel = &Channel[i]; if (pChannel->at0 > 0) @@ -392,7 +392,7 @@ void sndKillAllSounds(void) void sndProcess(void) { - for (int i = 0; i < kMaxChannels; i++) + for (int i = 0; i < kChannelMax; i++) { if (Channel[i].at0 <= 0 && Channel[i].at5) { diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index 7251b8e75..a906efbc2 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -85,7 +85,7 @@ unsigned int GetWaveValue(unsigned int nPhase, int nType) return nPhase; } -char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState) +char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState, short causedBy) { if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState) return 0; @@ -99,32 +99,31 @@ char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState) return 1; } if (pXSprite->restState != nState && pXSprite->waitTime > 0) - evPost(nSprite, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff); + evPost(nSprite, 3, (pXSprite->waitTime * 120) / 10, pXSprite->restState ? kCmdOn : kCmdOff, causedBy); if (pXSprite->txID) { if (pXSprite->command != kCmdLink && pXSprite->triggerOn && pXSprite->state) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); if (pXSprite->command != kCmdLink && pXSprite->triggerOff && !pXSprite->state) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); } return 1; } -char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState) +char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState, short causedBy) { - if ((pXSprite->busy&0xffff) == 0 && pXSprite->state == nState) - return 0; + if ((pXSprite->busy&0xffff) == 0 && pXSprite->state == nState) return 0; pXSprite->busy = nState<<16; pXSprite->state = nState; evKill(nSprite, 3); - if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax) - { + if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax) { pXSprite->respawnPending = 3; - evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); + evPost(nSprite, 3, gGameOptions.nMonsterRespawnTime, kCallbackRespawn, causedBy); return 1; } + if (pXSprite->restState != nState && pXSprite->waitTime > 0) - evPost(nSprite, 3, (pXSprite->waitTime*120) / 10, pXSprite->restState ? kCmdOn : kCmdOff); + evPost(nSprite, 3, (pXSprite->waitTime*120) / 10, pXSprite->restState ? kCmdOn : kCmdOff, causedBy); if (pXSprite->txID != 0 && ((pXSprite->triggerOn && pXSprite->state) || (pXSprite->triggerOff && !pXSprite->state))) { @@ -133,15 +132,15 @@ char modernTypeSetSpriteState(int nSprite, XSPRITE *pXSprite, int nState) switch (pXSprite->command) { case kCmdLink: case kCmdModernUse: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // just send command to change properties return 1; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // then send command to change properties return 1; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, causedBy); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); // then send normal command return 1; } @@ -184,7 +183,7 @@ char SetSectorState(int nSector, XSECTOR *pXSector, int nState) pXSector->stopOn = 0; pXSector->stopOff = 0; } - else if (pXSector->atf_6) + else if (pXSector->reTriggerA) evPost(nSector, 6, (pXSector->waitTimeA * 120) / 10, kCmdOff); } else @@ -196,7 +195,7 @@ char SetSectorState(int nSector, XSECTOR *pXSector, int nState) pXSector->stopOn = 0; pXSector->stopOff = 0; } - else if (pXSector->atf_7) + else if (pXSector->reTriggerB) evPost(nSector, 6, (pXSector->waitTimeB * 120) / 10, kCmdOn); } return 1; @@ -296,7 +295,7 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event) PLAYER *pPlayer = &gPlayer[nPlayer]; if (pPlayer->pXSprite->health > 0) { - pPlayer->ammCount[8] = ClipHigh(pPlayer->ammCount[8]+pXSprite->data3, gAmmoInfo[8].max); + pPlayer->ammoCount[8] = ClipHigh(pPlayer->ammoCount[8]+pXSprite->data3, gAmmoInfo[8].max); pPlayer->hasWeapon[9] = 1; if (pPlayer->curWeapon != 9) { @@ -369,6 +368,9 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) { spritetype *pSprite = &sprite[nSprite]; + if (pSprite->type != 706 && pSprite->type != 707 && pSprite->type != 37) + viewSetSystemMessage("SPRITE %d (TYPE %d), EVENT INITED BY: %d", nSprite, pSprite->type, event.causedBy); + if (gModernMap) { switch (event.cmd) { case kCmdUnlock: @@ -410,7 +412,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: if (pXSprite->txID <= 0) return; - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); return; } break; // go normal operate switch @@ -454,7 +456,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (tx > 0) { pXSprite->txID = tx; - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); } } return; @@ -476,7 +478,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pSprite->flags & kModernTypeFlag1) { for (pXSprite->txID = pXSprite->data1; pXSprite->txID <= pXSprite->data4; pXSprite->txID++) { if (pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); } pXSprite->txID = pXSprite->sysData1 = 0; @@ -495,7 +497,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pSprite->flags & kModernTypeFlag1) { for (int i = 0; i <= 3; i++) { if ((pXSprite->txID = GetDataVal(pSprite, i)) > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); } pXSprite->txID = pXSprite->sysData1 = 0; @@ -549,35 +551,40 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } pXSprite->txID = tx; - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); } return; case kMarkerWarpDest: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) - useTeleportTarget(pXSprite, NULL); + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) + if (pXSprite->data1 > 0) useTeleportTarget(pXSprite, NULL); + else if (pXSprite->data1 == 0 && event.causedBy >= 0) + useTeleportTarget(pXSprite, &sprite[event.causedBy]); return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); return; case kModernSpriteDamager: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) - useSpriteDamager(pXSprite, NULL); + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) { + if (pXSprite->data1 > 0) useSpriteDamager(pXSprite, NULL); + else if (pXSprite->data1 == 0 && event.causedBy >= 0) + useSpriteDamager(pXSprite, &sprite[event.causedBy]); + } return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); return; case kModernObjPropertiesChanger: if (pXSprite->txID <= 0) { - if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1) == 1) + if (SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy) == 1) usePropertiesChanger(pXSprite, -1, -1); return; } - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); return; case kModernObjPicnumChanger: @@ -585,7 +592,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernSectorFXChanger: case kModernObjDataChanger: case kModernConcussSprite: - modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + modernTypeSetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); return; case kModernCustomDudeSpawn: @@ -597,11 +604,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernEffectSpawner: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0) @@ -610,26 +617,26 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command break; } } if (pXSprite->busyTime > 0) - evPost(nSprite, 3, ClipLow((int(pXSprite->busyTime) + Random2(pXSprite->data1)) * 120 / 10, 0), kCmdRepeat); + evPost(nSprite, 3, ClipLow((int(pXSprite->busyTime) + Random2(pXSprite->data1)) * 120 / 10, 0), kCmdRepeat, event.causedBy); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } return; @@ -638,11 +645,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: stopWindOnSectors(pXSprite); - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0) useSectorWindGen(pXSprite, NULL); @@ -650,25 +657,25 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command break; } } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } return; @@ -687,41 +694,41 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: if (pXSprite->data4 == 3 && activated == false) activateDudes(pXSprite->txID); - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: if (pXSprite->txID <= 0 || !getDudesForTargetChg(pXSprite)) { freeAllTargets(pXSprite); - evPost(nSprite, 3, 0, kCmdOff); + evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } else { switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command break; } } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } @@ -732,17 +739,17 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernObjDataAccumulator: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: // force OFF after *all* TX objects reach the goal value if (pSprite->flags == 0 && goalValueIsReached(pXSprite)) { - evPost(nSprite, 3, 0, kCmdOff); + evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } @@ -750,24 +757,24 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (pXSprite->command) { case kCmdLink: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // just send command to change properties + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // just send command to change properties break; case kCmdUnlock: - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // send normal command first - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // then send command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // send normal command first + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // then send command to change properties break; default: - evSend(nSprite, 3, pXSprite->txID, kCmdModernUse); // send first command to change properties - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); // then send normal command + evSend(nSprite, 3, pXSprite->txID, kCmdModernUse, event.causedBy); // send first command to change properties + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); // then send normal command break; } - if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, pXSprite->busyTime, kCmdRepeat, event.causedBy); } break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } return; @@ -776,20 +783,20 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kModernRandom2: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: ActivateGenerator(nSprite); if (pXSprite->busyTime > 0) - evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); + evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } return; @@ -801,61 +808,81 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kGenModernMissileUniversal: switch (event.cmd) { case kCmdOff: - if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0); + if (pXSprite->state == 1) SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: evKill(nSprite, 3); // queue overflow protect - if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1); + if (pXSprite->state == 0) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); fallthrough__; case kCmdRepeat: ActivateGenerator(nSprite); - if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); - if (pXSprite->busyTime > 0) evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); + if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); + if (pXSprite->busyTime > 0) evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); break; default: - if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (pXSprite->state == 0) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } return; case kModernPlayerControl: // WIP PLAYER* pPlayer = NULL; - if ((pPlayer = getPlayerById(pXSprite->data1)) == NULL) return; + if ((pPlayer = getPlayerById(pXSprite->data1)) == NULL || pPlayer->pXSprite->health <= 0) return; else if (event.cmd < kCmdNumberic) { // play qav as weapon qav switch (event.cmd) { case kCmdOff: - if (gQavPlayerIndex == nSprite) { - pXSprite->sysData1 = 0; - pPlayer->input.newWeapon = pPlayer->curWeapon = pXSprite->data4; - gQavPlayerIndex = -1; + if (gQavScene[pPlayer->nPlayer].index == nSprite) { + viewSetSystemMessage("OFF %d", gQavScene[pPlayer->nPlayer].index); + + gQavScene[pPlayer->nPlayer].index = -1; + gQavScene[pPlayer->nPlayer].qavId = NULL; + pPlayer->weaponQav = -1; + // restore weapon + pPlayer->input.newWeapon = pPlayer->curWeapon = pXSprite->dropMsg; WeaponRaise(pPlayer); + } break; case kCmdOn: { - if (gQavPlayerIndex == nSprite && !pXSprite->Interrutable) break; + if (gQavScene[pPlayer->nPlayer].index == nSprite && !pXSprite->Interrutable) break; QAV* pQav = NULL; DICTNODE* hQav = gSysRes.Lookup(pXSprite->data2, "QAV"); if (hQav) { - pXSprite->data4 = pPlayer->curWeapon; - if (gQavPlayerIndex > -1 && gQavPlayerIndex != nSprite && sprite[gQavPlayerIndex].extra >= 0) { - pXSprite->data4 = xsprite[sprite[gQavPlayerIndex].extra].data4; - xsprite[sprite[gQavPlayerIndex].extra].data4 = 0; - } + // save current weapon + pXSprite->dropMsg = pPlayer->curWeapon; - WeaponLower(pPlayer); + short nIndex = gQavScene[pPlayer->nPlayer].index; + if (nIndex > -1 && nIndex != nSprite && sprite[nIndex].extra >= 0) + pXSprite->dropMsg = xsprite[sprite[nIndex].extra].dropMsg; + + if (nIndex < 0) + WeaponLower(pPlayer); + + pQav = (QAV*)gSysRes.Load(hQav); + pXSprite->sysData1 = ClipLow((pQav->at10 * pXSprite->waitTime) / 4, 0); // how many times animation should be played + gQavScene[pPlayer->nPlayer].index = nSprite; + + gQavScene[pPlayer->nPlayer].qavId = pQav; + gQavScene[pPlayer->nPlayer].qavId->Preload(); - pQav = (QAV*)gSysRes.Load(hQav); weaponQAV[kFreeQAVEntry] = pQav; - pXSprite->busyTime = ((((pQav->at10) / 12) * 120) / 10) - 12; - //pXSprite->busyTime = (((pQav->nFrames * pQav->ticksPerFrame) / 12) * 120) / 10; - pXSprite->sysData1 = pXSprite->waitTime; // how many times animation should be played - gQavPlayerIndex = nSprite; + pPlayer->weaponQav = pXSprite->data2; + pPlayer->weaponTimer = gQavScene[pPlayer->nPlayer].qavId->at10; + pPlayer->qavCallback = (pXSprite->data3 > 0) ? ClipRange(pXSprite->data3 - 1, 0, 32) : -1; + pPlayer->qavLoop = false; + //startQavScene(pPlayer, pXSprite->data2, -1, 0); + + + //viewSetSystemMessage("QAV %d", pXSprite->data2); + + } else { + viewSetSystemMessage("Failed to load QAV animation #%d", pXSprite->data2); } break; } default: - if (gQavPlayerIndex != nSprite) evPost(nSprite, 3, 0, kCmdOn); - else evPost(nSprite, 3, 0, kCmdOff); + if (gQavScene[pPlayer->nPlayer].index != nSprite) evPost(nSprite, 3, 0, kCmdOn, event.causedBy); + else evPost(nSprite, 3, 0, kCmdOff, event.causedBy); break; } } else if (event.cmd < kCmdNumbericMax) { @@ -916,6 +943,39 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case 6: // visibility pPlayer->visibility = pXSprite->data3; break; + case 7: // delirium + pPlayer->pwUpTime[kPwUpDeliriumShroom] = ClipHigh(pXSprite->data3 << 1, 432000); + if (pXSprite->data3 > 0) powerupActivate(pPlayer, kPwUpDeliriumShroom); + else powerupDeactivate(pPlayer, kPwUpDeliriumShroom); + break; + } + break; + case kCmdNumberic + 6: // erase player stuff... + switch (pXSprite->data2) { + case 0: + case 1: { + // erase all weapons except pitchfork + WeaponLower(pPlayer); + + for (int i = 0; i < 14; i++) { + pPlayer->hasWeapon[i] = false; + // also erase ammo + if (i < 12 && pXSprite->data3 == 1) + pPlayer->ammoCount[i] = 0; + } + + pPlayer->hasWeapon[1] = true; + pPlayer->curWeapon = 0; + pPlayer->nextWeapon = 1; + + WeaponRaise(pPlayer); + break; + } + case 2: + // erase all armor + for (int i = 0; i < 3; i++) + pPlayer->armor[i] = 0; + break; } break; } @@ -928,7 +988,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdSpriteProximity: if (pXSprite->state) break; @@ -936,7 +996,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdOn: case kCmdSpritePush: case kCmdSpriteTouch: - if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1); + if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1, event.causedBy); aiActivateDude(pSprite, pXSprite); break; } @@ -950,11 +1010,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) if (pXSprite->health <= 0) break; switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0)) break; + if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; seqSpawn(40, 3, pSprite->extra, -1); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1)) break; + if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; seqSpawn(38, 3, pSprite->extra, nMGunOpenClient); if (pXSprite->data1 > 0) pXSprite->data2 = pXSprite->data1; @@ -962,15 +1022,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } break; case kThingFallingRock: - if (SetSpriteState(nSprite, pXSprite, 1)) + if (SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) pSprite->flags |= 7; break; case kThingWallCrack: - if (SetSpriteState(nSprite, pXSprite, 0)) + if (SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) actPostSprite(nSprite, kStatFree); break; case kThingCrateFace: - if (SetSpriteState(nSprite, pXSprite, 0)) + if (SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) actPostSprite(nSprite, kStatFree); break; case kTrapZapSwitchable: @@ -995,12 +1055,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kTrapFlame: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0)) break; + if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; seqSpawn(40, 3, pSprite->extra, -1); sfxKill3DSound(pSprite, 0, -1); break; case kCmdOn: - if (SetSpriteState(nSprite, pXSprite, 1)) break; + if (SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; seqSpawn(38, 3, pSprite->extra, -1); sfxPlay3DSound(pSprite, 441, 0, 0); break; @@ -1009,14 +1069,14 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchPadlock: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1)) break; + if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; seqSpawn(37, 3, pSprite->extra, -1); break; default: - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); if (pXSprite->state) seqSpawn(37, 3, pSprite->extra, -1); break; } @@ -1024,15 +1084,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchToggle: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0)) break; + if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1)) break; + if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy)) break; if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; @@ -1041,15 +1101,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kSwitchOneWay: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0)) break; + if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1)) break; + if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1, event.causedBy)) break; if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); break; @@ -1072,12 +1132,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) sfxPlay3DSound(pSprite, pXSprite->data4, -1, 0); if (pXSprite->command == kCmdLink && pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, kCmdLink); + evSend(nSprite, 3, pXSprite->txID, kCmdLink, event.causedBy); if (pXSprite->data1 == pXSprite->data2) - SetSpriteState(nSprite, pXSprite, 1); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); else - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kMarkerDudeSpawn: @@ -1114,7 +1174,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kMarkerEarthQuake: pXSprite->triggerOn = 0; pXSprite->isTriggered = 1; - SetSpriteState(nSprite, pXSprite, 1); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); for (int p = connecthead; p >= 0; p = connectpoint2[p]) { spritetype *pPlayerSprite = gPlayer[p].pSprite; int dx = (pSprite->x - pPlayerSprite->x)>>4; @@ -1125,7 +1185,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) } break; case kThingTNTBarrel: - if (pSprite->flags&kHitagRespawn) return; + if (pSprite->flags & kHitagRespawn) return; fallthrough__; case kThingArmedTNTStick: case kThingArmedTNTBundle: @@ -1135,7 +1195,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kTrapExploder: switch (event.cmd) { case kCmdOn: - SetSpriteState(nSprite, pXSprite, 1); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); break; default: pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE; @@ -1151,7 +1211,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) break; default: sfxPlay3DSound(pSprite, 454, 0, 0); - evPost(nSprite, 3, 18, kCmdOff); + evPost(nSprite, 3, 18, kCmdOff, event.causedBy); break; } } @@ -1164,7 +1224,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kCmdSpriteProximity: if (pXSprite->state) break; sfxPlay3DSound(pSprite, 452, 0, 0); - evPost(nSprite, 3, 30, kCmdOff); + evPost(nSprite, 3, 30, kCmdOff, event.causedBy); pXSprite->state = 1; case kCmdOn: sfxPlay3DSound(pSprite, 451, 0, 0); @@ -1190,20 +1250,20 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kGenSound: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdRepeat: if (pSprite->type != kGenTrigger) ActivateGenerator(nSprite); - if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + if (pXSprite->txID) evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, event.causedBy); if (pXSprite->busyTime > 0) { int nRand = Random2(pXSprite->data1); - evPost(nSprite, 3, 120*(nRand+pXSprite->busyTime) / 10, kCmdRepeat); + evPost(nSprite, 3, 120*(nRand+pXSprite->busyTime) / 10, kCmdRepeat, event.causedBy); } break; default: if (!pXSprite->state) { - SetSpriteState(nSprite, pXSprite, 1); - evPost(nSprite, 3, 0, kCmdRepeat); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); + evPost(nSprite, 3, 0, kCmdRepeat, event.causedBy); } break; } @@ -1219,15 +1279,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) case kThingZombieHead: switch (event.cmd) { case kCmdOff: - if (!SetSpriteState(nSprite, pXSprite, 0)) break; + if (!SetSpriteState(nSprite, pXSprite, 0, event.causedBy)) break; actActivateGibObject(pSprite, pXSprite); break; case kCmdOn: - if (!SetSpriteState(nSprite, pXSprite, 1)) break; + if (!SetSpriteState(nSprite, pXSprite, 1, event.causedBy)) break; actActivateGibObject(pSprite, pXSprite); break; default: - if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break; + if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy)) break; actActivateGibObject(pSprite, pXSprite); break; } @@ -1235,13 +1295,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event) default: switch (event.cmd) { case kCmdOff: - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); break; case kCmdOn: - SetSpriteState(nSprite, pXSprite, 1); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); break; default: - SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1); + SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1, event.causedBy); break; } break; @@ -1680,28 +1740,17 @@ void useSectorWindGen(XSPRITE* pXSource, sectortype* pSector) { } void useSpriteDamager(XSPRITE* pXSource, spritetype* pSprite) { - int dmg = (pXSource->data4 == 0 || pXSource->data4 > 65534) ? 65535 : pXSource->data4; - int dmgType = (pXSource->data3 >= 7) ? Random(6) : ((pXSource->data3 < 0) ? 0 : pXSource->data3); - - // just damage / heal TX ID sprite - if (pSprite != NULL) { - actDamageSprite(pSprite->xvel, pSprite, (DAMAGE_TYPE) dmgType, dmg); - return; + int dmgType = (pXSource->data3 >= 7) ? Random(6) : ClipRange(pXSource->data3, 0, 6); + int dmg = (pXSource->data4 == 0) ? 65535 : ClipRange(pXSource->data4, 1, 65535); + // just damage TX ID sprite + if (pSprite != NULL) actDamageSprite(pSprite->index, pSprite, (DAMAGE_TYPE) dmgType, dmg); + else if (pXSource->data1 > 0) { - } // or damage / heal player# specified in data2 (or all players if data2 is empty) - else if (pXSource->data2 > 0 && pXSource->data2 <= kMaxPlayers) { + PLAYER* pPlayer = getPlayerById(pXSource->data1); + if (pPlayer != NULL) + actDamageSprite(sprite[pXSource->reference].index, pPlayer->pSprite, (DAMAGE_TYPE)dmgType, dmg); - for (int i = connecthead; i >= 0; i = connectpoint2[i]) { - if (pXSource->data1 < kMaxPlayers) // relative to connected players - if (pXSource->data1 != (i + 1)) - continue; - else if (pXSource->data1 < (kDudePlayer1 + kMaxPlayers)) // absolute type - if (pXSource->data1 >= kDudePlayer1 && (pXSource->data1 + (kDudePlayer1 - 1)) == gPlayer[i].pSprite->type) - continue; - actDamageSprite(sprite[pXSource->reference].xvel, gPlayer[i].pSprite, (DAMAGE_TYPE) dmgType, dmg); - return; - } } } @@ -2110,11 +2159,11 @@ void ZTranslateSector(int nSector, XSECTOR *pXSector, int a3, int a4) { sectortype *pSector = §or[nSector]; viewInterpolateSector(nSector, pSector); - int dz = pXSector->at28_0-pXSector->at24_0; + int dz = pXSector->onFloorZ-pXSector->offFloorZ; if (dz != 0) { int oldZ = pSector->floorz; - baseFloor[nSector] = pSector->floorz = pXSector->at24_0 + mulscale16(dz, GetWaveValue(a3, a4)); + baseFloor[nSector] = pSector->floorz = pXSector->offFloorZ + mulscale16(dz, GetWaveValue(a3, a4)); velFloor[nSector] += (pSector->floorz-oldZ)<<8; for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { @@ -2137,11 +2186,11 @@ void ZTranslateSector(int nSector, XSECTOR *pXSector, int a3, int a4) } } } - dz = pXSector->at20_0-pXSector->at1c_0; + dz = pXSector->onCeilZ-pXSector->offCeilZ; if (dz != 0) { int oldZ = pSector->ceilingz; - baseCeil[nSector] = pSector->ceilingz = pXSector->at1c_0 + mulscale16(dz, GetWaveValue(a3, a4)); + baseCeil[nSector] = pSector->ceilingz = pXSector->offCeilZ + mulscale16(dz, GetWaveValue(a3, a4)); velCeil[nSector] += (pSector->ceilingz-oldZ)<<8; for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { @@ -2212,15 +2261,15 @@ int VCrushBusy(unsigned int nSector, unsigned int a2) XSECTOR *pXSector = &xsector[nXSector]; int nWave; if (pXSector->busy < a2) - nWave = pXSector->at7_2; + nWave = pXSector->busyWaveA; else - nWave = pXSector->at7_5; - int dz1 = pXSector->at20_0 - pXSector->at1c_0; - int vc = pXSector->at1c_0; + nWave = pXSector->busyWaveB; + int dz1 = pXSector->onCeilZ - pXSector->offCeilZ; + int vc = pXSector->offCeilZ; if (dz1 != 0) vc += mulscale16(dz1, GetWaveValue(a2, nWave)); - int dz2 = pXSector->at28_0 - pXSector->at24_0; - int v10 = pXSector->at24_0; + int dz2 = pXSector->onFloorZ - pXSector->offFloorZ; + int v10 = pXSector->offFloorZ; if (dz2 != 0) v10 += mulscale16(dz2, GetWaveValue(a2, nWave)); int v18; @@ -2251,10 +2300,10 @@ int VSpriteBusy(unsigned int nSector, unsigned int a2) XSECTOR *pXSector = &xsector[nXSector]; int nWave; if (pXSector->busy < a2) - nWave = pXSector->at7_2; + nWave = pXSector->busyWaveA; else - nWave = pXSector->at7_5; - int dz1 = pXSector->at28_0 - pXSector->at24_0; + nWave = pXSector->busyWaveB; + int dz1 = pXSector->onFloorZ - pXSector->offFloorZ; if (dz1 != 0) { for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) @@ -2267,7 +2316,7 @@ int VSpriteBusy(unsigned int nSector, unsigned int a2) } } } - int dz2 = pXSector->at20_0 - pXSector->at1c_0; + int dz2 = pXSector->onCeilZ - pXSector->offCeilZ; if (dz2 != 0) { for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) @@ -2310,7 +2359,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2) spritetype *pSprite = &sprite[nSprite]; dassert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); XSPRITE *pXSprite = &xsprite[pSprite->extra]; - if (pXSector->at20_0 > pXSector->at1c_0 || pXSector->at28_0 < pXSector->at24_0) + if (pXSector->onCeilZ > pXSector->offCeilZ || pXSector->onFloorZ < pXSector->offFloorZ) { if (pXSector->interruptable) { @@ -2344,7 +2393,7 @@ int VDoorBusy(unsigned int nSector, unsigned int a2) spritetype *pSprite = &sprite[nSprite]; dassert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); XSPRITE *pXSprite = &xsprite[pSprite->extra]; - if (pXSector->at1c_0 > pXSector->at20_0 || pXSector->at24_0 < pXSector->at28_0) + if (pXSector->offCeilZ > pXSector->onCeilZ || pXSector->offFloorZ < pXSector->onFloorZ) { if (pXSector->interruptable) { @@ -2375,9 +2424,9 @@ int VDoorBusy(unsigned int nSector, unsigned int a2) } int nWave; if (pXSector->busy < a2) - nWave = pXSector->at7_2; + nWave = pXSector->busyWaveA; else - nWave = pXSector->at7_5; + nWave = pXSector->busyWaveB; ZTranslateSector(nSector, pXSector, a2, nWave); pXSector->busy = a2; if (pXSector->command == kCmdLink && pXSector->txID) @@ -2400,9 +2449,9 @@ int HDoorBusy(unsigned int nSector, unsigned int a2) XSECTOR *pXSector = &xsector[nXSector]; int nWave; if (pXSector->busy < a2) - nWave = pXSector->at7_2; + nWave = pXSector->busyWaveA; else - nWave = pXSector->at7_5; + nWave = pXSector->busyWaveB; spritetype *pSprite1 = &sprite[pXSector->marker0]; spritetype *pSprite2 = &sprite[pXSector->marker1]; TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite1->x, pSprite1->y, pSprite1->x, pSprite1->y, pSprite1->ang, pSprite2->x, pSprite2->y, pSprite2->ang, pSector->type == kSectorSlide); @@ -2428,9 +2477,9 @@ int RDoorBusy(unsigned int nSector, unsigned int a2) XSECTOR *pXSector = &xsector[nXSector]; int nWave; if (pXSector->busy < a2) - nWave = pXSector->at7_2; + nWave = pXSector->busyWaveA; else - nWave = pXSector->at7_5; + nWave = pXSector->busyWaveB; spritetype *pSprite = &sprite[pXSector->marker0]; TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, 0, pSprite->x, pSprite->y, pSprite->ang, pSector->type == kSectorRotate); ZTranslateSector(nSector, pXSector, a2, nWave); @@ -2458,13 +2507,13 @@ int StepRotateBusy(unsigned int nSector, unsigned int a2) if (pXSector->busy < a2) { vbp = pXSector->data+pSprite->ang; - int nWave = pXSector->at7_2; + int nWave = pXSector->busyWaveA; TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, pXSector->data, pSprite->x, pSprite->y, vbp, 1); } else { vbp = pXSector->data-pSprite->ang; - int nWave = pXSector->at7_5; + int nWave = pXSector->busyWaveB; TranslateSector(nSector, GetWaveValue(pXSector->busy, nWave), GetWaveValue(a2, nWave), pSprite->x, pSprite->y, pSprite->x, pSprite->y, vbp, pSprite->x, pSprite->y, pXSector->data, 1); } pXSector->busy = a2; @@ -2648,7 +2697,7 @@ void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT event) // by NoOne: trigger marker after it gets reached if (gModernMap && pXSprite2->state != 1) - trTriggerSprite(pSprite2->xvel, pXSprite2, kCmdOn); + trTriggerSprite(pSprite2->xvel, pXSprite2, kCmdOn, -1); if (nSprite < 0) { viewSetSystemMessage("Unable to find path marker with id #%d for path sector #%d", nId, nSector); @@ -2658,8 +2707,8 @@ void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT event) } pXSector->marker1 = nSprite; - pXSector->at24_0 = pSprite2->z; - pXSector->at28_0 = pSprite->z; + pXSector->offFloorZ = pSprite2->z; + pXSector->onFloorZ = pSprite->z; switch (event.cmd) { case kCmdOn: pXSector->state = 0; @@ -2968,9 +3017,9 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) { dassert(nXSprite2 > 0 && nXSprite2 < kMaxXSprites); pXSprite->data1 = xsprite[nXSprite2].data1; if (pXSprite->data1 == pXSprite->data2) - SetSpriteState(nSprite, pXSprite, 1); + SetSpriteState(nSprite, pXSprite, 1, event.causedBy); else - SetSpriteState(nSprite, pXSprite, 0); + SetSpriteState(nSprite, pXSprite, 0, event.causedBy); } } break; @@ -2978,7 +3027,7 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) { { pXSprite->busy = nBusy; if ((pXSprite->busy & 0xffff) == 0) - SetSpriteState(nSprite, pXSprite, nBusy >> 16); + SetSpriteState(nSprite, pXSprite, nBusy >> 16, event.causedBy); } break; } @@ -3069,18 +3118,19 @@ void trMessageWall(unsigned int nWall, EVENT event) { } } -void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command) { +void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command, int causedBy) { if (!pXSprite->locked && !pXSprite->isTriggered) { if (pXSprite->triggerOnce) pXSprite->isTriggered = 1; if (pXSprite->Decoupled && pXSprite->txID > 0) - evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command); + evSend(nSprite, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, causedBy); else { EVENT event; event.cmd = command; + event.causedBy = causedBy; OperateSprite(nSprite, pXSprite, event); } @@ -3953,9 +4003,9 @@ bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value) { switch (sprite[objIndex].type) { case kSwitchCombo: if (xsprite[sprite[objIndex].extra].data1 == xsprite[sprite[objIndex].extra].data2) - SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 1); + SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 1, -1); else - SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 0); + SetSpriteState(objIndex, &xsprite[sprite[objIndex].extra], 0, -1); break; } return true; @@ -4428,21 +4478,23 @@ void trInit(void) else sprite[i].flags &= ~7; break; } - if (pXSprite->Vector) - sprite[i].cstat |= 256; - if (pXSprite->Push) - sprite[i].cstat |= 4096; + if (pXSprite->Vector) sprite[i].cstat |= CSTAT_SPRITE_BLOCK_HITSCAN; + if (pXSprite->Push) sprite[i].cstat |= 4096; } } - evSend(0, 0, 7, kCmdOn); - if (gGameOptions.nGameType == 1) - evSend(0, 0, 9, kCmdOn); - else if (gGameOptions.nGameType == 2) - evSend(0, 0, 8, kCmdOn); - else if (gGameOptions.nGameType == 3) - { - evSend(0, 0, 8, kCmdOn); - evSend(0, 0, 10, kCmdOn); + + evSend(0, 0, kChannelLevelStart, kCmdOn); + switch (gGameOptions.nGameType) { + case 1: + evSend(0, 0, kChannelLevelStartCoop, kCmdOn); + break; + case 2: + evSend(0, 0, kChannelLevelStartMatch, kCmdOn); + break; + case 3: + evSend(0, 0, kChannelLevelStartMatch, kCmdOn); + evSend(0, 0, kChannelLevelStartTeamsOnly, kCmdOn); + break; } } @@ -4468,30 +4520,30 @@ void InitGenerator(int nSprite) pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat); + evPost(nSprite, 3, (120 * pXSprite->busyTime) / 10, kCmdRepeat, -1); return; case kModernDudeTargetChanger: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->busyTime <= 0) pXSprite->busyTime = 5; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat); + evPost(nSprite, 3, 0, kCmdRepeat, -1); return; case kModernEffectSpawner: case kModernSeqSpawner: if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat); + evPost(nSprite, 3, 0, kCmdRepeat, -1); return; case kModernObjDataAccumulator: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat); + evPost(nSprite, 3, 0, kCmdRepeat, -1); return; case kModernWindGenerator: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; if (pXSprite->state != pXSprite->restState) - evPost(nSprite, 3, 0, kCmdRepeat); + evPost(nSprite, 3, 0, kCmdRepeat, -1); return; case kGenTrigger: pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; @@ -4499,7 +4551,7 @@ void InitGenerator(int nSprite) break; } if (pXSprite->state != pXSprite->restState && pXSprite->busyTime > 0) - evPost(nSprite, 3, (120*(pXSprite->busyTime+Random2(pXSprite->data1)))/10, kCmdRepeat); + evPost(nSprite, 3, (120*(pXSprite->busyTime+Random2(pXSprite->data1)))/10, kCmdRepeat, -1); } void ActivateGenerator(int nSprite) @@ -4661,7 +4713,7 @@ void MGunFireSeqCallback(int, int nXSprite) { pXSprite->data2--; if (pXSprite->data2 == 0) - evPost(nSprite, 3, 1, kCmdOff); + evPost(nSprite, 3, 1, kCmdOff, nSprite); } int dx = (Cos(pSprite->ang)>>16)+Random2(1000); int dy = (Sin(pSprite->ang)>>16)+Random2(1000); diff --git a/source/blood/src/triggers.h b/source/blood/src/triggers.h index 1e493a340..57d2d378a 100644 --- a/source/blood/src/triggers.h +++ b/source/blood/src/triggers.h @@ -35,7 +35,7 @@ void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command); void trMessageSector(unsigned int nSector, EVENT event); void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command); void trMessageWall(unsigned int nWall, EVENT event); -void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command); +void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command, int causedBy); void trMessageSprite(unsigned int nSprite, EVENT event); void trProcessBusy(void); void trInit(void); diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 9df6d49a5..af2f6916f 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -259,7 +259,7 @@ void viewInitializePrediction(void) predict.at24 = gMe->q16horiz; predict.at28 = gMe->q16slopehoriz; predict.at2c = gMe->slope; - predict.at6f = gMe->canJump; + predict.at6f = gMe->cantJump; predict.at70 = gMe->isRunning; predict.at72 = gMe->isUnderwater; predict.at71 = gMe->input.buttonFlags.jump; @@ -1532,7 +1532,7 @@ void UpdateStatusBar(ClockTicks arg) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) { - int num = pPlayer->ammCount[pPlayer->weaponAmmo]; + int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; if (pPlayer->weaponAmmo == 6) num /= 10; if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles) @@ -1570,7 +1570,7 @@ void UpdateStatusBar(ClockTicks arg) } if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) { - int num = pPlayer->ammCount[pPlayer->weaponAmmo]; + int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; if (pPlayer->weaponAmmo == 6) num /= 10; DrawStatNumber("%3d", num, 2240, 42, 183, 0, 0, 256); @@ -1629,7 +1629,7 @@ void UpdateStatusBar(ClockTicks arg) } if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) { - int num = pPlayer->ammCount[pPlayer->weaponAmmo]; + int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; if (pPlayer->weaponAmmo == 6) num /= 10; DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0); @@ -1638,7 +1638,7 @@ void UpdateStatusBar(ClockTicks arg) { int x = 135+((i-1)/3)*23; int y = 182+((i-1)%3)*6; - int num = pPlayer->ammCount[i]; + int num = pPlayer->ammoCount[i]; if (i == 6) num /= 10; if (i == pPlayer->weaponAmmo) @@ -1653,20 +1653,20 @@ void UpdateStatusBar(ClockTicks arg) if (pPlayer->weaponAmmo == 10) { - DrawStatNumber("%2d", pPlayer->ammCount[10], 2230, 291, 194, -128, 10); + DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, -128, 10); } else { - DrawStatNumber("%2d", pPlayer->ammCount[10], 2230, 291, 194, 32, 10); + DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, 32, 10); } if (pPlayer->weaponAmmo == 11) { - DrawStatNumber("%2d", pPlayer->ammCount[11], 2230, 309, 194, -128, 10); + DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, -128, 10); } else { - DrawStatNumber("%2d", pPlayer->ammCount[11], 2230, 309, 194, 32, 10); + DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, 32, 10); } if (pPlayer->armor[1]) diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index fa6d66846..088f77828 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -174,7 +174,7 @@ char sub_4B1FC(PLAYER *pPlayer, int a2, int a3, int a4) return 1; if (a2 == 9 && pPlayer->pXSprite->health > 0) return 1; - return pPlayer->ammCount[a3] >= a4; + return pPlayer->ammoCount[a3] >= a4; } char CheckAmmo(PLAYER *pPlayer, int a2, int a3) @@ -187,7 +187,7 @@ char CheckAmmo(PLAYER *pPlayer, int a2, int a3) return 1; if (pPlayer->curWeapon == 9 && pPlayer->pXSprite->health >= (a3<<4)) return 1; - return pPlayer->ammCount[a2] >= a3; + return pPlayer->ammoCount[a2] >= a3; } char sub_4B2C8(PLAYER *pPlayer, int a2, int a3) @@ -196,7 +196,7 @@ char sub_4B2C8(PLAYER *pPlayer, int a2, int a3) return 1; if (a2 == -1) return 1; - return pPlayer->ammCount[a2] >= a3; + return pPlayer->ammoCount[a2] >= a3; } void SpawnBulletEject(PLAYER *pPlayer, int a2, int a3) @@ -518,24 +518,24 @@ void WeaponRaise(PLAYER *pPlayer) case 3: // sawed off if (powerupCheck(pPlayer, kPwUpTwoGuns)) { - if (gInfiniteAmmo || pPlayer->ammCount[2] >= 4) + if (gInfiniteAmmo || pPlayer->ammoCount[2] >= 4) StartQAV(pPlayer, 59, -1, 0); else StartQAV(pPlayer, 50, -1, 0); - if (gInfiniteAmmo || pPlayer->ammCount[2] >= 4) + if (gInfiniteAmmo || pPlayer->ammoCount[2] >= 4) pPlayer->weaponState = 7; - else if (pPlayer->ammCount[2] > 1) + else if (pPlayer->ammoCount[2] > 1) pPlayer->weaponState = 3; - else if (pPlayer->ammCount[2] > 0) + else if (pPlayer->ammoCount[2] > 0) pPlayer->weaponState = 2; else pPlayer->weaponState = 1; } else { - if (gInfiniteAmmo || pPlayer->ammCount[2] > 1) + if (gInfiniteAmmo || pPlayer->ammoCount[2] > 1) pPlayer->weaponState = 3; - else if (pPlayer->ammCount[2] > 0) + else if (pPlayer->ammoCount[2] > 0) pPlayer->weaponState = 2; else pPlayer->weaponState = 1; @@ -815,7 +815,7 @@ void WeaponUpdateState(PLAYER *pPlayer) StartQAV(pPlayer, 5, -1, 0); break; case 2: - if (pPlayer->ammCount[5] > 0) + if (pPlayer->ammoCount[5] > 0) { pPlayer->weaponState = 3; StartQAV(pPlayer, 16, -1, 0); @@ -850,7 +850,7 @@ void WeaponUpdateState(PLAYER *pPlayer) pPlayer->weaponQav = 37; break; case 12: - if (pPlayer->ammCount[11] > 0) + if (pPlayer->ammoCount[11] > 0) { pPlayer->weaponState = 10; StartQAV(pPlayer, 31, -1, 0); @@ -877,7 +877,7 @@ void WeaponUpdateState(PLAYER *pPlayer) { sfxPlay3DSound(pPlayer->pSprite, 410, 3, 2); StartQAV(pPlayer, 57, nClientEjectShell, 0); - if (gInfiniteAmmo || pPlayer->ammCount[2] > 1) + if (gInfiniteAmmo || pPlayer->ammoCount[2] > 1) pPlayer->weaponState = 3; else pPlayer->weaponState = 2; @@ -1397,7 +1397,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) // by NoOne: trying to simulate v1.0x voodoo here. // dunno how exactly it works, but at least it not spend all the ammo on alt fire if (gGameOptions.weaponsV10x && !VanillaMode() && !DemoRecordStatus()) { - int nCount = ClipHigh(pPlayer->ammCount[9], pPlayer->aimTargetsCount); + int nCount = ClipHigh(pPlayer->ammoCount[9], pPlayer->aimTargetsCount); if (nCount > 0) { for (int i = 0; i < pPlayer->aimTargetsCount; i++) @@ -1409,8 +1409,8 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) int nDist = approxDist(pTarget->x - pPlayer->pSprite->x, pTarget->y - pPlayer->pSprite->y); if (nDist > 0 && nDist < 51200) { - int vc = pPlayer->ammCount[9] >> 3; - int v8 = pPlayer->ammCount[9] << 1; + int vc = pPlayer->ammoCount[9] >> 3; + int v8 = pPlayer->ammoCount[9] << 1; int nDamage = (v8 + Random(vc)) << 4; nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200; nDamage = actDamageSprite(pPlayer->nSprite, pTarget, DAMAGE_TYPE_5, nDamage); @@ -1432,10 +1432,10 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) } //int nAmmo = pPlayer->ammCount[9]; - int nCount = ClipHigh(pPlayer->ammCount[9], pPlayer->aimTargetsCount); + int nCount = ClipHigh(pPlayer->ammoCount[9], pPlayer->aimTargetsCount); if (nCount > 0) { - int v4 = pPlayer->ammCount[9] - (pPlayer->ammCount[9] / nCount) * nCount; + int v4 = pPlayer->ammoCount[9] - (pPlayer->ammoCount[9] / nCount) * nCount; for (int i = 0; i < pPlayer->aimTargetsCount; i++) { int nTarget = pPlayer->aimTargets[i]; @@ -1447,8 +1447,8 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) int nDist = approxDist(pTarget->x - pPlayer->pSprite->x, pTarget->y - pPlayer->pSprite->y); if (nDist > 0 && nDist < 51200) { - int vc = pPlayer->ammCount[9] >> 3; - int v8 = pPlayer->ammCount[9] << 1; + int vc = pPlayer->ammoCount[9] >> 3; + int v8 = pPlayer->ammoCount[9] << 1; int nDamage = (v8 + Random2(vc)) << 4; nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200; nDamage = actDamageSprite(pPlayer->nSprite, pTarget, DAMAGE_TYPE_5, nDamage); @@ -1463,7 +1463,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) } } } - UseAmmo(pPlayer, 9, pPlayer->ammCount[9]); + UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]); pPlayer->hasWeapon[10] = 0; pPlayer->weaponState = -1; } @@ -1478,10 +1478,10 @@ void DropVoodoo(int nTrigger, PLAYER *pPlayer) { int nXSprite = pSprite->extra; XSPRITE *pXSprite = &xsprite[nXSprite]; - pXSprite->data1 = pPlayer->ammCount[9]; + pXSprite->data1 = pPlayer->ammoCount[9]; evPost(pSprite->index, 3, 90, kCallbackDropVoodoo); UseAmmo(pPlayer, 6, gAmmoItemData[0].count); - UseAmmo(pPlayer, 9, pPlayer->ammCount[9]); + UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]); pPlayer->hasWeapon[10] = 0; } } @@ -1581,7 +1581,7 @@ void AltFireNapalm(int nTrigger, PLAYER *pPlayer) if (pMissile) { XSPRITE *pXSprite = &xsprite[pMissile->extra]; - pXSprite->data4 = ClipHigh(pPlayer->ammCount[4], 12); + pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12); UseAmmo(pPlayer, 4, pXSprite->data4); seqSpawn(22, 3, pMissile->extra, -1); actBurnSprite(actSpriteIdToOwnerId(pPlayer->pSprite->index), pXSprite, 600); @@ -1625,12 +1625,12 @@ void AltFireLifeLeech(int nTrigger, PLAYER *pPlayer) pXSprite->Push = 1; pXSprite->Proximity = 1; pXSprite->DudeLockout = 1; - pXSprite->data4 = ClipHigh(pPlayer->ammCount[4], 12); + pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12); pXSprite->stateTimer = 1; evPost(pMissile->index, 3, 120, kCallbackLeechStateTimer); if (gGameOptions.nGameType <= 1) { - int nAmmo = pPlayer->ammCount[8]; + int nAmmo = pPlayer->ammoCount[8]; if (nAmmo < 25 && pPlayer->pXSprite->health > ((25-nAmmo)<<4)) { actDamageSprite(pPlayer->nSprite, pPlayer->pSprite, DAMAGE_TYPE_5, ((25-nAmmo)<<4)); @@ -1641,8 +1641,8 @@ void AltFireLifeLeech(int nTrigger, PLAYER *pPlayer) } else { - pXSprite->data3 = pPlayer->ammCount[8]; - pPlayer->ammCount[8] = 0; + pXSprite->data3 = pPlayer->ammoCount[8]; + pPlayer->ammoCount[8] = 0; } pPlayer->hasWeapon[9] = 0; } @@ -1924,9 +1924,31 @@ char sub_4F484(PLAYER *pPlayer) return 0; } -void WeaponProcess(PLAYER *pPlayer) -{ - pPlayer->flashEffect = ClipLow(pPlayer->flashEffect-1, 0); +void WeaponProcess(PLAYER *pPlayer) { + + pPlayer->flashEffect = ClipLow(pPlayer->flashEffect - 1, 0); + + if (gQavScene[pPlayer->nPlayer].index >= 0) { + + int nIndex = gQavScene[pPlayer->nPlayer].index; + if (sprite[nIndex].extra >= 0 && pPlayer->pXSprite->health > 0) { + XSPRITE* pXSprite = &xsprite[sprite[nIndex].extra]; + //viewSetSystemMessage("%d", pXSprite->sysData1); + if (pXSprite->waitTime > 0 && --pXSprite->sysData1 <= 0) { + evSend(nIndex, 3, pXSprite->txID, (COMMAND_ID)pXSprite->command, pPlayer->nSprite); + evPost(nIndex, 3, 0, kCmdOff, pPlayer->nSprite); + } else { + playQavScene(pPlayer); + pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= 4, 0); + } + } else { + gQavScene[pPlayer->nPlayer].index = -1; + gQavScene[pPlayer->nPlayer].qavId = NULL; + } + + return; + } + if (pPlayer->pXSprite->health == 0) { pPlayer->qavLoop = 0; @@ -2321,7 +2343,7 @@ void WeaponProcess(PLAYER *pPlayer) StartQAV(pPlayer, 38, nClientDropRemote, 0); return; case 11: - if (pPlayer->ammCount[11] > 0) + if (pPlayer->ammoCount[11] > 0) { pPlayer->weaponState = 10; StartQAV(pPlayer, 30, -1, 0); @@ -2346,7 +2368,7 @@ void WeaponProcess(PLAYER *pPlayer) StartQAV(pPlayer, 38, nClientDropRemote, 0); return; case 11: - if (pPlayer->ammCount[11] > 0) + if (pPlayer->ammoCount[11] > 0) { pPlayer->weaponState = 10; StartQAV(pPlayer, 30, -1, 0); diff --git a/source/blood/src/weapon.h b/source/blood/src/weapon.h index 17b39e937..147261900 100644 --- a/source/blood/src/weapon.h +++ b/source/blood/src/weapon.h @@ -37,6 +37,7 @@ void WeaponRaise(PLAYER *pPlayer); void WeaponLower(PLAYER *pPlayer); char WeaponUpgrade(PLAYER *pPlayer, char newWeapon); void WeaponProcess(PLAYER *pPlayer); +void WeaponUpdateState(PLAYER* pPlayer); void sub_51340(spritetype *pMissile, int a2); void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0); END_BLD_NS