ScummVM API documentation
party_path_finder.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_PATHFINDER_PARTY_PATH_FINDER_H
23 #define NUVIE_PATHFINDER_PARTY_PATH_FINDER_H
24 
25 #include "ultima/nuvie/core/party.h"
26 #include "ultima/nuvie/core/map.h"
27 
28 namespace Ultima {
29 namespace Nuvie {
30 
31 /* PartyPathFinder moves the entire party at once.
32  * FIXME: Move to target if one square away and unblocked. Shamino isn't in the
33  * correct square after moving through a doorway.
34  * FIXME: Perhaps is_contiguous() should require everyone in front of a follower
35  * to also be contiguous. If more than one followers are lost, they stay
36  * together more than look for the leader.
37  * FIXME: When walking along the wall, the last follower doesn't move up when
38  * there is a closer free square. (it sometimes behaves the same way in U6)
39  * FIXME: If a higher-number follower is closer to the leader than a lower-numbered
40  * one, the one with higher priority bumps him out of the way, and he loses a
41  * move. This causes him to become non-contiguous. Followers should NEVER be
42  * moved to non-contiguous squares. Strangely, this only happens when moving in
43  * certain directions. (disable SEEK mode to check)
44  * FIXME: When changing directions, followers on opposite sides of the party
45  * (perpendicular to the forward direction) shouldn't exchange positions until
46  * the leader stops.
47  */
48 
49 #define AVOID_DAMAGE_TILES true
50 
52  Party *party; // friend
53 public:
55  ~PartyPathFinder();
56 
57  bool follow_passA(uint32 p); // returns true if party member p moved
58  bool follow_passB(uint32 p);
59  void seek_leader(uint32 p);
60  void end_seek(uint32 p);
61 
62  bool move_member(uint32 member_num, sint16 relx, sint16 rely, bool ignore_position = false, bool can_bump = true, bool avoid_danger_tiles = true);
63  bool bump_member(uint32 bumped_member_num, uint32 member_num);
64 
65  bool is_seeking(uint32 member_num) {
66  return (get_member(member_num).actor->get_pathfinder() != 0);
67  }
68  bool is_contiguous(uint32 member_num, const MapCoord &from);
69  bool is_contiguous(uint32 member_num);
70  bool is_behind_target(uint32 member_num);
71  bool is_at_target(uint32 p);
72  void get_target_dir(uint32 p, sint8 &rel_x, sint8 &rel_y);
73  void get_forward_dir(sint8 &vec_x, sint8 &vec_y);
74  void get_last_move(sint8 &vec_x, sint8 &vec_y);
75 
76 protected:
77  bool try_moving_to_leader(uint32 p, bool ignore_position);
78  bool try_moving_forward(uint32 p);
79  bool try_moving_to_target(uint32 p, bool avoid_damage_tiles = false);
80  bool try_all_directions(uint32 p, MapCoord target_loc);
81  bool try_moving_sideways(uint32 p);
82 
83  bool leader_moved_away(uint32 p);
84  bool leader_moved_diagonally();
85  bool leader_moved();
86 
87  Std::vector<MapCoord> get_neighbor_tiles(const MapCoord &center, const MapCoord &target);
88 
89  // use party
90  struct PartyMember get_member(uint32 p) {
91  return (party->member[p]);
92  }
93  sint8 get_leader() {
94  return (party->get_leader());
95  }
96 };
97 
98 } // End of namespace Nuvie
99 } // End of namespace Ultima
100 
101 #endif
Definition: party.h:92
Definition: detection.h:27
Definition: party.h:50
Definition: map.h:84
Definition: party_path_finder.h:51
Definition: containers.h:38