Refactor: xsector, xwall and xsprite structs

- Added QAV scene player (playing user animation instead of weapon)
- Added trigger event intiator for sprites (WIP and experimental)

# Conflicts:
#	source/blood/src/actor.h
#	source/blood/src/player.h
This commit is contained in:
Grind Core 2019-10-25 23:53:41 +03:00 committed by Christoph Oelckers
parent 1c29169492
commit b6ad64ee54
20 changed files with 689 additions and 599 deletions

View file

@ -2430,9 +2430,9 @@ void DudeToGibCallback1(int, int);
void DudeToGibCallback2(int, int); void DudeToGibCallback2(int, int);
int nFireballClient = seqRegisterClient(FireballSeqCallback); int nFireballClient = seqRegisterClient(FireballSeqCallback);
int dword_2192D8 = seqRegisterClient(sub_38938); int dword_2192D8 = seqRegisterClient(sub_38938); // fireball smoke
int nNapalmClient = seqRegisterClient(NapalmSeqCallback); int nNapalmClient = seqRegisterClient(NapalmSeqCallback);
int dword_2192E0 = seqRegisterClient(sub_3888C); int dword_2192E0 = seqRegisterClient(sub_3888C); // flame lick
int nTreeToGibClient = seqRegisterClient(TreeToGibCallback); int nTreeToGibClient = seqRegisterClient(TreeToGibCallback);
int nDudeToGibClient1 = seqRegisterClient(DudeToGibCallback1); int nDudeToGibClient1 = seqRegisterClient(DudeToGibCallback1);
int nDudeToGibClient2 = seqRegisterClient(DudeToGibCallback2); 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 gPhysSpritesList[]; // by NoOne: list of additional sprites which can be affected by physics
short gPhysSpritesCount; // current count short gPhysSpritesCount; // current count
short gQavPlayerIndex = -1; // by NoOne: index of sprite which currently activated to play qav short gQavPlayerIndex = -1; // by NoOne: index of sprite which currently activated to play qav
void actInit(bool bSaveLoad) { void actInit(bool bSaveLoad) {
@ -2551,7 +2552,10 @@ void actInit(bool bSaveLoad) {
gProxySpritesCount = gSightSpritesCount = gPhysSpritesCount = 0; gProxySpritesCount = gSightSpritesCount = gPhysSpritesCount = 0;
// reset qav player index // 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 // fill arrays with negative values to avoid xvel 0 situation
memset(gSightSpritesList, -1, sizeof(gSightSpritesList)); memset(gSightSpritesList, -1, sizeof(gSightSpritesList));
@ -3217,7 +3221,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType,
gPlayer[p].fraggerId = -1; gPlayer[p].fraggerId = -1;
} }
if (pSprite->type != kDudeCultistBeast) if (pSprite->type != kDudeCultistBeast)
trTriggerSprite(pSprite->index, pXSprite, kCmdOff); trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nKillerSprite);
pSprite->flags |= 7; pSprite->flags |= 7;
if (VanillaMode()) { if (VanillaMode()) {
@ -3733,7 +3737,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in
break; break;
} }
trTriggerSprite(pSprite->index, pXSprite, kCmdOff); trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nSource);
switch (pSprite->type) { switch (pSprite->type) {
case kThingObjectGib: case kThingObjectGib:
@ -4351,8 +4355,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
break; break;
} }
nHitSprite = pSpriteHit->florhit & 0x3fff; nHitSprite = pSpriteHit->florhit & 0x3fff;
switch (pSpriteHit->florhit&0xc000) switch (pSpriteHit->florhit & 0xc000) {
{
case 0x8000: case 0x8000:
break; break;
case 0x4000: case 0x4000:
@ -4487,7 +4490,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
if (nHSprite >= 0 && sprite[nHSprite].extra >= 0) { if (nHSprite >= 0 && sprite[nHSprite].extra >= 0) {
XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra]; XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra];
if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite))) if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite)))
trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch); trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch, nSprite);
} }
// Touch walls // 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 // by NoOne: do not check state (so, things can work with touch too) and allow dudelockout
if ((gModernMap) && (!pHitXSprite->DudeLockout || IsPlayerSprite(pSprite))) if ((gModernMap) && (!pHitXSprite->DudeLockout || IsPlayerSprite(pSprite)))
trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch); trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch, nSprite);
else if (!pHitXSprite->state) // or check like vanilla do 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) 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; break;
} }
@ -4804,7 +4807,7 @@ void MoveDude(spritetype *pSprite)
XSECTOR *pHitXSector = NULL; XSECTOR *pHitXSector = NULL;
if (pHitSector->extra > 0) if (pHitSector->extra > 0)
pHitXSector = &xsector[pHitSector->extra]; 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); trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush);
if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) if (top < pHitSector->ceilingz || bottom > pHitSector->floorz)
{ {
@ -4830,13 +4833,13 @@ void MoveDude(spritetype *pSprite)
pXSector = &xsector[nXSector]; pXSector = &xsector[nXSector];
else else
pXSector = NULL; pXSector = NULL;
if (pXSector && pXSector->Exit && (pPlayer || !pXSector->at37_7)) if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout))
trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit); trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit);
ChangeSpriteSect(nSprite, nSector); ChangeSpriteSect(nSprite, nSector);
nXSector = sector[nSector].extra; nXSector = sector[nSector].extra;
pXSector = (nXSector > 0) ? pXSector = &xsector[nXSector] : NULL; 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) if (sector[nSector].type == kSectorTeleport)
pXSector->data = pPlayer ? nSprite : -1; pXSector->data = pPlayer ? nSprite : -1;
@ -4934,9 +4937,9 @@ void MoveDude(spritetype *pSprite)
if (pPlayer) { if (pPlayer) {
pPlayer->posture = 0; pPlayer->posture = 0;
pPlayer->bubbleTime = 0; pPlayer->bubbleTime = 0;
if (!pPlayer->canJump && pPlayer->input.buttonFlags.jump) { if (!pPlayer->cantJump && pPlayer->input.buttonFlags.jump) {
zvel[nSprite] = -0x6aaaa; zvel[nSprite] = -0x6aaaa;
pPlayer->canJump = 1; pPlayer->cantJump = 1;
} }
sfxPlay3DSound(pSprite, 721, -1, 0); sfxPlay3DSound(pSprite, 721, -1, 0);
} else { } else {
@ -5607,7 +5610,7 @@ void actProcessSprites(void)
if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue; if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue;
else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) { else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) {
trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity); trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, nAffected);
break; break;
} }
} }
@ -5616,7 +5619,7 @@ void actProcessSprites(void)
for (int a = connecthead; a >= 0; a = connectpoint2[a]) { for (int a = connecthead; a >= 0; a = connectpoint2[a]) {
if (gPlayer[a].pXSprite->health > 0 && CheckProximity(gPlayer[a].pSprite, x, y, z, sectnum, 96)) { 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; break;
} }
} }
@ -5641,7 +5644,7 @@ void actProcessSprites(void)
for (int a = connecthead; a >= 0; a = connectpoint2[a]) { for (int a = connecthead; a >= 0; a = connectpoint2[a]) {
spritetype* pPlaySprite = gPlayer[a].pSprite; spritetype* pPlaySprite = gPlayer[a].pSprite;
if (gPlayer[a].pXSprite->health > 0 && cansee(x, y, z, sectnum, pPlaySprite->x, pPlaySprite->y, pPlaySprite->z, pPlaySprite->sectnum)) { 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; 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]) for (nSprite = headspritestat[kStatThing]; nSprite >= 0; nSprite = nextspritestat[nSprite])
@ -5803,7 +5792,7 @@ void actProcessSprites(void)
break; break;
} }
if (pSprite->owner == -1) actPropagateSpriteOwner(pSprite, pSprite2); 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]; XSPRITE *pXSprite = &xsprite[nXSprite];
if (pXSprite->Impact) if (pXSprite->Impact)
trTriggerSprite(nSprite, pXSprite, kCmdOff); trTriggerSprite(nSprite, pXSprite, kCmdOff, -1);
switch (pSprite->type) switch (pSprite->type) {
{
case kThingDripWater: case kThingDripWater:
case kThingDripBlood: case kThingDripBlood:
MakeSplash(pSprite, pXSprite); MakeSplash(pSprite, pXSprite);
@ -6168,7 +6156,7 @@ void actProcessSprites(void)
pXIncarnation->triggerOff = false; pXIncarnation->triggerOff = false;
// trigger dude death before transform // trigger dude death before transform
trTriggerSprite(nSprite, pXSprite, kCmdOff); trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner);
pSprite->type = pIncarnation->type; pSprite->type = pIncarnation->type;
@ -6260,7 +6248,7 @@ void actProcessSprites(void)
} else { } else {
// just trigger dude death // 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) if (pSprite2->flags&32)
continue; continue;
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; 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)) if (CheckProximity(pSprite2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128))
{ trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index);
trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity);
}
} }
} }
} }
@ -6989,7 +6974,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
{ {
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE *pXSprite = &xsprite[nXSprite];
if (pXSprite->Vector) if (pXSprite->Vector)
trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact); trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact, nShooter);
} }
if (pSprite->statnum == kStatThing) if (pSprite->statnum == kStatThing)
{ {
@ -7899,8 +7884,9 @@ void debrisMove(int listIndex) {
//actPostSprite(nSprite, kStatThing); // !!!! not working here for some reason //actPostSprite(nSprite, kStatThing); // !!!! not working here for some reason
changespritestat(nSprite, kStatThing); 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);
} }
} }

View file

