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
26 changes: 14 additions & 12 deletions TheForceEngine/TFE_DarkForces/Actor/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ namespace TFE_DarkForces
{
angle14_32 rAngle = moveMod->physics.responseAngle + (s_curTick & 0xff) - 128;
angle14_32 angleDiff = getAngleDifference(obj->yaw, rAngle) & 8191;
if (angleDiff > 4095)
if (angleDiff > 4095) // 90 degrees
{
newAngle = moveMod->physics.responseAngle - 8191;
newAngle = moveMod->physics.responseAngle - 8191; // 180 degrees
}
else
{
Expand Down Expand Up @@ -632,7 +632,7 @@ namespace TFE_DarkForces
{
item, // obj
FIXED(2), 0, FIXED(2), // offset
ONE_16, COL_INFINITY, ONE_16, 0, // botOffset, yPos, height, u1c
ONE_16, COL_INFINITY, ONE_16, 0, // stepUpHeight, stepDownHeight, height, u1c
nullptr, 0, nullptr,
item->worldWidth, 0,
JFALSE,
Expand Down Expand Up @@ -1427,6 +1427,7 @@ namespace TFE_DarkForces
vec3_fixed desiredMove = { 0, 0, 0 };
vec3_fixed move = { 0, 0, 0 };

// First, handle active movement - movement that the actor "intends" to do
moveMod->collisionWall = nullptr;
if (!(moveMod->target.flags & TARGET_FREEZE))
{
Expand Down Expand Up @@ -1494,11 +1495,11 @@ namespace TFE_DarkForces
RSector* triggerSector = (nextSector) ? nextSector : wall->sector;
if (obj->entityFlags & ETFLAG_SMART_OBJ)
{
message_sendToSector(triggerSector, obj, 0, MSG_TRIGGER);
message_sendToSector(triggerSector, obj, 0, MSG_TRIGGER); // smart object will try to open a door or activate an elevator that it collides with
}
}
// Handles a single collision response + resolution step.
if (moveMod->collisionFlags & ACTORCOL_BIT2)
if (moveMod->collisionFlags & ACTORCOL_SLIDE_RESPONSE)
{
moveMod->collisionWall = wall;
dirX = physics->responseDir.x;
Expand All @@ -1509,17 +1510,18 @@ namespace TFE_DarkForces
}
}

// Now handle passive movement - movement caused by being pushed, eg. by explosions or projectile impacts
// Apply the per-frame delta computed from the actor's velocity.
if (moveMod->delta.x | moveMod->delta.z)
{
physics->flags |= 1;
physics->flags |= COLINFO_INFINITE_DROP; // actor can be pushed off a cliff
physics->offsetX = moveMod->delta.x;
physics->offsetY = 0;
physics->offsetZ = moveMod->delta.z;
handleCollision(physics);

// Handles a single collision response + resolution step from velocity delta.
if ((moveMod->collisionFlags & ACTORCOL_BIT2) && physics->responseStep)
if ((moveMod->collisionFlags & ACTORCOL_SLIDE_RESPONSE) && physics->responseStep)
{
moveMod->collisionWall = physics->wall;
dirX = physics->responseDir.x;
Expand Down Expand Up @@ -1649,8 +1651,8 @@ namespace TFE_DarkForces
{
SecObject* obj = moveMod->header.obj;

moveMod->physics.botOffset = 0x38000; // 3.5
moveMod->physics.yPos = FIXED(4);
moveMod->physics.stepUpHeight = 0x38000; // 3.5 units
moveMod->physics.stepDownHeight = FIXED(4); // 4 units
moveMod->physics.height = obj->worldHeight;
moveMod->physics.width = obj->worldWidth;
moveMod->physics.responseStep = JFALSE;
Expand All @@ -1662,7 +1664,7 @@ namespace TFE_DarkForces
moveMod->collisionWall = nullptr;
moveMod->unused = 0;

moveMod->collisionFlags = (moveMod->collisionFlags | (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY)) & ~ACTORCOL_BIT2; // Set bits 0, 1 and clear bit 2. This creates a non-flying AI by default.
moveMod->collisionFlags = (moveMod->collisionFlags | (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY)) & ~ACTORCOL_SLIDE_RESPONSE; // Set bits 0, 1 and clear bit 2. This creates a non-flying AI by default.
obj->entityFlags |= ETFLAG_SMART_OBJ;
}

Expand Down Expand Up @@ -2013,7 +2015,7 @@ namespace TFE_DarkForces
{
dispatch->alertSndID = sound_playCued(s_officerAlertSndSrc[s_actorState.officerAlertIndex], obj->posWS);
s_actorState.officerAlertIndex++;
if (s_actorState.officerAlertIndex >= 4)
if (s_actorState.officerAlertIndex >= OFFICER_ALERT_COUNT)
{
s_actorState.officerAlertIndex = 0;
}
Expand All @@ -2022,7 +2024,7 @@ namespace TFE_DarkForces
{
dispatch->alertSndID = sound_playCued(s_stormAlertSndSrc[s_actorState.stormtrooperAlertIndex], obj->posWS);
s_actorState.stormtrooperAlertIndex++;
if (s_actorState.stormtrooperAlertIndex >= 8)
if (s_actorState.stormtrooperAlertIndex >= STORM_ALERT_COUNT)
{
s_actorState.stormtrooperAlertIndex = 0;
}
Expand Down
8 changes: 4 additions & 4 deletions TheForceEngine/TFE_DarkForces/Actor/actorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ enum AttackFlags

enum ActorCollisionFlags
{
ACTORCOL_NO_Y_MOVE = FLAG_BIT(0), // When _not_ set, an actor can move vertically. Set for non-flying enemies.
ACTORCOL_GRAVITY = FLAG_BIT(1),
ACTORCOL_BIT2 = FLAG_BIT(2), // Alters the way collision is handled. This is generally set for flying enemies and bosses
ACTORCOL_ALL = ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY | ACTORCOL_BIT2
ACTORCOL_NO_Y_MOVE = FLAG_BIT(0), // When _not_ set, an actor can move vertically. Set for non-flying enemies.
ACTORCOL_GRAVITY = FLAG_BIT(1),
ACTORCOL_SLIDE_RESPONSE = FLAG_BIT(2), // Actor will "slide" along a wall that they collide with. This is generally set for flying enemies and bosses.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice, I never got around to naming all of the flags properly.

ACTORCOL_ALL = ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY | ACTORCOL_SLIDE_RESPONSE
};

struct ActorModule
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/actorSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ namespace TFE_DarkForces
SERIALIZE(SaveVersionInit, colInfo->offsetX, 0);
SERIALIZE(SaveVersionInit, colInfo->offsetY, 0);
SERIALIZE(SaveVersionInit, colInfo->offsetZ, 0);
SERIALIZE(SaveVersionInit, colInfo->botOffset, 0);
SERIALIZE(SaveVersionInit, colInfo->yPos, 0);
SERIALIZE(SaveVersionInit, colInfo->stepUpHeight, 0);
SERIALIZE(SaveVersionInit, colInfo->stepDownHeight, 0);
SERIALIZE(SaveVersionInit, colInfo->height, 0);
SERIALIZE(SaveVersionInit, colInfo->u24, 0);
SERIALIZE(SaveVersionInit, colInfo->width, 0);
Expand Down
12 changes: 6 additions & 6 deletions TheForceEngine/TFE_DarkForces/Actor/bobaFett.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ namespace TFE_DarkForces
local(nextCheckForPlayerTick) = 0;
local(changeStateTick) = s_curTick + SEARCH_DURATION;
local(nextChangePhaseTick) = s_curTick + SEARCH_PHASE_INTERVAL;
local(physicsActor)->moveMod.collisionFlags |= ACTORCOL_BIT2;
local(physicsActor)->moveMod.collisionFlags |= ACTORCOL_SLIDE_RESPONSE;

while (local(physicsActor)->state == BOBASTATE_SEARCH)
{
Expand Down Expand Up @@ -723,7 +723,7 @@ namespace TFE_DarkForces
}
} // while (state == BOBASTATE_SEARCH)

local(physicsActor)->moveMod.collisionFlags |= ACTORCOL_BIT2;
local(physicsActor)->moveMod.collisionFlags |= ACTORCOL_SLIDE_RESPONSE;
task_end;
}

Expand Down Expand Up @@ -955,11 +955,11 @@ namespace TFE_DarkForces
actor_setupSmartObj(&physicsActor->moveMod);

physicsActor->moveMod.physics.width = FIXED(2);
physicsActor->moveMod.physics.botOffset = 0;
physicsActor->moveMod.physics.stepUpHeight = 0;

physicsActor->moveMod.collisionFlags &= ~ACTORCOL_ALL;
physicsActor->moveMod.collisionFlags |= (ACTORCOL_GRAVITY | ACTORCOL_BIT2);
physicsActor->moveMod.physics.yPos = COL_INFINITY;
physicsActor->moveMod.collisionFlags |= (ACTORCOL_GRAVITY | ACTORCOL_SLIDE_RESPONSE);
physicsActor->moveMod.physics.stepDownHeight = COL_INFINITY;
physicsActor->moveMod.physics.height = obj->worldHeight;

LogicAnimation* anim = &physicsActor->anim;
Expand All @@ -981,4 +981,4 @@ namespace TFE_DarkForces
}
return (Logic*)bobaFett;
}
} // namespace TFE_DarkForces
} // namespace TFE_DarkForces
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/dragon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ namespace TFE_DarkForces
obj->flags |= OBJ_FLAG_MOVABLE;

