Skip to content

Commit

Permalink
- more leech stuff.
Browse files Browse the repository at this point in the history
# Conflicts:
#	source/games/blood/src/ai.cpp
  • Loading branch information
coelckers committed Oct 12, 2021
1 parent d2f16ec commit 040049f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
3 changes: 1 addition & 2 deletions source/games/blood/src/actor.cpp
Expand Up @@ -2526,7 +2526,6 @@ static void actInitDudes()

void actInit(bool bSaveLoad)
{

#ifdef NOONE_EXTENSIONS
if (!gModernMap) nnExtResetGlobals();
else nnExtInitModernStuff(bSaveLoad);
Expand Down Expand Up @@ -2947,7 +2946,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
auto pSprite = &actor->s();
auto pXSprite = &actor->x();
GENDUDEEXTRA* pExtra = &actor->genDudeExtra();
removeDudeStuff(pSprite);
removeDudeStuff(actor);
if (pXSprite->txID <= 0 || getNextIncarnation(pXSprite) == nullptr)
{
if (pExtra->weaponType == kGenDudeWeaponKamikaze && Chance(0x4000) && damageType != kDamageSpirit && damageType != kDamageDrown)
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/ai.cpp
Expand Up @@ -1058,7 +1058,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
if (pXSprite->health > (uint32_t)pDudeInfo->fleeHealth) return nDamage;
else if (pXSprite->txID <= 0 || getNextIncarnation(pXSprite) == nullptr)
{
removeDudeStuff(pSprite);
removeDudeStuff(actor);

if (pExtra->weaponType == kGenDudeWeaponKamikaze)
doExplosion(pSprite, pXSprite->data1 - kTrapExploder);
Expand Down
57 changes: 38 additions & 19 deletions source/games/blood/src/aiunicult.cpp
Expand Up @@ -348,7 +348,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
case kThingDroppedLifeLeech:
zThrow = 5000;
// pickup life leech before throw it again
if (pLeech != NULL) removeLeech(pLeech);
if (actLeech != NULL) removeLeech(actLeech);
break;
}

Expand Down Expand Up @@ -719,7 +719,7 @@ static void unicultThinkChase(DBloodActor* actor)
{
case kMissileLifeLeechRegular:
// pickup life leech if it was thrown previously
if (pLeech != NULL) removeLeech(pLeech);
if (actLeech != NULL) removeLeech(actLeech);
mdist = 1500;
break;
case kMissileFlareAlt:
Expand Down Expand Up @@ -1416,37 +1416,55 @@ DBloodActor* leechIsDropped(DBloodActor* actor)
return actor->genDudeExtra().pLifeLeech;
}

void removeDudeStuff(spritetype* pSprite) {
int nSprite;
StatIterator it(kStatThing);
while ((nSprite = it.NextIndex()) >= 0)
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

void removeDudeStuff(DBloodActor* actor)
{
auto pSprite = &actor->s();
BloodStatIterator it(kStatThing);
while (auto actor2 = it.Next())
{
if (sprite[nSprite].owner != pSprite->index) continue;
switch (sprite[nSprite].type) {
if ( actor2->GetOwner() != actor) continue;
auto pSprite2 = &actor2->s();
switch (pSprite2->type) {
case kThingArmedProxBomb:
case kThingArmedRemoteBomb:
case kModernThingTNTProx:
sprite[nSprite].type = kSpriteDecoration;
actPostSprite(sprite[nSprite].index, kStatFree);
pSprite2->type = kSpriteDecoration;
actPostSprite(actor2, kStatFree);
break;
case kModernThingEnemyLifeLeech:
killDudeLeech(&sprite[nSprite]);
killDudeLeech(pSprite2);
break;
}
}

it.Reset(kStatDude);
while ((nSprite = it.NextIndex()) >= 0)
while (auto actor2 = it.Next())
{
if (sprite[nSprite].owner != pSprite->index) continue;
actDamageSprite(&bloodActors[sprite[nSprite].owner], &bloodActors[nSprite], kDamageFall, 65535);
if (actor2->GetOwner() != actor) continue;
actDamageSprite(actor2->GetOwner(), actor2, kDamageFall, 65535);
}
}

void removeLeech(spritetype* pLeech, bool delSprite) {
if (pLeech != NULL) {
spritetype* pEffect = gFX.fxSpawn((FX_ID)52,pLeech->sectnum,pLeech->x,pLeech->y,pLeech->z,pLeech->ang);
if (pEffect != NULL) {
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

void removeLeech(DBloodActor* actLeech, bool delSprite)
{
if (actLeech != NULL)
{
auto const pLeech = &actLeech->s();
spritetype* pEffect = gFX.fxSpawn((FX_ID)52, pLeech->sectnum, pLeech->x, pLeech->y, pLeech->z, pLeech->ang);
if (pEffect != NULL)
{
pEffect->cstat = CSTAT_SPRITE_ALIGNMENT_FACING;
pEffect->pal = 6;
int repeat = 64 + Random(50);
Expand All @@ -1459,7 +1477,8 @@ void removeLeech(spritetype* pLeech, bool delSprite) {
if (pLeech->owner >= 0 && pLeech->owner < kMaxSprites)
gGenDudeExtra[sprite[pLeech->owner].index].pLifeLeech = nullptr;

if (delSprite) {
if (delSprite)
{
pLeech->type = kSpriteDecoration;
actPostSprite(pLeech->index, kStatFree);
}
Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/aiunicult.h
Expand Up @@ -197,8 +197,8 @@ extern GENDUDEEXTRA gGenDudeExtra[kMaxSprites];

XSPRITE* getNextIncarnation(XSPRITE* pXSprite);
void killDudeLeech(spritetype* pLeech);
void removeLeech(spritetype* pLeech, bool delSprite = true);
void removeDudeStuff(spritetype* pSprite);
void removeLeech(DBloodActor* pLeech, bool delSprite = true);
void removeDudeStuff(DBloodActor* pSprite);
DBloodActor* leechIsDropped(DBloodActor* pSprite);
bool spriteIsUnderwater(DBloodActor* pSprite, bool oldWay = false);
bool playGenDudeSound(DBloodActor* actor, int mode);
Expand Down
4 changes: 2 additions & 2 deletions source/games/blood/src/nnexts.cpp
Expand Up @@ -5913,11 +5913,11 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
aiSetTarget_(pXSprite, pSprite->x, pSprite->y, pSprite->z);
aiSetGenIdleState(pSprite, pXSprite);
if (pSprite->type == kDudeModernCustom && actLeech)
removeLeech(&actLeech->s());
removeLeech(actLeech);
} else if (pXSource->data4 == 4) {
aiSetTarget_(pXSprite, pPlayer->x, pPlayer->y, pPlayer->z);
if (pSprite->type == kDudeModernCustom && actLeech)
removeLeech(&actLeech->s());
removeLeech(actLeech);
}
}

Expand Down

0 comments on commit 040049f

Please sign in to comment.