@ -180,6 +180,7 @@ struct SPRITEMASS {
int fraction; // mainly needs for moving debris int fraction; // mainly needs for moving debris
}; };
extern AMMOITEMDATA gAmmoItemData[]; extern AMMOITEMDATA gAmmoItemData[];
extern WEAPONITEMDATA gWeaponItemData[]; extern WEAPONITEMDATA gWeaponItemData[];
extern ITEMDATA gItemData[]; extern ITEMDATA gItemData[];
@ -287,6 +288,4 @@ extern short gPhysSpritesList[kMaxSuperXSprites];
extern short gProxySpritesCount; extern short gProxySpritesCount;
extern short gSightSpritesCount; extern short gSightSpritesCount;
extern short gPhysSpritesCount; extern short gPhysSpritesCount;
extern short gQavPlayerIndex; //extern short gQavPlayerIndex;
END_BLD_NS

View file

@ -596,6 +596,12 @@ void StartLevel(GAMEOPTIONS *gameOptions)
break; 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 { } else {
switch (pSprite->type) { switch (pSprite->type) {

View file

@ -486,13 +486,13 @@ void returnFlagToBase(int nSprite) // 17
XSPRITE* pXOwner = &xsprite[pOwner->extra]; XSPRITE* pXOwner = &xsprite[pOwner->extra];
switch (pSprite->type) { switch (pSprite->type) {
case kItemFlagA: case kItemFlagA:
trTriggerSprite(pOwner->index, pXOwner, kCmdOn); trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index);
sndStartSample(8003, 255, 2, 0); sndStartSample(8003, 255, 2, 0);
gBlueFlagDropped = false; gBlueFlagDropped = false;
viewSetMessage("Blue Flag returned to base."); viewSetMessage("Blue Flag returned to base.");
break; break;
case kItemFlagB: case kItemFlagB:
trTriggerSprite(pOwner->index, pXOwner, kCmdOn); trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index);
sndStartSample(8002, 255, 2, 0); sndStartSample(8002, 255, 2, 0);
gRedFlagDropped = false; gRedFlagDropped = false;
viewSetMessage("Red Flag returned to base."); viewSetMessage("Red Flag returned to base.");

View file

@ -51,7 +51,7 @@ enum CALLBACK_ID {
kCallbackDropVoodoo = 21, // unused kCallbackDropVoodoo = 21, // unused
kCallbackMissileBurst = 22, // by NoOne kCallbackMissileBurst = 22, // by NoOne
kCallbackMissileSpriteBlock = 23, // by NoOne kCallbackMissileSpriteBlock = 23, // by NoOne
kCallbackMax = 24, kCallbackMax,
}; };
extern void (*gCallback[kCallbackMax])(int); extern void (*gCallback[kCallbackMax])(int);

View file

@ -189,7 +189,7 @@ enum {
kModernEffectSpawner = 38, kModernEffectSpawner = 38,
kModernWindGenerator = 39, kModernWindGenerator = 39,
kModernConcussSprite = 712, /// WIP kModernConcussSprite = 712, /// WIP
kModernPlayerControl = 713, /// WIP kModernPlayerControl = 500, /// WIP
// decorations // decorations
kDecorationTorch = 30, kDecorationTorch = 30,

View file

@ -906,20 +906,20 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
pXSector->busy = bitReader.readUnsigned(17); pXSector->busy = bitReader.readUnsigned(17);
pXSector->data = bitReader.readUnsigned(16); pXSector->data = bitReader.readUnsigned(16);
pXSector->txID = bitReader.readUnsigned(10); pXSector->txID = bitReader.readUnsigned(10);
pXSector->at7_2 = bitReader.readUnsigned(3); pXSector->busyWaveA = bitReader.readUnsigned(3);
pXSector->at7_5 = bitReader.readUnsigned(3); pXSector->busyWaveB = bitReader.readUnsigned(3);
pXSector->rxID = bitReader.readUnsigned(10); pXSector->rxID = bitReader.readUnsigned(10);
pXSector->command = bitReader.readUnsigned(8); pXSector->command = bitReader.readUnsigned(8);
pXSector->triggerOn = bitReader.readUnsigned(1); pXSector->triggerOn = bitReader.readUnsigned(1);
pXSector->triggerOff = bitReader.readUnsigned(1); pXSector->triggerOff = bitReader.readUnsigned(1);
pXSector->busyTimeA = bitReader.readUnsigned(12); pXSector->busyTimeA = bitReader.readUnsigned(12);
pXSector->waitTimeA = 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->interruptable = bitReader.readUnsigned(1);
pXSector->amplitude = bitReader.readSigned(8); pXSector->amplitude = bitReader.readSigned(8);
pXSector->freq = bitReader.readUnsigned(8); pXSector->freq = bitReader.readUnsigned(8);
pXSector->atf_6 = bitReader.readUnsigned(1); pXSector->reTriggerA = bitReader.readUnsigned(1);
pXSector->atf_7 = bitReader.readUnsigned(1); pXSector->reTriggerB = bitReader.readUnsigned(1);
pXSector->phase = bitReader.readUnsigned(8); pXSector->phase = bitReader.readUnsigned(8);
pXSector->wave = bitReader.readUnsigned(4); pXSector->wave = bitReader.readUnsigned(4);
pXSector->shadeAlways = bitReader.readUnsigned(1); 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->Depth = bitReader.readUnsigned(3);
pXSector->panVel = bitReader.readUnsigned(8); pXSector->panVel = bitReader.readUnsigned(8);
pXSector->panAngle = bitReader.readUnsigned(11); pXSector->panAngle = bitReader.readUnsigned(11);
pXSector->at16_3 = bitReader.readUnsigned(1); pXSector->unused1 = bitReader.readUnsigned(1);
pXSector->decoupled = bitReader.readUnsigned(1); pXSector->decoupled = bitReader.readUnsigned(1);
pXSector->triggerOnce = bitReader.readUnsigned(1); pXSector->triggerOnce = bitReader.readUnsigned(1);
pXSector->isTriggered = 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->Exit = bitReader.readUnsigned(1);
pXSector->Wallpush = bitReader.readUnsigned(1); pXSector->Wallpush = bitReader.readUnsigned(1);
pXSector->color = 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->busyTimeB = bitReader.readUnsigned(12);
pXSector->waitTimeB = bitReader.readUnsigned(12); pXSector->waitTimeB = bitReader.readUnsigned(12);
pXSector->stopOn = bitReader.readUnsigned(1); pXSector->stopOn = bitReader.readUnsigned(1);
pXSector->stopOff = bitReader.readUnsigned(1); pXSector->stopOff = bitReader.readUnsigned(1);
pXSector->ceilpal = bitReader.readUnsigned(4); pXSector->ceilpal = bitReader.readUnsigned(4);
pXSector->at1c_0 = bitReader.readSigned(32); pXSector->offCeilZ = bitReader.readSigned(32);
pXSector->at20_0 = bitReader.readSigned(32); pXSector->onCeilZ = bitReader.readSigned(32);
pXSector->at24_0 = bitReader.readSigned(32); pXSector->offFloorZ = bitReader.readSigned(32);
pXSector->at28_0 = bitReader.readSigned(32); pXSector->onFloorZ = bitReader.readSigned(32);
pXSector->marker0 = bitReader.readUnsigned(16); pXSector->marker0 = bitReader.readUnsigned(16);
pXSector->marker1 = bitReader.readUnsigned(16); pXSector->marker1 = bitReader.readUnsigned(16);
pXSector->Crush = bitReader.readUnsigned(1); pXSector->Crush = bitReader.readUnsigned(1);
pXSector->at30_1 = bitReader.readUnsigned(8); pXSector->ceilXPanFrac = bitReader.readUnsigned(8);
pXSector->at31_1 = bitReader.readUnsigned(8); pXSector->ceilYPanFrac = bitReader.readUnsigned(8);
pXSector->at32_1 = bitReader.readUnsigned(8); pXSector->floorXPanFrac = bitReader.readUnsigned(8);
pXSector->damageType = bitReader.readUnsigned(3); pXSector->damageType = bitReader.readUnsigned(3);
pXSector->floorpal = bitReader.readUnsigned(4); pXSector->floorpal = bitReader.readUnsigned(4);
pXSector->at34_0 = bitReader.readUnsigned(8); pXSector->floorYPanFrac = bitReader.readUnsigned(8);
pXSector->locked = bitReader.readUnsigned(1); pXSector->locked = bitReader.readUnsigned(1);
pXSector->windVel = bitReader.readUnsigned(10); pXSector->windVel = bitReader.readUnsigned(10);
pXSector->windAng = bitReader.readUnsigned(11); pXSector->windAng = bitReader.readUnsigned(11);
pXSector->windAlways = bitReader.readUnsigned(1); pXSector->windAlways = bitReader.readUnsigned(1);
pXSector->at37_7 = bitReader.readUnsigned(1); pXSector->dudeLockout = bitReader.readUnsigned(1);
pXSector->bobTheta = bitReader.readUnsigned(11); pXSector->bobTheta = bitReader.readUnsigned(11);
pXSector->bobZRange = bitReader.readUnsigned(5); pXSector->bobZRange = bitReader.readUnsigned(5);
pXSector->bobSpeed = bitReader.readSigned(12); 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->busy = bitReader.readUnsigned(17);
pXWall->data = bitReader.readSigned(16); pXWall->data = bitReader.readSigned(16);
pXWall->txID = bitReader.readUnsigned(10); pXWall->txID = bitReader.readUnsigned(10);
pXWall->at7_2 = bitReader.readUnsigned(6); pXWall->unused1 = bitReader.readUnsigned(6);
pXWall->rxID = bitReader.readUnsigned(10); pXWall->rxID = bitReader.readUnsigned(10);
pXWall->command = bitReader.readUnsigned(8); pXWall->command = bitReader.readUnsigned(8);
pXWall->triggerOn = bitReader.readUnsigned(1); 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->triggerPush = bitReader.readUnsigned(1);
pXWall->triggerVector = bitReader.readUnsigned(1); pXWall->triggerVector = bitReader.readUnsigned(1);
pXWall->triggerTouch = 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->xpanFrac = bitReader.readUnsigned(8);
pXWall->ypanFrac = bitReader.readUnsigned(8); pXWall->ypanFrac = bitReader.readUnsigned(8);
pXWall->locked = bitReader.readUnsigned(1); pXWall->locked = bitReader.readUnsigned(1);
pXWall->dudeLockout = bitReader.readUnsigned(1); pXWall->dudeLockout = bitReader.readUnsigned(1);
pXWall->at13_4 = bitReader.readUnsigned(4); pXWall->unused3 = bitReader.readUnsigned(4);
pXWall->at14_0 = bitReader.readUnsigned(32); pXWall->unused4 = bitReader.readUnsigned(32);
xwall[wall[i].extra].reference = i; xwall[wall[i].extra].reference = i;
xwall[wall[i].extra].busy = xwall[wall[i].extra].state << 16; 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->waitTime = bitReader.readUnsigned(12);
pXSprite->restState = bitReader.readUnsigned(1); pXSprite->restState = bitReader.readUnsigned(1);
pXSprite->Interrutable = 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->respawnPending = bitReader.readUnsigned(2);
pXSprite->atb_6 = bitReader.readUnsigned(1); pXSprite->unused2 = bitReader.readUnsigned(1);
pXSprite->lT = bitReader.readUnsigned(1); pXSprite->lT = bitReader.readUnsigned(1);
pXSprite->dropMsg = bitReader.readUnsigned(8); pXSprite->dropMsg = bitReader.readUnsigned(8);
pXSprite->Decoupled = bitReader.readUnsigned(1); 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->Touch = bitReader.readUnsigned(1);
pXSprite->Sight = bitReader.readUnsigned(1); pXSprite->Sight = bitReader.readUnsigned(1);
pXSprite->Proximity = 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->lSkill = bitReader.readUnsigned(5);
pXSprite->lS = bitReader.readUnsigned(1); pXSprite->lS = bitReader.readUnsigned(1);
pXSprite->lB = 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->medium = bitReader.readUnsigned(2);
pXSprite->respawn = bitReader.readUnsigned(2); pXSprite->respawn = bitReader.readUnsigned(2);
pXSprite->data4 = bitReader.readUnsigned(16); pXSprite->data4 = bitReader.readUnsigned(16);
pXSprite->at1a_2 = bitReader.readUnsigned(6); pXSprite->unused4 = bitReader.readUnsigned(6);
pXSprite->lockMsg = bitReader.readUnsigned(8); pXSprite->lockMsg = bitReader.readUnsigned(8);
pXSprite->health = bitReader.readUnsigned(12); pXSprite->health = bitReader.readUnsigned(12);
pXSprite->dudeDeaf = bitReader.readUnsigned(1); 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; pXSector->busyTimeB = pXSector->busyTimeA;
if (pXSector->busyTimeA > 0) if (pXSector->busyTimeA > 0)
{ {
if (!pXSector->atd_4) if (!pXSector->restState)
{ {
pXSector->atf_6 = 1; pXSector->reTriggerA = 1;
} }
else else
{ {
pXSector->waitTimeB = pXSector->busyTimeA; pXSector->waitTimeB = pXSector->busyTimeA;
pXSector->waitTimeA = 0; 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->busy, 17);
bitWriter.write(pXSector->data, 16); bitWriter.write(pXSector->data, 16);
bitWriter.write(pXSector->txID, 10); bitWriter.write(pXSector->txID, 10);
bitWriter.write(pXSector->at7_2, 3); bitWriter.write(pXSector->busyWaveA, 3);
bitWriter.write(pXSector->at7_5, 3); bitWriter.write(pXSector->busyWaveB, 3);
bitWriter.write(pXSector->rxID, 10); bitWriter.write(pXSector->rxID, 10);
bitWriter.write(pXSector->command, 8); bitWriter.write(pXSector->command, 8);
bitWriter.write(pXSector->triggerOn, 1); bitWriter.write(pXSector->triggerOn, 1);
bitWriter.write(pXSector->triggerOff, 1); bitWriter.write(pXSector->triggerOff, 1);
bitWriter.write(pXSector->busyTimeA, 12); bitWriter.write(pXSector->busyTimeA, 12);
bitWriter.write(pXSector->waitTimeA, 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->interruptable, 1);
bitWriter.write(pXSector->amplitude, 8); bitWriter.write(pXSector->amplitude, 8);
bitWriter.write(pXSector->freq, 8); bitWriter.write(pXSector->freq, 8);
bitWriter.write(pXSector->atf_6, 1); bitWriter.write(pXSector->reTriggerA, 1);
bitWriter.write(pXSector->atf_7, 1); bitWriter.write(pXSector->reTriggerB, 1);
bitWriter.write(pXSector->phase, 8); bitWriter.write(pXSector->phase, 8);
bitWriter.write(pXSector->wave, 4); bitWriter.write(pXSector->wave, 4);
bitWriter.write(pXSector->shadeAlways, 1); 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->Depth, 3);
bitWriter.write(pXSector->panVel, 8); bitWriter.write(pXSector->panVel, 8);
bitWriter.write(pXSector->panAngle, 11); bitWriter.write(pXSector->panAngle, 11);
bitWriter.write(pXSector->at16_3, 1); bitWriter.write(pXSector->unused1, 1);
bitWriter.write(pXSector->decoupled, 1); bitWriter.write(pXSector->decoupled, 1);
bitWriter.write(pXSector->triggerOnce, 1); bitWriter.write(pXSector->triggerOnce, 1);
bitWriter.write(pXSector->isTriggered, 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->Exit, 1);
bitWriter.write(pXSector->Wallpush, 1); bitWriter.write(pXSector->Wallpush, 1);
bitWriter.write(pXSector->color, 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->busyTimeB, 12);
bitWriter.write(pXSector->waitTimeB, 12); bitWriter.write(pXSector->waitTimeB, 12);
bitWriter.write(pXSector->stopOn, 1); bitWriter.write(pXSector->stopOn, 1);
bitWriter.write(pXSector->stopOff, 1); bitWriter.write(pXSector->stopOff, 1);
bitWriter.write(pXSector->ceilpal, 4); bitWriter.write(pXSector->ceilpal, 4);
bitWriter.write(pXSector->at1c_0, 32); bitWriter.write(pXSector->offCeilZ, 32);
bitWriter.write(pXSector->at20_0, 32); bitWriter.write(pXSector->onCeilZ, 32);
bitWriter.write(pXSector->at24_0, 32); bitWriter.write(pXSector->offFloorZ, 32);
bitWriter.write(pXSector->at28_0, 32); bitWriter.write(pXSector->onFloorZ, 32);
bitWriter.write(pXSector->marker0, 16); bitWriter.write(pXSector->marker0, 16);
bitWriter.write(pXSector->marker1, 16); bitWriter.write(pXSector->marker1, 16);
bitWriter.write(pXSector->Crush, 1); bitWriter.write(pXSector->Crush, 1);
bitWriter.write(pXSector->at30_1, 8); bitWriter.write(pXSector->ceilXPanFrac, 8);
bitWriter.write(pXSector->at31_1, 8); bitWriter.write(pXSector->ceilYPanFrac, 8);
bitWriter.write(pXSector->at32_1, 8); bitWriter.write(pXSector->floorXPanFrac, 8);
bitWriter.write(pXSector->damageType, 3); bitWriter.write(pXSector->damageType, 3);
bitWriter.write(pXSector->floorpal, 4); bitWriter.write(pXSector->floorpal, 4);
bitWriter.write(pXSector->at34_0, 8); bitWriter.write(pXSector->floorYPanFrac, 8);
bitWriter.write(pXSector->locked, 1); bitWriter.write(pXSector->locked, 1);
bitWriter.write(pXSector->windVel, 10); bitWriter.write(pXSector->windVel, 10);
bitWriter.write(pXSector->windAng, 11); bitWriter.write(pXSector->windAng, 11);
bitWriter.write(pXSector->windAlways, 1); bitWriter.write(pXSector->windAlways, 1);
bitWriter.write(pXSector->at37_7, 1); bitWriter.write(pXSector->dudeLockout, 1);
bitWriter.write(pXSector->bobTheta, 11); bitWriter.write(pXSector->bobTheta, 11);
bitWriter.write(pXSector->bobZRange, 5); bitWriter.write(pXSector->bobZRange, 5);
bitWriter.write(pXSector->bobSpeed, 12); 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->busy, 17);
bitWriter.write(pXWall->data, 16); bitWriter.write(pXWall->data, 16);
bitWriter.write(pXWall->txID, 10); bitWriter.write(pXWall->txID, 10);
bitWriter.write(pXWall->at7_2, 6); bitWriter.write(pXWall->unused1, 6);
bitWriter.write(pXWall->rxID, 10); bitWriter.write(pXWall->rxID, 10);
bitWriter.write(pXWall->command, 8); bitWriter.write(pXWall->command, 8);
bitWriter.write(pXWall->triggerOn, 1); 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->triggerPush, 1);
bitWriter.write(pXWall->triggerVector, 1); bitWriter.write(pXWall->triggerVector, 1);
bitWriter.write(pXWall->triggerTouch, 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->xpanFrac, 8);
bitWriter.write(pXWall->ypanFrac, 8); bitWriter.write(pXWall->ypanFrac, 8);
bitWriter.write(pXWall->locked, 1); bitWriter.write(pXWall->locked, 1);
bitWriter.write(pXWall->dudeLockout, 1); bitWriter.write(pXWall->dudeLockout, 1);
bitWriter.write(pXWall->at13_4, 4); bitWriter.write(pXWall->unused3, 4);
bitWriter.write(pXWall->at14_0, 32); bitWriter.write(pXWall->unused4, 32);
IOBuffer1.Write(pBuffer, nXWallSize); 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->waitTime, 12);
bitWriter.write(pXSprite->restState, 1); bitWriter.write(pXSprite->restState, 1);
bitWriter.write(pXSprite->Interrutable, 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->respawnPending, 2);
bitWriter.write(pXSprite->atb_6, 1); bitWriter.write(pXSprite->unused2, 1);
bitWriter.write(pXSprite->lT, 1); bitWriter.write(pXSprite->lT, 1);
bitWriter.write(pXSprite->dropMsg, 8); bitWriter.write(pXSprite->dropMsg, 8);
bitWriter.write(pXSprite->Decoupled, 1); 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->Touch, 1);
bitWriter.write(pXSprite->Sight, 1); bitWriter.write(pXSprite->Sight, 1);
bitWriter.write(pXSprite->Proximity, 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->lSkill, 5);
bitWriter.write(pXSprite->lS, 1); bitWriter.write(pXSprite->lS, 1);
bitWriter.write(pXSprite->lB, 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->medium, 2);
bitWriter.write(pXSprite->respawn, 2); bitWriter.write(pXSprite->respawn, 2);
bitWriter.write(pXSprite->data4, 16); bitWriter.write(pXSprite->data4, 16);
bitWriter.write(pXSprite->at1a_2, 6); bitWriter.write(pXSprite->unused4, 6);
bitWriter.write(pXSprite->lockMsg, 8); bitWriter.write(pXSprite->lockMsg, 8);
bitWriter.write(pXSprite->health, 12); bitWriter.write(pXSprite->health, 12);
bitWriter.write(pXSprite->dudeDeaf, 1); bitWriter.write(pXSprite->dudeDeaf, 1);

View file

@ -38,13 +38,12 @@ extern bool gModernMap;
struct AISTATE; struct AISTATE;
struct XSPRITE { struct XSPRITE {
//int isActive; unsigned int unused1 : 2; // unused
unsigned int atb_2 : 2; // unused // unsigned int unused2 : 1; // unused
unsigned int atb_6 : 1; // unused // let's use these to add more data unsigned int unused3 : 2; // unused
unsigned int ate_5 : 2; // unused // fields in the future? must be signed also unsigned int unused4 : 6; // unused
unsigned int at1a_2 : 6; // unused //
signed int reference : 15; // at0_0 signed int reference : 15;
unsigned int state : 1; // State 0 unsigned int state : 1; // State 0
unsigned int busy : 17; unsigned int busy : 17;
unsigned int txID : 10; // TX ID unsigned int txID : 10; // TX ID
@ -87,11 +86,11 @@ struct XSPRITE {
unsigned int medium : 2; // medium unsigned int medium : 2; // medium
unsigned int respawn : 2; // Respawn option unsigned int respawn : 2; // Respawn option
unsigned int lockMsg : 8; // Lock msg unsigned int lockMsg : 8; // Lock msg
unsigned int health : 20; // 1c_0 unsigned int health : 20;
unsigned int dudeDeaf : 1; // dudeDeaf unsigned int dudeDeaf : 1; // dudeDeaf
unsigned int dudeAmbush : 1; // dudeAmbush unsigned int dudeAmbush : 1; // dudeAmbush
unsigned int dudeGuard : 1; // dudeGuard unsigned int dudeGuard : 1; // dudeGuard
unsigned int dudeFlag4 : 1; // DF reserved unsigned int dudeFlag4 : 1; // unused
signed int target : 16; // target sprite signed int target : 16; // target sprite
signed int targetX : 32; // target x signed int targetX : 32; // target x
signed int targetY : 32; // target y signed int targetY : 32; // target y
@ -115,19 +114,19 @@ struct XSECTOR {
unsigned int data : 16; // Data unsigned int data : 16; // Data
unsigned int txID : 10; // TX ID unsigned int txID : 10; // TX ID
unsigned int rxID : 10; // RX ID unsigned int rxID : 10; // RX ID
unsigned int at7_2 : 3; // OFF->ON wave unsigned int busyWaveA : 3; // OFF->ON wave
unsigned int at7_5 : 3; // ON->OFF wave unsigned int busyWaveB : 3; // ON->OFF wave
unsigned int command : 8; // Cmd unsigned int command : 8; // Cmd
unsigned int triggerOn : 1; // Send at ON unsigned int triggerOn : 1; // Send at ON
unsigned int triggerOff : 1; // Send at OFF unsigned int triggerOff : 1; // Send at OFF
unsigned int busyTimeA : 12; // OFF->ON busyTime unsigned int busyTimeA : 12; // OFF->ON busyTime
unsigned int waitTimeA : 12; // OFF->ON waitTime unsigned int waitTimeA : 12; // OFF->ON waitTime
unsigned int atd_4 : 1; unsigned int restState : 1;
unsigned int interruptable : 1; // Interruptable unsigned int interruptable : 1; // Interruptable
unsigned int atf_6 : 1; // OFF->ON wait unsigned int reTriggerA : 1; // OFF->ON wait
unsigned int atf_7 : 1; // ON->OFF wait unsigned int reTriggerB : 1; // ON->OFF wait
signed int amplitude : 8; // Lighting amplitude signed int amplitude : 8; // Lighting amplitude
unsigned int freq : 8; // Lighting freq unsigned int freq : 8; // Lighting freq
unsigned int phase : 8; // Lighting phase unsigned int phase : 8; // Lighting phase
@ -145,7 +144,7 @@ struct XSECTOR {
unsigned int panAngle : 11; // Motion angle unsigned int panAngle : 11; // Motion angle
unsigned int Underwater : 1; // Underwater unsigned int Underwater : 1; // Underwater
unsigned int Depth : 3; // Depth unsigned int Depth : 3; // Depth
unsigned int at16_3 : 1; unsigned int unused1 : 1;
unsigned int decoupled : 1; // Decoupled unsigned int decoupled : 1; // Decoupled
unsigned int triggerOnce : 1; // 1-shot unsigned int triggerOnce : 1; // 1-shot
unsigned int isTriggered : 1; unsigned int isTriggered : 1;
@ -157,30 +156,30 @@ struct XSECTOR {
unsigned int Exit : 1; // Exit unsigned int Exit : 1; // Exit
unsigned int Wallpush : 1; // WallPush unsigned int Wallpush : 1; // WallPush
unsigned int color : 1; // Color Lights unsigned int color : 1; // Color Lights
unsigned int at18_1 : 1; unsigned int unused2 : 1;
unsigned int busyTimeB : 12; // ON->OFF busyTime unsigned int busyTimeB : 12; // ON->OFF busyTime
unsigned int waitTimeB : 12; // ON->OFF waitTime unsigned int waitTimeB : 12; // ON->OFF waitTime
unsigned int stopOn : 1; unsigned int stopOn : 1;
unsigned int stopOff : 1; unsigned int stopOff : 1;
unsigned int ceilpal : 4; // Ceil pal2 unsigned int ceilpal : 4; // Ceil pal2
signed int at1c_0 : 32; signed int offCeilZ : 32;
signed int at20_0 : 32; signed int onCeilZ : 32;
signed int at24_0 : 32; signed int offFloorZ : 32;
signed int at28_0 : 32; signed int onFloorZ : 32;
unsigned int marker0 : 16; unsigned int marker0 : 16;
unsigned int marker1 : 16; unsigned int marker1 : 16;
unsigned int Crush : 1; // Crush unsigned int Crush : 1; // Crush
unsigned int at30_1 : 8; // Ceiling x panning frac unsigned int ceilXPanFrac : 8; // Ceiling x panning frac
unsigned int at31_1 : 8; // Ceiling y panning frac unsigned int ceilYPanFrac : 8; // Ceiling y panning frac
unsigned int at32_1 : 8; // Floor x panning frac unsigned int floorXPanFrac : 8; // Floor x panning frac
unsigned int damageType : 3; // DamageType unsigned int damageType : 3; // DamageType
unsigned int floorpal : 4; // Floor pal2 unsigned int floorpal : 4; // Floor pal2
unsigned int at34_0 : 8; // Floor y panning frac unsigned int floorYPanFrac : 8; // Floor y panning frac
unsigned int locked : 1; // Locked unsigned int locked : 1; // Locked
unsigned int windVel; // Wind vel (by NoOne: changed from 10 bit to use higher velocity values) 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 windAng : 11; // Wind ang
unsigned int windAlways : 1; // Wind always unsigned int windAlways : 1; // Wind always
unsigned int at37_7 : 1; unsigned int dudeLockout : 1;
unsigned int bobTheta : 11; // Motion Theta unsigned int bobTheta : 11; // Motion Theta
unsigned int bobZRange : 5; // Motion Z range unsigned int bobZRange : 5; // Motion Z range
signed int bobSpeed : 12; // Motion speed signed int bobSpeed : 12; // Motion speed
@ -188,7 +187,7 @@ struct XSECTOR {
unsigned int bobFloor : 1; // Motion bob floor unsigned int bobFloor : 1; // Motion bob floor
unsigned int bobCeiling : 1; // Motion bob ceiling unsigned int bobCeiling : 1; // Motion bob ceiling
unsigned int bobRotate : 1; // Motion rotate unsigned int bobRotate : 1; // Motion rotate
}; // 60(0x3c) bytes };
struct XWALL { struct XWALL {
signed int reference : 15; signed int reference : 15;
@ -196,7 +195,7 @@ struct XWALL {
unsigned int busy : 17; unsigned int busy : 17;
signed int data : 16; // Data signed int data : 16; // Data
unsigned int txID : 10; // TX ID unsigned int txID : 10; // TX ID
unsigned int at7_2 : 6; // unused unsigned int unused1 : 6; // unused
unsigned int rxID : 10; // RX ID unsigned int rxID : 10; // RX ID
unsigned int command : 8; // Cmd unsigned int command : 8; // Cmd
unsigned int triggerOn : 1; // going ON unsigned int triggerOn : 1; // going ON
@ -215,14 +214,14 @@ struct XWALL {
unsigned int triggerPush : 1; // Push unsigned int triggerPush : 1; // Push
unsigned int triggerVector : 1; // Vector unsigned int triggerVector : 1; // Vector
unsigned int triggerTouch : 1; // by NoOne: renamed from Reserved to Touch as it works with Touch now. 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 unused2 : 2; // unused
unsigned int xpanFrac : 8; // x panning frac unsigned int xpanFrac : 8; // x panning frac
unsigned int ypanFrac : 8; // y panning frac unsigned int ypanFrac : 8; // y panning frac
unsigned int locked : 1; // Locked unsigned int locked : 1; // Locked
unsigned int dudeLockout : 1; // DudeLockout unsigned int dudeLockout : 1; // DudeLockout
unsigned int at13_4 : 4; // unused; unsigned int unused3 : 4; // unused;
unsigned int at14_0 : 32; // unused unsigned int unused4 : 32; // unused
}; // 24(0x18) bytes };
struct MAPSIGNATURE { struct MAPSIGNATURE {
char signature[4]; char signature[4];

View file

@ -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)); }); PQueue->Kill([=](EVENT nItem)->bool {return !memcmp(&nItem, &evn, sizeof(EVENT)); });
} }
//struct RXBUCKET RXBUCKET rxBucket[kChannelMax+1];
//{
// unsigned int at0_0 : 13;
// unsigned int at1_5 : 3;
//};
RXBUCKET rxBucket[kMaxChannels+1];
int GetBucketChannel(const RXBUCKET *pRX) int GetBucketChannel(const RXBUCKET *pRX)
{ {
@ -280,7 +274,7 @@ void evInit(void)
ThrowError("Invalid xsector reference in sector %d", i); ThrowError("Invalid xsector reference in sector %d", i);
if (nXSector > 0 && xsector[nXSector].rxID > 0) if (nXSector > 0 && xsector[nXSector].rxID > 0)
{ {
dassert(nCount < kMaxChannels); dassert(nCount < kChannelMax);
rxBucket[nCount].type = 6; rxBucket[nCount].type = 6;
rxBucket[nCount].index = i; rxBucket[nCount].index = i;
nCount++; nCount++;
@ -293,7 +287,7 @@ void evInit(void)
ThrowError("Invalid xwall reference in wall %d", i); ThrowError("Invalid xwall reference in wall %d", i);
if (nXWall > 0 && xwall[nXWall].rxID > 0) if (nXWall > 0 && xwall[nXWall].rxID > 0)
{ {
dassert(nCount < kMaxChannels); dassert(nCount < kChannelMax);
rxBucket[nCount].type = 0; rxBucket[nCount].type = 0;
rxBucket[nCount].index = i; rxBucket[nCount].index = i;
nCount++; nCount++;
@ -308,7 +302,7 @@ void evInit(void)
ThrowError("Invalid xsprite reference in sprite %d", i); ThrowError("Invalid xsprite reference in sprite %d", i);
if (nXSprite > 0 && xsprite[nXSprite].rxID > 0) if (nXSprite > 0 && xsprite[nXSprite].rxID > 0)
{ {
dassert(nCount < kMaxChannels); dassert(nCount < kChannelMax);
rxBucket[nCount].type = 3; rxBucket[nCount].type = 3;
rxBucket[nCount].index = i; rxBucket[nCount].index = i;
nCount++; nCount++;
@ -352,9 +346,9 @@ char evGetSourceState(int nType, int nIndex)
return 0; 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) { switch (command) {
case kCmdState: 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); dassert(command != kCmdCallback);
if (command == kCmdState) if (command == kCmdState) command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff;
command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; else if (command == kCmdNotState) command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn;
else if (command == kCmdNotState)
command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn;
EVENT evn = {}; EVENT evn = {};
evn.index = nIndex; evn.index = nIndex;
evn.type = nType; evn.type = nType;
evn.cmd = command; evn.cmd = command;
// Inlined? evn.causedBy = causedBy;
eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); 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 = {}; EVENT evn = {};
evn.index = nIndex; evn.index = nIndex;
evn.type = nType; evn.type = nType;
evn.cmd = kCmdCallback; evn.cmd = kCmdCallback;
evn.funcID = a4; evn.funcID = callback;
evn.causedBy = causedBy;
eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn);
} }

View file

@ -34,7 +34,7 @@ enum {
kChannelLevelExitNormal, kChannelLevelExitNormal,
kChannelLevelExitSecret, kChannelLevelExitSecret,
kChannelModernEndLevelCustom, // // custom level end kChannelModernEndLevelCustom, // // custom level end
kChannelLevelStartSinglePlayer, kChannelLevelStart,
kChannelLevelStartMatch, // DM and TEAMS kChannelLevelStartMatch, // DM and TEAMS
kChannelLevelStartCoop, kChannelLevelStartCoop,
kChannelLevelStartTeamsOnly, kChannelLevelStartTeamsOnly,
@ -51,10 +51,10 @@ enum {
kChannelRemoteBomb5, kChannelRemoteBomb5,
kChannelRemoteBomb6, kChannelRemoteBomb6,
kChannelRemoteBomb7, kChannelRemoteBomb7,
kChannelUser = 100,
kChannelMax = 4096,
}; };
#define kMaxChannels 4096
struct RXBUCKET struct RXBUCKET
{ {
unsigned int index : 13; unsigned int index : 13;
@ -105,17 +105,18 @@ enum COMMAND_ID {
}; };
struct EVENT { struct EVENT {
unsigned int index : 14; // index unsigned int index: 14; // index
unsigned int type : 3; // type unsigned int type: 3; // type
unsigned int cmd : 8; // cmd unsigned int cmd: 8; // cmd
unsigned int funcID : 8; // callback 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); void evInit(void);
char evGetSourceState(int nType, int nIndex); char evGetSourceState(int nType, int nIndex);
void evSend(int nIndex, int nType, int rxId, COMMAND_ID command); 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); 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 a4); void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy = -1);
void evProcess(unsigned int nTime); void evProcess(unsigned int nTime);
void evKill(int a1, int a2); void evKill(int a1, int a2);
void evKill(int a1, int a2, CALLBACK_ID a3); void evKill(int a1, int a2, CALLBACK_ID a3);

View file

@ -104,13 +104,13 @@ void SetAmmo(bool stat)
if (stat) if (stat)
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
gMe->ammCount[i] = gAmmoInfo[i].max; gMe->ammoCount[i] = gAmmoInfo[i].max;
viewSetMessage("You have full ammo."); viewSetMessage("You have full ammo.");
} }
else else
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
gMe->ammCount[i] = 0; gMe->ammoCount[i] = 0;
viewSetMessage("You have no ammo."); viewSetMessage("You have no ammo.");
} }
} }

View file

@ -435,6 +435,29 @@ DAMAGEINFO damageInfo[7] = {
{ 0, 0, 0, 0, 0, 0, 0 } { 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) int powerupCheck(PLAYER *pPlayer, int nPowerUp)
{ {
dassert(pPlayer != NULL); dassert(pPlayer != NULL);
@ -1037,9 +1060,9 @@ void playerReset(PLAYER *pPlayer)
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
if (gInfiniteAmmo) if (gInfiniteAmmo)
pPlayer->ammCount[i] = gAmmoInfo[i].max; pPlayer->ammoCount[i] = gAmmoInfo[i].max;
else else
pPlayer->ammCount[i] = 0; pPlayer->ammoCount[i] = 0;
} }
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
pPlayer->armor[i] = 0; pPlayer->armor[i] = 0;
@ -1126,7 +1149,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) { if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) {
pPlayer->hasFlag |= 1; pPlayer->hasFlag |= 1;
pPlayer->used2[0] = pItem->index; 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); sprintf(buffer, "%s stole Blue Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8007, 255, 2, 0); sndStartSample(8007, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1138,7 +1161,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) { if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) {
pPlayer->hasFlag &= ~1; pPlayer->hasFlag &= ~1;
pPlayer->used2[0] = -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); sprintf(buffer, "%s returned Blue Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8003, 255, 2, 0); sndStartSample(8003, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1170,7 +1193,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) { if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) {
pPlayer->hasFlag |= 2; pPlayer->hasFlag |= 2;
pPlayer->used2[1] = pItem->index; 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); sprintf(buffer, "%s stole Red Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8006, 255, 2, 0); sndStartSample(8006, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1182,7 +1205,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
{ {
pPlayer->hasFlag &= ~2; pPlayer->hasFlag &= ~2;
pPlayer->used2[1] = -1; 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); sprintf(buffer, "%s returned Red Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8002, 255, 2, 0); sndStartSample(8002, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1293,12 +1316,12 @@ char PickupAmmo(PLAYER* pPlayer, spritetype* pAmmo) {
AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[pAmmo->type - kItemAmmoBase]; AMMOITEMDATA* pAmmoItemData = &gAmmoItemData[pAmmo->type - kItemAmmoBase];
int nAmmoType = pAmmoItemData->type; 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) 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 // by NoOne: allow custom amount for item
else 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; if (pAmmoItemData->weaponType) pPlayer->hasWeapon[pAmmoItemData->weaponType] = 1;
sfxPlay3DSound(pPlayer->pSprite, 782, -1, 0); sfxPlay3DSound(pPlayer->pSprite, 782, -1, 0);
@ -1316,9 +1339,9 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) {
if (nAmmoType == -1) return 0; if (nAmmoType == -1) return 0;
// By NoOne: allow to set custom ammo count for weapon pickups // By NoOne: allow to set custom ammo count for weapon pickups
if (!gModernMap || pWeapon->extra < 0 || xsprite[pWeapon->extra].data1 <= 0) 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 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); int nNewWeapon = WeaponUpgrade(pPlayer, nWeaponType);
if (nNewWeapon != pPlayer->curWeapon) { if (nNewWeapon != pPlayer->curWeapon) {
@ -1329,11 +1352,11 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) {
return 1; 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) 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 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); sfxPlay3DSound(pPlayer->pSprite, 777, -1, 0);
return 1; return 1;
@ -1369,7 +1392,7 @@ void PickUp(PLAYER *pPlayer, spritetype *pSprite)
else if (pSprite->extra > 0) { else if (pSprite->extra > 0) {
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE *pXSprite = &xsprite[pSprite->extra];
if (pXSprite->Pickup) if (pXSprite->Pickup)
trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup); trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup, pPlayer->nSprite);
} }
if (!actCheckRespawn(pSprite)) if (!actCheckRespawn(pSprite))
@ -1464,7 +1487,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
zvel[*a2] += mulscale16(z, t2); zvel[*a2] += mulscale16(z, t2);
} }
if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered) if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered)
trTriggerSprite(*a2, pXSprite, kCmdSpritePush); trTriggerSprite(*a2, pXSprite, kCmdSpritePush, pPlayer->nSprite);
} }
break; break;
case 0: case 0:
@ -1627,7 +1650,7 @@ void ProcessInput(PLAYER *pPlayer)
pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff; pPlayer->q16ang = (pPlayer->q16ang+fix16_from_int(pSprite->ang-pPlayer->angold))&0x7ffffff;
pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang); pPlayer->angold = pSprite->ang = fix16_to_int(pPlayer->q16ang);
if (!pInput->buttonFlags.jump) if (!pInput->buttonFlags.jump)
pPlayer->canJump = 0; pPlayer->cantJump = 0;
switch (pPlayer->posture) switch (pPlayer->posture)
{ {
@ -1642,7 +1665,7 @@ void ProcessInput(PLAYER *pPlayer)
pPlayer->posture = 0; pPlayer->posture = 0;
break; break;
default: default:
if (!pPlayer->canJump && pInput->buttonFlags.jump && pXSprite->height == 0) if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0)
{ {
sfxPlay3DSound(pSprite, 700, 0, 0); sfxPlay3DSound(pSprite, 700, 0, 0);
if (packItemActive(pPlayer, 4)) if (packItemActive(pPlayer, 4))
@ -1654,7 +1677,7 @@ void ProcessInput(PLAYER *pPlayer)
if (isShrinked(pPlayer->pSprite)) zvel[nSprite] -= -200000; if (isShrinked(pPlayer->pSprite)) zvel[nSprite] -= -200000;
else if (isGrown(pPlayer->pSprite)) zvel[nSprite] += -250000; 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) if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg)
trTextOver(pXSprite->lockMsg); trTextOver(pXSprite->lockMsg);
if (!key || pPlayer->hasKey[key]) if (!key || pPlayer->hasKey[key])
trTriggerSprite(a2, pXSprite, kCmdSpritePush); trTriggerSprite(a2, pXSprite, kCmdSpritePush, pPlayer->nSprite);
else if (pPlayer == gMe) else if (pPlayer == gMe)
{ {
viewSetMessage("That requires a key."); viewSetMessage("That requires a key.");
@ -2283,7 +2306,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in
gPlayer[p].fraggerId = -1; gPlayer[p].fraggerId = -1;
} }
FragPlayer(pPlayer, nSource); FragPlayer(pPlayer, nSource);
trTriggerSprite(nSprite, pXSprite, kCmdOff); trTriggerSprite(nSprite, pXSprite, kCmdOff, nSource);
} }
dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL); dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL);
seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer); seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer);
@ -2296,8 +2319,8 @@ int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec)
return 9999; return 9999;
if (nAmmoType == -1) if (nAmmoType == -1)
return 9999; return 9999;
pPlayer->ammCount[nAmmoType] = ClipLow(pPlayer->ammCount[nAmmoType]-nDec, 0); pPlayer->ammoCount[nAmmoType] = ClipLow(pPlayer->ammoCount[nAmmoType]-nDec, 0);
return pPlayer->ammCount[nAmmoType]; return pPlayer->ammoCount[nAmmoType];
} }
void sub_41250(PLAYER *pPlayer) void sub_41250(PLAYER *pPlayer)

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "db.h" #include "db.h"
#include "dude.h" #include "dude.h"
#include "levels.h" #include "levels.h"
#include "qav.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -106,12 +107,12 @@ struct PLAYER {
char nextWeapon; char nextWeapon;
int weaponTimer; int weaponTimer;
int weaponState; int weaponState;
int weaponAmmo; int weaponAmmo; //rename
bool hasWeapon[14]; bool hasWeapon[14];
int weaponMode[14]; int weaponMode[14];
int weaponOrder[2][14]; int weaponOrder[2][14];
//int at149[14]; //int at149[14];
int ammCount[12]; int ammoCount[12];
bool qavLoop; bool qavLoop;
int fuseTime; int fuseTime;
int throwTime; int throwTime;
@ -143,7 +144,7 @@ struct PLAYER {
int spin; // turning around int spin; // turning around
bool godMode; bool godMode;
bool fallScream; bool fallScream;
bool canJump; bool cantJump;
int packItemTime; // pack timer int packItemTime; // pack timer
int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots 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 PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots
@ -209,6 +210,13 @@ struct POWERUPINFO {
int maxTime; int maxTime;
}; };
struct QAVSCENE {
short index;
QAV* qavId;
};
extern QAVSCENE gQavScene[kMaxPlayers];
extern PLAYER gPlayer[kMaxPlayers]; extern PLAYER gPlayer[kMaxPlayers];
extern PLAYER *gMe, *gView; extern PLAYER *gMe, *gView;
@ -302,5 +310,7 @@ bool growPlayerSize(PLAYER* pPlayer, int multiplier);
bool resetPlayerSize(PLAYER* pPlayer); bool resetPlayerSize(PLAYER* pPlayer);
void deactivateSizeShrooms(PLAYER* pPlayer); void deactivateSizeShrooms(PLAYER* pPlayer);
PLAYER* getPlayerById(short id); PLAYER* getPlayerById(short id);
void startQavScene(PLAYER* pPlayer, int qavId, int a3, char a4);
void playQavScene(PLAYER* pPlayer);
END_BLD_NS END_BLD_NS

