2003-07-28 01:44:38 +00:00
|
|
|
/* Copyright (C) 1994-2003 Revolution Software Ltd
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
2003-07-28 01:44:38 +00:00
|
|
|
// ROUTER.CPP by James
|
2003-09-20 15:34:53 +00:00
|
|
|
//
|
|
|
|
// A rehash of Jeremy's original jrouter.c, containing low-level system
|
|
|
|
// routines for calculating routes between points inside a walk-grid, and
|
|
|
|
// constructing walk animations from mega-sets.
|
|
|
|
//
|
|
|
|
// jrouter.c underwent 2 major reworks from the original:
|
|
|
|
// (1) Restructured to allow more flexibility in the mega-sets, ie. more info
|
|
|
|
// taken from the walk-data
|
|
|
|
// - the new George & Nico mega-sets & walk-data were then tested &
|
|
|
|
// tweaked in the Sword1 system
|
2003-07-28 01:44:38 +00:00
|
|
|
// (2) Updated for the new Sword2 system, ie. new object structures
|
2003-09-20 15:34:53 +00:00
|
|
|
// - now compatible with Sword2, the essential code already having been
|
|
|
|
// tested
|
|
|
|
//
|
|
|
|
// ---------------------------------------------------------------------------
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* JROUTER.C polygon router with modular walks
|
|
|
|
* using a tree of modules
|
|
|
|
* 21 july 94
|
|
|
|
* 3 november 94
|
|
|
|
* System currently works by scanning grid data and coming up with a ROUTE
|
|
|
|
* as a series of way points(nodes), the smoothest eight directional PATH
|
|
|
|
* through these nodes is then found, and a WALK created to fit the PATH.
|
|
|
|
*
|
|
|
|
* Two funtions are called by the user, RouteFinder creates a route as a
|
|
|
|
* module list, HardWalk creates an animation list from the module list.
|
|
|
|
* The split is only provided to allow the possibility of turning the
|
|
|
|
* autorouter over two game cycles.
|
|
|
|
****************************************************************************
|
|
|
|
*
|
|
|
|
* Routine timings on osborne 486
|
|
|
|
*
|
|
|
|
* Read floor resource (file already loaded) 112 pixels
|
|
|
|
*
|
|
|
|
* Read mega resource (file already loaded) 112 pixels
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
****************************************************************************
|
|
|
|
*
|
|
|
|
* Modified 12 Oct 95
|
|
|
|
*
|
|
|
|
* Target Points within 1 pixel of a line are ignored ???
|
|
|
|
*
|
|
|
|
* Modules split into Points within 1 pixel of a line are ignored ???
|
|
|
|
*
|
|
|
|
****************************************************************************
|
|
|
|
*
|
|
|
|
* TOTALLY REHASHED BY JAMES FOR NEW MEGAS USING OLD SYSTEM
|
|
|
|
* THEN REINCARNATED BY JAMES FOR NEW MEGAS USING NEW SYSTEM
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Include Files
|
|
|
|
*/
|
|
|
|
|
2003-07-28 03:12:49 +00:00
|
|
|
#include "stdafx.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
#include "driver/driver96.h"
|
|
|
|
#include "console.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "header.h"
|
|
|
|
#include "interpreter.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "resman.h"
|
|
|
|
#include "router.h"
|
|
|
|
|
|
|
|
#define MAX_FRAMES_PER_CYCLE 16
|
2003-09-20 15:34:53 +00:00
|
|
|
#define NO_DIRECTIONS 8
|
|
|
|
#define MAX_FRAMES_PER_CHAR (MAX_FRAMES_PER_CYCLE * NO_DIRECTIONS)
|
|
|
|
#define ROUTE_END_FLAG 255
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
//---------------------------------------
|
|
|
|
// TEMP!
|
2003-09-20 15:34:53 +00:00
|
|
|
// 1 = force the use of slidy router (so solid path not used when ending walk
|
|
|
|
// in ANY direction)
|
|
|
|
int8 forceSlidy;
|
2003-07-28 01:44:38 +00:00
|
|
|
//---------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Type Defines
|
|
|
|
*/
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
#define O_WALKANIM_SIZE 600 // max number of nodes in router output
|
|
|
|
#define O_GRID_SIZE 200 // max 200 lines & 200 points
|
|
|
|
#define EXTRA_GRID_SIZE 20 // max 20 lines & 20 points
|
|
|
|
#define O_ROUTE_SIZE 50 // max number of modules in a route
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 dirS;
|
|
|
|
int32 dirD;
|
2003-07-28 01:44:38 +00:00
|
|
|
} _routeData;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
typedef struct {
|
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 dir;
|
|
|
|
int32 num;
|
2003-07-28 01:44:38 +00:00
|
|
|
} _pathData;
|
|
|
|
|
|
|
|
// Function prototypes
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 GetRoute(void);
|
|
|
|
static void ExtractRoute(void);
|
|
|
|
static void LoadWalkGrid(void);
|
|
|
|
static void SetUpWalkGrid(Object_mega *ob_mega, int32 x, int32 y, int32 dir);
|
|
|
|
static void LoadWalkData(Object_walkdata *ob_walkdata);
|
|
|
|
static void PlotCross(int16 x, int16 y, uint8 colour);
|
|
|
|
|
|
|
|
static int32 Scan(int32 level);
|
|
|
|
static int32 NewCheck(int32 status, int32 x1, int32 y1, int32 x2, int32 y2);
|
|
|
|
static int32 LineCheck(int32 x1, int32 x2, int32 y1, int32 y2);
|
|
|
|
static int32 VertCheck(int32 x, int32 y1, int32 y2);
|
|
|
|
static int32 HorizCheck(int32 x1, int32 y, int32 x2);
|
|
|
|
static int32 Check(int32 x1, int32 y1, int32 x2, int32 y2);
|
|
|
|
static int32 CheckTarget(int32 x, int32 y);
|
|
|
|
|
|
|
|
static int32 SmoothestPath(void);
|
|
|
|
static int32 SlidyPath(void);
|
|
|
|
static int32 SolidPath(void);
|
|
|
|
|
|
|
|
static int32 SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
|
|
|
|
|
|
|
|
static int32 AddSlowInFrames(_walkData *walkAnim);
|
|
|
|
static void AddSlowOutFrames(_walkData *walkAnim);
|
|
|
|
static void SlidyWalkAnimator(_walkData *walkAnim);
|
|
|
|
static int32 SolidWalkAnimator(_walkData *walkAnim);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
#define MAX_WALKGRIDS 10
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 walkGridList[MAX_WALKGRIDS];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// because we only have 2 megas in the game!
|
|
|
|
#define TOTAL_ROUTE_SLOTS 2
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// stores pointers to mem blocks containing routes created & used by megas
|
|
|
|
// (NULL if slot not in use)
|
|
|
|
static mem *route_slots[TOTAL_ROUTE_SLOTS];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// Local Variables
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 nbars;
|
|
|
|
static int32 nnodes;
|
|
|
|
|
|
|
|
// because extra bars will be copied into here afer walkgrid loaded
|
|
|
|
static _barData bars[O_GRID_SIZE+EXTRA_GRID_SIZE];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static _nodeData node[O_GRID_SIZE+EXTRA_GRID_SIZE];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// area for extra route data to block parts of floors and enable routing
|
|
|
|
// round mega charaters
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 nExtraBars = 0;
|
|
|
|
static int32 nExtraNodes = 0;
|
|
|
|
static _barData extraBars[EXTRA_GRID_SIZE];
|
|
|
|
static _nodeData extraNode[EXTRA_GRID_SIZE];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 startX;
|
|
|
|
static int32 startY;
|
|
|
|
static int32 startDir;
|
|
|
|
static int32 targetX;
|
|
|
|
static int32 targetY;
|
|
|
|
static int32 targetDir;
|
|
|
|
static int32 scaleA;
|
|
|
|
static int32 scaleB;
|
|
|
|
static _routeData route[O_ROUTE_SIZE];
|
|
|
|
static _pathData smoothPath[O_ROUTE_SIZE];
|
|
|
|
static _pathData modularPath[O_ROUTE_SIZE];
|
|
|
|
static int32 routeLength;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 framesPerStep;
|
|
|
|
static int32 framesPerChar;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static uint8 nWalkFrames; // no. of frames per walk cycle
|
|
|
|
static uint8 usingStandingTurnFrames; // any standing turn frames?
|
|
|
|
static uint8 usingWalkingTurnFrames; // any walking turn frames?
|
|
|
|
static uint8 usingSlowInFrames; // any slow-in frames?
|
|
|
|
static uint8 usingSlowOutFrames; // any slow-out frames?
|
|
|
|
static int32 dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
|
|
|
|
static int32 dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
|
|
|
|
static int8 modX[NO_DIRECTIONS];
|
|
|
|
static int8 modY[NO_DIRECTIONS];
|
|
|
|
static int32 diagonalx = 0;
|
|
|
|
static int32 diagonaly = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 firstStandFrame;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 firstStandingTurnLeftFrame;
|
|
|
|
static int32 firstStandingTurnRightFrame;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 firstWalkingTurnLeftFrame; // left walking turn
|
|
|
|
static int32 firstWalkingTurnRightFrame; // right walking turn
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static uint32 firstSlowInFrame[NO_DIRECTIONS];
|
|
|
|
static uint32 numberOfSlowInFrames[NO_DIRECTIONS];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static uint32 leadingLeg[NO_DIRECTIONS];
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 firstSlowOutFrame;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// number of slow-out frames on for each leading-leg in each direction
|
|
|
|
// ie. total number of slow-out frames = (numberOfSlowOutFrames * 2 *
|
|
|
|
// NO_DIRECTIONS)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 numberOfSlowOutFrames;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
static int32 stepCount;
|
|
|
|
|
|
|
|
static int32 moduleX;
|
|
|
|
static int32 moduleY;
|
|
|
|
static int32 currentDir;
|
|
|
|
static int32 lastCount;
|
|
|
|
static int32 frame;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CODE
|
|
|
|
*/
|
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
uint8 ReturnSlotNo(uint32 megaId) {
|
|
|
|
if (ID == CUR_PLAYER_ID) {
|
|
|
|
// George (8)
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
// One of Nico's mega id's
|
|
|
|
return 1;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void AllocateRouteMem(void) {
|
2003-07-28 01:44:38 +00:00
|
|
|
uint8 slotNo;
|
|
|
|
|
|
|
|
// added (James23June96)
|
2003-09-20 15:34:53 +00:00
|
|
|
// Player character always always slot 0, while the other mega
|
|
|
|
// (normally Nico) always uses slot 1
|
|
|
|
// Better this way, so that if mega object removed from memory while
|
|
|
|
// in middle of route, the old route will be safely cleared from
|
|
|
|
// memory just before they create a new one
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
slotNo = ReturnSlotNo(ID);
|
|
|
|
|
|
|
|
// if this slot is already used, then it can't be needed any more
|
|
|
|
// because this id is creating a new route!
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (route_slots[slotNo])
|
|
|
|
FreeRouteMem();
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
route_slots[slotNo] = Twalloc(sizeof(_walkData) * O_WALKANIM_SIZE, MEM_locked, UID_walk_anim);
|
|
|
|
|
|
|
|
// 12000 bytes were used for this in Sword1 mega compacts, based on
|
|
|
|
// 20 bytes per '_walkData' frame
|
2003-07-28 01:44:38 +00:00
|
|
|
// ie. allowing for 600 frames including end-marker
|
|
|
|
// Now '_walkData' is 8 bytes, so 8*600 = 4800 bytes.
|
2003-09-20 15:34:53 +00:00
|
|
|
// Note that a 600 frame walk lasts about 48 seconds!
|
|
|
|
// (600fps / 12.5s = 48s)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// mega keeps note of which slot contains the pointer to it's walk
|
|
|
|
// animation mem block
|
|
|
|
// +1 so that '0' can mean "not walking"
|
|
|
|
// megaObject->route_slot_id = slotNo + 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
_walkData* LockRouteMem(void) {
|
2003-07-28 01:44:38 +00:00
|
|
|
uint8 slotNo = ReturnSlotNo(ID);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
Lock_mem(route_slots[slotNo]);
|
|
|
|
return (_walkData *) route_slots[slotNo]->ad;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void FloatRouteMem(void) {
|
2003-07-28 01:44:38 +00:00
|
|
|
uint8 slotNo = ReturnSlotNo(ID);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
Float_mem(route_slots[slotNo]);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void FreeRouteMem(void) {
|
2003-07-28 01:44:38 +00:00
|
|
|
uint8 slotNo = ReturnSlotNo(ID);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// free the mem block pointed to from this entry of route_slots[]
|
|
|
|
|
|
|
|
Free_mem(route_slots[slotNo]);
|
|
|
|
route_slots[slotNo] = NULL;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void FreeAllRouteMem(void) {
|
|
|
|
for (int slotNo = 0; slotNo < TOTAL_ROUTE_SLOTS; slotNo++) {
|
|
|
|
if (route_slots[slotNo]) {
|
|
|
|
// free the mem block pointed to from this entry of
|
|
|
|
// route_slots[]
|
|
|
|
Free_mem(route_slots[slotNo]);
|
2003-07-28 01:44:38 +00:00
|
|
|
route_slots[slotNo] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 RouteFinder(Object_mega *ob_mega, Object_walkdata *ob_walkdata, int32 x, int32 y, int32 dir) {
|
|
|
|
/*********************************************************************
|
|
|
|
* RouteFinder.C polygon router with modular walks
|
|
|
|
* 21 august 94
|
|
|
|
* 3 november 94
|
|
|
|
* RouteFinder creates a list of modules that enables HardWalk to
|
|
|
|
* create an animation list.
|
|
|
|
*
|
|
|
|
* RouteFinder currently works by scanning grid data and coming up
|
|
|
|
* with a ROUTE as a series of way points(nodes), the smoothest eight
|
|
|
|
* directional PATH through these nodes is then found, this
|
|
|
|
* information is made available to HardWalk for a WALK to be created
|
|
|
|
* to fit the PATH.
|
|
|
|
*
|
|
|
|
* 30 november 94 return values modified
|
|
|
|
*
|
|
|
|
* return 0 = failed to find a route
|
|
|
|
*
|
|
|
|
* 1 = found a route
|
|
|
|
*
|
|
|
|
* 2 = mega already at target
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
int32 routeFlag = 0;
|
|
|
|
int32 solidFlag = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
_walkData *walkAnim;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// megaId = id;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
SetUpWalkGrid(ob_mega, x, y, dir);
|
|
|
|
LoadWalkData(ob_walkdata);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// lock the _walkData array (NB. AFTER loading walkgrid & walkdata!)
|
|
|
|
walkAnim = LockRouteMem();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// All route data now loaded start finding a route
|
|
|
|
|
|
|
|
// Check if we can get a route through the floor. changed 12 Oct95 JPS
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
routeFlag = GetRoute();
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (routeFlag == 2) {
|
|
|
|
// special case for zero length route
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if target direction specified as any
|
|
|
|
if (targetDir > 7)
|
2003-07-28 01:44:38 +00:00
|
|
|
targetDir = startDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// just a turn on the spot is required set an end module for
|
|
|
|
// the route let the animator deal with it
|
2003-07-28 01:44:38 +00:00
|
|
|
// modularPath is normally set by ExtractRoute
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
modularPath[0].dir = startDir;
|
|
|
|
modularPath[0].num = 0;
|
|
|
|
modularPath[0].x = startX;
|
|
|
|
modularPath[0].y = startY;
|
|
|
|
modularPath[1].dir = targetDir;
|
|
|
|
modularPath[1].num = 0;
|
|
|
|
modularPath[1].x = startX;
|
|
|
|
modularPath[1].y = startY;
|
|
|
|
modularPath[2].dir = 9;
|
|
|
|
modularPath[2].num = ROUTE_END_FLAG;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
SlidyWalkAnimator(walkAnim);
|
|
|
|
routeFlag = 2;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else if (routeFlag == 1) {
|
|
|
|
// a normal route
|
|
|
|
|
|
|
|
// Convert the route to an exact path
|
|
|
|
SmoothestPath();
|
|
|
|
|
|
|
|
// The Route had waypoints and direction options
|
|
|
|
|
|
|
|
// The Path is an exact set of lines in 8 directions that
|
|
|
|
// reach the target.
|
|
|
|
|
|
|
|
// The path is in module format, but steps taken in each
|
|
|
|
// direction are not accurate
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// if target dir = 8 then the walk isn't linked to an anim so
|
2003-09-20 15:34:53 +00:00
|
|
|
// we can create a route without sliding and miss the exact
|
|
|
|
// target
|
|
|
|
|
|
|
|
if (!forceSlidy) {
|
|
|
|
if (targetDir == 8) {
|
|
|
|
// can end facing ANY direction (ie. exact end
|
|
|
|
// position not vital) - so use SOLID walk to
|
|
|
|
// avoid sliding to exact position
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
SolidPath();
|
|
|
|
solidFlag = SolidWalkAnimator(walkAnim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (!solidFlag) {
|
|
|
|
// if we failed to create a SOLID route, do a SLIDY
|
|
|
|
// one instead
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
SlidyPath();
|
|
|
|
SlidyWalkAnimator(walkAnim);
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
// Route didn't reach target so assume point was off the floor
|
|
|
|
// routeFlag = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FloatRouteMem(); // float the _walkData array again
|
|
|
|
|
|
|
|
return routeFlag; // send back null route
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 GetRoute(void) {
|
|
|
|
/*********************************************************************
|
|
|
|
* GetRoute.C extract a path from walk grid
|
|
|
|
* 12 october 94
|
|
|
|
*
|
|
|
|
* GetRoute currently works by scanning grid data and coming up with
|
|
|
|
* a ROUTE as a series of way points(nodes).
|
|
|
|
*
|
|
|
|
* static _routeData route[O_ROUTE_SIZE];
|
|
|
|
*
|
|
|
|
* return 0 = failed to find a route
|
|
|
|
*
|
|
|
|
* 1 = found a route
|
|
|
|
*
|
|
|
|
* 2 = mega already at target
|
|
|
|
*
|
|
|
|
* 3 = failed to find a route because target was on a line
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
int32 routeGot = 0;
|
|
|
|
int32 level;
|
|
|
|
int32 changed;
|
|
|
|
|
|
|
|
if (startX == targetX && startY == targetY)
|
2003-07-28 01:44:38 +00:00
|
|
|
routeGot = 2;
|
2003-09-20 15:34:53 +00:00
|
|
|
else {
|
|
|
|
// 'else' added by JEL (23jan96) otherwise 'routeGot' affected
|
|
|
|
// even when already set to '2' above - causing some 'turns'
|
|
|
|
// to walk downwards on the spot
|
|
|
|
|
|
|
|
// returns 3 if target on a line ( +- 1 pixel )
|
|
|
|
routeGot = CheckTarget(targetX,targetY);
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (routeGot == 0) {
|
|
|
|
// still looking for a route check if target is within a pixel
|
|
|
|
// of a line
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// scan through the nodes linking each node to its nearest
|
|
|
|
// neighbour until no more nodes change
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// This is the routine that finds a route using Scan()
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
level = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
2003-07-28 01:44:38 +00:00
|
|
|
changed = Scan(level);
|
2003-09-20 15:34:53 +00:00
|
|
|
level++;
|
|
|
|
} while(changed == 1);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// Check to see if the route reached the target
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (node[nnodes].dist < 9999) {
|
|
|
|
// it did so extract the route as nodes and the
|
|
|
|
// directions to go between each node
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
routeGot = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
ExtractRoute();
|
|
|
|
|
|
|
|
// route.X,route.Y and route.Dir now hold all the
|
|
|
|
// route infomation with the target dir or route
|
|
|
|
// continuation
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return routeGot;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SLIDY PATH ROUTINES
|
|
|
|
|
|
|
|
int32 SmoothestPath() {
|
|
|
|
// This is the second big part of the route finder and the the only
|
|
|
|
// bit that tries to be clever (the other bits are clever).
|
|
|
|
//
|
|
|
|
// This part of the autorouter creates a list of modules from a set of
|
|
|
|
// lines running across the screen. The task is complicated by two
|
|
|
|
// things:
|
|
|
|
//
|
|
|
|
// Firstly in choosing a route through the maze of nodes the routine
|
|
|
|
// tries to minimise the amount of each individual turn avoiding 90
|
|
|
|
// degree and greater turns (where possible) and reduces the total
|
|
|
|
// number of turns (subject to two 45 degree turns being better than
|
|
|
|
// one 90 degree turn).
|
|
|
|
//
|
|
|
|
// Secondly when walking in a given direction the number of steps
|
|
|
|
// required to reach the end of that run is not calculated accurately.
|
|
|
|
// This is because I was unable to derive a function to relate number
|
|
|
|
// of steps taken between two points to the shrunken step size
|
|
|
|
|
|
|
|
int32 p;
|
|
|
|
int32 dirS;
|
|
|
|
int32 dirD;
|
|
|
|
int32 dS;
|
|
|
|
int32 dD;
|
|
|
|
int32 dSS;
|
|
|
|
int32 dSD;
|
|
|
|
int32 dDS;
|
|
|
|
int32 dDD;
|
|
|
|
int32 SS;
|
|
|
|
int32 SD;
|
|
|
|
int32 DS;
|
|
|
|
int32 DD;
|
|
|
|
int32 i;
|
|
|
|
int32 j;
|
|
|
|
int32 temp;
|
|
|
|
int32 steps;
|
|
|
|
int32 option;
|
|
|
|
int32 options;
|
|
|
|
int32 lastDir;
|
|
|
|
int32 nextDirS;
|
|
|
|
int32 nextDirD;
|
|
|
|
int32 tempturns[4];
|
|
|
|
int32 turns[4];
|
|
|
|
int32 turntable[NO_DIRECTIONS] = { 0, 1, 3, 5, 7, 5, 3, 1 };
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// route.X route.Y and route.Dir start at far end
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
smoothPath[0].x = startX;
|
|
|
|
smoothPath[0].y = startY;
|
|
|
|
smoothPath[0].dir = startDir;
|
|
|
|
smoothPath[0].num = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
p = 0;
|
|
|
|
lastDir = startDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// for each section of the route
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
2003-07-28 01:44:38 +00:00
|
|
|
dirS = route[p].dirS;
|
|
|
|
dirD = route[p].dirD;
|
|
|
|
nextDirS = route[p+1].dirS;
|
|
|
|
nextDirD = route[p+1].dirD;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Check directions into and out of a pair of nodes going in
|
2003-07-28 01:44:38 +00:00
|
|
|
dS = dirS - lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dS < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dS = dS + NO_DIRECTIONS;
|
|
|
|
|
|
|
|
dD = dirD - lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dD < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dD = dD + NO_DIRECTIONS;
|
|
|
|
|
|
|
|
// coming out
|
|
|
|
dSS = dirS - nextDirS;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dSS < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dSS = dSS + NO_DIRECTIONS;
|
|
|
|
|
|
|
|
dDD = dirD - nextDirD;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dDD < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dDD = dDD + NO_DIRECTIONS;
|
|
|
|
|
|
|
|
dSD = dirS - nextDirD;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dSD < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dSD = dSD + NO_DIRECTIONS;
|
|
|
|
|
|
|
|
dDS = dirD - nextDirS;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (dDS < 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
dDS = dDS + NO_DIRECTIONS;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Determine the amount of turning involved in each possible
|
|
|
|
// path
|
|
|
|
|
|
|
|
dS = turntable[dS];
|
|
|
|
dD = turntable[dD];
|
2003-07-28 01:44:38 +00:00
|
|
|
dSS = turntable[dSS];
|
|
|
|
dDD = turntable[dDD];
|
2003-09-20 15:34:53 +00:00
|
|
|
dSD = turntable[dSD];
|
|
|
|
dDS = turntable[dDS];
|
|
|
|
|
|
|
|
// get the best path out ie assume next section uses best
|
|
|
|
// direction
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (dSD < dSS)
|
|
|
|
dSS = dSD;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (dDS < dDD)
|
|
|
|
dDD = dDS;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// Rate each option. Split routes look crap so weight against
|
|
|
|
// them
|
|
|
|
|
|
|
|
SS = dS + dSS + 3;
|
2003-07-28 01:44:38 +00:00
|
|
|
SD = dS + dDD;
|
|
|
|
DS = dD + dSS;
|
|
|
|
DD = dD + dDD + 3;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// set up turns as a sorted array of the turn values
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
tempturns[0] = SS;
|
|
|
|
turns[0] = 0;
|
|
|
|
tempturns[1] = SD;
|
|
|
|
turns[1] = 1;
|
|
|
|
tempturns[2] = DS;
|
|
|
|
turns[2] = 2;
|
|
|
|
tempturns[3] = DD;
|
|
|
|
turns[3] = 3;
|
|
|
|
i = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
if (tempturns[j] > tempturns[j + 1]) {
|
|
|
|
temp = turns[j];
|
|
|
|
turns[j] = turns[j + 1];
|
|
|
|
turns[j + 1] = temp;
|
|
|
|
temp = tempturns[j];
|
|
|
|
tempturns[j] = tempturns[j + 1];
|
|
|
|
tempturns[j + 1] = temp;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// best option matched in order of the priority we would like
|
|
|
|
// to see on the screen but each option must be checked to see
|
|
|
|
// if it can be walked
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
options = NewCheck(1, route[p].x, route[p].y, route[p + 1].x, route[p + 1].y);
|
|
|
|
|
2003-07-30 19:25:31 +00:00
|
|
|
#ifdef _SWORD2_DEBUG
|
2003-09-20 15:34:53 +00:00
|
|
|
if (options == 0) {
|
|
|
|
Zdebug("BestTurns fail %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y);
|
|
|
|
Zdebug("BestTurns fail %d %d %d %d", turns[0], turns[1], turns[2], options);
|
|
|
|
Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
steps = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
2003-07-28 01:44:38 +00:00
|
|
|
option = 1 << turns[i];
|
|
|
|
if (option & options)
|
2003-09-20 15:34:53 +00:00
|
|
|
steps = SmoothCheck(turns[i], p, dirS, dirD);
|
|
|
|
i++;
|
|
|
|
} while (steps == 0 && i < 4);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-07-30 19:25:31 +00:00
|
|
|
#ifdef _SWORD2_DEBUG
|
2003-09-20 15:34:53 +00:00
|
|
|
if (steps == 0) {
|
|
|
|
Zdebug("BestTurns failed %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y);
|
|
|
|
Zdebug("BestTurns failed %d %d %d %d", turns[0], turns[1], turns[2], options);
|
|
|
|
Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// route.X route.Y route.dir and bestTurns start at far end
|
2003-09-20 15:34:53 +00:00
|
|
|
p++;
|
|
|
|
} while (p < (routeLength));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// best turns will end heading as near as possible to target dir rest
|
|
|
|
// is down to anim for now
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
smoothPath[steps].dir = 9;
|
|
|
|
smoothPath[steps].num = ROUTE_END_FLAG;
|
2003-09-20 15:34:53 +00:00
|
|
|
return 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) {
|
|
|
|
/*********************************************************************
|
|
|
|
* Slip sliding away
|
|
|
|
* This path checker checks to see if a walk that exactly follows the
|
|
|
|
* path would be valid. This should be inherently true for atleast one
|
|
|
|
* of the turn options.
|
|
|
|
* No longer checks the data it only creates the smoothPath array JPS
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static int32 k;
|
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
int32 x2;
|
|
|
|
int32 y2;
|
|
|
|
int32 ldx;
|
|
|
|
int32 ldy;
|
|
|
|
int32 dsx;
|
|
|
|
int32 dsy;
|
|
|
|
int32 ddx;
|
|
|
|
int32 ddy;
|
|
|
|
int32 dirX;
|
|
|
|
int32 dirY;
|
|
|
|
int32 ss0;
|
|
|
|
int32 ss1;
|
|
|
|
int32 ss2;
|
|
|
|
int32 sd0;
|
|
|
|
int32 sd1;
|
|
|
|
int32 sd2;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (p == 0)
|
|
|
|
k = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
x = route[p].x;
|
|
|
|
y = route[p].y;
|
|
|
|
x2 = route[p + 1].x;
|
|
|
|
y2 = route[p + 1].y;
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = x2 - x;
|
|
|
|
ldy = y2 - y;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirX = 1;
|
|
|
|
dirY = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (ldx < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = -ldx;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirX = -1;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (ldy < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldy = -ldy;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirY = -1;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// set up sd0-ss2 to reflect possible movement in each direction
|
|
|
|
|
|
|
|
if (dirS == 0 || dirS == 4) { // vert and diag
|
2003-09-19 15:01:49 +00:00
|
|
|
ddx = ldx;
|
2003-09-20 15:34:53 +00:00
|
|
|
ddy = (ldx * diagonaly) / diagonalx;
|
2003-09-19 15:01:49 +00:00
|
|
|
dsy = ldy - ddy;
|
|
|
|
ddx = ddx * dirX;
|
|
|
|
ddy = ddy * dirY;
|
|
|
|
dsy = dsy * dirY;
|
|
|
|
dsx = 0;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
sd0 = (ddx + modX[dirD] / 2) / modX[dirD];
|
|
|
|
ss0 = (dsy + modY[dirS] / 2) / modY[dirS];
|
|
|
|
sd1 = sd0 / 2;
|
|
|
|
ss1 = ss0 / 2;
|
2003-09-19 15:01:49 +00:00
|
|
|
sd2 = sd0 - sd1;
|
|
|
|
ss2 = ss0 - ss1;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
2003-09-19 15:01:49 +00:00
|
|
|
ddy = ldy;
|
2003-09-20 15:34:53 +00:00
|
|
|
ddx = (ldy * diagonalx) / diagonaly;
|
2003-09-19 15:01:49 +00:00
|
|
|
dsx = ldx - ddx;
|
|
|
|
ddy = ddy * dirY;
|
|
|
|
ddx = ddx * dirX;
|
|
|
|
dsx = dsx * dirX;
|
|
|
|
dsy = 0;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
sd0 = (ddy + modY[dirD] / 2) / modY[dirD];
|
|
|
|
ss0 = (dsx + modX[dirS] / 2) / modX[dirS];
|
|
|
|
sd1 = sd0 / 2;
|
|
|
|
ss1 = ss0 / 2;
|
2003-09-19 15:01:49 +00:00
|
|
|
sd2 = sd0 - sd1;
|
|
|
|
ss2 = ss0 - ss1;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (best == 0) { // halfsquare, diagonal, halfsquare
|
|
|
|
smoothPath[k].x = x + dsx / 2;
|
|
|
|
smoothPath[k].y = y + dsy / 2;
|
|
|
|
smoothPath[k].dir = dirS;
|
|
|
|
smoothPath[k].num = ss1;
|
2003-09-19 15:01:49 +00:00
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
smoothPath[k].x = x + dsx / 2 + ddx;
|
|
|
|
smoothPath[k].y = y + dsy / 2 + ddy;
|
|
|
|
smoothPath[k].dir = dirD;
|
|
|
|
smoothPath[k].num = sd0;
|
2003-09-19 15:01:49 +00:00
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
smoothPath[k].x = x + dsx + ddx;
|
|
|
|
smoothPath[k].y = y + dsy + ddy;
|
|
|
|
smoothPath[k].dir = dirS;
|
|
|
|
smoothPath[k].num = ss2;
|
2003-09-19 15:01:49 +00:00
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else if (best == 1) { // square, diagonal
|
|
|
|
smoothPath[k].x = x + dsx;
|
|
|
|
smoothPath[k].y = y + dsy;
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].dir = dirS;
|
|
|
|
smoothPath[k].num = ss0;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].x = x2;
|
|
|
|
smoothPath[k].y = y2;
|
|
|
|
smoothPath[k].dir = dirD;
|
|
|
|
smoothPath[k].num = sd0;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else if (best == 2) { // diagonal square
|
|
|
|
smoothPath[k].x = x + ddx;
|
|
|
|
smoothPath[k].y = y + ddy;
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].dir = dirD;
|
|
|
|
smoothPath[k].num = sd0;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].x = x2;
|
|
|
|
smoothPath[k].y = y2;
|
|
|
|
smoothPath[k].dir = dirS;
|
|
|
|
smoothPath[k].num = ss0;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else { // halfdiagonal, square, halfdiagonal
|
|
|
|
smoothPath[k].x = x + ddx / 2;
|
|
|
|
smoothPath[k].y = y + ddy / 2;
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].dir = dirD;
|
|
|
|
smoothPath[k].num = sd1;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
smoothPath[k].x = x + dsx + ddx / 2;
|
|
|
|
smoothPath[k].y = y + dsy + ddy / 2;
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].dir = dirS;
|
|
|
|
smoothPath[k].num = ss0;
|
|
|
|
k++;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-09-19 15:01:49 +00:00
|
|
|
smoothPath[k].x = x2;
|
|
|
|
smoothPath[k].y = y2;
|
|
|
|
smoothPath[k].dir = dirD;
|
|
|
|
smoothPath[k].num = sd2;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return k;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 SlidyPath() {
|
|
|
|
/*********************************************************************
|
|
|
|
* SlidyPath creates a path based on part steps with no sliding to get
|
|
|
|
* as near as possible to the target without any sliding this routine
|
|
|
|
* is currently unused, but is intended for use when just clicking
|
|
|
|
* about.
|
|
|
|
*
|
|
|
|
* produce a module list from the line data
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
int32 smooth;
|
|
|
|
int32 slidy;
|
|
|
|
int32 scale;
|
|
|
|
int32 stepX;
|
|
|
|
int32 stepY;
|
|
|
|
int32 deltaX;
|
|
|
|
int32 deltaY;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// strip out the short sections
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
slidy = 1;
|
|
|
|
smooth = 1;
|
|
|
|
modularPath[0].x = smoothPath[0].x;
|
|
|
|
modularPath[0].y = smoothPath[0].y;
|
|
|
|
modularPath[0].dir = smoothPath[0].dir;
|
|
|
|
modularPath[0].num = 0;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
while (smoothPath[smooth].num < ROUTE_END_FLAG) {
|
2003-07-28 01:44:38 +00:00
|
|
|
scale = scaleA * smoothPath[smooth].y + scaleB;
|
2003-09-20 15:34:53 +00:00
|
|
|
deltaX = smoothPath[smooth].x - modularPath[slidy - 1].x;
|
|
|
|
deltaY = smoothPath[smooth].y - modularPath[slidy - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
stepX = modX[smoothPath[smooth].dir];
|
|
|
|
stepY = modY[smoothPath[smooth].dir];
|
|
|
|
stepX = stepX * scale;
|
|
|
|
stepY = stepY * scale;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepX = stepX >> 19; // quarter a step minimum
|
2003-07-28 01:44:38 +00:00
|
|
|
stepY = stepY >> 19;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-09-24 06:40:23 +00:00
|
|
|
if (ABS(deltaX) >= ABS(stepX) && ABS(deltaY) >= ABS(stepY)) {
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[slidy].x = smoothPath[smooth].x;
|
|
|
|
modularPath[slidy].y = smoothPath[smooth].y;
|
|
|
|
modularPath[slidy].dir = smoothPath[smooth].dir;
|
|
|
|
modularPath[slidy].num = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
slidy++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
smooth++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// in case the last bit had no steps
|
|
|
|
|
|
|
|
if (slidy > 1) {
|
|
|
|
modularPath[slidy - 1].x = smoothPath[smooth - 1].x;
|
|
|
|
modularPath[slidy - 1].y = smoothPath[smooth - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// set up the end of the walk
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
modularPath[slidy].x = smoothPath[smooth - 1].x;
|
|
|
|
modularPath[slidy].y = smoothPath[smooth - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[slidy].dir = targetDir;
|
|
|
|
modularPath[slidy].num = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
slidy++;
|
|
|
|
|
|
|
|
modularPath[slidy].x = smoothPath[smooth - 1].x;
|
|
|
|
modularPath[slidy].y = smoothPath[smooth - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[slidy].dir = 9;
|
|
|
|
modularPath[slidy].num = ROUTE_END_FLAG;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SLOW IN
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 AddSlowInFrames(_walkData *walkAnim) {
|
2003-07-28 01:44:38 +00:00
|
|
|
uint32 slowInFrameNo;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (usingSlowInFrames && modularPath[1].num > 0) {
|
|
|
|
for (slowInFrameNo = 0; slowInFrameNo < numberOfSlowInFrames[currentDir]; slowInFrameNo++) {
|
|
|
|
walkAnim[stepCount].frame = firstSlowInFrame[currentDir] + slowInFrameNo;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = currentDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
return 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
return 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 slowOutFrameNo;
|
|
|
|
int32 walk_pc;
|
|
|
|
_walkData *walkAnim;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("\nEARLY SLOW-OUT");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
LoadWalkData(ob_walkdata);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("********************************");
|
|
|
|
// Zdebug("framesPerStep =%d", framesPerStep);
|
|
|
|
// Zdebug("numberOfSlowOutFrames =%d", numberOfSlowOutFrames);
|
|
|
|
// Zdebug("firstWalkingTurnLeftFrame =%d", firstWalkingTurnLeftFrame);
|
|
|
|
// Zdebug("firstWalkingTurnRightFrame =%d", firstWalkingTurnRightFrame);
|
|
|
|
// Zdebug("firstSlowOutFrame =%d", firstSlowOutFrame);
|
|
|
|
// Zdebug("********************************");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
walk_pc = ob_mega->walk_pc;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// lock the _walkData array (NB. AFTER loading walkgrid & walkdata!)
|
|
|
|
walkAnim = LockRouteMem();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if this mega does actually have slow-out frames
|
|
|
|
if (usingSlowOutFrames) {
|
|
|
|
// overwrite the next step (half a cycle) of the walk
|
|
|
|
// (ie .step - 0..5)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
// Zdebug("\nSTEP NUMBER: walkAnim[%d].step = %d", walk_pc, walkAnim[walk_pc].step);
|
|
|
|
// Zdebug("ORIGINAL FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// map from existing walk frame across to correct
|
|
|
|
// frame number of slow-out - remember, there may be
|
|
|
|
// more slow-out frames than walk-frames!
|
|
|
|
|
|
|
|
if (walkAnim[walk_pc].frame >= firstWalkingTurnRightFrame) {
|
|
|
|
// if it's a walking turn-right, rather than a
|
|
|
|
// normal step, then map it to a normal step
|
|
|
|
// frame first
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[walk_pc].frame -= firstWalkingTurnRightFrame;
|
|
|
|
// Zdebug("MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-right frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame);
|
|
|
|
} else if (walkAnim[walk_pc].frame >= firstWalkingTurnLeftFrame) {
|
|
|
|
// if it's a walking turn-left, rather than a
|
|
|
|
// normal step, then map it to a normal step
|
|
|
|
// frame first
|
|
|
|
|
|
|
|
walkAnim[walk_pc].frame -= firstWalkingTurnLeftFrame;
|
|
|
|
// Zdebug("MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-left frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[walk_pc].frame += firstSlowOutFrame + ((walkAnim[walk_pc].frame / framesPerStep) * (numberOfSlowOutFrames - framesPerStep));
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[walk_pc].step = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("SLOW-OUT FRAME: walkAnim[%d].frame = %d",walk_pc, walkAnim[walk_pc].frame);
|
|
|
|
walk_pc++;
|
|
|
|
} while(walkAnim[walk_pc].step > 0);
|
|
|
|
|
|
|
|
// Zdebug("\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// add stationary frame(s) (OPTIONAL)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) {
|
|
|
|
walkAnim[walk_pc].frame = walkAnim[walk_pc - 1].frame + 1;
|
|
|
|
// Zdebug("EXTRA FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame);
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[walk_pc].step = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[walk_pc].dir = walkAnim[walk_pc - 1].dir;
|
|
|
|
walkAnim[walk_pc].x = walkAnim[walk_pc - 1].x;
|
|
|
|
walkAnim[walk_pc].y = walkAnim[walk_pc - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
walk_pc++;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
// this mega doesn't have slow-out frames
|
|
|
|
// stand in current direction
|
|
|
|
|
|
|
|
walkAnim[walk_pc].frame = firstStandFrame + walkAnim[walk_pc - 1].dir;
|
|
|
|
walkAnim[walk_pc].step = 0;
|
|
|
|
walkAnim[walk_pc].dir = walkAnim[walk_pc - 1].dir;
|
|
|
|
walkAnim[walk_pc].x = walkAnim[walk_pc - 1].x;
|
|
|
|
walkAnim[walk_pc].y = walkAnim[walk_pc - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
walk_pc++;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// end of sequence
|
|
|
|
walkAnim[walk_pc].frame = 512;
|
|
|
|
|
|
|
|
// so that this doesn't happen again while 'george_walking' is still
|
|
|
|
// '2'
|
|
|
|
walkAnim[walk_pc].step = 99;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// SLOW OUT
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void AddSlowOutFrames(_walkData *walkAnim) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 slowOutFrameNo;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if the mega did actually walk, we overwrite the last step (half a
|
|
|
|
// cycle) with slow-out frames + add any necessary stationary frames
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (usingSlowOutFrames && lastCount >= framesPerStep) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// place stop frames here
|
|
|
|
// slowdown at the end of the last walk
|
|
|
|
|
|
|
|
slowOutFrameNo = lastCount - framesPerStep;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("SLOW OUT: slowOutFrameNo(%d) = lastCount(%d) - framesPerStep(%d)", slowOutFrameNo, lastCount, framesPerStep);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// overwrite the last step (half a cycle) of the walk
|
|
|
|
|
|
|
|
do {
|
|
|
|
// map from existing walk frame across to correct
|
|
|
|
// frame number of slow-out - remember, there may be
|
|
|
|
// more slow-out frames than walk-frames!
|
|
|
|
|
|
|
|
walkAnim[slowOutFrameNo].frame += firstSlowOutFrame + ((walkAnim[slowOutFrameNo].frame / framesPerStep) * (numberOfSlowOutFrames - framesPerStep));
|
|
|
|
|
|
|
|
// because no longer a normal walk-step
|
|
|
|
walkAnim[slowOutFrameNo].step = 0;
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//Zdebug("walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame);
|
2003-09-20 15:34:53 +00:00
|
|
|
slowOutFrameNo++;
|
|
|
|
} while(slowOutFrameNo < lastCount);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// add stationary frame(s) (OPTIONAL)
|
|
|
|
|
|
|
|
for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) {
|
|
|
|
walkAnim[stepCount].frame = walkAnim[stepCount - 1].frame + 1;
|
|
|
|
|
|
|
|
// Zdebug("EXTRA FRAMES: walkAnim[%d].frame = %d", stepCount, walkAnim[stepCount].frame);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].step = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].dir = walkAnim[stepCount - 1].dir;
|
|
|
|
walkAnim[stepCount].x = walkAnim[stepCount - 1].x;
|
|
|
|
walkAnim[stepCount].y = walkAnim[stepCount - 1].y;
|
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void SlidyWalkAnimator(_walkData *walkAnim) {
|
|
|
|
/*********************************************************************
|
|
|
|
* Skidding every where HardWalk creates an animation that exactly
|
|
|
|
* fits the smoothPath and uses foot slipping to fit whole steps into
|
|
|
|
* the route
|
|
|
|
*
|
|
|
|
* Parameters: georgeg, mouseg
|
|
|
|
* Returns: rout
|
|
|
|
*
|
|
|
|
* produce a module list from the line data
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
static int32 left = 0;
|
|
|
|
int32 p;
|
|
|
|
int32 lastDir;
|
|
|
|
int32 lastRealDir;
|
|
|
|
int32 turnDir;
|
|
|
|
int32 scale;
|
|
|
|
int32 step;
|
|
|
|
int32 module;
|
|
|
|
int32 moduleEnd;
|
|
|
|
int32 module16X;
|
|
|
|
int32 module16Y;
|
|
|
|
int32 stepX;
|
|
|
|
int32 stepY;
|
|
|
|
int32 errorX;
|
|
|
|
int32 errorY;
|
|
|
|
int32 lastErrorX;
|
|
|
|
int32 lastErrorY;
|
|
|
|
int32 frameCount;
|
|
|
|
int32 frames;
|
|
|
|
|
|
|
|
p = 0;
|
|
|
|
lastDir = modularPath[0].dir;
|
|
|
|
currentDir = modularPath[1].dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (currentDir == NO_DIRECTIONS)
|
|
|
|
currentDir = lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleX = startX;
|
|
|
|
moduleY = startY;
|
|
|
|
module16X = moduleX << 16;
|
|
|
|
module16Y = moduleY << 16;
|
|
|
|
stepCount = 0;
|
|
|
|
|
|
|
|
// START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY
|
|
|
|
// BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// Zdebug("\nSLIDY: STARTING THE WALK");
|
|
|
|
|
|
|
|
module = framesPerChar + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// TURN TO START THE WALK
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// Zdebug("\nSLIDY: TURNING TO START THE WALK");
|
2003-07-28 01:44:38 +00:00
|
|
|
// rotate if we need to
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (lastDir != currentDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// get the direction to turn
|
|
|
|
turnDir = currentDir - lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (turnDir < 0)
|
|
|
|
turnDir += NO_DIRECTIONS;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (turnDir > 4)
|
|
|
|
turnDir = -1;
|
|
|
|
else if (turnDir > 0)
|
|
|
|
turnDir = 1;
|
|
|
|
|
|
|
|
// rotate to new walk direction
|
|
|
|
// for george and nico put in a head turn at the start
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (usingStandingTurnFrames) {
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0)
|
2003-09-19 15:01:49 +00:00
|
|
|
module = firstStandingTurnLeftFrame + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-19 15:01:49 +00:00
|
|
|
module = firstStandingTurnRightFrame + lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rotate till were facing new dir then go back 45 degrees
|
2003-09-20 15:34:53 +00:00
|
|
|
while (lastDir != currentDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
lastDir += turnDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
if ( lastDir < 0)
|
2003-09-19 15:01:49 +00:00
|
|
|
lastDir += NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnLeftFrame + lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
2003-07-28 01:44:38 +00:00
|
|
|
if ( lastDir > 7)
|
2003-09-19 15:01:49 +00:00
|
|
|
lastDir -= NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnRightFrame + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// the back 45 degrees bit
|
2003-09-20 15:34:53 +00:00
|
|
|
// step back one because new head turn for george takes us
|
|
|
|
// past the new dir
|
|
|
|
stepCount--;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// his head is in the right direction
|
|
|
|
lastRealDir = currentDir;
|
|
|
|
|
|
|
|
// SLIDY: THE SLOW IN
|
|
|
|
|
|
|
|
AddSlowInFrames(walkAnim);
|
|
|
|
|
|
|
|
// THE WALK
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("\nSLIDY: THE WALK");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// start the walk on the left or right leg, depending on how the
|
|
|
|
// slow-in frames were drawn
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// (0 = left; 1 = right)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (leadingLeg[currentDir] == 0) {
|
|
|
|
// start the walk on the left leg (ie. at beginning of the
|
|
|
|
// first step of the walk cycle)
|
|
|
|
left = 0;
|
|
|
|
} else {
|
|
|
|
// start the walk on the right leg (ie. at beginning of the
|
|
|
|
// second step of the walk cycle)
|
|
|
|
left = framesPerStep;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
lastCount = stepCount;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// this ensures that we don't put in turn frames for the start
|
|
|
|
lastDir = 99;
|
|
|
|
|
|
|
|
// this ensures that we don't put in turn frames for the start
|
|
|
|
currentDir = 99;
|
|
|
|
|
|
|
|
do {
|
2003-09-12 23:22:45 +00:00
|
|
|
assert(stepCount < O_WALKANIM_SIZE);
|
2003-09-20 15:34:53 +00:00
|
|
|
while (modularPath[p].num == 0) {
|
|
|
|
p++;
|
2003-07-28 01:44:38 +00:00
|
|
|
if (currentDir != 99)
|
|
|
|
lastRealDir = currentDir;
|
|
|
|
lastDir = currentDir;
|
|
|
|
lastCount = stepCount;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// calculate average amount to lose in each step on the way
|
|
|
|
// to the next node
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
currentDir = modularPath[p].dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (currentDir < NO_DIRECTIONS) {
|
|
|
|
module = currentDir * framesPerStep * 2 + left;
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (left == 0)
|
2003-09-20 15:34:53 +00:00
|
|
|
left = framesPerStep;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-20 15:34:53 +00:00
|
|
|
left = 0;
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleEnd = module + framesPerStep;
|
|
|
|
step = 0;
|
|
|
|
scale = (scaleA * moduleY + scaleB);
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
module16X += dx[module] * scale;
|
|
|
|
module16Y += dy[module] * scale;
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleX = module16X >> 16;
|
|
|
|
moduleY = module16Y >> 16;
|
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = step; // normally 0,1,2,3,4,5,0,1,2,etc
|
|
|
|
walkAnim[stepCount].dir = currentDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
|
|
|
step++;
|
|
|
|
module++;
|
|
|
|
} while(module < moduleEnd);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
stepX = modX[modularPath[p].dir];
|
|
|
|
stepY = modY[modularPath[p].dir];
|
2003-09-20 15:34:53 +00:00
|
|
|
errorX = modularPath[p].x - moduleX;
|
2003-07-28 01:44:38 +00:00
|
|
|
errorX = errorX * stepX;
|
2003-09-20 15:34:53 +00:00
|
|
|
errorY = modularPath[p].y - moduleY;
|
2003-07-28 01:44:38 +00:00
|
|
|
errorY = errorY * stepY;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (errorX < 0 || errorY < 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[p].num = 0; // the end of the path
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// okay those last steps took us past our
|
|
|
|
// target but do we want to scoot or moonwalk
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frames = stepCount - lastCount;
|
2003-09-20 15:34:53 +00:00
|
|
|
errorX = modularPath[p].x - walkAnim[stepCount - 1].x;
|
|
|
|
errorY = modularPath[p].y - walkAnim[stepCount - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (frames > framesPerStep) {
|
|
|
|
lastErrorX = modularPath[p].x - walkAnim[stepCount - 7].x;
|
|
|
|
lastErrorY = modularPath[p].y - walkAnim[stepCount - 7].y;
|
|
|
|
|
|
|
|
if (stepX == 0) {
|
2003-09-24 06:40:23 +00:00
|
|
|
if (3 * ABS(lastErrorY) < ABS(errorY)) {
|
2003-09-20 15:34:53 +00:00
|
|
|
// the last stop was
|
|
|
|
// closest
|
2003-07-28 01:44:38 +00:00
|
|
|
stepCount -= framesPerStep;
|
|
|
|
if (left == 0)
|
|
|
|
left = framesPerStep;
|
|
|
|
else
|
|
|
|
left = 0;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
2003-09-24 06:40:23 +00:00
|
|
|
if (3 * ABS(lastErrorX) < ABS(errorX)) {
|
2003-09-20 15:34:53 +00:00
|
|
|
//the last stop was
|
|
|
|
// closest
|
2003-07-28 01:44:38 +00:00
|
|
|
stepCount -= framesPerStep;
|
|
|
|
if (left == 0)
|
|
|
|
left = framesPerStep;
|
|
|
|
else
|
|
|
|
left = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
errorX = modularPath[p].x - walkAnim[stepCount-1].x;
|
|
|
|
errorY = modularPath[p].y - walkAnim[stepCount-1].y;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// okay we've reached the end but we still
|
|
|
|
// have an error
|
|
|
|
|
|
|
|
if (errorX != 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
frameCount = 0;
|
|
|
|
frames = stepCount - lastCount;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
frameCount++;
|
|
|
|
walkAnim[lastCount + frameCount - 1].x += errorX * frameCount / frames;
|
|
|
|
} while(frameCount < frames);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (errorY != 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
frameCount = 0;
|
|
|
|
frames = stepCount - lastCount;
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
frameCount++;
|
|
|
|
walkAnim[lastCount + frameCount - 1].y += errorY * frameCount / frames;
|
|
|
|
} while(frameCount < frames);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now is the time to put in the turn frames
|
|
|
|
// for the last turn
|
|
|
|
|
|
|
|
if (frames < framesPerStep) {
|
|
|
|
// this ensures that we don't put in
|
|
|
|
// turn frames for this walk or the
|
|
|
|
// next
|
|
|
|
currentDir = 99;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (currentDir != 99)
|
|
|
|
lastRealDir = currentDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// check each turn condition in turn
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// only for george
|
|
|
|
if (lastDir != 99 && currentDir != 99 && usingWalkingTurnFrames) {
|
|
|
|
// 1 and -7 going right -1 and 7 going
|
|
|
|
// left
|
|
|
|
lastDir = currentDir - lastDir;
|
|
|
|
|
|
|
|
if (lastDir == -1 || lastDir == 7 || lastDir == -2 || lastDir == 6) {
|
|
|
|
// turn at the end of the last
|
|
|
|
// walk
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frame = lastCount - framesPerStep;
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
// turning left
|
|
|
|
walkAnim[frame].frame += firstWalkingTurnLeftFrame;
|
|
|
|
frame++;
|
|
|
|
} while (frame < lastCount);
|
|
|
|
} else if (lastDir == 1 || lastDir == -7 || lastDir == 2 || lastDir == -6) {
|
|
|
|
// turn at the end of the
|
|
|
|
// current walk
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frame = lastCount - framesPerStep;
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
// turning right
|
|
|
|
walkAnim[frame].frame += firstWalkingTurnRightFrame;
|
|
|
|
frame++;
|
|
|
|
} while(frame < lastCount);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
lastDir = currentDir;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// all turns checked
|
|
|
|
|
|
|
|
lastCount = stepCount;
|
2003-09-20 15:34:53 +00:00
|
|
|
moduleX = walkAnim[stepCount - 1].x;
|
|
|
|
moduleY = walkAnim[stepCount - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
module16X = moduleX << 16;
|
|
|
|
module16Y = moduleY << 16;
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} while (modularPath[p].dir < NO_DIRECTIONS);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-07-30 19:25:31 +00:00
|
|
|
#ifdef _SWORD2_DEBUG
|
2003-07-28 01:44:38 +00:00
|
|
|
if (lastRealDir == 99)
|
2003-09-20 15:34:53 +00:00
|
|
|
Con_fatal_error("SlidyWalkAnimatorlast direction error (%s line %u)", __FILE__, __LINE__);
|
2003-07-28 01:44:38 +00:00
|
|
|
#endif
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SLOW OUT
|
2003-07-28 01:44:38 +00:00
|
|
|
AddSlowOutFrames(walkAnim);
|
|
|
|
|
|
|
|
// TURNS TO END THE WALK ?
|
|
|
|
|
|
|
|
// We've done the walk now put in any turns at the end
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (targetDir == 8) {
|
|
|
|
// ANY direction -> stand in the last direction
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
module = firstStandFrame + lastRealDir;
|
|
|
|
targetDir = lastRealDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastRealDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (targetDir == 9) {
|
|
|
|
// 'stance' was non-zero
|
|
|
|
if (stepCount == 0) {
|
|
|
|
module = framesPerChar + lastRealDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastRealDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} else if (targetDir != lastRealDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// rotate to target direction
|
|
|
|
turnDir = targetDir - lastRealDir;
|
|
|
|
if ( turnDir < 0)
|
2003-09-20 15:34:53 +00:00
|
|
|
turnDir += NO_DIRECTIONS;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (turnDir > 4)
|
|
|
|
turnDir = -1;
|
|
|
|
else if (turnDir > 0)
|
|
|
|
turnDir = 1;
|
|
|
|
|
|
|
|
// rotate to target direction
|
|
|
|
// for george and nico put in a head turn at the start
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (usingStandingTurnFrames) {
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0)
|
2003-09-19 15:01:49 +00:00
|
|
|
module = firstStandingTurnLeftFrame + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-19 15:01:49 +00:00
|
|
|
module = firstStandingTurnRightFrame + lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastRealDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rotate if we need to
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
while (lastRealDir != targetDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
lastRealDir += turnDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0) {
|
|
|
|
if (lastRealDir < 0)
|
2003-09-19 15:01:49 +00:00
|
|
|
lastRealDir += NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnLeftFrame + lastRealDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
if (lastRealDir > 7)
|
2003-09-19 15:01:49 +00:00
|
|
|
lastRealDir -= NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnRightFrame + lastRealDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastRealDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
module = firstStandFrame + lastRealDir;
|
|
|
|
walkAnim[stepCount - 1].frame = module;
|
|
|
|
} else {
|
|
|
|
// just stand at the end
|
|
|
|
module = firstStandFrame + lastRealDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastRealDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
#ifdef _SWORD2_DEBUG
|
|
|
|
// write all the frames to "debug.txt"
|
|
|
|
// Zdebug("\nTHE WALKDATA:");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (frame = 0; frame <= stepCount; frame++)
|
|
|
|
Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame);
|
|
|
|
#endif
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("RouteFinder RouteSize is %d", stepCount);
|
2003-07-28 01:44:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SOLID PATH ROUTINES
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 SolidPath() {
|
|
|
|
/*********************************************************************
|
|
|
|
* SolidPath creates a path based on whole steps with no sliding to
|
|
|
|
* get as near as possible to the target without any sliding this
|
|
|
|
* routine is currently unused, but is intended for use when just
|
|
|
|
* clicking about.
|
|
|
|
*
|
|
|
|
* produce a module list from the line data
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// FIXME: It says in the comment about that this function is currently
|
|
|
|
// unused, but is it really?
|
|
|
|
|
|
|
|
int32 smooth;
|
|
|
|
int32 solid;
|
|
|
|
int32 scale;
|
|
|
|
int32 stepX;
|
|
|
|
int32 stepY;
|
|
|
|
int32 deltaX;
|
|
|
|
int32 deltaY;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// strip out the short sections
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
solid = 1;
|
|
|
|
smooth = 1;
|
|
|
|
modularPath[0].x = smoothPath[0].x;
|
|
|
|
modularPath[0].y = smoothPath[0].y;
|
|
|
|
modularPath[0].dir = smoothPath[0].dir;
|
|
|
|
modularPath[0].num = 0;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
2003-07-28 01:44:38 +00:00
|
|
|
scale = scaleA * smoothPath[smooth].y + scaleB;
|
2003-09-20 15:34:53 +00:00
|
|
|
deltaX = smoothPath[smooth].x - modularPath[solid - 1].x;
|
|
|
|
deltaY = smoothPath[smooth].y - modularPath[solid - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
stepX = modX[smoothPath[smooth].dir];
|
|
|
|
stepY = modY[smoothPath[smooth].dir];
|
|
|
|
stepX = stepX * scale;
|
|
|
|
stepY = stepY * scale;
|
|
|
|
stepX = stepX >> 16;
|
|
|
|
stepY = stepY >> 16;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-09-24 06:40:23 +00:00
|
|
|
if (ABS(deltaX) >= ABS(stepX) && ABS(deltaY) >= ABS(stepY)) {
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[solid].x = smoothPath[smooth].x;
|
|
|
|
modularPath[solid].y = smoothPath[smooth].y;
|
|
|
|
modularPath[solid].dir = smoothPath[smooth].dir;
|
|
|
|
modularPath[solid].num = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
solid++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
smooth++;
|
|
|
|
} while (smoothPath[smooth].num < ROUTE_END_FLAG);
|
|
|
|
|
|
|
|
// in case the last bit had no steps
|
|
|
|
|
|
|
|
if (solid == 1) {
|
|
|
|
// there were no paths so put in a dummy end
|
|
|
|
solid = 2;
|
|
|
|
modularPath[1].dir = smoothPath[0].dir;
|
|
|
|
modularPath[1].num = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
modularPath[solid - 1].x = smoothPath[smooth - 1].x;
|
|
|
|
modularPath[solid - 1].y = smoothPath[smooth - 1].y;
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// set up the end of the walk
|
2003-09-20 15:34:53 +00:00
|
|
|
modularPath[solid].x = smoothPath[smooth - 1].x;
|
|
|
|
modularPath[solid].y = smoothPath[smooth - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[solid].dir = 9;
|
|
|
|
modularPath[solid].num = ROUTE_END_FLAG;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 SolidWalkAnimator(_walkData *walkAnim) {
|
|
|
|
/*********************************************************************
|
|
|
|
* SolidWalk creates an animation based on whole steps with no sliding
|
|
|
|
* to get as near as possible to the target without any sliding. This
|
|
|
|
* routine is is intended for use when just clicking about.
|
|
|
|
*
|
|
|
|
* produce a module list from the line data
|
|
|
|
*
|
|
|
|
* returns 0 if solid route not found
|
|
|
|
*********************************************************************/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
int32 p;
|
|
|
|
int32 i;
|
|
|
|
int32 left;
|
|
|
|
int32 lastDir;
|
|
|
|
int32 turnDir;
|
|
|
|
int32 scale;
|
|
|
|
int32 step;
|
|
|
|
int32 module;
|
|
|
|
int32 module16X;
|
|
|
|
int32 module16Y;
|
|
|
|
int32 errorX;
|
|
|
|
int32 errorY;
|
|
|
|
int32 moduleEnd;
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 slowStart = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// start at the beginning for a change
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
lastDir = modularPath[0].dir;
|
|
|
|
p = 1;
|
|
|
|
currentDir = modularPath[1].dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
module = framesPerChar + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleX = startX;
|
|
|
|
moduleY = startY;
|
|
|
|
module16X = moduleX << 16;
|
|
|
|
module16Y = moduleY << 16;
|
|
|
|
stepCount = 0;
|
|
|
|
|
|
|
|
// START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY
|
|
|
|
// BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED
|
|
|
|
|
|
|
|
//Zdebug("\nSOLID: STARTING THE WALK");
|
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// TURN TO START THE WALK
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// Zdebug("\nSOLID: TURNING TO START THE WALK");
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// rotate if we need to
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (lastDir != currentDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// get the direction to turn
|
|
|
|
turnDir = currentDir - lastDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (turnDir < 0)
|
|
|
|
turnDir += NO_DIRECTIONS;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (turnDir > 4)
|
|
|
|
turnDir = -1;
|
|
|
|
else if (turnDir > 0)
|
|
|
|
turnDir = 1;
|
|
|
|
|
|
|
|
// rotate to new walk direction
|
|
|
|
// for george and nico put in a head turn at the start
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (usingStandingTurnFrames) {
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0)
|
|
|
|
module = firstStandingTurnLeftFrame + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-20 15:34:53 +00:00
|
|
|
module = firstStandingTurnRightFrame + lastDir;
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rotate till were facing new dir then go back 45 degrees
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
while (lastDir != currentDir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
lastDir += turnDir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// new frames for turn frames 29oct95jps
|
|
|
|
if (turnDir < 0) {
|
|
|
|
if (lastDir < 0)
|
|
|
|
lastDir += NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnLeftFrame + lastDir;
|
|
|
|
} else {
|
2003-07-28 01:44:38 +00:00
|
|
|
if ( lastDir > 7)
|
2003-09-20 15:34:53 +00:00
|
|
|
lastDir -= NO_DIRECTIONS;
|
|
|
|
module = firstStandingTurnRightFrame + lastDir;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
|
|
|
walkAnim[stepCount].dir = lastDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// the back 45 degrees bit
|
2003-09-20 15:34:53 +00:00
|
|
|
// step back one because new head turn for george takes us
|
|
|
|
// past the new dir
|
|
|
|
|
|
|
|
stepCount--;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SLOW IN
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
slowStart = AddSlowInFrames(walkAnim);
|
|
|
|
|
|
|
|
// THE WALK
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("\nSOLID: THE WALK");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// start the walk on the left or right leg, depending on how the
|
|
|
|
// slow-in frames were drawn
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// (0 = left; 1 = right)
|
|
|
|
if (leadingLeg[currentDir] == 0) {
|
|
|
|
// start the walk on the left leg (ie. at beginning of the
|
|
|
|
// first step of the walk cycle)
|
|
|
|
left = 0;
|
|
|
|
} else {
|
|
|
|
// start the walk on the right leg (ie. at beginning of the
|
|
|
|
// second step of the walk cycle)
|
|
|
|
left = framesPerStep;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
lastCount = stepCount;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// this ensures that we don't put in turn frames for the start
|
|
|
|
lastDir = 99;
|
|
|
|
|
|
|
|
// this ensures that we don't put in turn frames for the start
|
|
|
|
currentDir = 99;
|
|
|
|
|
|
|
|
do {
|
|
|
|
while(modularPath[p].num > 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
currentDir = modularPath[p].dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
if (currentDir< NO_DIRECTIONS) {
|
|
|
|
module = currentDir * framesPerStep * 2 + left;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (left == 0)
|
|
|
|
left = framesPerStep;
|
|
|
|
else
|
|
|
|
left = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleEnd = module + framesPerStep;
|
|
|
|
step = 0;
|
|
|
|
scale = (scaleA * moduleY + scaleB);
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
module16X += dx[module] * scale;
|
|
|
|
module16Y += dy[module] * scale;
|
2003-07-28 01:44:38 +00:00
|
|
|
moduleX = module16X >> 16;
|
|
|
|
moduleY = module16Y >> 16;
|
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = step; // normally 0,1,2,3,4,5,0,1,2,etc
|
|
|
|
walkAnim[stepCount].dir = currentDir;
|
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
|
|
|
module++;
|
|
|
|
step++;
|
|
|
|
} while( module < moduleEnd);
|
|
|
|
|
|
|
|
errorX = modularPath[p].x - moduleX;
|
2003-07-28 01:44:38 +00:00
|
|
|
errorX = errorX * modX[modularPath[p].dir];
|
2003-09-20 15:34:53 +00:00
|
|
|
errorY = modularPath[p].y - moduleY;
|
2003-07-28 01:44:38 +00:00
|
|
|
errorY = errorY * modY[modularPath[p].dir];
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (errorX < 0 || errorY < 0) {
|
2003-07-28 01:44:38 +00:00
|
|
|
modularPath[p].num = 0;
|
|
|
|
stepCount -= framesPerStep;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (left == 0)
|
|
|
|
left = framesPerStep;
|
|
|
|
else
|
|
|
|
left = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// Okay this is the end of a section
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
moduleX = walkAnim[stepCount - 1].x;
|
|
|
|
moduleY = walkAnim[stepCount - 1].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
module16X = moduleX << 16;
|
|
|
|
module16Y = moduleY << 16;
|
|
|
|
modularPath[p].x =moduleX;
|
|
|
|
modularPath[p].y =moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// Now is the time to put in the turn
|
|
|
|
// frames for the last turn
|
|
|
|
|
|
|
|
if (stepCount - lastCount < framesPerStep) {
|
|
|
|
// no step taken
|
|
|
|
|
|
|
|
// clean up if a slow in but no
|
|
|
|
// walk
|
|
|
|
|
|
|
|
if (slowStart == 1) {
|
2003-07-28 01:44:38 +00:00
|
|
|
stepCount -= numberOfSlowInFrames[currentDir]; // (James08sep97)
|
|
|
|
lastCount -= numberOfSlowInFrames[currentDir]; // (James08sep97)
|
|
|
|
slowStart = 0;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// this ensures that we don't
|
|
|
|
// put in turn frames for this
|
|
|
|
// walk or the next
|
|
|
|
|
|
|
|
currentDir = 99;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// check each turn condition in turn
|
2003-09-20 15:34:53 +00:00
|
|
|
if (lastDir != 99 && currentDir != 99 && usingWalkingTurnFrames) {
|
|
|
|
// only for george
|
|
|
|
// 1 and -7 going right -1 and
|
|
|
|
// 7 going left
|
|
|
|
|
|
|
|
lastDir = currentDir - lastDir;
|
|
|
|
|
|
|
|
if (lastDir == -1 || lastDir == 7 || lastDir == -2 || lastDir == 6) {
|
|
|
|
// turn at the end of
|
|
|
|
// the last walk
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frame = lastCount - framesPerStep;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
// turning left
|
|
|
|
walkAnim[frame].frame += firstWalkingTurnLeftFrame;
|
|
|
|
frame++;
|
|
|
|
} while (frame < lastCount);
|
|
|
|
} else if (lastDir == 1 || lastDir == -7 || lastDir == 2 || lastDir == -6) {
|
|
|
|
// turn at the end of
|
|
|
|
// the current walk
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frame = lastCount - framesPerStep;
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
// turning right
|
|
|
|
walkAnim[frame].frame += firstWalkingTurnRightFrame;
|
|
|
|
frame++;
|
|
|
|
} while (frame < lastCount);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// all turns checked
|
|
|
|
lastCount = stepCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
p++;
|
2003-07-28 01:44:38 +00:00
|
|
|
lastDir = currentDir;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// can only be valid first time round
|
|
|
|
slowStart = 0;
|
|
|
|
} while (modularPath[p].dir < NO_DIRECTIONS);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SLOW OUT
|
|
|
|
|
|
|
|
AddSlowOutFrames(walkAnim);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
module = framesPerChar + modularPath[p - 1].dir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].frame = module;
|
|
|
|
walkAnim[stepCount].step = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].dir = modularPath[p - 1].dir;
|
2003-07-28 01:44:38 +00:00
|
|
|
walkAnim[stepCount].x = moduleX;
|
|
|
|
walkAnim[stepCount].y = moduleY;
|
2003-09-20 15:34:53 +00:00
|
|
|
stepCount++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
|
|
|
stepCount++;
|
|
|
|
|
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
|
|
|
stepCount++;
|
|
|
|
|
|
|
|
walkAnim[stepCount].frame = 512;
|
|
|
|
walkAnim[stepCount].step = 99;
|
|
|
|
|
|
|
|
#ifdef _SWORD2_DEBUG
|
|
|
|
// write all the frames to "debug.txt"
|
2003-07-28 01:44:38 +00:00
|
|
|
//Zdebug("\nTHE WALKDATA:");
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (frame = 0; frame <= stepCount; frame++)
|
|
|
|
Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame);
|
|
|
|
#endif
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// NO END TURNS
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Zdebug("RouteFinder RouteSize is %d", stepCount);
|
|
|
|
// now check the route
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (!Check(modularPath[i].x, modularPath[i].y, modularPath[i + 1].x, modularPath[i + 1].y))
|
|
|
|
p = 0;
|
|
|
|
i++;
|
|
|
|
} while (i < p - 1);
|
|
|
|
|
|
|
|
if (p != 0) {
|
|
|
|
targetDir = modularPath[p - 1].dir;
|
|
|
|
if (CheckTarget(moduleX, moduleY) == 3) {
|
|
|
|
// new target on a line
|
|
|
|
p = 0;
|
|
|
|
// Zdebug("Solid walk target was on a line %d %d", moduleX, moduleY);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SCAN ROUTINES
|
|
|
|
|
|
|
|
int32 Scan(int32 level) {
|
|
|
|
/*********************************************************************
|
|
|
|
* Called successively from RouteFinder until no more changes take
|
|
|
|
* place in the grid array, ie he best path has been found
|
|
|
|
*
|
|
|
|
* Scans through every point in the node array and checks if there is
|
|
|
|
* a route between each point and if this route gives a new route.
|
|
|
|
*
|
|
|
|
* This routine could probably halve its processing time if it doubled
|
|
|
|
* up on the checks after each route check
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 i;
|
|
|
|
int32 k;
|
|
|
|
int32 x1;
|
|
|
|
int32 y1;
|
|
|
|
int32 x2;
|
|
|
|
int32 y2;
|
|
|
|
int32 distance;
|
|
|
|
int32 changed = 0;
|
|
|
|
|
|
|
|
// For all the nodes that have new values and a distance less than
|
|
|
|
// enddist, ie dont check for new routes from a point we checked
|
|
|
|
// before or from a point that is already further away than the best
|
|
|
|
// route so far.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
i = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (node[i].dist < node[nnodes].dist && node[i].level == level) {
|
2003-07-28 01:44:38 +00:00
|
|
|
x1 = node[i].x;
|
|
|
|
y1 = node[i].y;
|
2003-09-20 15:34:53 +00:00
|
|
|
k = nnodes;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (node[k].dist > node[i].dist) {
|
2003-07-28 01:44:38 +00:00
|
|
|
x2 = node[k].x;
|
|
|
|
y2 = node[k].y;
|
|
|
|
|
2003-09-24 06:40:23 +00:00
|
|
|
if (ABS(x2 - x1) > 4.5 * ABS(y2-y1))
|
|
|
|
distance = (8 * ABS(x2 - x1) + 18 * ABS(y2 - y1)) / (54 * 8) + 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-09-24 06:40:23 +00:00
|
|
|
distance = (6 * ABS(x2 - x1) + 36 * ABS(y2 - y1)) / (36 * 14) + 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (distance + node[i].dist < node[nnodes].dist && distance + node[i].dist < node[k].dist) {
|
|
|
|
if (NewCheck(0, x1, y1, x2, y2)) {
|
2003-07-28 01:44:38 +00:00
|
|
|
node[k].level = level + 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
node[k].dist = distance + node[i].dist;
|
|
|
|
node[k].prev = i;
|
2003-07-28 01:44:38 +00:00
|
|
|
changed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
k--;
|
|
|
|
} while (k > 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
i++;
|
|
|
|
} while (i < nnodes);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 NewCheck(int32 status, int32 x1, int32 y1, int32 x2, int32 y2) {
|
|
|
|
/*********************************************************************
|
|
|
|
* NewCheck routine checks if the route between two points can be
|
|
|
|
* achieved without crossing any of the bars in the Bars array.
|
|
|
|
*
|
|
|
|
* NewCheck differs from check in that that 4 route options are
|
|
|
|
* considered corresponding to actual walked routes.
|
|
|
|
*
|
|
|
|
* Note distance doesnt take account of shrinking ???
|
|
|
|
*
|
|
|
|
* Note Bars array must be properly calculated ie min max dx dy co
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
int32 ldx;
|
|
|
|
int32 ldy;
|
|
|
|
int32 dlx;
|
|
|
|
int32 dly;
|
|
|
|
int32 dirX;
|
|
|
|
int32 dirY;
|
|
|
|
int32 step1;
|
|
|
|
int32 step2;
|
|
|
|
int32 step3;
|
|
|
|
int32 steps;
|
|
|
|
int32 options;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
steps = 0;
|
|
|
|
options = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
ldx = x2 - x1;
|
|
|
|
ldy = y2 - y1;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirX = 1;
|
|
|
|
dirY = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (ldx < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = -ldx;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirX = -1;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (ldy < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldy = -ldy;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirY = -1;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// make the route options
|
|
|
|
|
|
|
|
if (diagonaly * ldx > diagonalx * ldy) {
|
|
|
|
// dir = 1,2 or 2,3 or 5,6 or 6,7
|
|
|
|
|
|
|
|
dly = ldy;
|
|
|
|
dlx = (ldy * diagonalx) / diagonaly;
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = ldx - dlx;
|
2003-07-28 01:44:38 +00:00
|
|
|
dlx = dlx * dirX;
|
|
|
|
dly = dly * dirY;
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = ldx * dirX;
|
|
|
|
ldy = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
//options are
|
|
|
|
//square, diagonal a code 1 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
step1 = Check(x1, y1, x1 + ldx, y1);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1 + ldx, y1, x2, y2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
steps = step1 + step2;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 2;
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//diagonal, square a code 2 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x1 + dlx, y1 + dly);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1 + dlx, y2, x2, y2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
steps = step1 + step2;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//halfsquare, diagonal, halfsquare a code 0 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x1 + ldx / 2, y1);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1 + ldx / 2, y1, x1 + ldx / 2 + dlx, y2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
step3 = Check(x1 + ldx / 2 + dlx, y2, x2, y2);
|
|
|
|
if (step3 != 0) {
|
|
|
|
steps = step1 + step2 + step3;
|
|
|
|
options++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//halfdiagonal, square, halfdiagonal a code 3 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x1 + dlx / 2, y1 + dly / 2);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1 + dlx / 2, y1 + dly / 2, x1 + ldx + dlx / 2, y1 + dly / 2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
step3 = Check(x1 + ldx + dlx / 2, y1 + dly / 2, x2, y2);
|
|
|
|
if (step3 != 0) {
|
|
|
|
steps = step1 + step2 + step3;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
// dir = 7,0 or 0,1 or 3,4 or 4,5
|
|
|
|
|
|
|
|
dlx = ldx;
|
|
|
|
dly = (ldx * diagonaly) / diagonalx;
|
2003-07-28 12:24:13 +00:00
|
|
|
ldy = ldy - dly;
|
2003-07-28 01:44:38 +00:00
|
|
|
dlx = dlx * dirX;
|
|
|
|
dly = dly * dirY;
|
2003-07-28 12:24:13 +00:00
|
|
|
ldy = ldy * dirY;
|
|
|
|
ldx = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
//options are
|
|
|
|
//square, diagonal a code 1 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
step1 = Check(x1 ,y1, x1, y1 + ldy);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1, y1 + ldy, x2, y2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
steps = step1 + step2;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 2;
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//diagonal, square a code 2 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x2, y1 + dly);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x2, y1 + dly, x2, y2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
steps = step1 + step2;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//halfsquare, diagonal, halfsquare a code 0 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x1, y1 + ldy / 2);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1, y1 + ldy / 2, x2, y1 + ldy / 2 + dly);
|
|
|
|
if (step2 != 0) {
|
|
|
|
step3 = Check(x2, y1 + ldy / 2 + dly, x2, y2);
|
|
|
|
if (step3 != 0) {
|
|
|
|
steps = step1 + step2 + step3;
|
|
|
|
options++;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
//halfdiagonal, square, halfdiagonal a code 3 route
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (steps == 0 || status == 1) {
|
|
|
|
step1 = Check(x1, y1, x1 + dlx / 2, y1 + dly / 2);
|
|
|
|
if (step1 != 0) {
|
|
|
|
step2 = Check(x1 + dlx / 2, y1 + dly / 2, x1 + dlx / 2, y1 + ldy + dly / 2);
|
|
|
|
if (step2 != 0) {
|
|
|
|
step3 = Check(x1 + dlx / 2, y1 + ldy + dly / 2, x2, y2);
|
|
|
|
if (step3 != 0) {
|
|
|
|
steps = step1 + step2 + step3;
|
2003-07-28 01:44:38 +00:00
|
|
|
options = options + 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
if (status == 0)
|
|
|
|
status = steps;
|
|
|
|
else
|
|
|
|
status = options;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// CHECK ROUTINES
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 Check(int32 x1, int32 y1, int32 x2, int32 y2) {
|
|
|
|
// call the fastest line check for the given line
|
|
|
|
// returns 1 if line didn't cross any bars
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (x1 == x2 && y1 == y2)
|
|
|
|
return 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (x1 == x2)
|
|
|
|
return VertCheck(x1, y1, y2);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (y1 == y2)
|
|
|
|
return HorizCheck(x1, y1, x2);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return LineCheck(x1, y1, x2, y2);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 LineCheck(int32 x1, int32 y1, int32 x2, int32 y2) {
|
|
|
|
int32 dirx;
|
|
|
|
int32 diry;
|
|
|
|
int32 co;
|
|
|
|
int32 slope;
|
|
|
|
int32 i;
|
|
|
|
int32 xc;
|
|
|
|
int32 yc;
|
|
|
|
int32 xmin;
|
|
|
|
int32 ymin;
|
|
|
|
int32 xmax;
|
|
|
|
int32 ymax;
|
|
|
|
int32 linesCrossed = 1;
|
|
|
|
|
|
|
|
if (x1 > x2) {
|
|
|
|
xmin = x2;
|
|
|
|
xmax = x1;
|
|
|
|
} else {
|
|
|
|
xmin = x1;
|
|
|
|
xmax = x2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y1 > y2) {
|
|
|
|
ymin = y2;
|
|
|
|
ymax = y1;
|
|
|
|
} else {
|
|
|
|
ymin = y1;
|
|
|
|
ymax = y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// line set to go one step in chosen direction
|
|
|
|
// so ignore if it hits anything
|
|
|
|
|
|
|
|
dirx = x2 - x1;
|
2003-07-28 01:44:38 +00:00
|
|
|
diry = y2 - y1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
co = (y1 * dirx)- (x1 * diry); // new line equation
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
// skip if not on module
|
|
|
|
if (xmax >= bars[i].xmin && xmin <= bars[i].xmax) {
|
|
|
|
// skip if not on module
|
|
|
|
if (ymax >= bars[i].ymin && ymin <= bars[i].ymax) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// okay its a valid line calculate an intersept
|
2003-09-20 15:34:53 +00:00
|
|
|
// wow but all this arithmatic we must have
|
|
|
|
// loads of time
|
|
|
|
|
|
|
|
// slope it he slope between the two lines
|
|
|
|
slope = (bars[i].dx * diry) - (bars[i].dy *dirx);
|
|
|
|
// assuming parallel lines don't cross
|
|
|
|
if (slope != 0) {
|
|
|
|
// calculate x intercept and check its
|
|
|
|
// on both lines
|
|
|
|
xc = ((bars[i].co * dirx) - (co * bars[i].dx)) / slope;
|
|
|
|
|
|
|
|
// skip if not on module
|
|
|
|
if (xc >= xmin - 1 && xc <= xmax + 1) {
|
|
|
|
// skip if not on line
|
|
|
|
if (xc >= bars[i].xmin - 1 && xc <= bars[i].xmax + 1) {
|
|
|
|
yc = ((bars[i].co * diry) - (co * bars[i].dy)) / slope;
|
|
|
|
|
|
|
|
// skip if not on module
|
|
|
|
if (yc >= ymin - 1 && yc <= ymax + 1) {
|
|
|
|
// skip if not on line
|
|
|
|
if (yc >= bars[i].ymin - 1 && yc <= bars[i].ymax + 1) {
|
|
|
|
linesCrossed = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
i++;
|
|
|
|
} while(i < nbars && linesCrossed);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return linesCrossed;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 HorizCheck(int32 x1, int32 y, int32 x2) {
|
|
|
|
int32 ldy;
|
|
|
|
int32 i;
|
|
|
|
int32 xc;
|
|
|
|
int32 xmin;
|
|
|
|
int32 xmax;
|
|
|
|
int32 linesCrossed = 1;
|
|
|
|
|
|
|
|
if (x1 > x2) {
|
|
|
|
xmin = x2;
|
|
|
|
xmax = x1;
|
|
|
|
} else {
|
|
|
|
xmin = x1;
|
|
|
|
xmax = x2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// line set to go one step in chosen direction
|
|
|
|
// so ignore if it hits anything
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
// skip if not on module
|
|
|
|
if (xmax >= bars[i].xmin && xmin <= bars[i].xmax) {
|
|
|
|
// skip if not on module
|
|
|
|
if (y >= bars[i].ymin && y <= bars[i].ymax) {
|
|
|
|
// okay its a valid line calculate an intercept
|
|
|
|
// wow but all this arithmatic we must have
|
|
|
|
// loads of time
|
|
|
|
|
|
|
|
if (bars[i].dy == 0)
|
|
|
|
linesCrossed = 0;
|
|
|
|
else {
|
|
|
|
ldy = y - bars[i].y1;
|
|
|
|
xc = bars[i].x1 + (bars[i].dx * ldy) / bars[i].dy;
|
|
|
|
// skip if not on module
|
|
|
|
if (xc >= xmin - 1 && xc <= xmax + 1)
|
|
|
|
linesCrossed = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
i++;
|
|
|
|
} while(i < nbars && linesCrossed);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return linesCrossed;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 VertCheck(int32 x, int32 y1, int32 y2) {
|
|
|
|
int32 ldx;
|
|
|
|
int32 i;
|
|
|
|
int32 yc;
|
|
|
|
int32 ymin;
|
|
|
|
int32 ymax;
|
|
|
|
int32 linesCrossed = 1;
|
|
|
|
|
|
|
|
if (y1 > y2) {
|
|
|
|
ymin = y2;
|
|
|
|
ymax = y1;
|
|
|
|
} else {
|
|
|
|
ymin = y1;
|
|
|
|
ymax = y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// line set to go one step in chosen direction
|
|
|
|
// so ignore if it hits anything
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (x >= bars[i].xmin && x <= bars[i].xmax) {
|
|
|
|
// overlapping
|
|
|
|
// skip if not on module
|
|
|
|
if (ymax >= bars[i].ymin && ymin <= bars[i].ymax) {
|
|
|
|
// okay its a valid line calculate an intercept
|
|
|
|
// wow but all this arithmatic we must have
|
|
|
|
// loads of time
|
|
|
|
|
|
|
|
// both lines vertical and overlap in x and y
|
|
|
|
// so they cross
|
|
|
|
|
|
|
|
if (bars[i].dx == 0)
|
|
|
|
linesCrossed = 0;
|
|
|
|
else {
|
|
|
|
ldx = x - bars[i].x1;
|
|
|
|
yc = bars[i].y1 + (bars[i].dy * ldx) / bars[i].dx;
|
|
|
|
// the intercept overlaps
|
|
|
|
if (yc >= ymin - 1 && yc <= ymax + 1)
|
|
|
|
linesCrossed = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while(i < nbars && linesCrossed);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return linesCrossed;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 CheckTarget(int32 x, int32 y) {
|
|
|
|
int32 ldx;
|
|
|
|
int32 ldy;
|
|
|
|
int32 i;
|
|
|
|
int32 xc;
|
|
|
|
int32 yc;
|
|
|
|
int32 xmin;
|
|
|
|
int32 xmax;
|
|
|
|
int32 ymin;
|
|
|
|
int32 ymax;
|
|
|
|
int32 onLine = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
xmin = x - 1;
|
|
|
|
xmax = x + 1;
|
|
|
|
ymin = y - 1;
|
|
|
|
ymax = y + 1;
|
|
|
|
|
|
|
|
// check if point +- 1 is on the line
|
2003-09-20 15:34:53 +00:00
|
|
|
//so ignore if it hits anything
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
i = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
do {
|
|
|
|
// overlapping line
|
|
|
|
if (xmax >= bars[i].xmin && xmin <= bars[i].xmax) {
|
|
|
|
//overlapping line
|
|
|
|
if (ymax >= bars[i].ymin && ymin <= bars[i].ymax) {
|
|
|
|
// okay this line overlaps the target calculate
|
|
|
|
// an y intercept for x
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// vertical line so we know it overlaps y
|
|
|
|
if (bars[i].dx == 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
yc = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
else {
|
|
|
|
ldx = x - bars[i].x1;
|
|
|
|
yc = bars[i].y1 + (bars[i].dy * ldx) / bars[i].dx;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// overlapping point for y
|
|
|
|
if (yc >= ymin && yc <= ymax) {
|
|
|
|
// target on a line so drop out
|
|
|
|
onLine = 3;
|
|
|
|
// Zdebug("RouteFail due to target on a line %d %d", x, y);
|
|
|
|
} else {
|
|
|
|
// vertical line so we know it overlaps y
|
|
|
|
if (bars[i].dy == 0)
|
2003-07-28 01:44:38 +00:00
|
|
|
xc = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
else {
|
|
|
|
ldy = y - bars[i].y1;
|
|
|
|
xc = bars[i].x1 + (bars[i].dx * ldy) / bars[i].dy;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// skip if not on module
|
|
|
|
if (xc >= xmin && xc <= xmax) {
|
|
|
|
// target on a line so drop out
|
|
|
|
onLine = 3;
|
|
|
|
// Zdebug("RouteFail due to target on a line %d %d", x, y);
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while(i < nbars && onLine == 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
return onLine;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE SETUP ROUTINES
|
|
|
|
|
|
|
|
void LoadWalkData(Object_walkdata *ob_walkdata) {
|
|
|
|
uint8 direction;
|
|
|
|
uint16 firstFrameOfDirection;
|
|
|
|
uint16 walkFrameNo;
|
|
|
|
uint32 frameCounter = 0; // starts at frame 0 of mega set (16sep96 JEL)
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
nWalkFrames = ob_walkdata->nWalkFrames;
|
|
|
|
usingStandingTurnFrames = ob_walkdata->usingStandingTurnFrames;
|
|
|
|
usingWalkingTurnFrames = ob_walkdata->usingWalkingTurnFrames;
|
|
|
|
usingSlowInFrames = ob_walkdata->usingSlowInFrames;
|
|
|
|
usingSlowOutFrames = ob_walkdata->usingSlowOutFrames;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// 0 = not using slow out frames; non-zero = using that many frames
|
|
|
|
// for each leading leg for each direction
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
numberOfSlowOutFrames = usingSlowOutFrames;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
memcpy(&numberOfSlowInFrames[0], ob_walkdata->nSlowInFrames, NO_DIRECTIONS * sizeof(numberOfSlowInFrames[0]));
|
|
|
|
memcpy(&leadingLeg[0], ob_walkdata->leadingLeg, NO_DIRECTIONS * sizeof(leadingLeg[0]));
|
|
|
|
memcpy(&dx[0], ob_walkdata->dx, NO_DIRECTIONS * (nWalkFrames + 1) * sizeof(dx[0]));
|
|
|
|
memcpy(&dy[0], ob_walkdata->dy, NO_DIRECTIONS * (nWalkFrames + 1) * sizeof(dy[0]));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (direction=0; direction < NO_DIRECTIONS; direction++) {
|
2003-07-28 01:44:38 +00:00
|
|
|
firstFrameOfDirection = direction * nWalkFrames;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
modX[direction] = 0;
|
|
|
|
modY[direction] = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (walkFrameNo = firstFrameOfDirection; walkFrameNo < firstFrameOfDirection + nWalkFrames / 2; walkFrameNo++) {
|
|
|
|
// eg. modX[0] is the sum of the x-step sizes for the
|
|
|
|
// first half of the walk cycle for direction 0
|
|
|
|
modX[direction] += dx[walkFrameNo];
|
2003-07-28 01:44:38 +00:00
|
|
|
modY[direction] += dy[walkFrameNo];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
diagonalx = modX[3];
|
|
|
|
diagonaly = modY[3];
|
|
|
|
|
|
|
|
// interpret the walk data
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
framesPerStep = nWalkFrames / 2;
|
2003-07-28 01:44:38 +00:00
|
|
|
framesPerChar = nWalkFrames * NO_DIRECTIONS;
|
|
|
|
|
|
|
|
// offset pointers added Oct 30 95 JPS
|
|
|
|
// mega id references removed 16sep96 by JEL
|
|
|
|
|
|
|
|
// WALK FRAMES
|
|
|
|
// start on frame 0
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
frameCounter += framesPerChar;
|
|
|
|
|
|
|
|
// STAND FRAMES
|
2003-09-20 15:34:53 +00:00
|
|
|
// stand frames come after the walk frames
|
|
|
|
// one stand frame for each direction
|
|
|
|
|
|
|
|
firstStandFrame = frameCounter;
|
|
|
|
frameCounter += NO_DIRECTIONS;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// STANDING TURN FRAMES - OPTIONAL!
|
2003-09-20 15:34:53 +00:00
|
|
|
// standing turn-left frames come after the slow-out frames
|
|
|
|
// one for each direction
|
|
|
|
// standing turn-left frames come after the standing turn-right frames
|
|
|
|
// one for each direction
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (usingStandingTurnFrames) {
|
|
|
|
firstStandingTurnLeftFrame = frameCounter;
|
|
|
|
frameCounter += NO_DIRECTIONS;
|
|
|
|
|
|
|
|
firstStandingTurnRightFrame = frameCounter;
|
|
|
|
frameCounter += NO_DIRECTIONS;
|
|
|
|
} else {
|
|
|
|
// refer instead to the normal stand frames
|
|
|
|
firstStandingTurnLeftFrame = firstStandFrame;
|
|
|
|
firstStandingTurnRightFrame = firstStandFrame;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// WALKING TURN FRAMES - OPTIONAL!
|
2003-09-20 15:34:53 +00:00
|
|
|
// walking left-turn frames come after the stand frames
|
|
|
|
// walking right-turn frames come after the walking left-turn frames
|
|
|
|
|
|
|
|
if (usingWalkingTurnFrames) {
|
|
|
|
firstWalkingTurnLeftFrame = frameCounter;
|
2003-07-28 01:44:38 +00:00
|
|
|
frameCounter += framesPerChar;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
firstWalkingTurnRightFrame = frameCounter;
|
2003-07-28 01:44:38 +00:00
|
|
|
frameCounter += framesPerChar;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
firstWalkingTurnLeftFrame = 0;
|
|
|
|
firstWalkingTurnRightFrame = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// SLOW-IN FRAMES - OPTIONAL!
|
2003-09-20 15:34:53 +00:00
|
|
|
// slow-in frames come after the walking right-turn frames
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (usingSlowInFrames) {
|
|
|
|
// Make note of frame number of first slow-in frame for each
|
|
|
|
// direction. There may be a different number of slow-in
|
|
|
|
// frames in each direction
|
|
|
|
|
|
|
|
for (direction = 0; direction < NO_DIRECTIONS; direction++) {
|
|
|
|
firstSlowInFrame[direction] = frameCounter;
|
|
|
|
frameCounter += numberOfSlowInFrames[direction];
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// SLOW-OUT FRAMES - OPTIONAL!
|
2003-09-20 15:34:53 +00:00
|
|
|
// slow-out frames come after the slow-in frames
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
if (usingSlowOutFrames)
|
2003-09-20 15:34:53 +00:00
|
|
|
firstSlowOutFrame = frameCounter;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// THE ROUTE EXTRACTOR
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void ExtractRoute() {
|
|
|
|
/*********************************************************************
|
|
|
|
* ExtractRoute gets route from the node data after a full scan, route
|
|
|
|
* is written with just the basic way points and direction options for
|
|
|
|
* heading to the next point.
|
|
|
|
*********************************************************************/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 prev;
|
|
|
|
int32 prevx;
|
|
|
|
int32 prevy;
|
|
|
|
int32 last;
|
|
|
|
int32 point;
|
2003-09-19 15:01:49 +00:00
|
|
|
int32 p;
|
2003-09-20 15:34:53 +00:00
|
|
|
int32 dirx;
|
|
|
|
int32 diry;
|
|
|
|
int32 dir;
|
|
|
|
int32 ldx;
|
|
|
|
int32 ldy;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// extract the route from the node data
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
prev = nnodes;
|
|
|
|
last = prev;
|
|
|
|
point = O_ROUTE_SIZE - 1;
|
|
|
|
route[point].x = node[last].x;
|
|
|
|
route[point].y = node[last].y;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
point--;
|
2003-07-28 01:44:38 +00:00
|
|
|
prev = node[last].prev;
|
|
|
|
prevx = node[prev].x;
|
|
|
|
prevy = node[prev].y;
|
|
|
|
route[point].x = prevx;
|
|
|
|
route[point].y = prevy;
|
|
|
|
last = prev;
|
2003-09-20 15:34:53 +00:00
|
|
|
} while (prev > 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// now shuffle route down in the buffer
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
routeLength = 0;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
do {
|
2003-07-28 01:44:38 +00:00
|
|
|
route[routeLength].x = route[point].x;
|
|
|
|
route[routeLength].y = route[point].y;
|
2003-09-20 15:34:53 +00:00
|
|
|
point++;
|
|
|
|
routeLength++;
|
|
|
|
} while (point < O_ROUTE_SIZE);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
routeLength = routeLength - 1;
|
|
|
|
|
|
|
|
// okay the route exists as a series point now put in some directions
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
p = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
ldx = route[p + 1].x - route[p].x;
|
|
|
|
ldy = route[p + 1].y - route[p].y;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirx = 1;
|
|
|
|
diry = 1;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (ldx < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldx = -ldx;
|
2003-07-28 01:44:38 +00:00
|
|
|
dirx = -1;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (ldy < 0) {
|
2003-07-28 12:24:13 +00:00
|
|
|
ldy = -ldy;
|
2003-07-28 01:44:38 +00:00
|
|
|
diry = -1;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
if (diagonaly * ldx > diagonalx * ldy) {
|
|
|
|
// dir = 1,2 or 2,3 or 5,6 or 6,7
|
|
|
|
|
|
|
|
// 2 or 6
|
|
|
|
dir = 4 - 2 * dirx;
|
2003-07-28 01:44:38 +00:00
|
|
|
route[p].dirS = dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// 1, 3, 5 or 7
|
|
|
|
dir = dir + diry * dirx;
|
2003-07-28 01:44:38 +00:00
|
|
|
route[p].dirD = dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
} else {
|
|
|
|
// dir = 7,0 or 0,1 or 3,4 or 4,5
|
|
|
|
|
|
|
|
// 0 or 4
|
|
|
|
dir = 2 + 2 * diry;
|
2003-07-28 01:44:38 +00:00
|
|
|
route[p].dirS = dir;
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
// 2 or 6
|
|
|
|
dir = 4 - 2 * dirx;
|
|
|
|
|
|
|
|
// 1, 3, 5 or 7
|
|
|
|
dir = dir + diry * dirx;
|
2003-07-28 01:44:38 +00:00
|
|
|
route[p].dirD = dir;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
p++;
|
|
|
|
} while (p < routeLength);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// set the last dir to continue previous route unless specified
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
if (targetDir == 8) {
|
|
|
|
// ANY direction
|
|
|
|
route[p].dirS = route[p - 1].dirS;
|
|
|
|
route[p].dirD = route[p - 1].dirD;
|
|
|
|
} else {
|
2003-07-28 01:44:38 +00:00
|
|
|
route[p].dirS = targetDir;
|
|
|
|
route[p].dirD = targetDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void SetUpWalkGrid(Object_mega *ob_mega, int32 x, int32 y, int32 dir) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 i;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// get walk grid file + extra grid into 'bars' & 'node' arrays
|
|
|
|
LoadWalkGrid();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// copy the mega structure into the local variables for use in all
|
|
|
|
// subroutines
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
startX = ob_mega->feet_x;
|
|
|
|
startY = ob_mega->feet_y;
|
|
|
|
startDir = ob_mega->current_dir;
|
|
|
|
targetX = x;
|
|
|
|
targetY = y;
|
|
|
|
targetDir = dir;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
scaleA = ob_mega->scale_a;
|
|
|
|
scaleB = ob_mega->scale_b;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// mega's current position goes into first node
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
node[0].x = startX;
|
|
|
|
node[0].y = startY;
|
|
|
|
node[0].level = 1;
|
|
|
|
node[0].prev = 0;
|
|
|
|
node[0].dist = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// reset other nodes
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
for (i = 1; i < nnodes; i++) {
|
|
|
|
node[i].level = 0;
|
|
|
|
node[i].prev = 0;
|
|
|
|
node[i].dist = 9999;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// target position goes into final node
|
2003-09-20 15:34:53 +00:00
|
|
|
node[nnodes].x = targetX;
|
|
|
|
node[nnodes].y = targetY;
|
|
|
|
node[nnodes].level = 0;
|
|
|
|
node[nnodes].prev = 0;
|
|
|
|
node[nnodes].dist = 9999;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void PlotWalkGrid(void) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 j;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// get walk grid file + extra grid into 'bars' & 'node' arrays
|
|
|
|
LoadWalkGrid();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// lines
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
for (j = 0; j < nbars; j++)
|
|
|
|
DrawLine(bars[j].x1, bars[j].y1, bars[j].x2, bars[j].y2, 254);
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// nodes
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// leave node 0 for start node
|
|
|
|
for (j = 1; j < nnodes; j++)
|
|
|
|
PlotCross(node[j].x, node[j].y, 184);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void PlotCross(int16 x, int16 y, uint8 colour) {
|
|
|
|
DrawLine(x - 1, y - 1, x + 1, y + 1, colour);
|
|
|
|
DrawLine(x + 1, y - 1, x - 1, y + 1, colour);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void LoadWalkGrid(void) {
|
|
|
|
_walkGridHeader floorHeader;
|
|
|
|
uint32 j;
|
|
|
|
uint8 *fPolygrid;
|
2003-07-28 01:44:38 +00:00
|
|
|
int entry;
|
|
|
|
uint32 theseBars;
|
|
|
|
uint32 theseNodes;
|
|
|
|
|
|
|
|
nbars = 0; // reset counts
|
|
|
|
nnodes = 1; // leave node 0 for start-node
|
|
|
|
|
|
|
|
// STATIC GRIDS (added/removed by object logics)
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// go through walkgrid list
|
|
|
|
for (entry = 0; entry < MAX_WALKGRIDS; entry++) {
|
|
|
|
if (walkGridList[entry]) {
|
|
|
|
// open walk grid file
|
|
|
|
fPolygrid = res_man.Res_open(walkGridList[entry]);
|
2003-07-28 01:44:38 +00:00
|
|
|
fPolygrid += sizeof(_standardHeader);
|
2003-09-20 15:34:53 +00:00
|
|
|
memmove((uint8 *) &floorHeader, fPolygrid, sizeof(_walkGridHeader));
|
2003-07-28 01:44:38 +00:00
|
|
|
fPolygrid += sizeof(_walkGridHeader);
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// how many bars & nodes are we getting from this
|
|
|
|
// walkgrid file
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
theseBars = floorHeader.numBars;
|
|
|
|
theseNodes = floorHeader.numNodes;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
#ifdef _SWORD2_DEBUG
|
|
|
|
// check that we're not going to exceed the max
|
|
|
|
// allowed in the complete walkgrid arrays
|
|
|
|
|
|
|
|
if (nbars + theseBars >= O_GRID_SIZE)
|
|
|
|
Con_fatal_error("Adding walkgrid(%d): %d+%d bars exceeds max %d (%s line %u)",
|
|
|
|
walkGridList[entry], nbars, theseBars,
|
|
|
|
O_GRID_SIZE, __FILE__, __LINE__);
|
|
|
|
|
|
|
|
if (nnodes + theseNodes >= O_GRID_SIZE)
|
|
|
|
Con_fatal_error("Adding walkgrid(%d): %d+%d nodes exceeds max %d (%s line %u)",
|
|
|
|
walkGridList[entry], nnodes, theseBars,
|
|
|
|
O_GRID_SIZE, __FILE__, __LINE__);
|
|
|
|
#endif
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// lines
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
memmove((uint8 *) &bars[nbars], fPolygrid, theseBars * sizeof(_barData));
|
|
|
|
|
|
|
|
//move pointer to start of node data
|
|
|
|
fPolygrid += theseBars * sizeof(_barData);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// nodes
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// leave node 0 for start node
|
|
|
|
for (j = 0; j < theseNodes; j++) {
|
|
|
|
memmove((uint8 *) &node[nnodes + j].x, fPolygrid, 2 * sizeof(int16));
|
|
|
|
fPolygrid += 2 * sizeof(int16);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// close walk grid file
|
|
|
|
res_man.Res_close(walkGridList[entry]);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// increment counts of total bars & nodes in whole
|
|
|
|
// walkgrid
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
nbars += theseBars;
|
2003-07-28 01:44:38 +00:00
|
|
|
nnodes += theseNodes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// EXTRA GRIDS (moveable grids added by megas)
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// Note that these will be checked against allowed max at the time of
|
|
|
|
// creating them
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// extra lines
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
memmove((uint8 *) &bars[nbars], (uint8 *) &extraBars[0], nExtraBars * sizeof(_barData));
|
2003-07-28 01:44:38 +00:00
|
|
|
nbars += nExtraBars;
|
|
|
|
|
|
|
|
// extra nodes
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
memmove((uint8 *) &node[nnodes], (uint8 *) &extraNode[0], nExtraNodes * sizeof(_nodeData));
|
2003-07-28 01:44:38 +00:00
|
|
|
nnodes += nExtraNodes;
|
|
|
|
}
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
void ClearWalkGridList(void) {
|
|
|
|
for (int entry=0; entry < MAX_WALKGRIDS; entry++)
|
2003-07-28 01:44:38 +00:00
|
|
|
walkGridList[entry] = 0;
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// called from FN_add_walkgrid
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void AddWalkGrid(int32 gridResource) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int entry;
|
|
|
|
|
|
|
|
// first, scan list to see if this grid is already included
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
entry = 0;
|
|
|
|
while (entry < MAX_WALKGRIDS && walkGridList[entry] != gridResource)
|
2003-07-28 01:44:38 +00:00
|
|
|
entry++;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if this new resource isn't already in the list, then add it,
|
|
|
|
// (otherwise finish)
|
|
|
|
|
|
|
|
if (entry == MAX_WALKGRIDS) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// scan the list for a free slot
|
2003-09-20 15:34:53 +00:00
|
|
|
entry = 0;
|
|
|
|
while (entry < MAX_WALKGRIDS && walkGridList[entry])
|
2003-07-28 01:44:38 +00:00
|
|
|
entry++;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if we found a free slot
|
|
|
|
if (entry < MAX_WALKGRIDS)
|
2003-07-28 01:44:38 +00:00
|
|
|
walkGridList[entry] = gridResource;
|
|
|
|
else
|
2003-09-20 15:34:53 +00:00
|
|
|
Con_fatal_error("ERROR: walkGridList[] full in %s line %d", __FILE__, __LINE__);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2003-09-20 15:34:53 +00:00
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
// called from FN_remove_walkgrid
|
2003-09-20 15:34:53 +00:00
|
|
|
|
|
|
|
void RemoveWalkGrid(int32 gridResource) {
|
2003-07-28 01:44:38 +00:00
|
|
|
int entry;
|
|
|
|
|
|
|
|
// first, scan list to see if this grid is actually there
|
2003-09-20 15:34:53 +00:00
|
|
|
entry = 0;
|
|
|
|
while (entry < MAX_WALKGRIDS && walkGridList[entry] != gridResource)
|
2003-07-28 01:44:38 +00:00
|
|
|
entry++;
|
|
|
|
|
2003-09-20 15:34:53 +00:00
|
|
|
// if we've found it in the list, reset entry to zero (otherwise just
|
|
|
|
// ignore the request)
|
|
|
|
if (entry < MAX_WALKGRIDS)
|
2003-07-28 01:44:38 +00:00
|
|
|
walkGridList[entry] = 0;
|
|
|
|
}
|