UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Step Class Reference

a struct holding the relevant data to check if we can move between two adjacent cells More...

Public Member Functions

 Step (const Routing &r, const pos3_t fromPos, const actorSizeEnum_t actorSize, const byte crouchingState, const int dir)
 Constructor. More...
 
bool init ()
 Initialize the other Step data. More...
 
bool calcNewPos ()
 Calculate the cell the we end up in if moving in the give dir. More...
 
void calcNewTUs (const pathing_t *path)
 Calculate the TUs after we in the given dir. More...
 
bool checkWalkingDirections (const pathing_t *path)
 Checks if we can walk in the given direction First test for opening height availability. Then test for stepup compatibility. Last test for fall. More...
 
bool checkFlyingDirections () const
 Checks if we can move in the given flying direction. More...
 
bool checkVerticalDirections () const
 Checks if we can move in the given vertical direction. More...
 
bool isPossible (const pathing_t *path)
 

Data Fields

const int dir
 
pos3_t fromPos
 
pos3_t toPos
 
actorSizeEnum_t actorSize
 
const byte crouchingState
 
byte TUsAfter
 

Private Attributes

bool flier
 
bool hasLadderToClimb
 
bool hasLadderSupport
 
int actorHeight
 
int actorCrouchedHeight
 
const Routingrouting
 

Detailed Description

a struct holding the relevant data to check if we can move between two adjacent cells

Definition at line 134 of file grid.cpp.

Constructor & Destructor Documentation

Step::Step ( const Routing r,
const pos3_t  _fromPos,
const actorSizeEnum_t  _actorSize,
const byte  _crouchingState,
const int  _dir 
)

Constructor.

Parameters
[in]rReference to client or server side routing table (clMap, svMap)
[in]_fromPosPosition where we start this step
[in]_actorSizeGive the field size of the actor (e.g. for 2x2 units) to check linked fields as well.
[in]_crouchingStateWhether the actor is currently crouching, 1 is yes, 0 is no.
[in]_dirDirection vector index (see DIRECTIONS and dvecs)

Definition at line 177 of file grid.cpp.

References fromPos, and VectorCopy.

Member Function Documentation

bool Step::calcNewPos ( void  )

Calculate the cell the we end up in if moving in the give dir.

Returns
false if we can't move there

< "new" x value = starting x value + difference from chosen direction

< "new" y value = starting y value + difference from chosen direction

< "new" z value = starting z value + difference from chosen direction

Definition at line 217 of file grid.cpp.

References dir, dvecs, fromPos, PATHFINDING_HEIGHT, and toPos.

Referenced by isPossible().

void Step::calcNewTUs ( const pathing_t path)

Calculate the TUs after we in the given dir.

Parameters
[in]pathPointer to client or server side pathing table (clPathMap, svPathMap)

Definition at line 242 of file grid.cpp.

References crouchingState, dir, fromPos, Grid_GetTUsForDirection(), RT_AREA_POS, and TUsAfter.

Referenced by isPossible().

bool Step::checkFlyingDirections ( ) const

Checks if we can move in the given flying direction.

Returns
false if we can't fly there

< The compass direction of this flying move

Definition at line 378 of file grid.cpp.

References actorHeight, actorSize, CELL_HEIGHT, CORE_DIRECTIONS, dir, fromPos, Routing::getConn(), Routing::getFloor(), routing, and toPos.

Referenced by isPossible().

bool Step::checkVerticalDirections ( ) const

Checks if we can move in the given vertical direction.

Returns
false if we can't move there

Definition at line 408 of file grid.cpp.

References actorSize, dir, DIRECTION_CLIMB_DOWN, DIRECTION_CLIMB_UP, DIRECTION_FALL, flier, fromPos, Routing::getCeiling(), Routing::getFloor(), hasLadderSupport, hasLadderToClimb, PLAYER_HEIGHT, QuantToModel, routing, and UNIT_HEIGHT.

Referenced by isPossible().

bool Step::checkWalkingDirections ( const pathing_t path)

Checks if we can walk in the given direction First test for opening height availability. Then test for stepup compatibility. Last test for fall.

Note
Fliers use this code only when they are walking.
Parameters
[in]pathPointer to client or server side pathing table (clPathMap, svPathMap)
Returns
false if we can't fly there
Todo:
falling_height should be replaced with an arbitrary max falling height based on the actor.

<This is the maximum height that an actor can fall.

< The actual stepup height without the level flags

Todo:
actor_stepup_height should be replaced with an arbitrary max stepup height based on the actor.
Note
If you need to know about how pathfinding works, you need to understand the following brief. It may cause nausea, but is an important concept.