View file

@ -281,8 +281,8 @@ void DoSectorPanning(void)
if (pXSector->panFloor) // Floor if (pXSector->panFloor) // Floor
{ {
int nTile = pSector->floorpicnum; int nTile = pSector->floorpicnum;
int px = (pSector->floorxpanning<<8)+pXSector->at32_1; int px = (pSector->floorxpanning<<8)+pXSector->floorXPanFrac;
int py = (pSector->floorypanning<<8)+pXSector->at34_0; int py = (pSector->floorypanning<<8)+pXSector->floorYPanFrac;
if (pSector->floorstat&64) if (pSector->floorstat&64)
angle -= 512; angle -= 512;
int xBits = (picsiz[nTile]&15)-((pSector->floorstat&8)!=0); int xBits = (picsiz[nTile]&15)-((pSector->floorstat&8)!=0);
@ -291,14 +291,14 @@ void DoSectorPanning(void)
py -= mulscale30(speed<<2, Sin(angle))>>yBits; py -= mulscale30(speed<<2, Sin(angle))>>yBits;
pSector->floorxpanning = px>>8; pSector->floorxpanning = px>>8;
pSector->floorypanning = py>>8; pSector->floorypanning = py>>8;
pXSector->at32_1 = px&255; pXSector->floorXPanFrac = px&255;
pXSector->at34_0 = py&255; pXSector->floorYPanFrac = py&255;
} }
if (pXSector->panCeiling) // Ceiling if (pXSector->panCeiling) // Ceiling
{ {
int nTile = pSector->ceilingpicnum; int nTile = pSector->ceilingpicnum;
int px = (pSector->ceilingxpanning<<8)+pXSector->at30_1; int px = (pSector->ceilingxpanning<<8)+pXSector->ceilXPanFrac;
int py = (pSector->ceilingypanning<<8)+pXSector->at31_1; int py = (pSector->ceilingypanning<<8)+pXSector->ceilYPanFrac;
if (pSector->ceilingstat&64) if (pSector->ceilingstat&64)
angle -= 512; angle -= 512;
int xBits = (picsiz[nTile]&15)-((pSector->ceilingstat&8)!=0); int xBits = (picsiz[nTile]&15)-((pSector->ceilingstat&8)!=0);
@ -307,8 +307,8 @@ void DoSectorPanning(void)
py -= mulscale30(speed<<2, Sin(angle))>>yBits; py -= mulscale30(speed<<2, Sin(angle))>>yBits;
pSector->ceilingxpanning = px>>8; pSector->ceilingxpanning = px>>8;
pSector->ceilingypanning = py>>8; pSector->ceilingypanning = py>>8;
pXSector->at30_1 = px&255; pXSector->ceilXPanFrac = px&255;
pXSector->at31_1 = py&255; pXSector->ceilYPanFrac = py&255;
} }
} }
} }

