parse AI states into a temp array.

This commit is contained in:
Christoph Oelckers 2023-10-07 17:38:46 +02:00
parent f61dc0467f
commit 865cbd2fd9
4 changed files with 50 additions and 20 deletions

View file

@ -44,6 +44,7 @@ struct FActorInfo
// these are temporary. Due to how Build games handle their tiles, we cannot look up the textures when scripts are being parsed.
TArray<FString> SpriteSetNames;
TArray<FDefiningState> AIStates; // these can only get fully resolved after parsing everything.
FState* OwnedStates = nullptr;
int NumOwnedStates = 0;

View file

@ -149,6 +149,20 @@ public:
};
// used during definition of AIState properties.
struct FDefiningState
{
int sprite;
int Type;
int Tics;
FName Label;
FName NextState;
VMFunction* ActionFunc; // called when an attached animation triggers an event. (i.e. Blood's SEQs. Should be made game independent.)
VMFunction* EnterFunc; // called when entering the state.
VMFunction* TickFunc; // called when ticking the state.
VMFunction* MoveFunc; // called when moving the actor
};
struct FStateLabels;
struct FStateLabel
{

View file

@ -392,24 +392,4 @@ DEFINE_PROPERTY(precacheclass, Sssssssssssssssssssssssssssssss, CoreActor)
}
}
// hopefully this can later be integrated into the state block and made usable for all games.
// for now we need something that can be made to work quickly without messing around with the parser.
DEFINE_PROPERTY(aistate, SSIIGGGGs, CoreActor)
{
PROP_STRING_PARM(label, 0);
PROP_STRING_PARM(seq, 1); // either a sequence name or an Id as '#123'.
PROP_INT_PARM(type, 2);
PROP_INT_PARM(duration, 3);
PROP_FUNC_PARM(action, 4);
PROP_FUNC_PARM(enter, 5);
PROP_FUNC_PARM(tick, 6);
PROP_FUNC_PARM(move, 7);
const char* next = nullptr;
if (PROP_PARM_COUNT > 8)
{
PROP_STRING_PARM(_next, 8);
next = _next;
}
}

View file

@ -781,4 +781,39 @@ DEFINE_PROPERTY(dmgcontrol, IIIIIII, BloodActor)
}
}
// the state parser with its special semantics cannot be extended to handle this right. :(
DEFINE_PROPERTY(aistate, SSIIGGGGs, CoreActor)
{
PROP_STRING_PARM(label, 0);
PROP_STRING_PARM(seq, 1); // either a name, an absolute ID with #000 or a relative ID with +000. Empty string means nothing
PROP_INT_PARM(type, 2);
PROP_INT_PARM(duration, 3);
PROP_FUNC_PARM(action, 4);
PROP_FUNC_PARM(enter, 5);
PROP_FUNC_PARM(tick, 6);
PROP_FUNC_PARM(move, 7);
const char* next = nullptr;
if (PROP_PARM_COUNT > 8)
{
PROP_STRING_PARM(_next, 8);
next = _next;
}
bag.Info->ActorInfo()->AIStates.Reserve(1);
auto& state = bag.Info->ActorInfo()->AIStates.Last();
char* endp = (char*)"";
if (*seq == 0) state.sprite = 0;
else if (*seq == '#') state.sprite = strtoull(seq + 1, &endp, 10) | 0x10000000;
else if (*seq == '+') state.sprite = strtoull(seq + 1, &endp, 10) | 0x20000000;
state.Label = label;
state.Type = type;
state.Tics = duration;
state.ActionFunc = action;
state.EnterFunc = enter;
state.MoveFunc = move;
state.TickFunc = tick;
state.NextState = next ? FName(next) : FName(NAME_None);
}
END_BLD_NS