CollisionInfo* physics = &physicsActor->moveMod.physics;
physics->botOffset = 0x60000;
physics->yPos = 0x80000;
physics->stepUpHeight = 0x60000; // 6 units
physics->stepDownHeight = 0x80000; // 8 units
physics->width = obj->worldWidth;
physicsActor->moveMod.collisionFlags |= ACTORCOL_ALL;
physics->height = obj->worldHeight + HALF_16;
Expand Down
24 changes: 22 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/enemies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ namespace TFE_DarkForces
dispatch->fov = floatToAngle((f32)cust->fov);
dispatch->awareRange = FIXED(cust->awareRange);

if (cust->officerAlerts)
{
dispatch->flags |= ACTOR_OFFIC_ALERT;
}
if (cust->troopAlerts)
{
dispatch->flags |= ACTOR_TROOP_ALERT;
}

// Damage Module
DamageModule* damageMod = actor_createDamageModule(dispatch);
damageMod->hp = FIXED(cust->hitPoints);
Expand Down Expand Up @@ -253,17 +262,28 @@ namespace TFE_DarkForces
dispatch->moveMod = moveMod;
moveMod->physics.width = cust->collisionWidth < 0 ? obj->worldWidth : floatToFixed16(cust->collisionWidth);
moveMod->physics.height = cust->collisionHeight < 0 ? moveMod->physics.height : floatToFixed16(cust->collisionHeight);
moveMod->physics.stepUpHeight = floatToFixed16(cust->stepUpHeight);
moveMod->physics.stepDownHeight = floatToFixed16(cust->stepDownHeight);

