mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- handled the actDrop* functions.
This commit is contained in:
parent
d1cc7403b3
commit
34b7bfc10b
6 changed files with 162 additions and 111 deletions
|
@ -2766,122 +2766,156 @@ static void actNapalmMove(DBloodActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
spritetype *actSpawnFloor(spritetype *pSprite)
|
||||
static DBloodActor *actSpawnFloor(DBloodActor *actor)
|
||||
{
|
||||
short nSector = pSprite->sectnum;
|
||||
auto pSprite = &actor->s();
|
||||
short sector = pSprite->sectnum;
|
||||
int x = pSprite->x;
|
||||
int y = pSprite->y;
|
||||
updatesector(x, y, &nSector);
|
||||
int zFloor = getflorzofslope(nSector, x, y);
|
||||
spritetype *pSprite2 = actSpawnSprite(nSector, x, y, zFloor, 3, 0);
|
||||
if (pSprite2)
|
||||
pSprite2->cstat &= ~257;
|
||||
return pSprite2;
|
||||
updatesector(x, y, §or);
|
||||
int zFloor = getflorzofslope(sector, x, y);
|
||||
auto *spawned = actSpawnSprite(sector, x, y, zFloor, 3, 0);
|
||||
if (spawned) spawned->s().cstat &= ~257;
|
||||
return spawned;
|
||||
}
|
||||
|
||||
spritetype *actDropAmmo(spritetype *pSprite, int nType)
|
||||
static DBloodActor *actDropAmmo(DBloodActor *actor, int nType)
|
||||
{
|
||||
spritetype *pSprite2 = NULL;
|
||||
if (pSprite && pSprite->statnum < kMaxStatus && nType >= kItemAmmoBase && nType < kItemAmmoMax)
|
||||
if (!actor) return nullptr;
|
||||
auto pSprite = &actor->s();
|
||||
if (pSprite->statnum < kMaxStatus && nType >= kItemAmmoBase && nType < kItemAmmoMax)
|
||||
{
|
||||
pSprite2 = actSpawnFloor(pSprite);
|
||||
auto act2 = actSpawnFloor(actor);
|
||||
const AMMOITEMDATA *pAmmo = &gAmmoItemData[nType - kItemAmmoBase];
|
||||
auto pSprite2 = &act2->s();
|
||||
pSprite2->type = nType;
|
||||
pSprite2->picnum = pAmmo->picnum;
|
||||
pSprite2->shade = pAmmo->shade;
|
||||
pSprite2->xrepeat = pAmmo->xrepeat;
|
||||
pSprite2->yrepeat = pAmmo->yrepeat;
|
||||
return act2;
|
||||
}
|
||||
return pSprite2;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
spritetype *actDropWeapon(spritetype *pSprite, int nType)
|
||||
static DBloodActor *actDropWeapon(DBloodActor *actor, int nType)
|
||||
{
|
||||
spritetype *pSprite2 = NULL;
|
||||
if (pSprite && pSprite->statnum < kMaxStatus && nType >= kItemWeaponBase && nType < kItemWeaponMax)
|
||||
if (!actor) return nullptr;
|
||||
auto pSprite = &actor->s();
|
||||
if (pSprite->statnum < kMaxStatus && nType >= kItemWeaponBase && nType < kItemWeaponMax)
|
||||
{
|
||||
pSprite2 = actSpawnFloor(pSprite);
|
||||
auto act2 = actSpawnFloor(actor);
|
||||
const WEAPONITEMDATA *pWeapon = &gWeaponItemData[nType - kItemWeaponBase];
|
||||
auto pSprite2 = &act2->s();
|
||||
pSprite2->type = nType;
|
||||
pSprite2->picnum = pWeapon->picnum;
|
||||
pSprite2->shade = pWeapon->shade;
|
||||
pSprite2->xrepeat = pWeapon->xrepeat;
|
||||
pSprite2->yrepeat = pWeapon->yrepeat;
|
||||
return act2;
|
||||
}
|
||||
return pSprite2;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
spritetype *actDropItem(spritetype *pSprite, int nType)
|
||||
static DBloodActor* actDropItem(DBloodActor* actor, int nType)
|
||||
{
|
||||
spritetype *pSprite2 = NULL;
|
||||
if (pSprite && pSprite->statnum < kMaxStatus && nType >= kItemBase && nType < kItemMax)
|
||||
if (!actor) return nullptr;
|
||||
auto pSprite = &actor->s();
|
||||
if (pSprite->statnum < kMaxStatus && nType >= kItemBase && nType < kItemMax)
|
||||
{
|
||||
pSprite2 = actSpawnFloor(pSprite);
|
||||
auto act2 = actSpawnFloor(actor);
|
||||
const ITEMDATA *pItem = &gItemData[nType - kItemBase];
|
||||
auto pSprite2 = &act2->s();
|
||||
pSprite2->type = nType;
|
||||
pSprite2->picnum = pItem->picnum;
|
||||
pSprite2->shade = pItem->shade;
|
||||
pSprite2->xrepeat = pItem->xrepeat;
|
||||
pSprite2->yrepeat = pItem->yrepeat;
|
||||
return act2;
|
||||
}
|
||||
return pSprite2;
|
||||
}
|
||||
|
||||
spritetype *actDropKey(spritetype *pSprite, int nType)
|
||||
{
|
||||
spritetype *pSprite2 = NULL;
|
||||
if (pSprite && pSprite->statnum < kMaxStatus && nType >= kItemKeyBase && nType < kItemKeyMax)
|
||||
{
|
||||
pSprite2 = actDropItem(pSprite, nType);
|
||||
if (pSprite2 && gGameOptions.nGameType == 1)
|
||||
{
|
||||
if (pSprite2->extra == -1)
|
||||
dbInsertXSprite(pSprite2->index);
|
||||
xsprite[pSprite2->extra].respawn = 3;
|
||||
gSpriteHit[pSprite2->extra].florhit = 0;
|
||||
gSpriteHit[pSprite2->extra].ceilhit = 0;
|
||||
}
|
||||
}
|
||||
return pSprite2;
|
||||
}
|
||||
|
||||
spritetype *actDropFlag(spritetype *pSprite, int nType)
|
||||
{
|
||||
spritetype *pSprite2 = NULL;
|
||||
if (pSprite && pSprite->statnum < kMaxStatus && (nType == 147 || nType == 148))
|
||||
{
|
||||
pSprite2 = actDropItem(pSprite, nType);
|
||||
if (pSprite2 && gGameOptions.nGameType == 3)
|
||||
{
|
||||
evPost(pSprite2->index, 3, 1800, kCallbackReturnFlag);
|
||||
}
|
||||
}
|
||||
return pSprite2;
|
||||
}
|
||||
|
||||
spritetype *actDropObject(spritetype *pSprite, int nType) {
|
||||
spritetype *pSprite2 = NULL;
|
||||
|
||||
if (nType >= kItemKeyBase && nType < kItemKeyMax) pSprite2 = actDropKey(pSprite, nType);
|
||||
else if (nType == kItemFlagA || nType == kItemFlagB) pSprite2 = actDropFlag(pSprite, nType);
|
||||
else if (nType >= kItemBase && nType < kItemMax) pSprite2 = actDropItem(pSprite, nType);
|
||||
else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) pSprite2 = actDropAmmo(pSprite, nType);
|
||||
else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) pSprite2 = actDropWeapon(pSprite, nType);
|
||||
|
||||
if (pSprite2) {
|
||||
if (pSprite2->picnum == -1)
|
||||
{
|
||||
DeleteSprite(pSprite2 - sprite);
|
||||
return nullptr;
|
||||
}
|
||||
int top, bottom;
|
||||
GetSpriteExtents(pSprite2, &top, &bottom);
|
||||
if (bottom >= pSprite2->z)
|
||||
pSprite2->z -= bottom - pSprite2->z;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static DBloodActor *actDropKey(DBloodActor *actor, int nType)
|
||||
{
|
||||
if (!actor) return nullptr;
|
||||
auto pSprite = &actor->s();
|
||||
if (pSprite->statnum < kMaxStatus && nType >= kItemKeyBase && nType < kItemKeyMax)
|
||||
{
|
||||
auto act2 = actDropItem(actor, nType);
|
||||
if (act2 && gGameOptions.nGameType == 1)
|
||||
{
|
||||
act2->addX();
|
||||
auto pSprite2 = &act2->s();
|
||||
act2->x().respawn = 3;
|
||||
act2->hit().florhit = 0;
|
||||
act2->hit().ceilhit = 0;
|
||||
}
|
||||
return act2;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pSprite2;
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static DBloodActor*actDropFlag(DBloodActor* actor, int nType)
|
||||
{
|
||||
if (!actor) return nullptr;
|
||||
auto pSprite = &actor->s();
|
||||
if (pSprite->statnum < kMaxStatus && (nType == 147 || nType == 148))
|
||||
{
|
||||
auto act2 = actDropItem(actor, nType);
|
||||
if (act2 && gGameOptions.nGameType == 3)
|
||||
{
|
||||
evPost(act2->s().index, 3, 1800, kCallbackReturnFlag);
|
||||
}
|
||||
return act2;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static DBloodActor* actDropObject(DBloodActor* pSprite, int nType)
|
||||
{
|
||||
DBloodActor *act2 = nullptr;
|
||||
|
||||
if (nType >= kItemKeyBase && nType < kItemKeyMax) act2 = actDropKey(pSprite, nType);
|
||||
else if (nType == kItemFlagA || nType == kItemFlagB) act2 = actDropFlag(pSprite, nType);
|
||||
else if (nType >= kItemBase && nType < kItemMax) act2 = actDropItem(pSprite, nType);
|
||||
else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) act2 = actDropAmmo(pSprite, nType);
|
||||
else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) act2 = actDropWeapon(pSprite, nType);
|
||||
|
||||
if (act2)
|
||||
{
|
||||
int top, bottom;
|
||||
GetActorExtents(act2, &top, &bottom);
|
||||
if (bottom >= act2->s().z)
|
||||
act2->s().z -= bottom - act2->s().z;
|
||||
}
|
||||
|
||||
return act2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool actHealDude(XSPRITE *pXDude, int a2, int a3)
|
||||
{
|
||||
|
@ -5287,7 +5321,7 @@ void actExplodeSprite(spritetype *pSprite)
|
|||
break;
|
||||
case kThingTNTBarrel:
|
||||
{
|
||||
spritetype *pSprite2 = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0, 1);
|
||||
spritetype *pSprite2 = actSpawnSprite_(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0, 1);
|
||||
pSprite2->owner = pSprite->owner;
|
||||
if (actCheckRespawn(pSprite))
|
||||
{
|
||||
|
@ -6063,7 +6097,7 @@ void actProcessSprites(void)
|
|||
gFX.fxProcess();
|
||||
}
|
||||
|
||||
spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6)
|
||||
spritetype * actSpawnSprite_(int nSector, int x, int y, int z, int nStat, char a6)
|
||||
{
|
||||
int nSprite = InsertSprite(nSector, nStat);
|
||||
if (nSprite >= 0)
|
||||
|
@ -6092,6 +6126,12 @@ spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6
|
|||
return pSprite;
|
||||
}
|
||||
|
||||
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6)
|
||||
{
|
||||
auto spr = actSpawnSprite_(nSector, x, y, z, nStat, a6);
|
||||
return &bloodActors[spr->index];
|
||||
}
|
||||
|
||||
spritetype * actSpawnSprite(spritetype *pSource, int nStat);
|
||||
|
||||
spritetype *actSpawnDude(spritetype *pSource, short nType, int a3, int a4)
|
||||
|
@ -6188,7 +6228,7 @@ spritetype * actSpawnSprite(spritetype *pSource, int nStat)
|
|||
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
|
||||
{
|
||||
assert(nThingType >= kThingBase && nThingType < kThingMax);
|
||||
spritetype *pSprite = actSpawnSprite(nSector, x, y, z, 4, 1);
|
||||
spritetype *pSprite = actSpawnSprite_(nSector, x, y, z, 4, 1);
|
||||
int nType = nThingType-kThingBase;
|
||||
int nThing = pSprite->index;
|
||||
int nXThing = pSprite->extra;
|
||||
|
@ -6329,7 +6369,7 @@ spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5,
|
|||
y = gHitInfo.hity-MulScale(pMissileInfo->clipDist<<1, Sin(pSprite->ang), 28);
|
||||
}
|
||||
}
|
||||
spritetype *pMissile = actSpawnSprite(pSprite->sectnum, x, y, z, 5, 1);
|
||||
spritetype *pMissile = actSpawnSprite_(pSprite->sectnum, x, y, z, 5, 1);
|
||||
int nMissile = pMissile->index;
|
||||
show2dsprite.Set(nMissile);
|
||||
pMissile->type = nType;
|
||||
|
@ -6995,5 +7035,11 @@ void SerializeActor(FSerializer& arc)
|
|||
}
|
||||
}
|
||||
|
||||
spritetype* actDropObject(spritetype* pSprite, int nType)
|
||||
{
|
||||
auto act = actDropObject(&bloodActors[pSprite->index], nType);
|
||||
return act ? &act->s() : nullptr;
|
||||
}
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -214,12 +214,6 @@ void actInit(bool bSaveLoad);
|
|||
int actWallBounceVector(int *x, int *y, int nWall, int a4);
|
||||
int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5);
|
||||
void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11);
|
||||
spritetype *actSpawnFloor(spritetype *pSprite);
|
||||
spritetype *actDropAmmo(spritetype *pSprite, int nType);
|
||||
spritetype *actDropWeapon(spritetype *pSprite, int nType);
|
||||
spritetype *actDropItem(spritetype *pSprite, int nType);
|
||||
spritetype *actDropKey(spritetype *pSprite, int nType);
|
||||
spritetype *actDropFlag(spritetype *pSprite, int nType);
|
||||
spritetype *actDropObject(spritetype *pSprite, int nType);
|
||||
bool actHealDude(XSPRITE *pXDude, int a2, int a3);
|
||||
void actKillDude(int a1, spritetype *pSprite, DAMAGE_TYPE a3, int a4);
|
||||
|
@ -238,7 +232,8 @@ void actExplodeSprite(spritetype *pSprite);
|
|||
void actActivateGibObject(DBloodActor *actor);
|
||||
bool IsUnderWater(spritetype *pSprite);
|
||||
void actProcessSprites(void);
|
||||
spritetype * actSpawnSprite(int nSector, int x, int y, int z, int nStat, char a6);
|
||||
spritetype * actSpawnSprite_(int nSector, int x, int y, int z, int nStat, char a6);
|
||||
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6);
|
||||
spritetype *actSpawnDude(spritetype *pSource, short nType, int a3, int a4);
|
||||
spritetype * actSpawnSprite(spritetype *pSource, int nStat);
|
||||
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType);
|
||||
|
|
|
@ -306,7 +306,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
|
|||
}
|
||||
|
||||
spritetype* pThing = NULL;
|
||||
if ((pThing = actFireThing(pSprite, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == NULL) return;
|
||||
if ((pThing = actFireThing_(pSprite, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == NULL) return;
|
||||
else if (pThinkInfo->picnum < 0 && pThing->type != kModernThingThrowableRock) pThing->picnum = 0;
|
||||
|
||||
pThing->owner = pSprite->index;
|
||||
|
@ -1592,7 +1592,7 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT event)
|
|||
}
|
||||
|
||||
bool doExplosion(spritetype* pSprite, int nType) {
|
||||
spritetype* pExplosion = actSpawnSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, kStatExplosion, true);
|
||||
spritetype* pExplosion = actSpawnSprite_(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, kStatExplosion, true);
|
||||
if (pExplosion->extra < 0 || pExplosion->extra >= kMaxXSprites)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ public:
|
|||
dudeSlope = 0;
|
||||
}
|
||||
bool hasX() { return sprite[index].extra > 0; }
|
||||
void addX()
|
||||
{
|
||||
if (s().extra == -1) dbInsertXSprite(s().index);
|
||||
}
|
||||
spritetype& s() { return sprite[index]; }
|
||||
XSPRITE& x() { return xsprite[sprite[index].extra]; } // calling this does not validate the xsprite!
|
||||
SPRITEHIT& hit() { return gSpriteHit[sprite[index].extra]; }
|
||||
|
@ -131,4 +135,10 @@ inline void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime)
|
|||
pXSprite->burnSource = pSource->s().index;
|
||||
}
|
||||
|
||||
inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom)
|
||||
{
|
||||
GetSpriteExtents(&actor->s(), top, bottom);
|
||||
}
|
||||
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -164,7 +164,7 @@ spritetype * CFX::fxSpawn(FX_ID nFx, int nSector, int x, int y, int z, unsigned
|
|||
return NULL;
|
||||
destroy(nSprite);
|
||||
}
|
||||
spritetype *pSprite = actSpawnSprite(nSector, x, y, z, 1, 0);
|
||||
spritetype *pSprite = actSpawnSprite_(nSector, x, y, z, 1, 0);
|
||||
pSprite->type = nFx;
|
||||
pSprite->picnum = pFX->picnum;
|
||||
pSprite->cstat |= pFX->cstat;
|
||||
|
|
|
@ -660,7 +660,7 @@ void playerStart(int nPlayer, int bNewLevel)
|
|||
pStartZone = &gStartZone[Random(8)];
|
||||
}
|
||||
|
||||
spritetype *pSprite = actSpawnSprite(pStartZone->sectnum, pStartZone->x, pStartZone->y, pStartZone->z, 6, 1);
|
||||
spritetype *pSprite = actSpawnSprite_(pStartZone->sectnum, pStartZone->x, pStartZone->y, pStartZone->z, 6, 1);
|
||||
assert(pSprite->extra > 0 && pSprite->extra < kMaxXSprites);
|
||||
XSPRITE *pXSprite = &xsprite[pSprite->extra];
|
||||
pPlayer->pSprite = pSprite;
|
||||
|
|
Loading…
Reference in a new issue