- more use* functions.

This commit is contained in:
Christoph Oelckers 2021-10-13 19:17:45 +02:00
parent c54dd079fb
commit a60617c688
2 changed files with 44 additions and 30 deletions

View file

@ -4793,17 +4793,17 @@ void modernTypeTrigger(int destObjType, int destObjIndex, DBloodActor* destactor
break; break;
// change data field value of destination object // change data field value of destination object
case kModernObjDataChanger: case kModernObjDataChanger:
useDataChanger(pXSource, destObjType, destObjIndex); useDataChanger(event.actor, destObjType, destObjIndex, destactor);
break; break;
// change sector lighting dynamically // change sector lighting dynamically
case kModernSectorFXChanger: case kModernSectorFXChanger:
if (destObjType != OBJ_SECTOR) break; if (destObjType != OBJ_SECTOR) break;
useSectorLigthChanger(pXSource, &xsector[sector[destObjIndex].extra]); useSectorLigthChanger(event.actor, &xsector[sector[destObjIndex].extra]);
break; break;
// change target of dudes and make it fight // change target of dudes and make it fight
case kModernDudeTargetChanger: case kModernDudeTargetChanger:
if (destObjType != OBJ_SPRITE) break; if (destObjType != OBJ_SPRITE) break;
useTargetChanger(pXSource, &destactor->s()); useTargetChanger(event.actor, destactor);
break; break;
// change picture and palette of TX ID object // change picture and palette of TX ID object
case kModernObjPicnumChanger: case kModernObjPicnumChanger:
@ -6495,7 +6495,7 @@ void useSlopeChanger(DBloodActor* sourceactor, int objType, int objIndex, DBlood
auto pXSource = &sourceactor->x(); auto pXSource = &sourceactor->x();
spritetype* pSource = &sourceactor->s(); spritetype* pSource = &sourceactor->s();
int slope, oslope, i; int slope, oslope;
bool flag2 = (pSource->flags & kModernTypeFlag2); bool flag2 = (pSource->flags & kModernTypeFlag2);
if (pSource->flags & kModernTypeFlag1) slope = ClipRange(pXSource->data2, -32767, 32767); if (pSource->flags & kModernTypeFlag1) slope = ClipRange(pXSource->data2, -32767, 32767);
@ -6643,10 +6643,11 @@ void useSlopeChanger(DBloodActor* sourceactor, int objType, int objIndex, DBlood
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void useDataChanger(XSPRITE* pXSource, int objType, int objIndex) { void useDataChanger(DBloodActor* sourceactor, int objType, int objIndex, DBloodActor* objActor)
{
auto pXSource = &sourceactor->x();
spritetype* pSource = &sourceactor->s();
auto objActor = &bloodActors[objIndex];
spritetype* pSource = &sprite[pXSource->reference];
switch (objType) switch (objType)
{ {
case OBJ_SECTOR: case OBJ_SECTOR:
@ -6679,9 +6680,11 @@ void useDataChanger(XSPRITE* pXSource, int objType, int objIndex) {
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector) { void useSectorLigthChanger(DBloodActor* sourceactor, XSECTOR* pXSector)
{
auto pXSource = &sourceactor->x();
spritetype* pSource = &sourceactor->s();
spritetype* pSource = &sprite[pXSource->reference];
if (valueIsBetween(pXSource->data1, -1, 32767)) if (valueIsBetween(pXSource->data1, -1, 32767))
pXSector->wave = ClipHigh(pXSource->data1, 11); pXSector->wave = ClipHigh(pXSource->data1, 11);
@ -6732,16 +6735,18 @@ void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector) {
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
{
spritetype* pSprite = &actor->s();
if (!actor->IsDudeActor() || pSprite->statnum != kStatDude)
if (!IsDudeSprite(pSprite) || pSprite->statnum != kStatDude) { {
switch (pSprite->type) // can be dead dude turned in gib switch (pSprite->type) // can be dead dude turned in gib
{ {
// make current target and all other dudes not attack this dude anymore // make current target and all other dudes not attack this dude anymore
case kThingBloodBits: case kThingBloodBits:
case kThingBloodChunks: case kThingBloodChunks:
aiFightFreeTargets(&bloodActors[pSprite->index]); aiFightFreeTargets(actor);
return; return;
default: default:
return; return;
@ -6749,10 +6754,14 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
} }
auto actor = &bloodActors[pSprite->index]; auto pXSource = &sourceactor->x();
XSPRITE* pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &actor->x();
spritetype* pTarget = NULL; XSPRITE* pXTarget = NULL; int receiveHp = 33 + Random(33);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type); int matesPerEnemy = 1; spritetype* pTarget = NULL;
XSPRITE* pXTarget = NULL;
int receiveHp = 33 + Random(33);
DUDEINFO* pDudeInfo = getDudeInfo(pSprite->type);
int matesPerEnemy = 1;
// dude is burning? // dude is burning?
if (pXSprite->burnTime > 0 && spriRangeIsFine(pXSprite->burnSource)) if (pXSprite->burnTime > 0 && spriRangeIsFine(pXSprite->burnSource))
@ -6760,15 +6769,20 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
if (IsBurningDude(pSprite)) return; if (IsBurningDude(pSprite)) return;
else else
{ {
spritetype* pBurnSource = &sprite[pXSprite->burnSource]; auto burnactor = actor->GetBurnSource();
if (pBurnSource->extra >= 0) { spritetype* pBurnSource = &burnactor->s();
if (pXSource->data2 == 1 && pXSprite->rxID == xsprite[pBurnSource->extra].rxID) { if (burnactor->hasX())
{
if (pXSource->data2 == 1 && pXSprite->rxID == burnactor->x().rxID)
{
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
// heal dude a bit in case of friendly fire // heal dude a bit in case of friendly fire
int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4; int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4;
if (pXSprite->health < (unsigned)startHp) actHealDude(&bloodActors[pXSprite->reference], receiveHp, startHp); if (pXSprite->health < (unsigned)startHp) actHealDude(actor, receiveHp, startHp);
} else if (xsprite[pBurnSource->extra].health <= 0) { }
else if (burnactor->x().health <= 0)
{
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
} }
} }
@ -6783,14 +6797,14 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
auto actLeech = leechIsDropped(actor); auto actLeech = leechIsDropped(actor);
if (pXSource->data4 == 3) if (pXSource->data4 == 3)
{ {
aiSetTarget_(pXSprite, pSprite->x, pSprite->y, pSprite->z); aiSetTarget(actor, pSprite->x, pSprite->y, pSprite->z);
aiSetGenIdleState(&bloodActors[pSprite->index]); aiSetGenIdleState(actor);
if (pSprite->type == kDudeModernCustom && actLeech) if (pSprite->type == kDudeModernCustom && actLeech)
removeLeech(actLeech); removeLeech(actLeech);
} }
else if (pXSource->data4 == 4) else if (pXSource->data4 == 4)
{ {
aiSetTarget_(pXSprite, pPlayer->x, pPlayer->y, pPlayer->z); aiSetTarget(actor, pPlayer->x, pPlayer->y, pPlayer->z);
if (pSprite->type == kDudeModernCustom && actLeech) if (pSprite->type == kDudeModernCustom && actLeech)
removeLeech(actLeech); removeLeech(actLeech);
} }

View file

@ -325,9 +325,9 @@ void useRandomItemGen(DBloodActor* pSource);
void useUniMissileGen(DBloodActor* sourceactor, DBloodActor* actor); void useUniMissileGen(DBloodActor* sourceactor, DBloodActor* actor);
void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor); void useSoundGen(DBloodActor* sourceactor, DBloodActor* actor);
void useIncDecGen(DBloodActor* sourceactor, short objType, int objIndex, DBloodActor* objactor); void useIncDecGen(DBloodActor* sourceactor, short objType, int objIndex, DBloodActor* objactor);
void useDataChanger(XSPRITE* pXSource, int objType, int objIndex); void useDataChanger(DBloodActor* sourceactor, int objType, int objIndex, DBloodActor* objActor);
void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector); void useSectorLigthChanger(DBloodActor* pXSource, XSECTOR* pXSector);
void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite); void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor);
void usePictureChanger(XSPRITE* pXSource, int objType, int objIndex); void usePictureChanger(XSPRITE* pXSource, int objType, int objIndex);
void useSequentialTx(DBloodActor* pXSource, COMMAND_ID cmd, bool setState); void useSequentialTx(DBloodActor* pXSource, COMMAND_ID cmd, bool setState);
void useRandomTx(DBloodActor* sourceactor, COMMAND_ID cmd, bool setState); void useRandomTx(DBloodActor* sourceactor, COMMAND_ID cmd, bool setState);