source: abuse/trunk/src/chars.hpp @ 97

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