updated the rest of nnexts.cpp

This commit is contained in:
Christoph Oelckers 2023-10-15 16:01:24 +02:00
parent 463eb7cc9e
commit 45e14732f2
12 changed files with 900 additions and 476 deletions

View file

@ -31,6 +31,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "blood.h"
#include "texids.h"
#include "nnexts.h"
#include "nnextcdud.h"
BEGIN_BLD_NS
@ -771,17 +773,6 @@ TArray<POSTPONE> gPost;
//
//---------------------------------------------------------------------------
bool IsUnderwaterSector(sectortype* pSector)
{
return !!pSector->hasX() && pSector->xs().Underwater;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void actInitTraps()
{
BloodStatIterator it(kStatTraps);
@ -2363,10 +2354,12 @@ bool IsBurningDude(DBloodActor* actor)
case kDudeBurningZombieButcher:
case kDudeBurningTinyCaleb:
case kDudeBurningBeast:
#ifdef NOONE_EXTENSIONS
case kDudeModernCustomBurning:
#endif
return true;
#ifdef NOONE_EXTENSIONS
case kDudeModernCustom:
CUSTOMDUDE* pDude = cdudeGet(actor);
return (pDude->StatusTest(kCdudeStatusBurning));
#endif
}
return false;

View file

@ -131,7 +131,11 @@ void actAddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange
void actDoLight(int spriteNum);
#endif
bool IsUnderwaterSector(sectortype* pSector);
inline bool IsUnderwaterSector(sectortype* pSector)
{
return !!pSector->hasX() && pSector->xs().Underwater;
}
void actInit(TArray<DBloodActor*>& actors);
void actWallBounceVector(DBloodActor* actor, walltype* pWall, double factor);
DVector4 actFloorBounceVector(DBloodActor* actor, double oldz, sectortype* pSector, double factor);
@ -170,8 +174,6 @@ void callActorFunction(VMFunction* funcID, DBloodActor* actor);
extern const int16_t DudeDifficulty[];
bool IsUnderwaterSector(sectortype* pSector);
// route state, seq and event callbacks through the scripting interface.
// this needs to work with incomplete data, so avoid the asserting macros.
#define DEF_ANIMATOR(func) \

View file

@ -592,7 +592,7 @@ inline double Random2F(int a1, int scale = 16)
return FixedToFloat(Random2(a1), scale);
}
inline double Random2D(double val, int scale)
inline double Random2D(double val, int scale = 16)
{
return FixedToFloat(Random2(FloatToFixed(val, scale)), scale);
}

View file

