Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions TheForceEngine/TFE_DarkForces/Actor/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ namespace TFE_DarkForces
ThinkerModule* thinkerMod = (ThinkerModule*)module;
SecObject* obj = thinkerMod->header.obj;

if (thinkerMod->anim.state == 1)
if (thinkerMod->anim.state == STATE_MOVE)
{
ActorTarget* target = &thinkerMod->target;
JBool arrivedAtTarget = actor_arrivedAtTarget(target, obj);
Expand All @@ -1151,7 +1151,7 @@ namespace TFE_DarkForces
{
thinkerMod->playerLastSeen = 0xffffffff;
}
thinkerMod->anim.state = STATE_FIRE1;
thinkerMod->anim.state = STATE_TURN;
}
else
{
Expand Down Expand Up @@ -1185,7 +1185,7 @@ namespace TFE_DarkForces
}
}
}
else if (thinkerMod->anim.state == 2)
else if (thinkerMod->anim.state == STATE_TURN)
{
ActorDispatch* logic = actor_getCurrentLogic();
fixed16_16 targetX, targetZ;
Expand Down Expand Up @@ -1239,7 +1239,7 @@ namespace TFE_DarkForces
}
logic->flags |= 2;
}
thinkerMod->anim.state = STATE_ANIMATEATTACK;
thinkerMod->anim.state = STATE_MOVE;
thinkerMod->nextTick = s_curTick + thinkerMod->maxWalkTime;

if (obj->entityFlags & ETFLAG_REMOTE)
Expand Down
9 changes: 8 additions & 1 deletion TheForceEngine/TFE_DarkForces/Actor/actorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ enum LogicAnimFlags

enum LogicAnimState : u32
{
//GENERAL
STATE_DELAY = 0u,
//ATTACK MODULE
STATE_ANIMATEATTACK,
STATE_FIRE1,
STATE_ANIMATE1,
STATE_FIRE2,
STATE_ANIMATE2,
STATE_COUNT
STATE_COUNT,
//THINKER MODULE
// Move towards our destination
STATE_MOVE = 1u,
// Update our destination (generally moving towards the player).
STATE_TURN = 2u,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinfoley My opinion is that it would be cleaner, and more readable code if we just make a separate enum

So change the existing LogicAnimState to LogicAttackAnimState (or something like that)

and add a LogicThinkerAnimState with MOVE and TURN

Copy link
Contributor

@jerethk jerethk Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed in Discord - this won't work because both modules use the same struct
Please ignore :-)


typedef JBool(*ActorFunc)(ActorModule*, MovementModule*);
Expand Down
20 changes: 10 additions & 10 deletions TheForceEngine/TFE_DarkForces/Actor/flyers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace TFE_DarkForces
{
ThinkerModule* flyingMod = (ThinkerModule*)module;
SecObject* obj = flyingMod->header.obj;
if (flyingMod->anim.state == 0)
if (flyingMod->anim.state == STATE_DELAY)
{
flyingMod->anim.state = STATE_FIRE1;
flyingMod->anim.state = STATE_TURN;
return s_curTick + random(flyingMod->delay);
}
else if (flyingMod->anim.state == 1)
else if (flyingMod->anim.state == STATE_MOVE)
{
if (actor_handleSteps(moveMod, &flyingMod->target))
{
Expand All @@ -39,7 +39,7 @@ namespace TFE_DarkForces
flyingMod->anim.state = STATE_DELAY;
}
}
else if (flyingMod->anim.state == STATE_FIRE1)
else if (flyingMod->anim.state == STATE_TURN)
{
RSector* sector = obj->sector;
if (sector == s_playerObject->sector)
Expand All @@ -48,7 +48,7 @@ namespace TFE_DarkForces
fixed16_16 heightChange = random(FIXED(5)) - 0x18000; // rand(5) - 1.5
flyingMod->target.pos.y = s_eyePos.y - heightChange;
flyingMod->target.flags |= TARGET_MOVE_Y;
flyingMod->anim.state = STATE_ANIMATEATTACK;
flyingMod->anim.state = STATE_MOVE;
}
else
{
Expand All @@ -66,25 +66,25 @@ namespace TFE_DarkForces
ActorTarget* target = &flyingMod->target;
SecObject* obj = flyingMod->header.obj;

if (flyingMod->anim.state == 0)
if (flyingMod->anim.state == STATE_DELAY)
{
flyingMod->anim.state = STATE_FIRE1;
flyingMod->anim.state = STATE_TURN;
return s_curTick + random(flyingMod->delay);
}
else if (flyingMod->anim.state == 1)
else if (flyingMod->anim.state == STATE_MOVE)
{
if (actor_arrivedAtTarget(target, obj))
{
flyingMod->anim.state = STATE_DELAY;
}
}
else if (flyingMod->anim.state == 2)
else if (flyingMod->anim.state == STATE_TURN)
{
target->yaw = random_next() & ANGLE_MASK;
target->pitch = obj->pitch;
target->roll = obj->roll;
target->flags |= TARGET_MOVE_ROT;
flyingMod->anim.state = STATE_ANIMATEATTACK;
flyingMod->anim.state = STATE_MOVE;
}

moveMod->updateTargetFunc(moveMod, target);
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_DarkForces/Actor/sewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace TFE_DarkForces
obj->flags |= OBJ_FLAG_NEEDS_TRANSFORM;
if (obj->type == OBJ_TYPE_SPRITE)
{
if (attackMod->anim.state == 2) // Attack animation
if (attackMod->anim.state == STATE_FIRE1) // Attack animation
{
actor_setupAnimation(1, &attackMod->anim);
}
Expand Down
Loading