00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ACTIONS_H
00022 #define ACTIONS_H 1
00023
00024 #include "tiles.h"
00025
00026 class Actor;
00027 class Game_object;
00028 class Tile_coord;
00029 class PathFinder;
00030 class Pathfinder_client;
00031 class If_else_path_actor_action;
00032
00033
00034
00035
00036 class Actor_action
00037 {
00038 static long seqcnt;
00039 protected:
00040 bool get_party;
00041
00042 long seq;
00043 public:
00044 Actor_action() : get_party(false)
00045 { seq = ++seqcnt; }
00046 virtual ~Actor_action() { }
00047 void set_get_party(bool tf = true)
00048 { get_party = true; }
00049 int handle_event_safely(Actor *actor, bool& deleted);
00050
00051 virtual int handle_event(Actor *actor) = 0;
00052 virtual void stop(Actor *actor)
00053 { }
00054
00055 virtual Actor_action *walk_to_tile(Actor *npc, Tile_coord src,
00056 Tile_coord dest, int dist = 0);
00057
00058
00059 static Actor_action *create_action_sequence(Actor *actor,
00060 Tile_coord dest, Actor_action *when_there,
00061 bool from_off_screen = false);
00062
00063 virtual int get_dest(Tile_coord& dest)
00064 { return 0; }
00065
00066 virtual int following_smart_path()
00067 { return 0; }
00068 virtual If_else_path_actor_action *as_usecode_path()
00069 { return 0; }
00070 };
00071
00072
00073
00074
00075 class Null_action : public Actor_action
00076 {
00077 public:
00078 Null_action() { }
00079 virtual int handle_event(Actor *actor);
00080 };
00081
00082
00083
00084
00085 class Path_walking_actor_action : public Actor_action
00086 {
00087 protected:
00088 bool reached_end;
00089 PathFinder *path;
00090 private:
00091 int original_dir;
00092 int speed;
00093 bool from_offscreen;
00094 Actor_action *subseq;
00095 unsigned char blocked;
00096 unsigned char max_blocked;
00097 unsigned char blocked_frame;
00098 Tile_coord blocked_tile;
00099 void set_subseq(Actor_action *sub)
00100 {
00101 delete subseq;
00102 subseq = sub;
00103 }
00104 public:
00105 Path_walking_actor_action(PathFinder *p = 0, int maxblk = 3);
00106 virtual ~Path_walking_actor_action();
00107 static Path_walking_actor_action *create_path(Tile_coord src,
00108 Tile_coord dest, Pathfinder_client& cost);
00109
00110 virtual int handle_event(Actor *actor);
00111 int open_door(Actor *actor, Game_object *door);
00112 virtual void stop(Actor *actor);
00113
00114 virtual Actor_action *walk_to_tile(Actor *npc, Tile_coord src,
00115 Tile_coord dest, int dist = 0);
00116
00117 virtual int get_dest(Tile_coord& dest);
00118
00119 virtual int following_smart_path();
00120 };
00121
00122
00123
00124
00125
00126 class Approach_actor_action : public Path_walking_actor_action
00127 {
00128 Game_object *dest_obj;
00129 Tile_coord orig_dest_pos;
00130 int cur_step;
00131 int check_step;
00132 public:
00133 Approach_actor_action(PathFinder *p, Game_object *d);
00134
00135 virtual int handle_event(Actor *actor);
00136 };
00137
00138
00139
00140
00141
00142 class If_else_path_actor_action : public Path_walking_actor_action
00143 {
00144 bool succeeded, failed, done;
00145 Actor_action *success, *failure;
00146 public:
00147 If_else_path_actor_action(Actor *actor, Tile_coord dest,
00148 Actor_action *s, Actor_action *f = 0);
00149 ~If_else_path_actor_action();
00150 void set_failure(Actor_action *f);
00151 bool done_and_failed()
00152 { return done && failed; }
00153
00154 virtual int handle_event(Actor *actor);
00155 virtual If_else_path_actor_action *as_usecode_path()
00156 { return this; }
00157 };
00158
00159
00160
00161
00162 class Move_actor_action : public Actor_action
00163 {
00164 Tile_coord dest;
00165 public:
00166 Move_actor_action(Tile_coord d) : dest(d)
00167 { }
00168
00169 virtual int handle_event(Actor *actor);
00170 };
00171
00172 #if 0
00173
00174
00175
00176 class Combat_path_actor_action : public Actor_action
00177 {
00178 PathFinder *path;
00179 int frame_index;
00180 public:
00181 Combat_path_walking_actor_action(PathFinder *p);
00182 virtual ~Combat_path_walking_actor_action();
00183
00184 virtual int handle_event(Actor *actor);
00185
00186 virtual int get_dest(Tile_coord& dest);
00187 };
00188 #endif
00189
00190
00191
00192
00193 class Activate_actor_action : public Actor_action
00194 {
00195 Game_object *obj;
00196 public:
00197 Activate_actor_action(Game_object *o) : obj(o)
00198 { }
00199
00200 virtual int handle_event(Actor *actor);
00201 };
00202
00203
00204
00205
00206 class Frames_actor_action : public Actor_action
00207 {
00208 signed char *frames;
00209
00210 int cnt;
00211 int index;
00212 int speed;
00213 Game_object *obj;
00214 public:
00215 Frames_actor_action(signed char *f, int c, int spd = 200, Game_object *o = 0);
00216 virtual ~Frames_actor_action()
00217 { delete [] frames; }
00218
00219 virtual int handle_event(Actor *actor);
00220 int get_index()
00221 { return index; }
00222 };
00223
00224
00225
00226
00227 class Usecode_actor_action : public Actor_action
00228 {
00229 int fun;
00230 Game_object *item;
00231 int eventid;
00232 public:
00233 Usecode_actor_action(int f, Game_object *i, int ev)
00234 : fun(f), item(i), eventid(ev)
00235 { }
00236
00237 virtual int handle_event(Actor *actor);
00238 };
00239
00240
00241
00242
00243 class Sequence_actor_action : public Actor_action
00244 {
00245 Actor_action **actions;
00246 int index;
00247 int speed;
00248
00249 public:
00250
00251 Sequence_actor_action(Actor_action **act, int spd = 100)
00252 : actions(act), index(0), speed(spd)
00253 { }
00254
00255 Sequence_actor_action(Actor_action *a0, Actor_action *a1,
00256 Actor_action *a2 = 0, Actor_action *a3 = 0);
00257 void set_speed(int spd)
00258 { speed = spd; }
00259 virtual ~Sequence_actor_action();
00260
00261 virtual int handle_event(Actor *actor);
00262 };
00263
00264
00265
00266
00267
00268
00269
00270
00271 class Object_animate_actor_action : public Actor_action
00272 {
00273 Game_object *obj;
00274 int nframes;
00275 int cycles;
00276 int speed;
00277 public:
00278 Object_animate_actor_action(Game_object *o, int cy, int spd);
00279 Object_animate_actor_action(Game_object *o, int nframes, int cy, int spd);
00280
00281 virtual int handle_event(Actor *actor);
00282 };
00283
00284
00285
00286
00287
00288 class Pickup_actor_action : public Actor_action
00289 {
00290 Game_object *obj;
00291 int pickup;
00292 int speed;
00293 int cnt;
00294 Tile_coord objpos;
00295 int dir;
00296 public:
00297
00298 Pickup_actor_action(Game_object *o, int spd);
00299
00300 Pickup_actor_action(Game_object *o, Tile_coord opos, int spd);
00301 virtual int handle_event(Actor *actor);
00302 };
00303
00304
00305
00306
00307
00308
00309 class Face_pos_actor_action : public Actor_action
00310 {
00311 int speed;
00312 Tile_coord pos;
00313 public:
00314 Face_pos_actor_action(Tile_coord p, int spd);
00315
00316 Face_pos_actor_action(Game_object *o, int spd);
00317 virtual int handle_event(Actor *actor);
00318 };
00319
00320
00321 #endif
00322