mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
- actSpawnThing and actFireThing.
This commit is contained in:
parent
7c1826e909
commit
4526f4149b
9 changed files with 68 additions and 54 deletions
|
@ -6534,33 +6534,31 @@ DBloodActor* actSpawnDude(DBloodActor* source, short nType, int a3, int a4)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
|
||||
DBloodActor* actSpawnThing(int nSector, int x, int y, int z, int nThingType)
|
||||
{
|
||||
assert(nThingType >= kThingBase && nThingType < kThingMax);
|
||||
auto actor = actSpawnSprite(nSector, x, y, z, 4, 1);
|
||||
spritetype* pSprite = &actor->s();
|
||||
int nType = nThingType-kThingBase;
|
||||
int nType = nThingType - kThingBase;
|
||||
int nThing = pSprite->index;
|
||||
int nXThing = pSprite->extra;
|
||||
pSprite->type = nThingType;
|
||||
assert(nXThing > 0 && nXThing < kMaxXSprites);
|
||||
XSPRITE *pXThing = &xsprite[nXThing];
|
||||
const THINGINFO *pThingInfo = &thingInfo[nType];
|
||||
pXThing->health = pThingInfo->startHealth<<4;
|
||||
XSPRITE* pXThing = &xsprite[nXThing];
|
||||
const THINGINFO* pThingInfo = &thingInfo[nType];
|
||||
pXThing->health = pThingInfo->startHealth << 4;
|
||||
pSprite->clipdist = pThingInfo->clipdist;
|
||||
pSprite->flags = pThingInfo->flags;
|
||||
if (pSprite->flags & 2)
|
||||
pSprite->flags |= 4;
|
||||
if (pSprite->flags & 2) pSprite->flags |= 4;
|
||||
pSprite->cstat |= pThingInfo->cstat;
|
||||
pSprite->picnum = pThingInfo->picnum;
|
||||
pSprite->shade = pThingInfo->shade;
|
||||
pSprite->pal = pThingInfo->pal;
|
||||
if (pThingInfo->xrepeat)
|
||||
pSprite->xrepeat = pThingInfo->xrepeat;
|
||||
if (pThingInfo->yrepeat)
|
||||
pSprite->yrepeat = pThingInfo->yrepeat;
|
||||
if (pThingInfo->xrepeat) pSprite->xrepeat = pThingInfo->xrepeat;
|
||||
if (pThingInfo->yrepeat) pSprite->yrepeat = pThingInfo->yrepeat;
|
||||
show2dsprite.Set(pSprite->index);
|
||||
switch (nThingType) {
|
||||
switch (nThingType)
|
||||
{
|
||||
case kThingVoodooHead:
|
||||
pXThing->data1 = 0;
|
||||
pXThing->data2 = 0;
|
||||
|
@ -6570,10 +6568,11 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
|
|||
pXThing->triggerOnce = 1;
|
||||
pXThing->isTriggered = 0;
|
||||
break;
|
||||
|
||||
case kThingDroppedLifeLeech:
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
case kModernThingEnemyLifeLeech:
|
||||
#endif
|
||||
#endif
|
||||
pXThing->data1 = 0;
|
||||
pXThing->data2 = 0;
|
||||
pXThing->data3 = 0;
|
||||
|
@ -6582,74 +6581,87 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType)
|
|||
pXThing->triggerOnce = 0;
|
||||
pXThing->isTriggered = 0;
|
||||
break;
|
||||
|
||||
case kThingZombieHead:
|
||||
pXThing->data1 = 8;
|
||||
pXThing->data2 = 0;
|
||||
pXThing->data3 = 0;
|
||||
pXThing->data4 = 318;
|
||||
pXThing->targetX = PlayClock+180;
|
||||
pXThing->targetX = PlayClock + 180;
|
||||
pXThing->locked = 1;
|
||||
pXThing->state = 1;
|
||||
pXThing->triggerOnce = 0;
|
||||
pXThing->isTriggered = 0;
|
||||
break;
|
||||
|
||||
case kThingBloodBits:
|
||||
case kThingBloodChunks:
|
||||
pXThing->data1 = (nThingType == kThingBloodBits) ? 19 : 8;
|
||||
pXThing->data2 = 0;
|
||||
pXThing->data3 = 0;
|
||||
pXThing->data4 = 318;
|
||||
pXThing->targetX = PlayClock+180;
|
||||
pXThing->targetX = PlayClock + 180;
|
||||
pXThing->locked = 1;
|
||||
pXThing->state = 1;
|
||||
pXThing->triggerOnce = 0;
|
||||
pXThing->isTriggered = 0;
|
||||
break;
|
||||
|
||||
case kThingArmedTNTStick:
|
||||
evPost(nThing, 3, 0, kCallbackFXDynPuff);
|
||||
sfxPlay3DSound(pSprite, 450, 0, 0);
|
||||
break;
|
||||
|
||||
case kThingArmedTNTBundle:
|
||||
sfxPlay3DSound(pSprite, 450, 0, 0);
|
||||
evPost(nThing, 3, 0, kCallbackFXDynPuff);
|
||||
break;
|
||||
|
||||
case kThingArmedSpray:
|
||||
evPost(nThing, 3, 0, kCallbackFXDynPuff);
|
||||
break;
|
||||
}
|
||||
return pSprite;
|
||||
return actor;
|
||||
}
|
||||
|
||||
spritetype * actFireThing_(spritetype *pSprite, int a2, int a3, int a4, int thingType, int a6)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DBloodActor* actFireThing(DBloodActor* actor, int a2, int a3, int a4, int thingType, int a6)
|
||||
{
|
||||
auto pSprite = &actor->s();
|
||||
assert(thingType >= kThingBase && thingType < kThingMax);
|
||||
int x = pSprite->x+MulScale(a2, Cos(pSprite->ang+512), 30);
|
||||
int y = pSprite->y+MulScale(a2, Sin(pSprite->ang+512), 30);
|
||||
int z = pSprite->z+a3;
|
||||
x += MulScale(pSprite->clipdist, Cos(pSprite->ang), 28);
|
||||
y += MulScale(pSprite->clipdist, Sin(pSprite->ang), 28);
|
||||
if (HitScan(pSprite, z, x-pSprite->x, y-pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1)
|
||||
if (HitScan(pSprite, z, x - pSprite->x, y - pSprite->y, 0, CLIPMASK0, pSprite->clipdist) != -1)
|
||||
{
|
||||
x = gHitInfo.hitx-MulScale(pSprite->clipdist<<1, Cos(pSprite->ang), 28);
|
||||
y = gHitInfo.hity-MulScale(pSprite->clipdist<<1, Sin(pSprite->ang), 28);
|
||||
}
|
||||
spritetype *pThing = actSpawnThing(pSprite->sectnum, x, y, z, thingType);
|
||||
auto fired = actSpawnThing(pSprite->sectnum, x, y, z, thingType);
|
||||
spritetype* pThing = &fired->s();
|
||||
pThing->owner = pSprite->index;
|
||||
pThing->ang = pSprite->ang;
|
||||
xvel[pThing->index] = MulScale(a6, Cos(pThing->ang), 30);
|
||||
yvel[pThing->index] = MulScale(a6, Sin(pThing->ang), 30);
|
||||
zvel[pThing->index] = MulScale(a6, a4, 14);
|
||||
xvel[pThing->index] += xvel[pSprite->index]/2;
|
||||
yvel[pThing->index] += yvel[pSprite->index]/2;
|
||||
zvel[pThing->index] += zvel[pSprite->index]/2;
|
||||
return pThing;
|
||||
fired->xvel() = MulScale(a6, Cos(pThing->ang), 30);
|
||||
fired->yvel() = MulScale(a6, Sin(pThing->ang), 30);
|
||||
fired->zvel() = MulScale(a6, a4, 14);
|
||||
fired->xvel() += actor->xvel() / 2;
|
||||
fired->yvel() += actor->yvel() / 2;
|
||||
fired->zvel() += actor->zvel() / 2;
|
||||
return fired;
|
||||
}
|
||||
|
||||
DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6)
|
||||
{
|
||||
auto spr = actFireThing_(&pSprite->s(), a2, a3, a4, thingType, a6);
|
||||
return &bloodActors[spr->index];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
spritetype* actFireMissile(spritetype *pSprite, int a2, int a3, int a4, int a5, int a6, int nType)
|
||||
{
|
||||
|
|
|
@ -235,7 +235,7 @@ void actProcessSprites(void);
|
|||
DBloodActor* actSpawnSprite(int nSector, int x, int y, int z, int nStat, bool a6);
|
||||
DBloodActor* actSpawnDude(DBloodActor* pSource, short nType, int a3, int a4);
|
||||
DBloodActor * actSpawnSprite(DBloodActor *pSource, int nStat);
|
||||
spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType);
|
||||
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);
|
||||
DBloodActor* actFireThing(DBloodActor* pSprite, int a2, int a3, int a4, int thingType, int a6);
|
||||
|
||||
|
|
|
@ -146,11 +146,11 @@ void cultThrowSeqCallback(int, DBloodActor* actor)
|
|||
int nDist2 = nDist / 540;
|
||||
if (nDist > 0x1e00)
|
||||
v4 = 0;
|
||||
spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120);
|
||||
auto* pMissile = actFireThing(actor, 0, 0, dz/128-14500, nMissile, (nDist2<<23)/120);
|
||||
if (v4)
|
||||
xsprite[pMissile->extra].Impact = 1;
|
||||
pMissile->x().Impact = 1;
|
||||
else
|
||||
evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn);
|
||||
evPost(pMissile, 120 * (1 + Random(2)), kCmdOn);
|
||||
}
|
||||
|
||||
void sub_68170(int, DBloodActor* actor)
|
||||
|
@ -161,8 +161,8 @@ void sub_68170(int, DBloodActor* actor)
|
|||
if (gGameOptions.nDifficulty > 2)
|
||||
nMissile = kThingArmedTNTBundle;
|
||||
sfxPlay3DSound(pSprite, 455, -1, 0);
|
||||
spritetype* pMissile = actFireThing_(pSprite, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333);
|
||||
evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn);
|
||||
auto pMissile = actFireThing(actor, 0, 0, actor->dudeSlope - 9460, nMissile, 0x133333);
|
||||
evPost(pMissile, 120 * (2 + Random(2)), kCmdOn);
|
||||
}
|
||||
|
||||
void sub_68230(int, DBloodActor* actor)
|
||||
|
@ -181,8 +181,8 @@ void sub_68230(int, DBloodActor* actor)
|
|||
int dz = pTarget->z - pSprite->z;
|
||||
int nDist = approxDist(dx, dy);
|
||||
int nDist2 = nDist / 540;
|
||||
spritetype *pMissile = actFireThing_(pSprite, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120);
|
||||
xsprite[pMissile->extra].Impact = 1;
|
||||
auto pMissile = actFireThing(actor, 0, 0, dz/128-14500, nMissile, (nDist2<<17)/120);
|
||||
pMissile->x().Impact = 1;
|
||||
}
|
||||
|
||||
static char TargetNearExplosion(spritetype *pSprite)
|
||||
|
|
|
@ -102,7 +102,7 @@ void ThrowFSeqCallback(int, DBloodActor* actor)
|
|||
{
|
||||
XSPRITE* pXSprite = &actor->x();
|
||||
spritetype* pSprite = &actor->s();
|
||||
actFireThing_(&actor->s(), 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee);
|
||||
actFireThing(actor, 0, 0, actor->dudeSlope-7500, kThingBone, 0xeeeee);
|
||||
}
|
||||
|
||||
void BlastSSeqCallback(int, DBloodActor* actor)
|
||||
|
@ -201,8 +201,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
|
|||
|
||||
void ThrowSSeqCallback(int, DBloodActor* actor)
|
||||
{
|
||||
spritetype* pSprite = &actor->s();
|
||||
actFireThing_(pSprite, 0, 0, actor->dudeSlope - 7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111);
|
||||
actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, Chance(0x6000) ? 0x133333 : 0x111111);
|
||||
}
|
||||
|
||||
static void gargThinkTarget(DBloodActor* actor)
|
||||
|
|
|
@ -85,7 +85,7 @@ void ghostSlashSeqCallback(int, DBloodActor* actor)
|
|||
|
||||
void ghostThrowSeqCallback(int, DBloodActor* actor)
|
||||
{
|
||||
actFireThing_(&actor->s(), 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee);
|
||||
actFireThing(actor, 0, 0, actor->dudeSlope - 7500, kThingBone, 0xeeeee);
|
||||
}
|
||||
|
||||
void ghostBlastSeqCallback(int, DBloodActor* actor)
|
||||
|
|
|
@ -86,7 +86,7 @@ void podAttack(int, DBloodActor* actor)
|
|||
y += Random2(1000);
|
||||
int nDist = approxDist(x, y);
|
||||
int nDist2 = nDist / 540;
|
||||
spritetype *pMissile = NULL;
|
||||
DBloodActor* pMissile = nullptr;
|
||||
switch (pSprite->type)
|
||||
{
|
||||
case kDudePodGreen:
|
||||
|
@ -97,20 +97,20 @@ void podAttack(int, DBloodActor* actor)
|
|||
sfxPlay3DSound(pSprite, 2474, -1, 0);
|
||||
else
|
||||
sfxPlay3DSound(pSprite, 2475, -1, 0);
|
||||
pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120);
|
||||
pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodGreenBall, (nDist2<<23)/120);
|
||||
}
|
||||
if (pMissile)
|
||||
seqSpawn(68, 3, pMissile->extra, -1);
|
||||
seqSpawn(68, pMissile, -1);
|
||||
break;
|
||||
case kDudePodFire:
|
||||
dz += 8000;
|
||||
if (pDudeInfo->seeDist*0.1 < nDist)
|
||||
{
|
||||
sfxPlay3DSound(pSprite, 2454, -1, 0);
|
||||
pMissile = actFireThing_(pSprite, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120);
|
||||
pMissile = actFireThing(actor, 0, -8000, dz/128-14500, kThingPodFireBall, (nDist2<<23)/120);
|
||||
}
|
||||
if (pMissile)
|
||||
seqSpawn(22, 3, pMissile->extra, -1);
|
||||
seqSpawn(22, pMissile, -1);
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
|
@ -315,9 +315,11 @@ static void ThrowThing(DBloodActor* actor, bool impact)
|
|||
break;
|
||||
}
|
||||
|
||||
spritetype* pThing = NULL;
|
||||
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;
|
||||
DBloodActor* spawned = nullptr;
|
||||
if ((spawned = actFireThing(actor, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == nullptr) return;
|
||||
|
||||
spritetype* pThing = &spawned->s();
|
||||
if (pThinkInfo->picnum < 0 && pThing->type != kModernThingThrowableRock) pThing->picnum = 0;
|
||||
|
||||
pThing->owner = pSprite->index;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "build.h"
|
||||
|
||||
#include "blood.h"
|
||||
#include "bloodactor.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -381,7 +382,7 @@ void GibThing(spritetype *pSprite, GIBTHING *pGThing, CGibPosition *pPos, CGibVe
|
|||
getzsofslope(nSector, x, y, &ceilZ, &floorZ);
|
||||
int dz1 = floorZ-z;
|
||||
int dz2 = z-ceilZ;
|
||||
spritetype *pGib = actSpawnThing(nSector, x, y, z, pGThing->type);
|
||||
spritetype *pGib = &actSpawnThing(nSector, x, y, z, pGThing->type)->s();
|
||||
assert(pGib != NULL);
|
||||
if (pGThing->Kills > -1)
|
||||
pGib->picnum = pGThing->Kills;
|
||||
|
|
|
@ -1784,7 +1784,7 @@ spritetype *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, i
|
|||
spritetype * playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5)
|
||||
{
|
||||
assert(thingType >= kThingBase && thingType < kThingMax);
|
||||
return actFireThing_(pPlayer->pSprite, a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5);
|
||||
return &actFireThing(&bloodActors[pPlayer->pSprite->index], a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5)->s();
|
||||
}
|
||||
|
||||
void playerFrag(PLAYER *pKiller, PLAYER *pVictim)
|
||||
|
|
Loading…
Reference in a new issue