- several is...() functions.

This commit is contained in:
Christoph Oelckers 2021-08-29 13:44:04 +02:00
parent 49879af921
commit 3928407eae
4 changed files with 39 additions and 35 deletions

View file

@ -4259,7 +4259,7 @@ static void checkCeilHit(DBloodActor* actor)
#ifdef NOONE_EXTENSIONS
// add size shroom abilities
if ((actor->IsPlayerActor() && isShrinked(pSprite)) || (actor2->IsPlayerActor() && isGrown(pSprite2))) {
if ((actor->IsPlayerActor() && isShrinked(actor)) || (actor2->IsPlayerActor() && isGrown(actor2))) {
int mass1 = getDudeInfo(pSprite2->type)->mass;
int mass2 = getDudeInfo(pSprite->type)->mass;
@ -4349,7 +4349,7 @@ static void checkHit(DBloodActor* actor)
#ifdef NOONE_EXTENSIONS
// add size shroom abilities
if ((actor2->IsPlayerActor() && isShrinked(pSprite2)) || (actor->IsPlayerActor() && isGrown(pSprite)))
if ((actor2->IsPlayerActor() && isShrinked(actor2)) || (actor->IsPlayerActor() && isGrown(actor)))
{
if (actor->xvel() != 0 && actor2->IsDudeActor())
{
@ -4427,7 +4427,7 @@ static void checkFloorHit(DBloodActor* actor)
#ifdef NOONE_EXTENSIONS
// add size shroom abilities
if ((actor2->IsPlayerActor() && isShrinked(pSprite2)) || (actor->IsPlayerActor() && isGrown(pSprite)))
if ((actor2->IsPlayerActor() && isShrinked(actor2)) || (actor->IsPlayerActor() && isGrown(actor)))
{
int mass1 = getDudeInfo(pSprite->type)->mass;
@ -4519,7 +4519,7 @@ static void checkFloorHit(DBloodActor* actor)
case kDudePlayer7:
case kDudePlayer8:
#ifdef NOONE_EXTENSIONS
if (pPlayer && !isShrinked(pSprite))
if (pPlayer && !isShrinked(actor))
#else
if (pPlayer)
#endif
@ -6158,7 +6158,7 @@ static void actCheckDudes()
if (actor->hasX())
{
XSPRITE* pXSprite = &actor->x();
const bool fixBurnGlitch = !cl_bloodvanillaenemies && IsBurningDude(pSprite) && !VanillaMode(); // if enemies are burning, always apply burning damage per tick
const bool fixBurnGlitch = !cl_bloodvanillaenemies && IsBurningDude(actor) && !VanillaMode(); // if enemies are burning, always apply burning damage per tick
if ((pXSprite->burnTime > 0) || fixBurnGlitch)
{
switch (pSprite->type)

View file

@ -331,7 +331,7 @@ static DBloodActor* nnExtSpawnDude(DBloodActor* sourceActor, DBloodActor* origin
gKillMgr.AddNewKill(1);
bool burning = IsBurningDude(pDude);
bool burning = IsBurningDude(pDudeActor);
if (burning) {
pXDude->burnTime = 10;
pDudeActor->SetTarget(nullptr);
@ -4179,11 +4179,9 @@ bool condCheckPlayer(XSPRITE* pXCond, int cmpOp, bool PUSH) {
return false;
}
spritetype* pSpr = pPlayer->pSprite;
switch (cond) {
case 0: // check if this player is connected
if (!condCmp(pPlayer->nPlayer + 1, arg1, arg2, cmpOp) || !spriRangeIsFine(pPlayer->nSprite)) return false;
if (!condCmp(pPlayer->nPlayer + 1, arg1, arg2, cmpOp) || pPlayer->actor() == nullptr) return false;
else if (PUSH) condPush(pXCond, OBJ_SPRITE, pPlayer->nSprite);
return (pPlayer->nPlayer >= 0);
case 1: return condCmp((gGameOptions.nGameType != 3) ? 0 : pPlayer->teamId + 1, arg1, arg2, cmpOp); // compare team
@ -4226,8 +4224,8 @@ bool condCheckPlayer(XSPRITE* pXCond, int cmpOp, bool PUSH) {
case 14: return condCmp(pPlayer->posture + 1, arg1, arg2, cmpOp);
case 46: return condCmp(pPlayer->sceneQav, arg1, arg2, cmpOp);
case 47: return (pPlayer->godMode || powerupCheck(pPlayer, kPwUpDeathMask));
case 48: return isShrinked(pSpr);
case 49: return isGrown(pSpr);
case 48: return isShrinked(pPlayer->actor());
case 49: return isGrown(pPlayer->actor());
}
condError(pXCond, "Unexpected condition #%d!", cond);
@ -4861,7 +4859,7 @@ DBloodActor* aiFightGetTargetInRange(DBloodActor* actor, int minDist, int maxDis
if (dist < minDist || dist > maxDist) continue;
else if (actor->GetTarget() == targactor) return targactor;
else if (!targactor->IsDudeActor() || targactor == actor || targactor->IsPlayerActor()) continue;
else if (IsBurningDude(pTarget) || !IsKillableDude(pTarget) || pTarget->owner == pSprite->index) continue;
else if (IsBurningDude(targactor) || !IsKillableDude(targactor) || targactor->GetOwner() == actor) continue;
else if ((teamMode == 1 && pXSprite->rxID == pXTarget->rxID) || aiFightMatesHaveSameTarget(actor, targactor, 1)) continue;
else if (data == 666 || pXTarget->data1 == data)
{
@ -6764,7 +6762,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
// dude is burning?
if (pXSprite->burnTime > 0 && spriRangeIsFine(pXSprite->burnSource))
{
if (IsBurningDude(pSprite)) return;
if (IsBurningDude(actor)) return;
else
{
auto burnactor = actor->GetBurnSource();
@ -6958,7 +6956,7 @@ void useTargetChanger(DBloodActor* sourceactor, DBloodActor* actor)
// if Target Changer have data1 = 666, everyone can be target, except AI team mates.
else if (pXSource->data1 != 666 && pXSource->data1 != pXNewTarg->data1) continue;
// don't attack immortal, burning dudes and mates
if (IsBurningDude(&newtargactor->s()) || !IsKillableDude(&newtargactor->s()) || (pXSource->data2 == 1 && pXSprite->rxID == pXNewTarg->rxID))
if (IsBurningDude(newtargactor) || !IsKillableDude(newtargactor) || (pXSource->data2 == 1 && pXSprite->rxID == pXNewTarg->rxID))
continue;
if (pXSource->data2 == 0 || (pXSource->data2 == 1 && !aiFightMatesHaveSameTarget(actor, newtargactor, matesPerEnemy)))
@ -7283,9 +7281,11 @@ PLAYER* getPlayerById(short id)
//
//---------------------------------------------------------------------------
bool IsBurningDude(spritetype* pSprite) {
if (pSprite == NULL) return false;
switch (pSprite->type) {
bool IsBurningDude(DBloodActor* actor)
{
if (actor == NULL) return false;
switch (actor->s().type)
{
case kDudeBurningInnocent:
case kDudeBurningCultist:
case kDudeBurningZombieAxe:
@ -7299,26 +7299,30 @@ bool IsBurningDude(spritetype* pSprite) {
return false;
}
bool IsKillableDude(spritetype* pSprite) {
switch (pSprite->type) {
bool IsKillableDude(DBloodActor* actor)
{
switch (actor->s().type)
{
case kDudeGargoyleStatueFlesh:
case kDudeGargoyleStatueStone:
return false;
default:
if (!IsDudeSprite(pSprite) || xsprite[pSprite->extra].locked == 1) return false;
if (!actor->IsDudeActor() || actor->x().locked == 1) return false;
return true;
}
}
bool isGrown(spritetype* pSprite) {
if (powerupCheck(&gPlayer[pSprite->type - kDudePlayer1], kPwUpGrowShroom) > 0) return true;
else if (pSprite->extra >= 0 && xsprite[pSprite->extra].scale >= 512) return true;
bool isGrown(DBloodActor* actor)
{
if (powerupCheck(&gPlayer[actor->s().type - kDudePlayer1], kPwUpGrowShroom) > 0) return true;
else if (actor->hasX() && actor->x().scale >= 512) return true;
else return false;
}
bool isShrinked(spritetype* pSprite) {
if (powerupCheck(&gPlayer[pSprite->type - kDudePlayer1], kPwUpShrinkShroom) > 0) return true;
else if (pSprite->extra >= 0 && xsprite[pSprite->extra].scale > 0 && xsprite[pSprite->extra].scale <= 128) return true;
bool isShrinked(DBloodActor* actor)
{
if (powerupCheck(&gPlayer[actor->s().type - kDudePlayer1], kPwUpShrinkShroom) > 0) return true;
else if (actor->hasX() && actor->x().scale > 0 && actor->x().scale <= 128) return true;
else return false;
}

View file

@ -360,10 +360,10 @@ void callbackMakeMissileBlocking(DBloodActor* actor, int nSprite);
void callbackGenDudeUpdate(DBloodActor* actor, int nSprite);
// ------------------------------------------------------------------------- //
PLAYER* getPlayerById(short id);
bool isGrown(spritetype* pSprite);
bool isShrinked(spritetype* pSprite);
bool IsBurningDude(spritetype* pSprite);
bool IsKillableDude(spritetype* pSprite);
bool isGrown(DBloodActor* pSprite);
bool isShrinked(DBloodActor* pSprite);
bool IsBurningDude(DBloodActor* pSprite);
bool IsKillableDude(DBloodActor* pSprite);
bool isActive(DBloodActor* nSprite);
int getDataFieldOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex);
bool setDataValueOfObject(int objType, int objIndex, DBloodActor* objActor, int dataIndex, int value);

View file

@ -254,12 +254,12 @@ char powerupActivate(PLAYER *pPlayer, int nPowerUp)
break;
case kItemShroomShrink:
if (!gModernMap) break;
else if (isGrown(pPlayer->pSprite)) playerDeactivateShrooms(pPlayer);
else if (isGrown(pPlayer->actor())) playerDeactivateShrooms(pPlayer);
else playerSizeShrink(pPlayer, 2);
break;
case kItemShroomGrow:
if (!gModernMap) break;
else if (isShrinked(pPlayer->pSprite)) playerDeactivateShrooms(pPlayer);
else if (isShrinked(pPlayer->actor())) playerDeactivateShrooms(pPlayer);
else {
playerSizeGrow(pPlayer, 2);
if (powerupCheck(&gPlayer[pPlayer->pSprite->type - kDudePlayer1], kPwUpShadowCloak) > 0) {
@ -877,7 +877,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
switch (pItem->type) {
case kItemShadowCloak:
#ifdef NOONE_EXTENSIONS
if (isGrown(pPlayer->pSprite) || !powerupActivate(pPlayer, nType)) return false;
if (isGrown(pPlayer->actor()) || !powerupActivate(pPlayer, nType)) return false;
#else
if (!powerupActivate(pPlayer, nType)) return false;
#endif
@ -889,10 +889,10 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if (gModernMap) {
switch (pItem->type) {
case kItemShroomShrink:
if (isShrinked(pSprite)) return false;
if (isShrinked(pPlayer->actor())) return false;
break;
case kItemShroomGrow:
if (isGrown(pSprite)) return false;
if (isGrown(pPlayer->actor())) return false;
break;
}