#include "chars.hpp" #include "game.hpp" #include "intsect.hpp" #include "lisp.hpp" #include "jwindow.hpp" #include "input.hpp" #include "id.hpp" #include "clisp.hpp" #include "dprint.hpp" #include "lisp_gc.hpp" #define FADING_FRAMES 26 #define FADING_MAX 32 character_type **figures; int total_weapons=0; int *weapon_types=NULL; // maps 0..total_weapons into 'real' weapon type char *state_names[MAX_STATE]= { "dead", "dieing", "stopped", "start_run_jump","run_jump","run_jump_fall","end_run_jump", "flinch_up","flinch_down", "morph_pose", "running" }; /* "start_still_jump","still_jump","still_jump_fall","end_still_jump", "morph_pose", "walking", "weapon_draw", "weapon_put_away", "weapon_fire", "weapon_end_fire", "weapon_fire_up", "weapon_end_fire_up", "blocking", "block_recoil", "turn_around", "flinch_up","flinch_down","flinch_back", "flinch_air","flinch_ground","flinch_getup","woze", "stance" } ; */ char *cflag_names[TOTAL_CFLAGS]={"hurt_all","is_weapon","stoppable","can_block", "hurtable","pushable","unlistable", "add_front","cached_in","need_cache_in","unactive_shield"}; char *ofun_names[TOTAL_OFUNS]={"ai_fun","move_fun","draw_fun","map_draw_fun","damage_fun", "next_state_fun","user_fun", "constructor","reload_fun","get_cache_list_fun", "type_change_fun"}; int character_type::add_state(void *symbol) // returns index into seq to use { if (item_type(symbol)!=L_SYMBOL) { lprint(symbol); lbreak("is not a symbol (in def_char)"); exit(0); } void *val=symbol_value(symbol); int num; if (DEFINEDP(val)) { if (item_type(val)!=L_NUMBER) { lprint(symbol); dprintf("expecting symbol value to be a number, instead got : "); lprint(val); lbreak(""); exit(0); } num=lnumber_value(val); } else { num=ts; if (num=ts) { seq=(sequence **)jrealloc(seq,sizeof(sequence *)*(num+1),"state list"); seq_syms=(void **)jrealloc(seq_syms,sizeof(void *)*(num+1),"state sym list"); memset(&seq[ts],0,sizeof(sequence *)*((num+1)-ts)); memset(&seq_syms[ts],0,sizeof(void *)*((num+1)-ts)); ts=num+1; } seq_syms[num]=symbol; return num; } int flinch_state(character_state state) { if (state==flinch_up || state==flinch_down) return 1; else return 0; } int character_type::cache_in() // returns false if out of cache memory { int i; if (get_cflag(CFLAG_CACHED_IN)) return 1; cflags|=1<cache_in(); } return 1; } void character_type::add_sequence(character_state which, sequence *new_seq) { if (seq[which]) delete seq[which]; seq[which]=new_seq; } void *l_obj_get(long number) // exten lisp function switches on number { character_type *t=figures[current_object->otype]; if (t->tiv<=number || !t->vars[number]) { lbreak("access : variable does not exsist for this class\n"); return 0; } return new_lisp_number(current_object->lvars[t->var_index[number]]); } void l_obj_set(long number, void *arg) // exten lisp function switches on number { character_type *t=figures[current_object->otype]; if (t->tiv<=number || !t->vars[number]) { lbreak("set : variable does not exsist for this class\n"); return; } current_object->lvars[t->var_index[number]]=lnumber_value(arg); } void l_obj_print(long number) // exten lisp function switches on number { character_type *t=figures[current_object->otype]; if (t->tiv<=number || !t->vars[number]) { lbreak("access : variable does not exsist for this class\n"); return; } dprintf("%d",current_object->lvars[t->var_index[number]]); } void character_type::add_var(void *symbol, void *name) { /* First see if the variable has been defined for another object if so report a conflict if any occur */ lisp_symbol *s=(lisp_symbol *)symbol; if (DEFINEDP(s->value) && (item_type(s->value)!=L_OBJECT_VAR)) { lprint(symbol); lbreak("symbol already has a value, cannot instantiate an object varible"); exit(0); } else if (DEFINEDP(s->value)) { int index=((lisp_object_var *)s->value)->number; if (indexcheck_sizes(); } } void character_type::check_sizes() { for (int i=0;i