View file

@ -53,7 +53,7 @@ int soundRates[13] = {
44100, 44100,
44100, 44100,
}; };
#define kMaxChannels 32 #define kChannelMax 32
int sndGetRate(int format) int sndGetRate(int format)
{ {
@ -62,11 +62,11 @@ int sndGetRate(int format)
return 11025; return 11025;
} }
SAMPLE2D Channel[kMaxChannels]; SAMPLE2D Channel[kChannelMax];
SAMPLE2D * FindChannel(void) 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]; if (Channel[i].at5 == 0) return &Channel[i];
consoleSysMsg("No free channel available for sample"); consoleSysMsg("No free channel available for sample");
//ThrowError("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; return;
if (!strlen(pzSound)) if (!strlen(pzSound))
return; return;
dassert(nChannel >= -1 && nChannel < kMaxChannels); dassert(nChannel >= -1 && nChannel < kChannelMax);
SAMPLE2D *pChannel; SAMPLE2D *pChannel;
if (nChannel == -1) if (nChannel == -1)
pChannel = FindChannel(); pChannel = FindChannel();
@ -269,7 +269,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
{ {
if (!snd_enabled) if (!snd_enabled)
return; return;
dassert(nChannel >= -1 && nChannel < kMaxChannels); dassert(nChannel >= -1 && nChannel < kChannelMax);
DICTNODE *hSfx = gSoundRes.Lookup(nSound, "SFX"); DICTNODE *hSfx = gSoundRes.Lookup(nSound, "SFX");
if (!hSfx) if (!hSfx)
return; return;
@ -313,7 +313,7 @@ void sndStartWavID(unsigned int nSound, int nVolume, int nChannel)
{ {
if (!snd_enabled) if (!snd_enabled)
return; return;
dassert(nChannel >= -1 && nChannel < kMaxChannels); dassert(nChannel >= -1 && nChannel < kChannelMax);
SAMPLE2D *pChannel; SAMPLE2D *pChannel;
if (nChannel == -1) if (nChannel == -1)
pChannel = FindChannel(); pChannel = FindChannel();
@ -340,7 +340,7 @@ void sndKillSound(SAMPLE2D *pChannel)
void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel) void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel)
{ {
dassert(nChannel >= -1 && nChannel < kMaxChannels); dassert(nChannel >= -1 && nChannel < kChannelMax);
SAMPLE2D *pChannel; SAMPLE2D *pChannel;
if (nChannel == -1) if (nChannel == -1)
pChannel = FindChannel(); pChannel = FindChannel();
@ -365,7 +365,7 @@ void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel)
void sndKillAllSounds(void) void sndKillAllSounds(void)
{ {
for (int i = 0; i < kMaxChannels; i++) for (int i = 0; i < kChannelMax; i++)
{ {
SAMPLE2D *pChannel = &Channel[i]; SAMPLE2D *pChannel = &Channel[i];
if (pChannel->at0 > 0) if (pChannel->at0 > 0)
@ -392,7 +392,7 @@ void sndKillAllSounds(void)
void sndProcess(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) if (Channel[i].at0 <= 0 && Channel[i].at5)
{ {

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,7 @@ void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command);
void trMessageSector(unsigned int nSector, EVENT event); void trMessageSector(unsigned int nSector, EVENT event);
void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command); void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command);
void trMessageWall(unsigned int nWall, EVENT event); 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 trMessageSprite(unsigned int nSprite, EVENT event);
void trProcessBusy(void); void trProcessBusy(void);
void trInit(void); void trInit(void);

View file

@ -259,7 +259,7 @@ void viewInitializePrediction(void)
predict.at24 = gMe->q16horiz; predict.at24 = gMe->q16horiz;
predict.at28 = gMe->q16slopehoriz; predict.at28 = gMe->q16slopehoriz;
predict.at2c = gMe->slope; predict.at2c = gMe->slope;
predict.at6f = gMe->canJump; predict.at6f = gMe->cantJump;
predict.at70 = gMe->isRunning; predict.at70 = gMe->isRunning;
predict.at72 = gMe->isUnderwater; predict.at72 = gMe->isUnderwater;
predict.at71 = gMe->input.buttonFlags.jump; predict.at71 = gMe->input.buttonFlags.jump;
@ -1532,7 +1532,7 @@ void UpdateStatusBar(ClockTicks arg)
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
int num = pPlayer->ammCount[pPlayer->weaponAmmo]; int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles) if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles)
@ -1570,7 +1570,7 @@ void UpdateStatusBar(ClockTicks arg)
} }
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
int num = pPlayer->ammCount[pPlayer->weaponAmmo]; int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
DrawStatNumber("%3d", num, 2240, 42, 183, 0, 0, 256); DrawStatNumber("%3d", num, 2240, 42, 183, 0, 0, 256);
@ -1629,7 +1629,7 @@ void UpdateStatusBar(ClockTicks arg)
} }
if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1)
{ {
int num = pPlayer->ammCount[pPlayer->weaponAmmo]; int num = pPlayer->ammoCount[pPlayer->weaponAmmo];
if (pPlayer->weaponAmmo == 6) if (pPlayer->weaponAmmo == 6)
num /= 10; num /= 10;
DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0); DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0);
@ -1638,7 +1638,7 @@ void UpdateStatusBar(ClockTicks arg)
{ {
int x = 135+((i-1)/3)*23; int x = 135+((i-1)/3)*23;
int y = 182+((i-1)%3)*6; int y = 182+((i-1)%3)*6;
int num = pPlayer->ammCount[i]; int num = pPlayer->ammoCount[i];
if (i == 6) if (i == 6)
num /= 10; num /= 10;
if (i == pPlayer->weaponAmmo) if (i == pPlayer->weaponAmmo)
@ -1653,20 +1653,20 @@ void UpdateStatusBar(ClockTicks arg)
if (pPlayer->weaponAmmo == 10) 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 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) 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 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]) if (pPlayer->armor[1])

