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

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

style: remove trailing spaces, fix copyright statements.

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