if (cust->isFlying)
{
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_BIT2; // Remove bits 0, 1 and set bit 2
moveMod->physics.yPos = FIXED(200);
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_SLIDE_RESPONSE; // Remove bits 0, 1 and set bit 2
moveMod->physics.stepDownHeight = FIXED(200);
}
else
{
moveMod->collisionFlags |= ACTORCOL_NO_Y_MOVE;
}

if (cust->slideOnCollision == 0)
{
moveMod->collisionFlags &= ~ACTORCOL_SLIDE_RESPONSE;
}
else if (cust->slideOnCollision == 1)
{
moveMod->collisionFlags |= ACTORCOL_SLIDE_RESPONSE;
}

dispatch->animTable = s_customAnimTable;
actor_setupInitAnimation();

Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/exploders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ namespace TFE_DarkForces
colInfo.offsetY = 0;
colInfo.offsetX = mul16(actorLogic->vel.x, 0x4000);
colInfo.offsetZ = mul16(actorLogic->vel.z, 0x4000);
colInfo.botOffset = ONE_16;
colInfo.yPos = COL_INFINITY;
colInfo.stepUpHeight = ONE_16;
colInfo.stepDownHeight = COL_INFINITY;
colInfo.height = ONE_16;
colInfo.unused = 0;
colInfo.width = colInfo.obj->worldWidth;
Expand Down
12 changes: 6 additions & 6 deletions TheForceEngine/TFE_DarkForces/Actor/flyers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ namespace TFE_DarkForces

MovementModule* moveMod = actor_createMovementModule(dispatch);
dispatch->moveMod = moveMod;
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_BIT2;
moveMod->physics.yPos = FIXED(200);
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_SLIDE_RESPONSE;
moveMod->physics.stepDownHeight = FIXED(200);
moveMod->physics.width = obj->worldWidth;

