forked from Whales/Cataclysm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.h
342 lines (310 loc) · 14.2 KB
/
game.h
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#ifndef _GAME_H_
#define _GAME_H_
#include "mtype.h"
#include "monster.h"
#include "map.h"
#include "player.h"
#include "overmap.h"
#include "omdata.h"
#include "mapitems.h"
#include "crafting.h"
#include "trap.h"
#include "npc.h"
#include "tutorial.h"
#include "faction.h"
#include "event.h"
#include "mission.h"
#include "weather.h"
#include "construction.h"
#include "calendar.h"
#include "posix_time.h"
#include "artifact.h"
#include "mutation.h"
#include <vector>
#define LONG_RANGE 10
#define BLINK_SPEED 300
#define BULLET_SPEED 10000000
#define EXPLOSION_SPEED 70000000
enum tut_type {
TUT_NULL,
TUT_BASIC, TUT_COMBAT,
TUT_MAX
};
enum quit_status {
QUIT_NO = 0, // Still playing
QUIT_MENU, // Quit at the menu
QUIT_SUICIDE, // Quit with 'Q'
QUIT_SAVED, // Saved and quit
QUIT_DIED // Actual death
};
struct monster_and_count
{
monster mon;
int count;
monster_and_count(monster M, int C) : mon (M), count (C) {};
};
struct mtype;
struct mission_type;
class map;
class player;
class calendar;
struct mutation_branch;
class game
{
public:
game();
~game();
bool game_quit(); // True if we actually quit the game - used in main.cpp
void save();
bool do_turn();
void tutorial_message(tut_lesson lesson);
void draw();
void draw_ter();
void advance_nextinv(); // Increment the next inventory letter
void add_msg(const char* msg, ...);
void add_event(event_type type, int on_turn, int faction_id = -1,
int x = -1, int y = -1);
bool event_queued(event_type type);
// Sound at (x, y) of intensity (vol), described to the player is (description)
void sound(int x, int y, int vol, std::string description);
// creates a list of coordinates to draw footsteps
void add_footstep(int x, int y, int volume, int distance);
std::vector<point> footsteps;
// visual cue to monsters moving out of the players sight
void draw_footsteps();
// Explosion at (x, y) of intensity (power), with (shrapnel) chunks of shrapnel
void explosion(int x, int y, int power, int shrapnel, bool fire);
// Flashback at (x, y)
void flashbang(int x, int y);
// Move the player vertically, if (force) then they fell
void vertical_move(int z, bool force);
void use_computer(int x, int y);
void resonance_cascade(int x, int y);
void emp_blast(int x, int y);
int npc_at(int x, int y); // Index of the npc at (x, y); -1 for none
int mon_at(int x, int y); // Index of the monster at (x, y); -1 for none
bool is_empty(int x, int y); // True if no PC, no monster, move cost > 0
bool isBetween(int test, int down, int up);
bool is_in_sunlight(int x, int y); // Checks outdoors + sunny
void kill_mon(int index); // Kill that monster; fixes any pointers etc
void explode_mon(int index); // Explode a monster; like kill_mon but messier
// hit_monster_with_flags processes ammo flags (e.g. incendiary, etc)
void hit_monster_with_flags(monster &z, unsigned int flags);
void plfire(bool burst); // Player fires a gun (target selection)...
// ... a gun is fired, maybe by an NPC (actual damage, etc.).
void fire(player &p, int tarx, int tary, std::vector<point> &trajectory,
bool burst);
void throw_item(player &p, int tarx, int tary, item &thrown,
std::vector<point> &trajectory);
void cancel_activity();
void cancel_activity_query(std::string message);
int assign_mission_id(); // Just returns the next available one
void give_mission(mission_id type);
void assign_mission(int id);
// reserve_mission() creates a new mission of the given type and pushes it to
// active_missions. The function returns the UID of the new mission, which can
// then be passed to a MacGuffin or something else that needs to track a mission
int reserve_mission(mission_id type, int npc_id = -1);
int reserve_random_mission(mission_origin origin, point p = point(-1, -1),
int npc_id = -1);
npc* find_npc(int id);
mission* find_mission(int id); // Mission with UID=id; NULL if non-existant
mission_type* find_mission_type(int id); // Same, but returns its type
bool mission_complete(int id, int npc_id); // True if we made it
bool mission_failed(int id); // True if we failed it
void wrap_up_mission(int id); // Perform required actions
void fail_mission(int id); // Perform required actions, move to failed list
void mission_step_complete(int id, int step); // Parial completion
void process_missions(); // Process missions, see if time's run out
void teleport(player *p = NULL);
void plswim(int x, int y); // Called by plmove. Handles swimming
void nuke(int x, int y);
std::vector<faction *> factions_at(int x, int y);
int& scent(int x, int y);
unsigned char light_level();
int assign_npc_id();
int assign_faction_id();
faction* faction_by_id(int it);
bool sees_u(int x, int y, int &t);
bool u_see (int x, int y, int &t);
bool u_see (monster *mon, int &t);
bool pl_sees(player *p, monster *mon, int &t);
void refresh_all();
void update_map(int &x, int &y); // Called by plmove when the map updates
void update_overmap_seen(); // Update which overmap tiles we can see
point om_location(); // levx and levy converted to overmap coordinates
faction* random_good_faction();
faction* random_evil_faction();
itype* new_artifact();
void process_artifact(item *it, player *p, bool wielded = false);
void add_artifact_messages(std::vector<art_effect_passive> effects);
point look_around();// Look at nearby terrain ';'
char inv(std::string title = "Inventory:");
std::vector<item> multidrop();
faction* list_factions(std::string title = "FACTIONS:");
point find_item(item *it);
void remove_item(item *it);
std::vector <itype*> itypes;
std::vector <mtype*> mtypes;
std::vector <trap*> traps;
std::vector <itype_id> mapitems[num_itloc]; // Items at various map types
std::vector <items_location_and_chance> monitems[num_monsters];
std::vector <mission_type> mission_types; // The list of mission templates
mutation_branch mutation_data[PF_MAX2]; // Mutation data
calendar turn;
signed char temperature; // The air temperature
weather_type weather; // Weather pattern--SEE weather.h
char nextinv; // Determines which letter the next inv item will have
overmap cur_om;
map m;
int levx, levy, levz; // Placement inside the overmap
player u;
std::vector<monster> z;
std::vector<monster_and_count> coming_to_stairs;
int monstairx, monstairy, monstairz;
std::vector<npc> active_npc;
std::vector<mon_id> moncats[num_moncats];
std::vector<faction> factions;
std::vector<mission> active_missions; // Missions which may be assigned
// NEW: Dragging a piece of furniture, with a list of items contained
ter_id dragging;
std::vector<item> items_dragged;
int weight_dragged; // Computed once, when you start dragging
bool debugmon;
// Display data... TODO: Make this more portable?
WINDOW *w_terrain;
WINDOW *w_minimap;
WINDOW *w_HP;
WINDOW *w_moninfo;
WINDOW *w_messages;
WINDOW *w_status;
private:
// Game-start procedures
bool opening_screen();// Warn about screen size, then present the main menu
bool load_master(); // Load the master data file, with factions &c
void load(std::string name); // Load a player-specific save file
void start_game(); // Starts a new game
void start_tutorial(tut_type type); // Starts a new tutorial
// Data Initialization
void init_itypes(); // Initializes item types
void init_mapitems(); // Initializes item placement
void init_mtypes(); // Initializes monster types
void init_moncats(); // Initializes monster categories
void init_monitems(); // Initializes monster inventory selection
void init_traps(); // Initializes trap types
void init_recipes(); // Initializes crafting recipes
void init_construction(); // Initializes construction "recipes"
void init_missions(); // Initializes mission templates
void init_mutations(); // Initializes mutation "tech tree"
void create_factions(); // Creates new factions (for a new game world)
void create_starting_npcs(); // Creates NPCs that start near you
// Player actions
void wish(); // Cheat by wishing for an item 'Z'
void monster_wish(); // Create a monster
void mutation_wish(); // Mutate
void plmove(int x, int y); // Standard movement; handles attacks, traps, &c
void wait(); // Long wait (player action) '^'
void open(); // Open a door 'o'
void close(); // Close a door 'c'
void smash(); // Smash terrain
void craft(); // See crafting.cpp
void make_craft(recipe *making); // See crafting.cpp
void complete_craft(); // See crafting.cpp
void pick_recipes(std::vector<recipe*> ¤t,
std::vector<bool> &available, craft_cat tab);// crafting.cpp
void construction_menu(); // See construction.cpp
bool player_can_build(player &p, inventory inv, constructable* con,
int level = -1, bool cont = false);
void place_construction(constructable *con); // See construction.cpp
void complete_construction(); // See construction.cpp
void examine();// Examine nearby terrain 'e'
void pickup(int posx, int posy, int min);// Pickup items; ',' or via examine()
// Pick where to put liquid; false if it's left where it was
bool handle_liquid(item &liquid, bool from_ground, bool infinite);
void drop(); // Drop an item 'd'
void drop_in_direction(); // Drop w/ direction 'D'
void reassign_item(); // Reassign the letter of an item '='
void butcher(); // Butcher a corpse 'B'
void complete_butcher(int index); // Finish the butchering process
void eat(); // Eat food or fuel 'E' (or 'a')
void use_item();// Use item; also tries E,R,W 'a'
void wear(); // Wear armor 'W' (or 'a')
void takeoff(); // Remove armor 'T'
void reload(); // Reload a wielded gun/tool 'r'
void unload(); // Unload a wielded gun/tool 'U'
void wield(); // Wield a weapon 'w'
void read(); // Read a book 'R' (or 'a')
void chat(); // Talk to a nearby NPC 'C'
void plthrow(); // Throw an item 't'
void help(); // Help screen '?'
// Target is an interactive function which allows the player to choose a nearby
// square. It display information on any monster/NPC on that square, and also
// returns a Bresenham line to that square. It is called by plfire() and
// throw().
std::vector<point> target(int &x, int &y, int lowx, int lowy, int hix,
int hiy, std::vector <monster> t, int &target,
item *relevent);
// Map updating and monster spawning
void replace_stair_monsters();
void update_stair_monsters();
void spawn_mon(int shift, int shifty); // Called by update_map, sometimes
mon_id valid_monster_from(std::vector<mon_id> group);
int valid_group(mon_id type, int x, int y);// Picks a group from cur_om
moncat_id mt_to_mc(mon_id type);// Monster type to monster category
void set_adjacent_overmaps(bool from_scratch = false);
// Routine loop functions, approximately in order of execution
void monmove(); // Monster movement
void om_npcs_move(); // Movement of NPCs on the overmap (non-local)
void check_warmth(); // Checks the player's warmth (applying clothing)
void update_skills(); // Degrades practice levels, checks & upgrades skills
void process_events(); // Processes and enacts long-term events
void process_activity(); // Processes and enacts the player's activity
void update_weather(); // Updates the temperature and weather patten
void hallucinate(); // Prints hallucination junk to the screen
void mon_info(); // Prints a list of nearby monsters (top right)
void get_input(); // Gets player input and calls the proper function
void update_scent(); // Updates the scent map
bool is_game_over(); // Returns true if the player quit or died
void death_screen(); // Display our stats, "GAME OVER BOO HOO"
void gameover(); // Ends the game
void write_msg(); // Prints the messages in the messages list
void draw_minimap(); // Draw the 5x5 minimap
void draw_HP(); // Draws the player's HP and Power level
// On-request draw functions
void draw_overmap(); // Draws the overmap, allows note-taking etc.
void disp_kills(); // Display the player's kill counts
void disp_NPCs(); // Currently UNUSED. Lists global NPCs.
void list_missions(); // Listed current, completed and failed missions.
// If x & y are OOB, creates a new overmap and returns the proper terrain; also,
// may mark the square as seen by the player
oter_id ter_at(int x, int y, bool& mark_as_seen);
// Debug functions
void debug(); // All-encompassing debug screen. TODO: This.
void display_scent(); // Displays the scent map
void mondebug(); // Debug monster behavior directly
void groupdebug(); // Get into on monster groups
// ########################## DATA ################################
signed char last_target;// The last monster targeted
char run_mode; // 0 - Normal run always; 1 - Running allowed, but if a new
// monsters spawns, go to 2 - No movement allowed
int mostseen; // # of mons seen last turn; if this increases, run_mode++
bool autosafemode; // is autosafemode enabled?
int turnssincelastmon; // needed for auto run mode
quit_status uquit; // Set to true if the player quits ('Q')
calendar nextspawn; // The turn on which monsters will spawn next.
calendar nextweather; // The turn on which weather will shift next.
overmap *om_hori, *om_vert, *om_diag; // Adjacent overmaps
int next_npc_id, next_faction_id, next_mission_id; // Keep track of UIDs
std::vector <std::string> messages; // Messages to be printed
unsigned char curmes; // The last-seen message. Older than 256 is deleted.
int grscent[SEEX * MAPSIZE][SEEY * MAPSIZE]; // The scent map
int nulscent; // Returned for OOB scent checks
std::vector<event> events; // Game events to be processed
int kills[num_monsters]; // Player's kill count
std::string last_action; // The keypresses of last turn
std::vector<recipe*> recipes; // The list of valid recipes
std::vector<constructable*> constructions; // The list of constructions
bool tutorials_seen[NUM_LESSONS]; // Which tutorial lessons have we learned
bool in_tutorial; // True if we're in a tutorial right now
};
#endif