- actGetRespawnTime + actCheckRespawn.

This commit is contained in:
Christoph Oelckers 2021-08-30 20:21:49 +02:00
parent 6db18e61d9
commit d7078dda48
4 changed files with 59 additions and 42 deletions

View file

@ -3341,7 +3341,7 @@ static void modernCustomDudeDeath(DBloodActor* actor, int nSeq, int damageType)
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
playGenDudeSound(pSprite, kGenDudeSndDeathNormal); playGenDudeSound(pSprite, kGenDudeSndDeathNormal);
int dudeToGib = (actCheckRespawn(pSprite)) ? -1 : ((nSeq == 3) ? nDudeToGibClient2 : nDudeToGibClient1); int dudeToGib = (actCheckRespawn(actor)) ? -1 : ((nSeq == 3) ? nDudeToGibClient2 : nDudeToGibClient1);
if (nSeq == 3) if (nSeq == 3)
{ {
GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); GENDUDEEXTRA* pExtra = genDudeExtra(pSprite);
@ -3369,7 +3369,7 @@ static void modernCustomDudeBurningDeath(DBloodActor* actor, int nSeq)
auto pSprite = &actor->s(); auto pSprite = &actor->s();
playGenDudeSound(pSprite, kGenDudeSndDeathExplode); playGenDudeSound(pSprite, kGenDudeSndDeathExplode);
int dudeToGib = (actCheckRespawn(pSprite)) ? -1 : nDudeToGibClient1; int dudeToGib = (actCheckRespawn(actor)) ? -1 : nDudeToGibClient1;
if (Chance(0x4000)) spawnGibs(actor, GIBTYPE_27, -0xccccc); if (Chance(0x4000)) spawnGibs(actor, GIBTYPE_27, -0xccccc);
@ -3659,7 +3659,7 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag
fxSpawnBlood(pSprite, damage); fxSpawnBlood(pSprite, damage);
} }
gKillMgr.AddKill(pSprite); gKillMgr.AddKill(pSprite);
actCheckRespawn(pSprite); actCheckRespawn(actor);
pSprite->type = kThingBloodChunks; pSprite->type = kThingBloodChunks;
actPostSprite(actor, kStatThing); actPostSprite(actor, kStatThing);
} }
@ -5566,7 +5566,7 @@ void actExplodeSprite(DBloodActor* actor)
{ {
auto spawned = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0, 1); auto spawned = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0, 1);
spawned->SetOwner(actor->GetOwner()); spawned->SetOwner(actor->GetOwner());
if (actCheckRespawn(pSprite)) if (actCheckRespawn(actor))
{ {
pXSprite->state = 1; pXSprite->state = 1;
pXSprite->health = thingInfo[0].startHealth << 4; pXSprite->health = thingInfo[0].startHealth << 4;
@ -6796,38 +6796,48 @@ void actBuildMissile(spritetype* pMissile, int nXSprite, int nSprite) {
} }
} }
int actGetRespawnTime(spritetype *pSprite) { int actGetRespawnTime(DBloodActor* actor)
if (pSprite->extra <= 0) return -1; {
XSPRITE *pXSprite = &xsprite[pSprite->extra]; spritetype* pSprite = &actor->s();
if (IsDudeSprite(pSprite) && !IsPlayerSprite(pSprite)) { if (!actor->hasX()) return -1;
if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nMonsterSettings == 2))
XSPRITE* pXSprite = &actor->x();
if (actor->IsDudeActor() && !actor->IsPlayerActor())
{
if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nMonsterSettings == 2))
return gGameOptions.nMonsterRespawnTime; return gGameOptions.nMonsterRespawnTime;
return -1; return -1;
} }
if (IsWeaponSprite(pSprite)) { if (actor->IsWeaponActor())
{
if (pXSprite->respawn == 3 || gGameOptions.nWeaponSettings == 1) return 0; if (pXSprite->respawn == 3 || gGameOptions.nWeaponSettings == 1) return 0;
else if (pXSprite->respawn != 1 && gGameOptions.nWeaponSettings != 0) else if (pXSprite->respawn != 1 && gGameOptions.nWeaponSettings != 0)
return gGameOptions.nWeaponRespawnTime; return gGameOptions.nWeaponRespawnTime;
return -1; return -1;
} }
if (IsAmmoSprite(pSprite)) { if (actor->IsAmmoActor())
if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nWeaponSettings != 0)) {
if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nWeaponSettings != 0))
return gGameOptions.nWeaponRespawnTime; return gGameOptions.nWeaponRespawnTime;
return -1; return -1;
} }
if (IsItemSprite(pSprite)) { if (actor->IsItemActor())
{
if (pXSprite->respawn == 3 && gGameOptions.nGameType == 1) return 0; if (pXSprite->respawn == 3 && gGameOptions.nGameType == 1) return 0;
else if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nItemSettings != 0)) { else if (pXSprite->respawn == 2 || (pXSprite->respawn != 1 && gGameOptions.nItemSettings != 0))
switch (pSprite->type) { {
switch (pSprite->type)
{
case kItemShadowCloak: case kItemShadowCloak:
case kItemTwoGuns: case kItemTwoGuns:
case kItemReflectShots: case kItemReflectShots:
return gGameOptions.nSpecialRespawnTime; return gGameOptions.nSpecialRespawnTime;
case kItemDeathMask: case kItemDeathMask:
return gGameOptions.nSpecialRespawnTime<<1; return gGameOptions.nSpecialRespawnTime << 1;
default: default:
return gGameOptions.nItemRespawnTime; return gGameOptions.nItemRespawnTime;
} }
@ -6837,38 +6847,42 @@ int actGetRespawnTime(spritetype *pSprite) {
return -1; return -1;
} }
bool actCheckRespawn(spritetype *pSprite) //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool actCheckRespawn(DBloodActor* actor)
{ {
int nSprite = pSprite->index; spritetype* pSprite = &actor->s();
int nXSprite = pSprite->extra; if (actor->hasX())
if (nXSprite > 0)
{ {
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE* pXSprite = &actor->x();
int nRespawnTime = actGetRespawnTime(pSprite); int nRespawnTime = actGetRespawnTime(actor);
if (nRespawnTime < 0) if (nRespawnTime < 0) return 0;
return 0;
pXSprite->respawnPending = 1; pXSprite->respawnPending = 1;
if (pSprite->type >= kThingBase && pSprite->type < kThingMax) if (pSprite->type >= kThingBase && pSprite->type < kThingMax)
{ {
pXSprite->respawnPending = 3; pXSprite->respawnPending = 3;
if (pSprite->type == kThingTNTBarrel) if (pSprite->type == kThingTNTBarrel) pSprite->cstat |= 32768;
pSprite->cstat |= 32768;
} }
if (nRespawnTime > 0) if (nRespawnTime > 0)
{ {
if (pXSprite->respawnPending == 1) if (pXSprite->respawnPending == 1) nRespawnTime = MulScale(nRespawnTime, 0xa000, 16);
nRespawnTime = MulScale(nRespawnTime, 0xa000, 16);
pSprite->owner = pSprite->statnum; pSprite->owner = pSprite->statnum;
actPostSprite(pSprite->index, kStatRespawn); actPostSprite(actor, kStatRespawn);
pSprite->flags |= kHitagRespawn; pSprite->flags |= kHitagRespawn;
if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax)) if (!(pSprite->type >= kDudeBase && pSprite->type < kDudeMax))
{ {
pSprite->cstat &= ~257; pSprite->cstat &= ~257;
pSprite->x = baseSprite[nSprite].x; pSprite->x = actor->basePoint().x;
pSprite->y = baseSprite[nSprite].y; pSprite->y = actor->basePoint().y;
pSprite->z = baseSprite[nSprite].z; pSprite->z = actor->basePoint().z;
} }
evPost(nSprite, 3, nRespawnTime, kCallbackRespawn); evPost(actor, nRespawnTime, kCallbackRespawn);
} }
return 1; return 1;
} }

View file

@ -239,9 +239,8 @@ DBloodActor * actSpawnThing(int nSector, int x, int y, int z, int nThingType);
spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6); spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6);
DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6); DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6);
spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType); int actGetRespawnTime(DBloodActor *pSprite);
int actGetRespawnTime(spritetype *pSprite); bool actCheckRespawn(DBloodActor *pSprite);
bool actCheckRespawn(spritetype *pSprite);
bool actCanSplatWall(int nWall); bool actCanSplatWall(int nWall);
void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, VECTOR_TYPE vectorType); void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6, VECTOR_TYPE vectorType);
void actPostSprite(int nSprite, int nStatus); void actPostSprite(int nSprite, int nStatus);