View file

@ -174,7 +174,7 @@ char sub_4B1FC(PLAYER *pPlayer, int a2, int a3, int a4)
return 1; return 1;
if (a2 == 9 && pPlayer->pXSprite->health > 0) if (a2 == 9 && pPlayer->pXSprite->health > 0)
return 1; return 1;
return pPlayer->ammCount[a3] >= a4; return pPlayer->ammoCount[a3] >= a4;
} }
char CheckAmmo(PLAYER *pPlayer, int a2, int a3) char CheckAmmo(PLAYER *pPlayer, int a2, int a3)
@ -187,7 +187,7 @@ char CheckAmmo(PLAYER *pPlayer, int a2, int a3)
return 1; return 1;
if (pPlayer->curWeapon == 9 && pPlayer->pXSprite->health >= (a3<<4)) if (pPlayer->curWeapon == 9 && pPlayer->pXSprite->health >= (a3<<4))
return 1; return 1;
return pPlayer->ammCount[a2] >= a3; return pPlayer->ammoCount[a2] >= a3;
} }
char sub_4B2C8(PLAYER *pPlayer, int a2, int 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; return 1;
if (a2 == -1) if (a2 == -1)
return 1; return 1;
return pPlayer->ammCount[a2] >= a3; return pPlayer->ammoCount[a2] >= a3;
} }
void SpawnBulletEject(PLAYER *pPlayer, int a2, int a3) void SpawnBulletEject(PLAYER *pPlayer, int a2, int a3)
@ -518,24 +518,24 @@ void WeaponRaise(PLAYER *pPlayer)
case 3: // sawed off case 3: // sawed off
if (powerupCheck(pPlayer, kPwUpTwoGuns)) if (powerupCheck(pPlayer, kPwUpTwoGuns))
{ {
if (gInfiniteAmmo || pPlayer->ammCount[2] >= 4) if (gInfiniteAmmo || pPlayer->ammoCount[2] >= 4)
StartQAV(pPlayer, 59, -1, 0); StartQAV(pPlayer, 59, -1, 0);
else else
StartQAV(pPlayer, 50, -1, 0); StartQAV(pPlayer, 50, -1, 0);
if (gInfiniteAmmo || pPlayer->ammCount[2] >= 4) if (gInfiniteAmmo || pPlayer->ammoCount[2] >= 4)
pPlayer->weaponState = 7; pPlayer->weaponState = 7;
else if (pPlayer->ammCount[2] > 1) else if (pPlayer->ammoCount[2] > 1)
pPlayer->weaponState = 3; pPlayer->weaponState = 3;
else if (pPlayer->ammCount[2] > 0) else if (pPlayer->ammoCount[2] > 0)
pPlayer->weaponState = 2; pPlayer->weaponState = 2;
else else
pPlayer->weaponState = 1; pPlayer->weaponState = 1;
} }
else else
{ {
if (gInfiniteAmmo || pPlayer->ammCount[2] > 1) if (gInfiniteAmmo || pPlayer->ammoCount[2] > 1)
pPlayer->weaponState = 3; pPlayer->weaponState = 3;
else if (pPlayer->ammCount[2] > 0) else if (pPlayer->ammoCount[2] > 0)
pPlayer->weaponState = 2; pPlayer->weaponState = 2;
else else
pPlayer->weaponState = 1; pPlayer->weaponState = 1;
@ -815,7 +815,7 @@ void WeaponUpdateState(PLAYER *pPlayer)
StartQAV(pPlayer, 5, -1, 0); StartQAV(pPlayer, 5, -1, 0);
break; break;
case 2: case 2:
if (pPlayer->ammCount[5] > 0) if (pPlayer->ammoCount[5] > 0)
{ {
pPlayer->weaponState = 3; pPlayer->weaponState = 3;
StartQAV(pPlayer, 16, -1, 0); StartQAV(pPlayer, 16, -1, 0);
@ -850,7 +850,7 @@ void WeaponUpdateState(PLAYER *pPlayer)
pPlayer->weaponQav = 37; pPlayer->weaponQav = 37;
break; break;
case 12: case 12:
if (pPlayer->ammCount[11] > 0) if (pPlayer->ammoCount[11] > 0)
{ {
pPlayer->weaponState = 10; pPlayer->weaponState = 10;
StartQAV(pPlayer, 31, -1, 0); StartQAV(pPlayer, 31, -1, 0);
@ -877,7 +877,7 @@ void WeaponUpdateState(PLAYER *pPlayer)
{ {
sfxPlay3DSound(pPlayer->pSprite, 410, 3, 2); sfxPlay3DSound(pPlayer->pSprite, 410, 3, 2);
StartQAV(pPlayer, 57, nClientEjectShell, 0); StartQAV(pPlayer, 57, nClientEjectShell, 0);
if (gInfiniteAmmo || pPlayer->ammCount[2] > 1) if (gInfiniteAmmo || pPlayer->ammoCount[2] > 1)
pPlayer->weaponState = 3; pPlayer->weaponState = 3;
else else
pPlayer->weaponState = 2; pPlayer->weaponState = 2;
@ -1397,7 +1397,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
// by NoOne: trying to simulate v1.0x voodoo here. // 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 // dunno how exactly it works, but at least it not spend all the ammo on alt fire
if (gGameOptions.weaponsV10x && !VanillaMode() && !DemoRecordStatus()) { if (gGameOptions.weaponsV10x && !VanillaMode() && !DemoRecordStatus()) {
int nCount = ClipHigh(pPlayer->ammCount[9], pPlayer->aimTargetsCount); int nCount = ClipHigh(pPlayer->ammoCount[9], pPlayer->aimTargetsCount);
if (nCount > 0) if (nCount > 0)
{ {
for (int i = 0; i < pPlayer->aimTargetsCount; i++) 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); int nDist = approxDist(pTarget->x - pPlayer->pSprite->x, pTarget->y - pPlayer->pSprite->y);
if (nDist > 0 && nDist < 51200) if (nDist > 0 && nDist < 51200)
{ {
int vc = pPlayer->ammCount[9] >> 3; int vc = pPlayer->ammoCount[9] >> 3;
int v8 = pPlayer->ammCount[9] << 1; int v8 = pPlayer->ammoCount[9] << 1;
int nDamage = (v8 + Random(vc)) << 4; int nDamage = (v8 + Random(vc)) << 4;
nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200; nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200;
nDamage = actDamageSprite(pPlayer->nSprite, pTarget, DAMAGE_TYPE_5, nDamage); 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 nAmmo = pPlayer->ammCount[9];
int nCount = ClipHigh(pPlayer->ammCount[9], pPlayer->aimTargetsCount); int nCount = ClipHigh(pPlayer->ammoCount[9], pPlayer->aimTargetsCount);
if (nCount > 0) 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++) for (int i = 0; i < pPlayer->aimTargetsCount; i++)
{ {
int nTarget = pPlayer->aimTargets[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); int nDist = approxDist(pTarget->x - pPlayer->pSprite->x, pTarget->y - pPlayer->pSprite->y);
if (nDist > 0 && nDist < 51200) if (nDist > 0 && nDist < 51200)
{ {
int vc = pPlayer->ammCount[9] >> 3; int vc = pPlayer->ammoCount[9] >> 3;
int v8 = pPlayer->ammCount[9] << 1; int v8 = pPlayer->ammoCount[9] << 1;
int nDamage = (v8 + Random2(vc)) << 4; int nDamage = (v8 + Random2(vc)) << 4;
nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200; nDamage = (nDamage * ((51200 - nDist) + 1)) / 51200;
nDamage = actDamageSprite(pPlayer->nSprite, pTarget, DAMAGE_TYPE_5, nDamage); 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->hasWeapon[10] = 0;
pPlayer->weaponState = -1; pPlayer->weaponState = -1;
} }
@ -1478,10 +1478,10 @@ void DropVoodoo(int nTrigger, PLAYER *pPlayer)
{ {
int nXSprite = pSprite->extra; int nXSprite = pSprite->extra;
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE *pXSprite = &xsprite[nXSprite];
pXSprite->data1 = pPlayer->ammCount[9]; pXSprite->data1 = pPlayer->ammoCount[9];
evPost(pSprite->index, 3, 90, kCallbackDropVoodoo); evPost(pSprite->index, 3, 90, kCallbackDropVoodoo);
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
UseAmmo(pPlayer, 9, pPlayer->ammCount[9]); UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]);
pPlayer->hasWeapon[10] = 0; pPlayer->hasWeapon[10] = 0;
} }
} }
@ -1581,7 +1581,7 @@ void AltFireNapalm(int nTrigger, PLAYER *pPlayer)
if (pMissile) if (pMissile)
{ {
XSPRITE *pXSprite = &xsprite[pMissile->extra]; XSPRITE *pXSprite = &xsprite[pMissile->extra];
pXSprite->data4 = ClipHigh(pPlayer->ammCount[4], 12); pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12);
UseAmmo(pPlayer, 4, pXSprite->data4); UseAmmo(pPlayer, 4, pXSprite->data4);
seqSpawn(22, 3, pMissile->extra, -1); seqSpawn(22, 3, pMissile->extra, -1);
actBurnSprite(actSpriteIdToOwnerId(pPlayer->pSprite->index), pXSprite, 600); actBurnSprite(actSpriteIdToOwnerId(pPlayer->pSprite->index), pXSprite, 600);
@ -1625,12 +1625,12 @@ void AltFireLifeLeech(int nTrigger, PLAYER *pPlayer)
pXSprite->Push = 1; pXSprite->Push = 1;
pXSprite->Proximity = 1; pXSprite->Proximity = 1;
pXSprite->DudeLockout = 1; pXSprite->DudeLockout = 1;
pXSprite->data4 = ClipHigh(pPlayer->ammCount[4], 12); pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12);
pXSprite->stateTimer = 1; pXSprite->stateTimer = 1;
evPost(pMissile->index, 3, 120, kCallbackLeechStateTimer); evPost(pMissile->index, 3, 120, kCallbackLeechStateTimer);
if (gGameOptions.nGameType <= 1) if (gGameOptions.nGameType <= 1)
{ {
int nAmmo = pPlayer->ammCount[8]; int nAmmo = pPlayer->ammoCount[8];
if (nAmmo < 25 && pPlayer->pXSprite->health > ((25-nAmmo)<<4)) if (nAmmo < 25 && pPlayer->pXSprite->health > ((25-nAmmo)<<4))
{ {
actDamageSprite(pPlayer->nSprite, pPlayer->pSprite, DAMAGE_TYPE_5, ((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 else
{ {
pXSprite->data3 = pPlayer->ammCount[8]; pXSprite->data3 = pPlayer->ammoCount[8];
pPlayer->ammCount[8] = 0; pPlayer->ammoCount[8] = 0;
} }
pPlayer->hasWeapon[9] = 0; pPlayer->hasWeapon[9] = 0;
} }
@ -1924,9 +1924,31 @@ char sub_4F484(PLAYER *pPlayer)
return 0; return 0;
} }
void WeaponProcess(PLAYER *pPlayer) void WeaponProcess(PLAYER *pPlayer) {
{
pPlayer->flashEffect = ClipLow(pPlayer->flashEffect-1, 0); 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) if (pPlayer->pXSprite->health == 0)
{ {
pPlayer->qavLoop = 0; pPlayer->qavLoop = 0;
@ -2321,7 +2343,7 @@ void WeaponProcess(PLAYER *pPlayer)
StartQAV(pPlayer, 38, nClientDropRemote, 0); StartQAV(pPlayer, 38, nClientDropRemote, 0);
return; return;
case 11: case 11:
if (pPlayer->ammCount[11] > 0) if (pPlayer->ammoCount[11] > 0)
{ {
pPlayer->weaponState = 10; pPlayer->weaponState = 10;
StartQAV(pPlayer, 30, -1, 0); StartQAV(pPlayer, 30, -1, 0);
@ -2346,7 +2368,7 @@ void WeaponProcess(PLAYER *pPlayer)
StartQAV(pPlayer, 38, nClientDropRemote, 0); StartQAV(pPlayer, 38, nClientDropRemote, 0);
return; return;
case 11: case 11:
if (pPlayer->ammCount[11] > 0) if (pPlayer->ammoCount[11] > 0)
{ {
pPlayer->weaponState = 10; pPlayer->weaponState = 10;
StartQAV(pPlayer, 30, -1, 0); StartQAV(pPlayer, 30, -1, 0);

View file

@ -37,6 +37,7 @@ void WeaponRaise(PLAYER *pPlayer);
void WeaponLower(PLAYER *pPlayer); void WeaponLower(PLAYER *pPlayer);
char WeaponUpgrade(PLAYER *pPlayer, char newWeapon); char WeaponUpgrade(PLAYER *pPlayer, char newWeapon);
void WeaponProcess(PLAYER *pPlayer); void WeaponProcess(PLAYER *pPlayer);
void WeaponUpdateState(PLAYER* pPlayer);
void sub_51340(spritetype *pMissile, int a2); void sub_51340(spritetype *pMissile, int a2);
void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0); void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0);
END_BLD_NS END_BLD_NS