source: abuse/trunk/src/chars.h @ 481

Last change on this file since 481 was 481, checked in by Sam Hocevar, 11 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

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