mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-22 12:11:17 +00:00
renamed the state types.
This commit is contained in:
parent
dc846ca27b
commit
0aaefceb04
10 changed files with 61 additions and 60 deletions
|
@ -78,7 +78,7 @@ void aiPlay3DSound(DBloodActor* actor, int soundid, AI_SFX_PRIORITY a3, int play
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void aiNewState(DBloodActor* actor, AISTATES* pAIState)
|
||||
void aiNewState(DBloodActor* actor, AISTATE* pAIState)
|
||||
{
|
||||
DUDEINFO* pDudeInfo = getDudeInfo(actor);
|
||||
actor->xspr.stateTimer = pAIState->stateTicks;
|
||||
|
@ -101,7 +101,7 @@ void aiNewState(DBloodActor* actor, AISTATES* pAIState)
|
|||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
AISTATES* FindState(FName name);
|
||||
AISTATE* FindState(FName name);
|
||||
|
||||
void aiNewState(DBloodActor* actor, FName nAIState)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
BEGIN_BLD_NS
|
||||
|
||||
|
||||
struct AISTATES {
|
||||
struct AISTATE {
|
||||
int stateType; // By NoOne: current type of state. Basically required for kModernDudeTargetChanger, but can be used for something else.
|
||||
int seqId;
|
||||
int stateTicks;
|
||||
|
@ -38,19 +38,7 @@ struct AISTATES {
|
|||
VMFunction* enterFunc;
|
||||
VMFunction* moveFunc;
|
||||
VMFunction* thinkFunc;
|
||||
AISTATES* nextState;
|
||||
};
|
||||
|
||||
struct AISTATE_TPL {
|
||||
int stateType; // By NoOne: current type of state. Basically required for kModernDudeTargetChanger, but can be used for something else.
|
||||
int seqId;
|
||||
VMNativeFunction** funcId;
|
||||
int stateTicks;
|
||||
VMNativeFunction** enterFunc;
|
||||
VMNativeFunction** moveFunc;
|
||||
VMNativeFunction** thinkFunc;
|
||||
|
||||
AISTATE_TPL *nextState;
|
||||
AISTATE* nextState;
|
||||
};
|
||||
|
||||
enum AI_SFX_PRIORITY {
|
||||
|
|
|
@ -786,7 +786,7 @@ DEFINE_PROPERTY(dmgcontrol, IIIIIII, BloodActor)
|
|||
|
||||
// this is rather makeshift for now, it needs to be cleaned up once the native states are gone.
|
||||
// it only supports the minimum needed set of features to allow getting rid of them and takes all available shortcuts.
|
||||
TArray<AISTATES> allStates;
|
||||
TArray<AISTATE> allStates;
|
||||
|
||||
DEFINE_PROPERTY(aistate, SSIIGGGGs, BloodActor)
|
||||
{
|
||||
|
@ -805,11 +805,11 @@ DEFINE_PROPERTY(aistate, SSIIGGGGs, BloodActor)
|
|||
next = _next;
|
||||
}
|
||||
int seqno = (int)strtol(seq + 1, nullptr, 10); // skip the '+', this needs to be done better later.
|
||||
AISTATES state = { type, seqno, duration, FName(label), action, enter, move, tick, (AISTATES*)(intptr_t)(FName(next).GetIndex()) };
|
||||
AISTATE state = { type, seqno, duration, FName(label), action, enter, move, tick, (AISTATE*)(intptr_t)(FName(next).GetIndex()) };
|
||||
allStates.Push(state);
|
||||
}
|
||||
|
||||
AISTATES* FindState(FName name)
|
||||
AISTATE* FindState(FName name)
|
||||
{
|
||||
int index = name.GetIndex() - NAME_genIdle;
|
||||
if (index < allStates.SSize()) return &allStates[index];
|
||||
|
|
|
@ -170,7 +170,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATE*& w, AISTA
|
|||
|
||||
#endif
|
||||
#else
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATES*& w, AISTATES** def)
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATE*& w, AISTATE** def)
|
||||
{
|
||||
return arc;
|
||||
}
|
||||
|
|
|
@ -57,11 +57,11 @@ struct walltypedisk
|
|||
BEGIN_BLD_NS
|
||||
|
||||
class DBloodActor;
|
||||
struct AISTATES;
|
||||
struct AISTATE;
|
||||
|
||||
struct XSPRITE {
|
||||
|
||||
AISTATES* aiState; // ai
|
||||
AISTATE* aiState; // ai
|
||||
union
|
||||
{
|
||||
uint32_t flags;
|
||||
|
|
|
@ -393,6 +393,19 @@ VMNativeFunction** const gCdudeCustomCallback[] =
|
|||
};
|
||||
|
||||
|
||||
// statically initializable state template. This has to take the function descriptors by reference so it can be done in a static context.
|
||||
struct AISTATE_TPL {
|
||||
int stateType; // By NoOne: current type of state. Basically required for kModernDudeTargetChanger, but can be used for something else.
|
||||
int seqId;
|
||||
VMNativeFunction** funcId;
|
||||
int stateTicks;
|
||||
VMNativeFunction** enterFunc;
|
||||
VMNativeFunction** moveFunc;
|
||||
VMNativeFunction** thinkFunc;
|
||||
|
||||
AISTATE_TPL* nextState;
|
||||
};
|
||||
|
||||
// Land, Crouch, Swim (proper order matters!)
|
||||
AISTATE_TPL gCdudeStateTemplate[kCdudeStateNormalMax][kCdudePostureMax] =
|
||||
{
|
||||
|
@ -822,7 +835,7 @@ void DCustomDude::ProcessEffects(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool DCustomDude::NewState(AISTATES* pState)
|
||||
bool DCustomDude::NewState(AISTATE* pState)
|
||||
{
|
||||
if (!IsMorphing())
|
||||
{
|
||||
|
@ -849,8 +862,8 @@ bool DCustomDude::NewState(AISTATES* pState)
|
|||
|
||||
void DCustomDude::NewState(int nStateType, int nTimeOverride)
|
||||
{
|
||||
AISTATES* pTmp = &states[nStateType][posture];
|
||||
AISTATES* pState = &states[nStateType][kCdudePostureL];
|
||||
AISTATE* pTmp = &states[nStateType][posture];
|
||||
AISTATE* pState = &states[nStateType][kCdudePostureL];
|
||||
if (pTmp->seqId > 0)
|
||||
pState = pTmp;
|
||||
|
||||
|
@ -861,7 +874,7 @@ void DCustomDude::NewState(int nStateType, int nTimeOverride)
|
|||
}
|
||||
}
|
||||
|
||||
void DCustomDude::NextState(AISTATES* pState, int nTimeOverride)
|
||||
void DCustomDude::NextState(AISTATE* pState, int nTimeOverride)
|
||||
{
|
||||
pSpr->xspr.aiState->nextState = pState;
|
||||
if (pSpr->xspr.aiState->nextState && nTimeOverride > 0)
|
||||
|
@ -879,7 +892,7 @@ void DCustomDude::SyncState(void)
|
|||
if (pSpr->xspr.aiState && FindState(pSpr->xspr.aiState, &t1, &t2) && t2 != posture)
|
||||
{
|
||||
t2 = pSpr->xspr.stateTimer; // save time
|
||||
AISTATES* pState = &states[t1][posture];
|
||||
AISTATE* pState = &states[t1][posture];
|
||||
|
||||
NewState(pState);
|
||||
if (pState->stateTicks)
|
||||
|
@ -887,7 +900,7 @@ void DCustomDude::SyncState(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool DCustomDude::FindState(AISTATES* pState, int* nStateType, int* nPosture)
|
||||
bool DCustomDude::FindState(AISTATE* pState, int* nStateType, int* nPosture)
|
||||
{
|
||||
return setup.FindAiState(states, countof(states), pState, nStateType, nPosture);
|
||||
}
|
||||
|
@ -1089,10 +1102,10 @@ void DCustomDude::Recoil(void)
|
|||
pSpr->dudeExtra.teslaHit = 0;
|
||||
}
|
||||
|
||||
AISTATES* DCustomDude::PickDeath(int nDmgType)
|
||||
AISTATE* DCustomDude::PickDeath(int nDmgType)
|
||||
{
|
||||
int i, nRand = Random(kCdudePostureMax);
|
||||
AISTATES* pDeath = &states[kCdudeStateDeathBase + nDmgType][nRand];
|
||||
AISTATE* pDeath = &states[kCdudeStateDeathBase + nDmgType][nRand];
|
||||
if (pDeath->seqId > 0)
|
||||
return pDeath;
|
||||
|
||||
|
@ -1111,7 +1124,7 @@ AISTATES* DCustomDude::PickDeath(int nDmgType)
|
|||
void DCustomDude::Kill(DBloodActor* pFrom, int nDmgType, int nDmg)
|
||||
{
|
||||
GAMEOPTIONS* pOpt = &gGameOptions;
|
||||
AISTATES* pDeath;
|
||||
AISTATE* pDeath;
|
||||
int i;
|
||||
|
||||
if (IsDying())
|
||||
|
@ -1632,7 +1645,7 @@ void CUSTOMDUDE_SETUP::RandomizeDudeSettings()
|
|||
|
||||
for (i = 0; i < countof(states); i++)
|
||||
{
|
||||
AISTATES* pState = pDude->states[states[i]];
|
||||
AISTATE* pState = pDude->states[states[i]];
|
||||
for (j = 0; j < kCdudePostureMax; j++)
|
||||
{
|
||||
nTime = pState->stateTicks;
|
||||
|
@ -1671,7 +1684,7 @@ void CUSTOMDUDE_SETUP::Setup(DBloodActor* pSpr)
|
|||
setup.DoSetup(pSpr);
|
||||
}
|
||||
|
||||
static void Copy(AISTATES* to, AISTATE_TPL* from)
|
||||
static void Copy(AISTATE* to, AISTATE_TPL* from)
|
||||
{
|
||||
to->name = NAME_None; // needs special handling
|
||||
to->stateType = from->stateType;
|
||||
|
@ -1687,7 +1700,7 @@ static void Copy(AISTATES* to, AISTATE_TPL* from)
|
|||
void CUSTOMDUDE_SETUP::DoSetup(DBloodActor* pSpr)
|
||||
{
|
||||
AISTATE_TPL* pModel;
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
int nStateType, nPosture;
|
||||
int i, j;
|
||||
|
||||
|
@ -1737,7 +1750,7 @@ void CUSTOMDUDE_SETUP::DoSetup(DBloodActor* pSpr)
|
|||
|
||||
// copy dying states
|
||||
pModel = gCdudeStateDyingTemplate;
|
||||
AISTATES* nextState = FindState(NAME_cdudeDeath);
|
||||
AISTATE* nextState = FindState(NAME_cdudeDeath);
|
||||
for (i = kCdudeStateDeathBase; i < kCdudeStateDeathMax; i++)
|
||||
{
|
||||
for (j = 0; j < kCdudePostureMax; j++)
|
||||
|
@ -2004,7 +2017,7 @@ void CUSTOMDUDE_SETUP::WeaponSoundSetDefault(CUSTOMDUDE_WEAPON* pWeapon)
|
|||
void CUSTOMDUDE_SETUP::AnimationConvert(int baseID)
|
||||
{
|
||||
const SEQCOMPAT* pEntry;
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
|
||||
int i, j, nSeq;
|
||||
for (i = 0; i < kCdudeStateMax; i++)
|
||||
|
@ -2028,14 +2041,14 @@ void CUSTOMDUDE_SETUP::AnimationConvert(int baseID)
|
|||
}
|
||||
}
|
||||
|
||||
void CUSTOMDUDE_SETUP::AnimationFill(AISTATES* pState, int nAnim)
|
||||
void CUSTOMDUDE_SETUP::AnimationFill(AISTATE* pState, int nAnim)
|
||||
{
|
||||
for (int i = 0; i < kCdudePostureMax; i++) pState[i].seqId = nAnim;
|
||||
}
|
||||
|
||||
void CUSTOMDUDE_SETUP::AnimationFill(void)
|
||||
{
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < kCdudeStateMax; i++)
|
||||
|
@ -2184,7 +2197,7 @@ void CUSTOMDUDE_SETUP::SoundFill(void)
|
|||
void CUSTOMDUDE_SETUP::FindLargestPic(void)
|
||||
{
|
||||
int i, j, nHeigh = 0;
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
const Seq* pSeq;
|
||||
|
||||
for (i = 0; i < kCdudeStateMax; i++)
|
||||
|
@ -2428,7 +2441,7 @@ void CUSTOMDUDEV2_SETUP::SetupVelocity(void)
|
|||
}
|
||||
}
|
||||
|
||||
void CUSTOMDUDEV2_SETUP::SetupAnimation(AISTATES* pState, bool asPosture)
|
||||
void CUSTOMDUDEV2_SETUP::SetupAnimation(AISTATE* pState, bool asPosture)
|
||||
{
|
||||
AnimationFill(pState, 0); // clear seqID first
|
||||
ParseAnimation(pValue, pState, asPosture);
|
||||
|
@ -2486,7 +2499,7 @@ void CUSTOMDUDEV2_SETUP::SetupAnimation(void)
|
|||
}
|
||||
else if (rngok(pParam->id, kCdudeStateDeathBase, kCdudeStateDeathMax))
|
||||
{
|
||||
AISTATES* pState = pDude->states[pParam->id];
|
||||
AISTATE* pState = pDude->states[pParam->id];
|
||||
SetupAnimation(pState, false);
|
||||
}
|
||||
break;
|
||||
|
@ -2649,7 +2662,7 @@ void CUSTOMDUDEV2_SETUP::SetupKnockout(void)
|
|||
{
|
||||
CUSTOMDUDE_KNOCKOUT* pKnock = &pDude->knockout;
|
||||
int onEventDmg[3];
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
int i;
|
||||
|
||||
/* ----------------------------------*/
|
||||
|
@ -3192,7 +3205,7 @@ void CUSTOMDUDEV2_SETUP::SetupWeapons(void)
|
|||
char tmp[64]; int range[2];
|
||||
|
||||
CUSTOMDUDE_WEAPON* pWeap;
|
||||
AISTATES* pState;
|
||||
AISTATE* pState;
|
||||
|
||||
/* ----------------------------------*/
|
||||
/* DEFAULT VALUES */
|
||||
|
@ -3613,7 +3626,7 @@ bool CUSTOMDUDEV2_SETUP::ParseSound(const char* str, CUSTOMDUDE_SOUND* pSound)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CUSTOMDUDEV2_SETUP::ParseAnimation(const char* str, AISTATES* pState, bool asPosture)
|
||||
bool CUSTOMDUDEV2_SETUP::ParseAnimation(const char* str, AISTATE* pState, bool asPosture)
|
||||
{
|
||||
int i, j, nPar, nLen;
|
||||
int nVal;
|
||||
|
@ -4092,7 +4105,7 @@ void CUSTOMDUDEV1_SETUP::WeaponMeleeSet(CUSTOMDUDE_WEAPON* pWeapon)
|
|||
|
||||
WeaponRangeSet(pWeapon, 0, 512);
|
||||
|
||||
AISTATES* pState = pDude->states[pWeapon->stateID];
|
||||
AISTATE* pState = pDude->states[pWeapon->stateID];
|
||||
for (int i = 0; i < kCdudePostureMax; i++)
|
||||
{
|
||||
if (!helperSeqTriggerExists(pState->seqId))
|
||||
|
|
|
@ -1218,7 +1218,7 @@ class DCustomDude : public DObject
|
|||
CUSTOMDUDE_KNOCKOUT knockout; // knock control
|
||||
CUSTOMDUDE_DROPITEM dropItem; // drop item control
|
||||
CUSTOMDUDE_EFFECT effects[kCdudeMaxEffectGroups]; // fx, gib effect stuff
|
||||
AISTATES states[kCdudeStateMax][kCdudePostureMax]; // includes states for weapons
|
||||
AISTATE states[kCdudeStateMax][kCdudePostureMax]; // includes states for weapons
|
||||
TArray<TObjPtr<DBloodActor*>> pSlaves; // summoned dudes under control of this dude
|
||||
TArray<int> triggerSeqs; // this originally hacked the global ser
|
||||
uint8_t medium ; // medium in which it can live
|
||||
|
@ -1283,12 +1283,12 @@ class DCustomDude : public DObject
|
|||
void Kill(DBloodActor* nFrom, int nDmgType, int nDmg);
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool CanMove(sectortype* pXSect, bool Crusher, bool Water, bool Uwater, bool Depth, double bottom, double floorZ);
|
||||
bool FindState(AISTATES* pState, int* nStateType, int* nPosture);
|
||||
bool FindState(AISTATE* pState, int* nStateType, int* nPosture);
|
||||
void NewState(int nStateType, int nTimeOverride = -1);
|
||||
bool NewState(AISTATES* pState);
|
||||
bool NewState(AISTATE* pState);
|
||||
void NextState(int nStateType, int nTimeOverride = 0);
|
||||
void NextState(AISTATES* pState, int nTimeOverride = 0);
|
||||
AISTATES* PickDeath(int nDmgType);
|
||||
void NextState(AISTATE* pState, int nTimeOverride = 0);
|
||||
AISTATE* PickDeath(int nDmgType);
|
||||
void SyncState(void);
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void LeechPickup(void);
|
||||
|
@ -1343,7 +1343,7 @@ class CUSTOMDUDE_SETUP
|
|||
void WeaponRangeSet(CUSTOMDUDE_WEAPON* pWeapon, int nMin, int nMax);
|
||||
/*------------------------------------------------------------*/
|
||||
void AnimationConvert(int baseID);
|
||||
void AnimationFill(AISTATES* pState, int nAnim);
|
||||
void AnimationFill(AISTATE* pState, int nAnim);
|
||||
void AnimationFill(void);
|
||||
/*------------------------------------------------------------*/
|
||||
void SoundConvert(int baseID);
|
||||
|
@ -1389,7 +1389,7 @@ class CUSTOMDUDEV2_SETUP : public CUSTOMDUDE_SETUP
|
|||
bool ParseVelocity(const char* str, CUSTOMDUDE_VELOCITY* pVelocity);
|
||||
bool ParseAppearance(const char* str, APPEARANCE* pAppear);
|
||||
bool ParseSound(const char* str, CUSTOMDUDE_SOUND* pSound);
|
||||
bool ParseAnimation(const char* str, AISTATES* pState, bool asPosture);
|
||||
bool ParseAnimation(const char* str, AISTATE* pState, bool asPosture);
|
||||
int ParseRange(const char* str, int nValType, int out[2], int nBaseVal = 0);
|
||||
int ParseMedium(const char* str);
|
||||
bool ParseOffsets(const char* str, DVector3& pOut);
|
||||
|
@ -1417,7 +1417,7 @@ class CUSTOMDUDEV2_SETUP : public CUSTOMDUDE_SETUP
|
|||
/*-------------------------------------------------*/
|
||||
void SetupGeneral(void);
|
||||
void SetupVelocity(void);
|
||||
void SetupAnimation(AISTATES* pState, bool asPosture);
|
||||
void SetupAnimation(AISTATE* pState, bool asPosture);
|
||||
void SetupAnimation(void);
|
||||
void SetupSound(CUSTOMDUDE_SOUND* pSound);
|
||||
void SetupMovePattern(void);
|
||||
|
|
|
@ -307,7 +307,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, CUSTOMDUDE_DROPITE
|
|||
return arc;
|
||||
}
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATES& w, AISTATES* def)
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, AISTATE& w, AISTATE* def)
|
||||
{
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
|
|
|
@ -7043,7 +7043,7 @@ void aiPatrolState(DBloodActor* actor, int state)
|
|||
for (i = 0; i < kPatrolStateSize; i++)
|
||||
{
|
||||
FName name = ENamedName(int(NAME_genPatrolState_0) + i);
|
||||
AISTATES* const newState = FindState(name);
|
||||
AISTATE* const newState = FindState(name);
|
||||
if (newState->stateType != state)
|
||||
continue;
|
||||
|
||||
|
@ -7058,7 +7058,7 @@ void aiPatrolState(DBloodActor* actor, int state)
|
|||
continue;
|
||||
|
||||
DCustomDude* pDude = cdudeGet(actor);
|
||||
AISTATES* pState = pDude->states[0];
|
||||
AISTATE* pState = pDude->states[0];
|
||||
seq = pState[seq].seqId;
|
||||
if (seq <= 0)
|
||||
continue;
|
||||
|
|
|
@ -350,19 +350,19 @@ inline int aiPatrolGetVelocity(int speed, int value) {
|
|||
return (value > 0) ? ClipRange((speed / 3) + (2500 * value), 0, 0x47956) : speed;
|
||||
}
|
||||
|
||||
inline bool aiPatrolWaiting(AISTATES* pAiState) {
|
||||
inline bool aiPatrolWaiting(AISTATE* pAiState) {
|
||||
return (pAiState && pAiState->stateType >= kAiStatePatrolWaitL && pAiState->stateType <= kAiStatePatrolWaitW);
|
||||
}
|
||||
|
||||
inline bool aiPatrolMoving(AISTATES* pAiState) {
|
||||
inline bool aiPatrolMoving(AISTATE* pAiState) {
|
||||
return (pAiState && pAiState->stateType >= kAiStatePatrolMoveL && pAiState->stateType <= kAiStatePatrolMoveW);
|
||||
}
|
||||
|
||||
inline bool aiPatrolTurning(AISTATES* pAiState) {
|
||||
inline bool aiPatrolTurning(AISTATE* pAiState) {
|
||||
return (pAiState && pAiState->stateType >= kAiStatePatrolTurnL && pAiState->stateType <= kAiStatePatrolTurnW);
|
||||
}
|
||||
|
||||
inline bool aiInPatrolState(AISTATES* pAiState) {
|
||||
inline bool aiInPatrolState(AISTATE* pAiState) {
|
||||
return (pAiState && pAiState->stateType >= kAiStatePatrolBase && pAiState->stateType < kAiStatePatrolMax);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue