File: paths.h

package info (click to toggle)
exult 1.2-16.2
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 8,676 kB
  • ctags: 10,520
  • sloc: cpp: 99,373; sh: 7,324; ansic: 4,659; makefile: 938; yacc: 769; lex: 313; xml: 19
file content (134 lines) | stat: -rw-r--r-- 4,488 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 *	Paths.h - Various pathfinding clients.
 *
 *  Copyright (C) 2000-2001  The Exult Team
 *
 *  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.
 */

#ifndef PATHS_H
#define PATHS_H	1

#include "PathFinder.h"
#include "tiles.h"
#include "rect.h"
#include "chunks.h"

class Actor;
class Game_object;
class Game_window;

/*
 *	This class provides A* cost methods.
 */
class Actor_pathfinder_client : public Pathfinder_client
	{
	int dist;			// Distance for success.
	Actor *npc;			// Who this represents.
public:
//	Actor_pathfinder_client(Actor *npc, int d = 0) : dist(d)
//		{ set_move_flags(mf); }
	Actor_pathfinder_client(Actor *npc, int d = 0);
					// Figure when to give up.
	virtual int get_max_cost(int cost_to_goal);
					// Figure cost for a single step.
	virtual int get_step_cost(Tile_coord from, Tile_coord& to);
					// Estimate cost between two points.
	virtual int estimate_cost(Tile_coord& from, Tile_coord& to);
					// Is tile at the goal?
	virtual int at_goal(Tile_coord& tile, Tile_coord& goal);
	};

/*
 *	This client succeeds when the path makes it to just one X/Y coord.
 *	It assumes that a -1 was placed in the coord. that we should ignore.
 */
class Onecoord_pathfinder_client : public Actor_pathfinder_client
	{
public:
	Onecoord_pathfinder_client(Actor *n) : Actor_pathfinder_client(n)
		{  }
					// Estimate cost between two points.
	virtual int estimate_cost(Tile_coord& from, Tile_coord& to);
					// Is tile at the goal?
	virtual int at_goal(Tile_coord& tile, Tile_coord& goal);
	};

/*
 *	This client succeeds when the path makes it offscreen.
 *	Only the tz coord. of the dest. is used.
 */
class Offscreen_pathfinder_client : public Actor_pathfinder_client
	{
	Rectangle screen;		// Screen rect. in tiles.
	Tile_coord best;		// Best offscreen pt. to aim for.
public:
	Offscreen_pathfinder_client(Actor *n);
	Offscreen_pathfinder_client(Actor *n, Tile_coord b);
					// Figure cost for a single step.
	virtual int get_step_cost(Tile_coord from, Tile_coord& to);
					// Estimate cost between two points.
	virtual int estimate_cost(Tile_coord& from, Tile_coord& to);
					// Is tile at the goal?
	virtual int at_goal(Tile_coord& tile, Tile_coord& goal);
	};

/*
 *	This client is supposed to fail quickly, so that it can be used to
 *	test for when an object can be grabbed.
 */
class Fast_pathfinder_client : public Pathfinder_client
	{
	int dist;			// Succeeds at this distance from goal.
public:
	Fast_pathfinder_client(int d = 0, int mf = 1 << 5) : dist(d)
		{ set_move_flags(mf); }
					// Figure when to give up.
	virtual int get_max_cost(int cost_to_goal);
					// Figure cost for a single step.
	virtual int get_step_cost(Tile_coord from, Tile_coord& to);
					// Estimate cost between two points.
	virtual int estimate_cost(Tile_coord& from, Tile_coord& to);
					// Is tile at the goal?
	virtual int at_goal(Tile_coord& tile, Tile_coord& goal);
	static int is_grabable(Tile_coord from, Tile_coord to);
					// Check for unblocked straight path.
	static int is_straight_path(Tile_coord from, Tile_coord to);
	};

/*
 *	Pathfinding for monsters, who may be bigger than 1x1:
 */
class Monster_pathfinder_client : public Fast_pathfinder_client
	{
	Rectangle destbox;		// Got to intersect this box.
	int intelligence;		// NPC's intelligence.
	int axtiles, aytiles, aztiles;	// NPC's dims. in tiles.
public:
	Monster_pathfinder_client(Actor *npc, Tile_coord dest, int dist);
					// For combat:
	Monster_pathfinder_client(Actor *attacker, int reach,
						Game_object *opponent);
					// Figure when to give up.
	virtual int get_max_cost(int cost_to_goal);
					// Is tile at the goal?
	virtual int at_goal(Tile_coord& tile, Tile_coord& goal);
					// Figure cost for a single step.
	virtual int get_step_cost(Tile_coord from, Tile_coord& to);
	};


#endif	/* INCL_PATHS */