@ -496,7 +496,7 @@ void DBloodActor::Serialize(FSerializer& arc)
#ifdef NOONE_EXTENSIONS
if (gModernMap)
{
arc("spritemass", spriteMass)
arc//("spritemass", spriteMass)
("prevmarker", prevmarker)
.Array("conditions", condition, 2);

View file

@ -422,7 +422,6 @@ class CUSTOMDUDE_SOUND
{
if (nID != NO_SOUND)
{
int i, j;
int nClock = PlayClock;
char uwater = spriteIsUnderwater(pSpr, true);
int nRand = Random2(80);
@ -588,7 +587,7 @@ class APPEARANCE
if (shd != 127)
{
seqKill(pSpr);
pSpr->spr.shade = shd;
pSpr->spr.shade = (int8_t)shd;
}
if (pal >= 0)
@ -596,7 +595,7 @@ class APPEARANCE
if (!plu)
seqKill(pSpr);
pSpr->spr.pal = pal;
pSpr->spr.pal = (int8_t)pal;
}
if (xrp)
@ -898,7 +897,7 @@ class CUSTOMDUDE_EFFECT
pEff->ownerActor = pSrc;
dvel.Z += Random2F(perc2val(rp, dvel.Z));
dvel.Z += Random2D(perc2val(rp, dvel.Z));
nAng += RandomAngle(perc2val(rp >> 1, nAng.Buildang())).Normalized360();
pEff->spr.Angles.Yaw = nAng.Normalized360();
@ -906,7 +905,7 @@ class CUSTOMDUDE_EFFECT
if (nVel >= 0)
{
nVel += Random2F(perc2val(rp, nVel));
nVel += Random2D(perc2val(rp, nVel));
dvel.XY() = nAng.ToVector(); // todo: determine factor (dx = (Cos(nAng) >> 16);)
if (nVel == 0)
@ -1019,7 +1018,7 @@ class CUSTOMDUDE_DODGE
unsigned int dmgReq;
char Allow(int nDamage)
{
if (nDamage > dmgReq)
if (nDamage > (int)dmgReq)
{
unsigned int nClock = (unsigned int)PlayClock;
unsigned int nChance = chance;
@ -1057,7 +1056,7 @@ class CUSTOMDUDE_RECOIL
unsigned int dmgReq;
char Allow(int nDamage)
{
if (nDamage > dmgReq)
if (nDamage > (int)dmgReq)
{
unsigned int nClock = (unsigned int)PlayClock;
unsigned int nChance = chance;
@ -1087,7 +1086,7 @@ class CUSTOMDUDE_KNOCKOUT
unsigned int dmgReq;
char Allow(int nDamage)
{
if (nDamage > dmgReq)
if (nDamage > (int)dmgReq)
{
unsigned int nClock = (unsigned int)PlayClock;
unsigned int nChance = chance;
@ -1334,7 +1333,7 @@ class CUSTOMDUDE_SETUP
public:
char FindAiState(AISTATE stateArr[][kCdudePostureMax], int arrLen, AISTATE* pNeedle, int* nType, int* nPosture);
void Setup(spritetype* pSpr, XSPRITE* pXSpr);
void Setup(CUSTOMDUDE* pOver = nullptr);
static void Setup(CUSTOMDUDE* pOver = nullptr);
};
@ -1404,9 +1403,8 @@ class CUSTOMDUDEV2_SETUP : CUSTOMDUDE_SETUP
void cdudeFree();
CUSTOMDUDE* cdudeAlloc();
CUSTOMDUDE* cdudeGet(int nIndex);
bool IsCustomDude(DBloodActor* pSpr) { return (pSpr->GetType() == kDudeModernCustom); }
CUSTOMDUDE* cdudeGet(DBloodActor* pSpr) { return cdudeGet(pSpr); };
CUSTOMDUDE* cdudeGet(DBloodActor* pSpr);
spritetype* cdudeSpawn(DBloodActor* pSource, DBloodActor* pSprite, int nDist);
void cdudeLeechOperate(DBloodActor* pSprite);

File diff suppressed because it is too large Load diff

View file

@ -64,7 +64,9 @@ enum
kModernTypeFlag4 = 0x0004,
kModernTypeFlag8 = 0x0008,
kModernTypeFlag16 = 0x0010,
kModernTypeFlag32 = 0x0020,
kModernTypeFlag64 = 0x0040,
kModernTypeFlag128 = 0x0080,
kMaxRandomizeRetries = 16,
kCondRange = 100,
@ -367,10 +369,6 @@ bool incDecGoalValueIsReached(DBloodActor* actor);
int getSpriteMassBySize(DBloodActor* pSprite);
bool ceilIsTooLow(DBloodActor* pSprite);
void levelEndLevelCustom(int nLevel);
int useCondition(DBloodActor*, EVENT& event);
bool condCmp(int val, int arg1, int arg2, int comOp);
void condError(DBloodActor* pXCond, const char* pzFormat, ...);
void conditionsUpdateIndex(DBloodActor* oldplayer, DBloodActor* newplayer);
DBloodActor* evrListRedirectors(int objType, sectortype*, walltype*, DBloodActor* objActor, DBloodActor* pXRedir, int* tx);
void seqSpawnerOffSameTx(DBloodActor* actor);
void triggerTouchSprite(DBloodActor* pSprite, DBloodActor* nHSprite);
@ -434,7 +432,15 @@ inline int perc2val(int reqPerc, int val) { return (val * reqPerc) / 100; }
inline double perc2val(int reqPerc, double val) { return (val * reqPerc) / 100; }
void nnExtScaleVelocity(DBloodActor* pSpr, double nVel, const DVector3& dv, int which = 0x03);
void nnExtScaleVelocityRel(DBloodActor* pSpr, double nVel, const DVector3& dv, int which = 0x03);
int nnExtGibSprite(DBloodActor* pSpr, TArray<DBloodActor*>& pOut, GIBTYPE nGibType, const DVector3* pPos, const DVector3* pVel);
enum GIBTYPE;
int nnExtGibSprite(DBloodActor* pSpr, TArray<DBloodActor*>& pOut, GIBTYPE nGibType, DVector3* pPos, DVector3* pVel);
void useGibObject(DBloodActor* pXSource, DBloodActor* pSpr);
void useDripGenerator(DBloodActor* pXSource, DBloodActor* pSprite);
int nnExtGetStartHealth(DBloodActor* actor);
int nnExtResAddExternalFiles();
inline bool mapRev1() { return (gModernMap == 1); }
inline bool mapRev2() { return (gModernMap == 2); }
inline bool valueIsBetween(int val, int min, int max)

View file

@ -1920,7 +1920,7 @@ void conditionsInit()
{
if (gConditions.Size() == 0) conditionInitData();
int nCount = 0, i, j, s, e;
int nCount = 0;
gTrackingConditionsList.Clear();
@ -1991,7 +1991,7 @@ void conditionsInit()
}
}
void conditionsTrackingProcess(DBloodActor* pSpr)
void conditionsTrackingProcess()
{
EVENT evn;
evn.funcID = nullptr;
@ -2001,7 +2001,7 @@ void conditionsTrackingProcess(DBloodActor* pSpr)
for(int i = gTrackingConditionsList.Size() - 1; i >= 0; i--)
{
auto pTr = &gTrackingConditionsList[i];
auto actor = pTr->condi;
auto pSpr = pTr->condi;
if (pSpr->xspr.locked || pSpr->xspr.isTriggered || ++pSpr->xspr.busy < pSpr->xspr.busyTime)
continue;
@ -2009,7 +2009,7 @@ void conditionsTrackingProcess(DBloodActor* pSpr)
for(auto o : pTr->objects)
{
evn.target = o;
useCondition(actor, &evn);
useCondition(pSpr, &evn);
}
}
}
@ -2233,8 +2233,6 @@ void useCondition(DBloodActor* source, EVENT* pEvn)
#ifdef CONDITIONS_USE_BUBBLE_ACTION
void conditionsBubble(DBloodActor* pStart, void(*pActionFunc)(DBloodActor*, int), int nValue)
{
int i, j;
pActionFunc(pStart, nValue);
// perform action for whole branch from bottom to top while there is no forks
@ -2248,11 +2246,11 @@ void conditionsBubble(DBloodActor* pStart, void(*pActionFunc)(DBloodActor*, int)
while (auto actor2 = it2.Next())
{
if (actor2->xspr.rxID == pStart->xspr.rxID && actor2->xspr.txID != pStart->xspr.txID)
{
conditionsBubble(actor, pActionFunc, nValue);
break; // fork found
}
}
if (j < 0)
conditionsBubble(actor, pActionFunc, nValue);
}
}
void conditionsSetIsTriggered(DBloodActor* actor, int nValue)

View file

@ -38,12 +38,10 @@ BEGIN_BLD_NS
#define CONDITIONS_USE_BUBBLE_ACTION 1
void conditionsInit(bool bSaveLoad);
void conditionsTrackingAlloc(bool bSaveLoad);
void conditionsTrackingClear();
void conditionsInit();
void conditionsTrackingProcess();
void conditionsLinkPlayer(DBloodActor* pXCtrl, DBloodPlayer* pPlay);
void conditionsUpdateIndex(int oType, int oldIndex, int newIndex);
void conditionsUpdateIndex(EventObject Old, EventObject New);
void useCondition(DBloodActor* pSource, EVENT* pEvn);
void conditionListReset();

View file

@ -187,7 +187,6 @@ int btoi(const char* str)
{
if (str)
{
int i;
const NAMED_TYPE* pEntry = gBoolNames;
for (auto & e : gBoolNames)
{

View file

@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gstrings.h"
#include "gamestate.h"
#include "automap.h"
#include "nnextsif.h"
BEGIN_BLD_NS
@ -929,7 +930,7 @@ void playerStart(int nPlayer, int bNewLevel)
DBloodActor* SpriteOld = iactor->prevmarker;
trPlayerCtrlLink(iactor, pPlayer, (SpriteOld == nullptr)); // this modifies iactor's prevmarker field!
if (SpriteOld)
conditionsUpdateIndex(SpriteOld, iactor->prevmarker);
conditionsUpdateIndex(EventObject(SpriteOld), EventObject(iactor->prevmarker));
}
}

View file

@ -400,6 +400,7 @@ DBloodActor* actDropObject(DBloodActor* actor, int nType)
auto ty = GetSpawnType(nType);
auto spawned = actDropObject(actor, ty);
if (ty == nullptr) spawned->spr.lotag = nType; // make sure the type is correct even if not bound to a class.
return spawned;
}
//---------------------------------------------------------------------------