// Setup the animation.
Expand Down Expand Up @@ -209,8 +209,8 @@ namespace TFE_DarkForces

MovementModule* moveMod = actor_createMovementModule(dispatch);
dispatch->moveMod = moveMod;
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_BIT2;
moveMod->physics.yPos = FIXED(200);
moveMod->collisionFlags = (moveMod->collisionFlags & ~ACTORCOL_ALL) | ACTORCOL_SLIDE_RESPONSE;
moveMod->physics.stepDownHeight = FIXED(200);
moveMod->physics.width = obj->worldWidth;

// Setup the animation.
Expand Down Expand Up @@ -264,8 +264,8 @@ namespace TFE_DarkForces
MovementModule* moveMod = actor_createMovementModule(dispatch);
dispatch->moveMod = moveMod;
moveMod->collisionFlags &= ~ACTORCOL_ALL;
moveMod->collisionFlags |= ACTORCOL_BIT2;
moveMod->physics.yPos = FIXED(200);
moveMod->collisionFlags |= ACTORCOL_SLIDE_RESPONSE;
moveMod->physics.stepDownHeight = FIXED(200);

// should be: 0xa7ec
moveMod->physics.width = obj->worldWidth;
Expand Down
6 changes: 3 additions & 3 deletions TheForceEngine/TFE_DarkForces/Actor/mousebot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ namespace TFE_DarkForces
obj->worldWidth = width;
obj->worldHeight = width >> 1;

physActor->moveMod.physics.botOffset = 0;
physActor->moveMod.physics.yPos = 0;
physActor->moveMod.collisionFlags = (physActor->moveMod.collisionFlags | (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY)) & ~ACTORCOL_BIT2;
physActor->moveMod.physics.stepUpHeight = 0;
physActor->moveMod.physics.stepDownHeight = 0;
physActor->moveMod.collisionFlags = (physActor->moveMod.collisionFlags | (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY)) & ~ACTORCOL_SLIDE_RESPONSE;
physActor->moveMod.physics.height = obj->worldHeight + HALF_16;
physActor->moveMod.target.speed = FIXED(22);
physActor->moveMod.target.speedRotation = FIXED(3185);
Expand Down
2 changes: 1 addition & 1 deletion TheForceEngine/TFE_DarkForces/Actor/phaseOne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ namespace TFE_DarkForces
actor_setupSmartObj(&physicsActor->moveMod);

physicsActor->moveMod.collisionFlags |= ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY;
physicsActor->moveMod.collisionFlags &= ~ACTORCOL_BIT2;
physicsActor->moveMod.collisionFlags &= ~ACTORCOL_SLIDE_RESPONSE;

ActorTarget* target = &physicsActor->moveMod.target;
target->flags &= ~TARGET_ALL;
Expand Down
6 changes: 3 additions & 3 deletions TheForceEngine/TFE_DarkForces/Actor/phaseThree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace TFE_DarkForces
local(target)->speed = FIXED(70);
local(flying) = JTRUE;
local(physicsActor)->moveMod.collisionFlags &= (~(ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY));
local(physicsActor)->moveMod.physics.yPos = COL_INFINITY;
local(physicsActor)->moveMod.physics.stepDownHeight = COL_INFINITY;
}
else
{
Expand Down Expand Up @@ -355,7 +355,7 @@ namespace TFE_DarkForces
} while (msg != MSG_RUN_TASK || !(local(anim)->flags & AFLAG_READY));

local(physicsActor)->moveMod.collisionFlags |= (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY);
local(physicsActor)->moveMod.physics.yPos = COL_INFINITY;
local(physicsActor)->moveMod.physics.stepDownHeight = COL_INFINITY;
local(target)->speed = FIXED(25);
local(target)->flags &= ~TARGET_MOVE_Y;
sound_stop(local(trooper)->rocketSndId);
Expand Down Expand Up @@ -1051,7 +1051,7 @@ namespace TFE_DarkForces
actor_setupSmartObj(&physicsActor->moveMod);

physicsActor->moveMod.collisionFlags |= ACTORCOL_ALL;
physicsActor->moveMod.physics.yPos = COL_INFINITY;
physicsActor->moveMod.physics.stepDownHeight = COL_INFINITY;

