[49] | 1 | #ifndef __CHARACTERZ_HPP_ |
---|
| 2 | #define __CHARACTERZ_HPP_ |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | #include "seq.hpp" |
---|
| 6 | #include "sound.hpp" |
---|
| 7 | #include "ability.hpp" |
---|
| 8 | #include "event.hpp" |
---|
| 9 | #include "macs.hpp" |
---|
| 10 | #include <stdarg.h> |
---|
| 11 | #include <time.h> |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | enum character_state {dead, |
---|
| 15 | dieing, |
---|
| 16 | stopped, |
---|
| 17 | start_run_jump,run_jump, run_jump_fall, end_run_jump, |
---|
| 18 | flinch_up,flinch_down, |
---|
| 19 | morph_pose, |
---|
| 20 | running |
---|
| 21 | } ; |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | #define MAX_STATE (running+1) |
---|
| 26 | extern char *state_names[]; |
---|
| 27 | |
---|
| 28 | class named_field |
---|
| 29 | { |
---|
| 30 | public : |
---|
| 31 | char *real_name; |
---|
| 32 | char *descript_name; |
---|
| 33 | named_field(char *real, char *fake) |
---|
| 34 | { real_name=strcpy((char *)jmalloc(strlen(real)+1,"var_name"),real); |
---|
| 35 | descript_name=strcpy((char *)jmalloc(strlen(fake)+1,"var_name"),fake); |
---|
| 36 | } |
---|
| 37 | ~named_field() { jfree(real_name); jfree(descript_name); } |
---|
| 38 | } ; |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | // all cflags default is 0 |
---|
| 43 | #define TOTAL_CFLAGS 11 |
---|
| 44 | enum { CFLAG_HURT_ALL, // if object hurts all characters, not just player |
---|
| 45 | CFLAG_IS_WEAPON, // if object is a collectable weapon (should have a logo) |
---|
| 46 | CFLAG_STOPPABLE, // if object can be stopped by any other object |
---|
| 47 | CFLAG_CAN_BLOCK, // if object can block other object |
---|
| 48 | CFLAG_HURTABLE, |
---|
| 49 | CFLAG_PUSHABLE, // can push other pushable characters |
---|
| 50 | CFLAG_UNLISTABLE, // if object should appear in object list during edit mode |
---|
| 51 | CFLAG_ADD_FRONT, |
---|
| 52 | CFLAG_CACHED_IN, |
---|
| 53 | CFLAG_NEED_CACHE_IN, |
---|
| 54 | CFLAG_UNACTIVE_SHIELD // if object is not active (i.e. link 0 aistate==0) |
---|
| 55 | // then objects will not draw a damage when hitting it |
---|
| 56 | }; |
---|
| 57 | extern char *cflag_names[TOTAL_CFLAGS]; |
---|
| 58 | |
---|
| 59 | // all object functions default to NULL |
---|
| 60 | #define TOTAL_OFUNS 11 |
---|
| 61 | enum { OFUN_AI, // objects ai function called by the mover, should call (tick) |
---|
| 62 | OFUN_MOVER, // objects move function, gets x y and but |
---|
| 63 | OFUN_DRAW, |
---|
| 64 | OFUN_MAP_DRAW, |
---|
| 65 | OFUN_DAMAGE, // called when the object receives damage |
---|
| 66 | OFUN_NEXT_STATE, // called at the end of an object sequence |
---|
| 67 | OFUN_USER_FUN, // can by called (user_fun x y z) |
---|
| 68 | OFUN_CONSTRUCTOR, // called when object is created, dev & play modes |
---|
| 69 | OFUN_RELOAD, // called when the object is loaded from disk (not save games) |
---|
| 70 | OFUN_GET_CACHE_LIST, // called on level load, should return list (a . b) a is character id, and b is other ids |
---|
| 71 | OFUN_CHANGE_TYPE |
---|
| 72 | } ; |
---|
| 73 | extern char *ofun_names[TOTAL_OFUNS]; |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | class character_type |
---|
| 77 | { |
---|
| 78 | public : |
---|
| 79 | ushort ts,tiv,tv; // total states, total index vars, total local vars |
---|
| 80 | sequence **seq; // [0..ts-1] |
---|
| 81 | void **seq_syms; // symbol describing what this state is [0..ts-1] |
---|
| 82 | |
---|
| 83 | void **vars; // symbol describing variable names [0..tiv-1] |
---|
| 84 | short *var_index; // index into local var [0..tiv-1] |
---|
| 85 | |
---|
| 86 | void add_var(void *symbol, void *name); |
---|
| 87 | int add_state(void *symbol); // returns index into seq to use |
---|
| 88 | int abil[TOTAL_ABILITIES]; |
---|
| 89 | void *fun_table[TOTAL_OFUNS]; // pointers to lisp function for this object |
---|
| 90 | int logo,morph_mask,morph_power; |
---|
| 91 | long rangex,rangey,draw_rangex,draw_rangey; // range off screen before character is skipped |
---|
| 92 | |
---|
| 93 | ushort cflags; |
---|
| 94 | void *get_fun(int name) { return fun_table[name]; } |
---|
| 95 | int get_cflag(int name) { return cflags&(1<<name); } |
---|
| 96 | void set_cflag(int name, int x) { if (x) cflags|=(1<<name); else cflags&=~(1<<name); } |
---|
| 97 | int total_fields; // used by game editor to replace field names |
---|
| 98 | named_field **fields; |
---|
| 99 | character_type(void *args, void *name); // lisp object describes object |
---|
| 100 | |
---|
| 101 | sequence *get_sequence(character_state s); |
---|
| 102 | void add_sequence(character_state which, sequence *new_seq); |
---|
| 103 | int has_sequence(character_state s) { return s<ts && (seq[s]!=NULL); } |
---|
| 104 | int cache_in(); // returns false if out of cache memory |
---|
| 105 | void check_sizes(); |
---|
| 106 | long isa_var_name(char *name); |
---|
| 107 | |
---|
| 108 | ~character_type(); |
---|
| 109 | } ; |
---|
| 110 | |
---|
| 111 | extern character_type **figures; |
---|
| 112 | int flinch_state(character_state state); |
---|
| 113 | |
---|
| 114 | void *def_char(void *args); |
---|
| 115 | |
---|
| 116 | extern int total_weapons; |
---|
| 117 | extern int *weapon_types; // maps 0..total_weapons into 'real' weapon type |
---|
| 118 | |
---|
| 119 | #endif |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|