00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SCHEDULE_H
00022 #define SCHEDULE_H 1
00023
00024 #include "tiles.h"
00025 #include "vec.h"
00026 #include "lists.h"
00027 #include "singles.h"
00028
00029 #ifdef WIN32
00030 #include <windows.h>
00031 #define Rectangle RECTX
00032 #endif
00033
00034 class Game_object;
00035 class Actor;
00036 class Rectangle;
00037 class Actor_action;
00038
00039
00040
00041
00042 class Schedule : public Game_singletons
00043 {
00044 protected:
00045 Actor *npc;
00046 Tile_coord blocked;
00047 short prev_type;
00048 int street_maintenance_failures;
00049 long street_maintenance_time;
00050 public:
00051 Schedule(Actor *n);
00052 virtual ~Schedule()
00053 { }
00054 int get_prev_type() const
00055 { return prev_type; }
00056 void set_blocked(Tile_coord b)
00057 { blocked = b; }
00058 enum Schedule_types {
00059 combat = 0, horiz_pace = 1,
00060 vert_pace = 2, talk = 3,
00061 dance = 4, eat = 5,
00062 farm = 6, tend_shop = 7,
00063 miner = 8, hound = 9,
00064 stand = 10, loiter = 11,
00065 wander = 12, blacksmith = 13,
00066 sleep = 14, wait = 15,
00067 sit = 16, graze = 17,
00068 bake = 18, sew = 19,
00069 shy = 20, lab = 21,
00070 thief = 22, waiter = 23,
00071 special = 24, kid_games = 25,
00072 eat_at_inn = 26,duel = 27,
00073 preach = 28, patrol = 29,
00074 desk_work = 30, follow_avatar = 31,
00075
00076 walk_to_schedule = 32,
00077 street_maintenance = 33
00078 };
00079
00080
00081 static void set_action_sequence(Actor *actor, Tile_coord dest,
00082 Actor_action *when_there, bool from_off_screen = false,
00083 int delay = 0);
00084 int try_street_maintenance();
00085 virtual void now_what() = 0;
00086
00087 virtual void im_dormant()
00088 { }
00089 virtual void ending(int newtype)
00090 { }
00091 virtual void set_weapon()
00092 { }
00093
00094 virtual void set_bed(Game_object *b)
00095 { }
00096
00097
00098 virtual void notify_object_gone(Game_object *obj)
00099 { }
00100
00101 virtual int get_actual_type(Actor *npc);
00102 };
00103
00104
00105
00106
00107 class Street_maintenance_schedule : public Schedule
00108 {
00109 Game_object *obj;
00110 int shapenum, framenum;
00111 Actor_action *paction;
00112 public:
00113 Street_maintenance_schedule(Actor *n, Actor_action *p, Game_object *o);
00114 virtual void now_what();
00115
00116 virtual int get_actual_type(Actor *npc);
00117 };
00118
00119
00120
00121
00122 class Follow_avatar_schedule : public Schedule
00123 {
00124 unsigned long next_path_time;
00125
00126 public:
00127 Follow_avatar_schedule(Actor *n) : Schedule(n), next_path_time(0)
00128 { }
00129 virtual void now_what();
00130 };
00131
00132
00133
00134
00135 class Wait_schedule : public Schedule
00136 {
00137 public:
00138 Wait_schedule(Actor *n) : Schedule(n)
00139 { }
00140 virtual void now_what();
00141 };
00142
00143
00144
00145
00146 class Pace_schedule : public Schedule
00147 {
00148 Tile_coord p0;
00149 Tile_coord p1;
00150 char which;
00151 public:
00152 Pace_schedule(Actor *n, Tile_coord pt0, Tile_coord pt1)
00153 : Schedule(n), p0(pt0), p1(pt1), which(0)
00154 { }
00155
00156 static Pace_schedule *create_horiz(Actor *n);
00157 static Pace_schedule *create_vert(Actor *n);
00158 virtual void now_what();
00159 };
00160
00161
00162
00163
00164 class Eat_at_inn_schedule : public Schedule
00165 {
00166 public:
00167 Eat_at_inn_schedule(Actor *n) : Schedule(n)
00168 { }
00169 virtual void now_what();
00170 };
00171
00172
00173
00174
00175 class Preach_schedule : public Schedule
00176 {
00177 enum {
00178 find_podium,
00179 at_podium,
00180 exhort,
00181 visit,
00182 talk_member,
00183 find_icon,
00184 pray
00185 } state;
00186 public:
00187 Preach_schedule(Actor *n) : Schedule(n), state(find_podium)
00188 { }
00189 virtual void now_what();
00190 };
00191
00192
00193
00194
00195 class Patrol_schedule : public Schedule
00196 {
00197 Game_object_vector paths;
00198 int pathnum;
00199 int dir;
00200 int failures;
00201 bool sitting;
00202 bool find_next;
00203 public:
00204 Patrol_schedule(Actor *n)
00205 : Schedule(n), pathnum(-1), dir(1), failures(0),
00206 sitting(false), find_next(true)
00207 { }
00208 virtual void now_what();
00209 };
00210
00211
00212
00213
00214 class Talk_schedule : public Schedule
00215 {
00216 int phase;
00217 public:
00218 Talk_schedule(Actor *n) : Schedule(n), phase(0)
00219 { }
00220 virtual void now_what();
00221 };
00222
00223
00224
00225
00226 class Loiter_schedule : public Schedule
00227 {
00228 protected:
00229 Tile_coord center;
00230 int dist;
00231
00232 public:
00233 Loiter_schedule(Actor *n, int d = 12);
00234 virtual void now_what();
00235 };
00236
00237
00238
00239
00240 class Kid_games_schedule : public Loiter_schedule
00241 {
00242 Actor_queue kids;
00243 public:
00244 Kid_games_schedule(Actor *n) : Loiter_schedule(n, 10)
00245 { }
00246 virtual void now_what();
00247 };
00248
00249
00250
00251
00252 class Dance_schedule : public Loiter_schedule
00253 {
00254 public:
00255 Dance_schedule(Actor *n) : Loiter_schedule(n, 4)
00256 { }
00257 virtual void now_what();
00258 };
00259
00260
00261
00262
00263 class Tool_schedule : public Loiter_schedule
00264 {
00265 int toolshape;
00266 Game_object *tool;
00267 public:
00268 Tool_schedule(Actor *n, int shnum) : Loiter_schedule(n, 12),
00269 toolshape(shnum), tool(0)
00270 { }
00271 virtual void now_what();
00272 virtual void ending(int newtype);
00273 };
00274
00275
00276
00277
00278 class Hound_schedule : public Schedule
00279 {
00280 public:
00281 Hound_schedule(Actor *n) : Schedule(n)
00282 { }
00283 virtual void now_what();
00284 };
00285
00286
00287
00288
00289 class Wander_schedule : public Loiter_schedule
00290 {
00291 public:
00292 Wander_schedule(Actor *n) : Loiter_schedule(n, 128)
00293 { }
00294 virtual void now_what();
00295 };
00296
00297
00298
00299
00300 class Sleep_schedule : public Schedule
00301 {
00302 Tile_coord floorloc;
00303 Game_object *bed;
00304 int state;
00305 int spread0, spread1;
00306 public:
00307 Sleep_schedule(Actor *n);
00308 virtual void now_what();
00309 virtual void ending(int newtype);
00310
00311 virtual void set_bed(Game_object *b)
00312 { bed = b; state = 0; }
00313 };
00314
00315
00316
00317
00318 class Sit_schedule : public Schedule
00319 {
00320 Game_object *chair;
00321 bool sat;
00322 bool did_barge_usecode;
00323 public:
00324 Sit_schedule(Actor *n, Game_object *ch = 0);
00325 virtual void now_what();
00326 static bool is_occupied(Game_object *chairobj, Actor *actor);
00327 static bool set_action(Actor *actor, Game_object *chairobj = 0,
00328 int delay = 0, Game_object **chair_found = 0);
00329 };
00330
00331
00332
00333
00334 class Desk_schedule : public Schedule
00335 {
00336 Game_object *chair;
00337 public:
00338 Desk_schedule(Actor *n);
00339 virtual void now_what();
00340 };
00341
00342
00343
00344
00345 class Shy_schedule : public Schedule
00346 {
00347 public:
00348 Shy_schedule(Actor *n) : Schedule(n)
00349 { }
00350 virtual void now_what();
00351 };
00352
00353
00354
00355
00356 class Lab_schedule : public Schedule
00357 {
00358 Game_object_vector tables;
00359 Game_object *chair;
00360 Game_object *book;
00361 Game_object *cauldron;
00362 Tile_coord spot_on_table;
00363 enum {
00364 start,
00365 walk_to_cauldron,
00366 use_cauldron,
00367 sit_down,
00368 read_book,
00369 stand_up,
00370 walk_to_table,
00371 use_potion
00372 } state;
00373 void init();
00374 public:
00375 Lab_schedule(Actor *n);
00376 virtual void now_what();
00377 };
00378
00379
00380
00381
00382 class Waiter_schedule : public Schedule
00383 {
00384 int first;
00385 Tile_coord startpos;
00386 Actor *customer;
00387 Actor_queue customers;
00388 Game_object_vector prep_tables;
00389 Game_object_vector eating_tables;
00390 void get_customer();
00391 void find_tables(int shapenum);
00392 Game_object *find_serving_spot(Tile_coord& spot);
00393 public:
00394 Waiter_schedule(Actor *n);
00395 virtual void now_what();
00396 virtual void ending(int newtype);
00397 };
00398
00399
00400
00401
00402 class Sew_schedule : public Schedule
00403 {
00404 Game_object *bale;
00405 Game_object *spinwheel;
00406 Game_object *chair;
00407 Game_object *spindle;
00408 Game_object *loom;
00409 Game_object *cloth;
00410 Game_object *work_table, *wares_table;
00411 int sew_clothes_cnt;
00412 enum {
00413 get_wool,
00414 sit_at_wheel,
00415 spin_wool,
00416 get_thread,
00417 weave_cloth,
00418 get_cloth,
00419 to_work_table,
00420 set_to_sew,
00421 sew_clothes,
00422 get_clothes,
00423 display_clothes,
00424 done
00425 } state;
00426 public:
00427 Sew_schedule(Actor *n);
00428 virtual void now_what();
00429 virtual void ending(int newtype);
00430 };
00431
00432
00433
00434
00435 class Bake_schedule : public Schedule
00436 {
00437 Game_object *oven;
00438 Game_object *worktable;
00439 Game_object *displaytable;
00440 Game_object *flourbag;
00441 Game_object *dough;
00442 Game_object *dough_in_oven;
00443 int baked_count;
00444 enum {
00445 to_flour,
00446 get_flour,
00447 to_table,
00448 make_dough,
00449 remove_from_oven,
00450 display_wares,
00451 get_dough,
00452 put_in_oven
00453 } state;
00454 public:
00455 Bake_schedule(Actor *n);
00456 virtual void now_what();
00457 virtual void ending(int newtype);
00458 virtual void notify_object_gone(Game_object *obj);
00459 };
00460
00461
00462
00463
00464 class Forge_schedule : public Schedule
00465 {
00466 Game_object *tongs;
00467 Game_object *hammer;
00468 Game_object *blank;
00469 Game_object *firepit;
00470 Game_object *anvil;
00471 Game_object *trough;
00472 Game_object *bellows;
00473 enum {
00474 put_sword_on_firepit,
00475 use_bellows,
00476 get_tongs,
00477 sword_on_anvil,
00478 get_hammer,
00479 use_hammer,
00480 walk_to_trough,
00481 fill_trough,
00482 get_tongs2,
00483 use_trough,
00484 done
00485 } state;
00486 public:
00487 Forge_schedule(Actor *n);
00488 virtual void now_what();
00489 virtual void ending(int newtype);
00490 };
00491
00492
00493
00494
00495 class Walk_to_schedule : public Schedule
00496 {
00497 Tile_coord dest;
00498 int first_delay;
00499 int new_schedule;
00500 int retries;
00501 int legs;
00502
00503 void walk_off_screen(Rectangle& screen, Tile_coord& goal);
00504 public:
00505 Walk_to_schedule(Actor *n, Tile_coord d, int new_sched,
00506 int delay = -1);
00507 virtual void now_what();
00508 virtual void im_dormant();
00509
00510 virtual int get_actual_type(Actor *npc);
00511 };
00512
00513
00514
00515
00516 class Schedule_change
00517 {
00518 unsigned char time;
00519 unsigned char type;
00520 unsigned char x, y;
00521 unsigned char superchunk;
00522 public:
00523 Schedule_change() : time(0), type(0), x(0), y(0), superchunk(0)
00524 { }
00525 void set(unsigned char *ent);
00526 void get(unsigned char *ent);
00527 void set(int ax, int ay, unsigned char stype, unsigned char stime);
00528 int get_type() const
00529 { return type; }
00530 int get_time() const
00531 { return time; }
00532 Tile_coord get_pos() const;
00533 };
00534
00535 #endif