View file

@ -208,6 +208,7 @@ void fxDynPuff(int nSprite) // 8
void Respawn(int nSprite) // 9 void Respawn(int nSprite) // 9
{ {
auto actor = &bloodActors[nSprite];
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &sprite[nSprite];
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites); assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE *pXSprite = &xsprite[pSprite->extra];
@ -222,13 +223,13 @@ void Respawn(int nSprite) // 9
switch (pXSprite->respawnPending) { switch (pXSprite->respawnPending) {
case 1: { case 1: {
int nTime = MulScale(actGetRespawnTime(pSprite), 0x4000, 16); int nTime = MulScale(actGetRespawnTime(actor), 0x4000, 16);
pXSprite->respawnPending = 2; pXSprite->respawnPending = 2;
evPost(nSprite, 3, nTime, kCallbackRespawn); evPost(nSprite, 3, nTime, kCallbackRespawn);
break; break;
} }
case 2: { case 2: {
int nTime = MulScale(actGetRespawnTime(pSprite), 0x2000, 16); int nTime = MulScale(actGetRespawnTime(actor), 0x2000, 16);
pXSprite->respawnPending = 3; pXSprite->respawnPending = 3;
evPost(nSprite, 3, nTime, kCallbackRespawn); evPost(nSprite, 3, nTime, kCallbackRespawn);
break; break;

View file

@ -1113,7 +1113,9 @@ char PickupAmmo(PLAYER* pPlayer, spritetype* pAmmo) {
return 1; return 1;
} }
char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) { char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon)
{
auto actor = &bloodActors[pWeapon->index];
const WEAPONITEMDATA *pWeaponItemData = &gWeaponItemData[pWeapon->type - kItemWeaponBase]; const WEAPONITEMDATA *pWeaponItemData = &gWeaponItemData[pWeapon->type - kItemWeaponBase];
int nWeaponType = pWeaponItemData->type; int nWeaponType = pWeaponItemData->type;
int nAmmoType = pWeaponItemData->ammoType; int nAmmoType = pWeaponItemData->ammoType;
@ -1139,7 +1141,7 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) {
return 1; return 1;
} }
if (!actGetRespawnTime(pWeapon) || nAmmoType == -1 || pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0; if (!actGetRespawnTime(actor) || nAmmoType == -1 || pPlayer->ammoCount[nAmmoType] >= gAmmoInfo[nAmmoType].max) return 0;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
else if (gModernMap && pWeapon->extra >= 0 && xsprite[pWeapon->extra].data1 > 0) else if (gModernMap && pWeapon->extra >= 0 && xsprite[pWeapon->extra].data1 > 0)
pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max); pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType] + xsprite[pWeapon->extra].data1, gAmmoInfo[nAmmoType].max);
@ -1153,6 +1155,7 @@ char PickupWeapon(PLAYER *pPlayer, spritetype *pWeapon) {
void PickUp(PLAYER *pPlayer, spritetype *pSprite) void PickUp(PLAYER *pPlayer, spritetype *pSprite)
{ {
auto actor = &bloodActors[pSprite->index];
const char *msg = nullptr; const char *msg = nullptr;
int nType = pSprite->type; int nType = pSprite->type;
char pickedUp = 0; char pickedUp = 0;
@ -1185,7 +1188,7 @@ void PickUp(PLAYER *pPlayer, spritetype *pSprite)
trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup); trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup);
} }
if (!actCheckRespawn(pSprite)) if (!actCheckRespawn(actor))
actPostSprite(pSprite->index, kStatFree); actPostSprite(pSprite->index, kStatFree);
pPlayer->pickupEffect = 30; pPlayer->pickupEffect = 30;