ActorTarget* target = &physicsActor->moveMod.target;
target->flags &= ~TARGET_ALL;
Expand Down
10 changes: 5 additions & 5 deletions TheForceEngine/TFE_DarkForces/Actor/phaseTwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ namespace TFE_DarkForces
local(target)->speed = FIXED(60);
local(flying) = JTRUE;
local(physicsActor)->moveMod.collisionFlags &= (~(ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY)); // flying
local(physicsActor)->moveMod.physics.yPos = COL_INFINITY;
local(physicsActor)->moveMod.physics.stepDownHeight = COL_INFINITY;
}
else
{
Expand Down Expand Up @@ -347,7 +347,7 @@ namespace TFE_DarkForces
} while (msg != MSG_RUN_TASK || !(local(anim)->flags & AFLAG_READY));

local(physicsActor)->moveMod.collisionFlags |= (ACTORCOL_NO_Y_MOVE | ACTORCOL_GRAVITY);
local(physicsActor)->moveMod.physics.yPos = COL_INFINITY;
local(physicsActor)->moveMod.physics.stepDownHeight = COL_INFINITY;
local(target)->speed = FIXED(15);
local(target)->flags &= ~TARGET_MOVE_Y;
sound_stop(local(trooper)->rocketSndId);
Expand Down Expand Up @@ -728,7 +728,7 @@ namespace TFE_DarkForces
{
item,
FIXED(3), 0, FIXED(3), // offset
ONE_16, COL_INFINITY, ONE_16, 0, // botOffset, yPos, height, 0x1c
ONE_16, COL_INFINITY, ONE_16, 0, // stepUpHeight, stepDownHeight, height, 0x1c
nullptr, 0, nullptr, // wall, u24, collidedObj
item->worldWidth, 0, 0, // width, u30, responseStep
{0,0}, {0,0}, 0 // responseDir, responsePos, responseAngle.
Expand All @@ -752,7 +752,7 @@ namespace TFE_DarkForces
{
item,
0, FIXED(3), FIXED(3), // offset
ONE_16, COL_INFINITY, ONE_16, 0, // botOffset, yPos, height, 0x1c
ONE_16, COL_INFINITY, ONE_16, 0, // stepUpHeight, stepDownHeight, height, 0x1c
nullptr, 0, nullptr, // wall, u24, collidedObj
item->worldWidth, 0, 0, // width, u30, responseStep
{0,0}, {0,0}, 0 // responseDir, responsePos, responseAngle.
Expand Down Expand Up @@ -1090,7 +1090,7 @@ namespace TFE_DarkForces
actor_setupSmartObj(&physicsActor->moveMod);

physicsActor->moveMod.collisionFlags |= ACTORCOL_ALL;
physicsActor->moveMod.physics.yPos = COL_INFINITY;
physicsActor->moveMod.physics.stepDownHeight = COL_INFINITY;

ActorTarget* target = &physicsActor->moveMod.target;
target->flags &= ~TARGET_ALL;
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/sewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ namespace TFE_DarkForces
obj->entityFlags &= ~ETFLAG_SMART_OBJ;

moveMod->collisionFlags = (moveMod->collisionFlags | ACTORCOL_NO_Y_MOVE) & ~ACTORCOL_GRAVITY; // gravity is removed so they remain on the surface of water (floor height) rather than sinking down (second height)
moveMod->physics.yPos = 0;
moveMod->physics.botOffset = 0;
moveMod->physics.stepDownHeight = 0;
moveMod->physics.stepUpHeight = 0;
moveMod->physics.width = obj->worldWidth;
actor_setupInitAnimation();

Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,8 @@ namespace TFE_DarkForces
physics->height = obj->worldHeight + HALF_16;
physics->wall = nullptr;
physics->u24 = 0;
physics->botOffset = 0;
physics->yPos = 0;
physics->stepUpHeight = 0;
physics->stepDownHeight = 0;

MovementModule* moveMod = &physicsActor->moveMod;
moveMod->header.obj = obj;
Expand Down
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_DarkForces/Actor/welder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ namespace TFE_DarkForces
physics->width = obj->worldWidth;
physics->wall = nullptr;
physics->u24 = 0;
physics->botOffset = 0;
physics->yPos = 0;
physics->stepUpHeight = 0;
physics->stepDownHeight = 0;
physics->height = obj->worldHeight + HALF_16;

physicsActor->moveMod.delta = { 0, 0, 0 };
Expand Down
Loading