Unit smell

Description

Smell map, a copy of the map is floodfilled with integers. Each integer increments the further away it is from the player. Creatures can then track the player by finding a tile with a lower number than the one that they're standing on.

The below routine is based on code from Stephen Peter (AKA speter)

Uses

Overview

Functions and Procedures

function blockORnot(x, y: integer): Tbkinds;
procedure calcDistances(x, y: smallint);
procedure sniff;
function scentDirection(y, x: smallint): char;
function scentDirectionCoords(y, x: smallint): TPoint;
function pathFinding(id: smallint): path;

Types

Tbkinds = (...);
TDist = array [1..MAXROWS, 1..MAXCOLUMNS] of smallint;

Constants

BLOCKVALUE = 500;

Variables

distances: TDist;
smellCounter: byte;
smellmap: array[1..MAXROWS, 1..MAXCOLUMNS] of smallint;

Description

Functions and Procedures

function blockORnot(x, y: integer): Tbkinds;

filename: shortstring; myfile: Text;

procedure calcDistances(x, y: smallint);

Calculate distance from player

procedure sniff;

Generate smell map

function scentDirection(y, x: smallint): char;

Find the tile with the highest scent value

function scentDirectionCoords(y, x: smallint): TPoint;

Get Coordinates of the tile with highest scent value

function pathFinding(id: smallint): path;

Generate a path to the player

Types

Tbkinds = (...);
 
Values
  • bNone
  • bWall
  • bClear
TDist = array [1..MAXROWS, 1..MAXCOLUMNS] of smallint;
 

Constants

BLOCKVALUE = 500;

used on the smell map to denote a wall

Variables

distances: TDist;
 
smellCounter: byte;

Tracks the scent decaying over time

smellmap: array[1..MAXROWS, 1..MAXCOLUMNS] of smallint;
 

Generated by PasDoc 0.16.0.