OK, now some crazy tests: Because of the grid based nature of this game, each cell can have at most only ONE floor that can be stood upon. If an actor can walk down a slope that is in the same level, and actor should be able to walk on (and not fall into) the slope that decends a game level. BUT it is possible for an actor to be able to crawl under a floor that can be stood on, with this opening being in the same cell as the floor. SO to prevent any conflicts, we will move down a floor under the following conditions:

  • The STEPDOWN flag is set
  • The floor in the immediately adjacent cell is lower than the current floor, but not more than CELL_HEIGHT units (in QUANT units) below the current floor.
  • The actor's stepup value is at least the inverse stepup value. This is the stepup FROM the cell we are moving towards back into the cell we are starting in. This ensures that the actor can actually WALK BACK. If the actor does not have a high enough stepup but meets all the other requirements to descend the level, the actor will move into a fall state, provided that there is no floor in the adjacent cell.

This will prevent actors from walking under a floor in the same cell in order to fall to the floor beneath. They will need to be able to step down into the cell or will not be able to use the opening.

Definition at line 259 of file grid.cpp.

References actorCrouchedHeight, actorHeight, actorSize, CELL_HEIGHT, crouchingState, dir, DV_FLAG_AUTOCROUCH, DV_FLAG_AUTOCROUCHED, DV_FLAG_AUTODIVE, fromPos, Routing::getCeiling(), Routing::getConn(), getDVflags, Routing::getFloor(), Routing::getStepupHeight(), Grid_GetTUsForDirection(), hasLadderSupport, Routing::isStepDownLevel(), Routing::isStepUpLevel(), PATHFINDING_HEIGHT, PATHFINDING_MAX_FALL, PATHFINDING_MAX_STEPUP, routing, RT_AREA_POS, toPos, and TU_CROUCH.

Referenced by isPossible().

bool Step::init ( )

Initialize the other Step data.

Returns
false if dir is irrelevant or something went wrong
Note
This is the actor's height in QUANT units.
Todo:
actor_height is currently the fixed height of a 1x1 actor. This needs to be adjusted to the actor's actual height.

< The actor's height

Definition at line 188 of file grid.cpp.

References actorCrouchedHeight, actorHeight, crouchingState, dir, flier, FLYING_DIRECTIONS, ModelCeilingToQuant, PATHFINDING_DIRECTIONS, PLAYER_CROUCHING_HEIGHT, and PLAYER_STANDING_HEIGHT.

Referenced by Grid_CalcPathing(), and Grid_FindPath().

bool Step::isPossible ( const pathing_t path)
Parameters
[in]pathPointer to client or server side pathing table (clMap, svMap)

note that this function may modify toPos !

Definition at line 443 of file grid.cpp.

References calcNewPos(), calcNewTUs(), checkFlyingDirections(), checkVerticalDirections(), checkWalkingDirections(), CORE_DIRECTIONS, dir, and FLYING_DIRECTIONS.

Referenced by Grid_CalcPathing(), and Grid_FindPath().

Field Documentation

int Step::actorCrouchedHeight
private

Definition at line 149 of file grid.cpp.

Referenced by checkWalkingDirections(), and init().

int Step::actorHeight
private

The actor's height in QUANT units.

Definition at line 148 of file grid.cpp.

Referenced by checkFlyingDirections(), checkWalkingDirections(), and init().

const byte Step::crouchingState

Definition at line 156 of file grid.cpp.

Referenced by calcNewTUs(), checkWalkingDirections(), Grid_CalcPathing(), Grid_FindPath(), and init().

bool Step::flier
private
Todo:
flier should return true if the actor can fly.

This can be keyed into whether an actor can fly or not to allow flying

Definition at line 137 of file grid.cpp.

Referenced by checkVerticalDirections(), and init().

bool Step::hasLadderSupport
private
Todo:
has_ladder_support should return true if 1) There is a ladder in the new cell in the specified direction or 2) There is a ladder in any direction in the cell below the new cell and no ladder in the new cell itself.

Indicates if there is a ladder present providing support.

Definition at line 146 of file grid.cpp.

Referenced by checkVerticalDirections(), and checkWalkingDirections().

bool Step::hasLadderToClimb
private
Todo:
has_ladder_climb should return true if 1) There is a ladder in the new cell in the specified direction.

Indicates if there is a ladder present providing ability to climb.

Definition at line 141 of file grid.cpp.

Referenced by checkVerticalDirections().

const Routing& Step::routing
private
byte Step::TUsAfter

Definition at line 157 of file grid.cpp.

Referenced by calcNewTUs(), Grid_CalcPathing(), and Grid_FindPath().


The documentation for this class was generated from the following file: