ScummVM API documentation
u6_actor.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_ACTORS_U6_ACTOR_H
23#define NUVIE_ACTORS_U6_ACTOR_H
24
25#include "ultima/nuvie/actors/actor.h"
26#include "ultima/nuvie/misc/actor_list.h"
27#include "ultima/nuvie/core/u6_objects.h"
28
29namespace Ultima {
30namespace Nuvie {
31
32enum ActorMovetype {
33 MOVETYPE_U6_NONE = 0,
34 MOVETYPE_U6_LAND = 1,
35 MOVETYPE_U6_WATER_LOW = 2, // skiffs, rafts
36 MOVETYPE_U6_WATER_HIGH = 3, // ships
37 MOVETYPE_U6_AIR_LOW = 4, // balloon, birds... this movetype cannot cross mountain tops.
38 MOVETYPE_U6_AIR_HIGH = 5, // dragons
39 MOVETYPE_U6_ETHEREAL = 6,
40};
41
42#define REMOVE_SURROUNDING_OBJS true
43
44#define ACTOR_MOVEMENT_FLAGS_CORPSER 0x10
45
46typedef struct {
47 uint16 base_obj_n;
48 uint8 frames_per_direction;
49 uint8 tiles_per_direction;
50 uint8 tiles_per_frame;
51 uint8 tile_start_offset; //used for ships where the frame_n starts at 8
52 uint16 dead_obj_n;
53 uint8 dead_frame_n;
54 bool can_laydown;
55 bool can_sit;
56 ActorTileType tile_type;
57 ActorMovetype movetype;
58 uint16 twitch_rand; //used to control how frequently an actor twitches, lower numbers twitch more
59 uint8 body_armor_class;
61
62class U6Actor: public Actor {
63protected:
64
65 const U6ActorType *actor_type;
66 const U6ActorType *base_actor_type;
67 ActorMovetype current_movetype;
68
69 sint8 walk_frame_inc; // added to walk_frame each step
70
71public:
72
73 U6Actor(Map *m, ObjManager *om, GameClock *c);
74 ~U6Actor() override;
75
76 bool init(uint8 obj_status = NO_OBJ_STATUS) override;
77 uint16 get_downward_facing_tile_num() const override;
78 bool updateSchedule(uint8 hour, bool teleport = false) override;
79 void set_worktype(uint8 new_worktype, bool init = false) override;
80 void revert_worktype() override;
81 void change_base_obj_n(uint16 val) override;
82 void set_direction(NuvieDir d) override;
83 void face_location(uint16 lx, uint16 ly) override;
84 void clear() override;
85 bool move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0) override;
86 bool check_move(uint16 new_x, uint16 new_y, uint8 new_z, ActorMoveFlags flags = 0) override;
87 void twitch() override;
88 void do_twitch();
89 void die(bool create_body = true) override;
90 void set_paralyzed(bool paralyzed) override;
91 void set_protected(bool val) override;
92 void set_charmed(bool val) override;
93 void set_corpser_flag(bool val) override;
94 void set_cursed(bool val) override;
95 void set_asleep(bool val) override;
96 void set_ethereal(bool val) override {
97 current_movetype = val ? MOVETYPE_U6_ETHEREAL : actor_type->movetype;
98 ethereal = val;
99 }
100
101 uint8 get_object_readiable_location(Obj *obj) override;
102 const CombatType *get_object_combat_type(uint16 objN) override;
103 ActorTileType get_tile_type() const override {
104 return (actor_type->tile_type);
105 }
106 Obj *inventory_get_food(Obj *container = 0) override;
107 uint8 get_maxhp() const override {
108 return (((level * 30) <= 255) ? (level * 30) : 255); // U6
109 }
110 uint8 get_maxmagic() const override;
111
112 bool weapon_can_hit(const CombatType *weapon, Actor *target, uint16 *hit_x, uint16 *hit_y) override;
113
114 bool is_immobile() const override; // frozen by worktype or status
115 bool can_twitch();
116
117 bool get_corpser_flag() const override {
118 return (movement_flags & ACTOR_MOVEMENT_FLAGS_CORPSER);
119 }
120 bool can_be_passed(const Actor *other, bool ignoreParty) const override;
121 bool will_not_talk() const override;
122
123 void set_actor_obj_n(uint16 new_obj_n);
124 void pathfind_to(const MapCoord &d) override;
125 void handle_lightsource(uint8 hour) override;
126
127 uint8 get_hp_text_color() const override;
128 uint8 get_str_text_color() const override {
129 return 0x48;
130 }
131 uint8 get_dex_text_color() const override {
132 return 0x48;
133 }
134 bool isFlying() const override {
135 // FIXME: Get flying flag from lua actor_tbl
136 // in devtools/create_ultima/files/ultima6/scripts/u6/actor.lua
137 const uint16 flyingObjs[] = {
138 OBJ_U6_INSECTS, OBJ_U6_GIANT_BAT, OBJ_U6_GAZER, OBJ_U6_BIRD,
139 OBJ_U6_WINGED_GARGOYLE, OBJ_U6_DAEMON, OBJ_U6_DRAKE,
140 OBJ_U6_MONGBAT, OBJ_U6_DRAGON, OBJ_U6_INFLATED_BALLOON };
141
142 for (const auto flyingObj : flyingObjs)
143 if (obj_n == flyingObj)
144 return true;
145 return false;
146 }
147 bool isNonBlocking() const override {
148 // These are hard-coded in original U6
149 const uint16 u6NonBlockingObjs[] = {
150 OBJ_U6_INSECTS, OBJ_U6_MOUSE, OBJ_U6_BIRD, OBJ_U6_CORPSER,
151 OBJ_U6_RABBIT };
152
153 for (const auto nonBlockingObj : u6NonBlockingObjs)
154 if (obj_n == nonBlockingObj)
155 return true;
156 return false;
157 }
158
159protected:
160 bool init_ship();
161 bool init_splitactor(uint8 obj_status); //cows, horses etc.
162 bool init_dragon();
163 bool init_hydra();
164 bool init_silver_serpent();
165 void init_new_silver_serpent();
166 void gather_snake_objs_from_map(Obj *start_obj, uint16 ax, uint16 ay, uint16 az);
167 inline bool check_move_silver_serpent(uint16 x, uint16 y);
168 bool sit_on_chair(Obj *obj);
169
170 inline void discover_direction();
171 void setup_walk_to_location();
172 void wt_sleep(bool init = false);
173 void wt_play_lute();
174
175 inline const U6ActorType *get_actor_type(uint16 new_obj_n);
176
177 inline bool has_surrounding_objs();
178 inline void remove_surrounding_objs_from_map();
179 inline void add_surrounding_objs_to_map();
180 inline void move_surrounding_objs_relative(sint16 rel_x, sint16 rel_y);
181 inline void move_silver_serpent_objs_relative(sint16 rel_x, sint16 rel_y);
182 inline void set_direction_of_surrounding_objs(NuvieDir new_direction);
183 inline void set_direction_of_surrounding_ship_objs(NuvieDir new_direction);
184 inline void set_direction_of_surrounding_splitactor_objs(NuvieDir new_direction);
185 inline void set_direction_of_surrounding_dragon_objs(NuvieDir new_direction);
186
187 inline void twitch_surrounding_objs();
188 inline void twitch_surrounding_dragon_objs();
189 inline void twitch_surrounding_hydra_objs();
190 inline void twitch_obj(Obj *obj);
191
192 inline void clear_surrounding_objs_list(bool delete_objs = false);
193 inline void init_surrounding_obj(uint16 x, uint16 y, uint8 z, uint16 actor_obj_n, uint16 obj_frame_n);
194
195 const CombatType *get_hand_combat_type() const override;
196
197 void print() override;
198 const char *get_worktype_string(uint32 wt) const override;
199 void inventory_make_all_objs_ok_to_take();
200};
201
202} // End of namespace Nuvie
203} // End of namespace Ultima
204
205#endif
Definition: actor.h:174
Definition: game_clock.h:45
Definition: map.h:84
Definition: map.h:147
Definition: obj.h:84
Definition: obj_manager.h:74
Definition: u6_actor.h:62
Definition: actor.h:131
Definition: u6_actor.h:46