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

View file

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