source: abuse/branches/pd/abuse/inc/extend.hpp @ 483

Last change on this file since 483 was 49, checked in by Sam Hocevar, 15 years ago
  • Imported original public domain release, for future reference.
File size: 4.8 KB
Line 
1#ifndef EXTEND_HPP_
2#define EXTEND_HPP_
3
4#define NNET_HISTSIZE 10
5#define FLAG_JUST_HIT     1
6#define FLAG_JUST_BLOCKED 2
7#define FLOATING_FLAG     4
8#define KNOWN_FLAG        8
9
10
11#include "jmalloc.hpp"
12#include "macs.hpp"
13#include "morpher.hpp"
14#include "chars.hpp"
15#include "lisp.hpp"
16
17
18class view;
19class game_object;
20class light_source;
21
22class simple_object
23{
24  public :
25  schar Fade_dir;
26  uchar Fade_count,Fade_max;
27  uchar Flags,grav_on,targetable_on;
28  long Xvel,Yvel,Xacel,Yacel;
29  uchar Fx,Fy,Fxvel,Fyvel,Fxacel,Fyacel;
30  uchar Aitype;
31  ushort Aistate,Aistate_time;
32  unsigned short Hp,Mp,Fmp;
33  schar Frame_dir;       
34
35
36  uchar tobjs,tlights;
37  game_object **objs,*link;
38  light_source **lights;
39
40  view *Controller;
41  morph_char *mc;
42  int total_vars();
43  char *var_name(int x);
44  int   var_type(int x);
45  void set_var(int x, ulong v);
46  long get_var(int x);
47
48  // leave these public, so I don't have monster code changes.
49  simple_object();
50  long x,y,
51       last_x,last_y;              // used for frame interpolation on fast machines
52  schar direction,active;
53  ushort otype;
54  character_state state;
55  short current_frame;
56
57  int targetable()           { return targetable_on; }
58  int gravity()              { return grav_on; }
59  int floating()             { return flags()&FLOATING_FLAG; }
60
61  int keep_ai_info()         { return 1; }
62  uchar flags()              { return Flags; }
63  long xvel()                { return Xvel; }
64  long yvel()                { return Yvel; }
65  long xacel()               { return Xacel; }
66  long yacel()               { return Yacel; }
67
68  uchar fx()                 { return Fx; }
69  uchar fy()                 { return Fy; }
70  uchar fxvel()              { return Fxvel; }
71  uchar fyvel()              { return Fyvel; }
72  uchar fxacel()             { return Fxacel; }
73  uchar fyacel()             { return Fyacel; }
74
75  uchar sfx()                { return Fx; }  // x & y should always be positive
76  uchar sfy()                { return Fy; }
77  uchar sfxvel()             { if (Xvel>=0) return Fxvel; else return -Fxvel; }
78  uchar sfyvel()             { if (Yvel>=0) return Fyvel; else return -Fyvel; }
79  uchar sfxacel()            { if (Xacel>=0) return Fxacel; else return -Fxacel; }
80  uchar sfyacel()            { if (Yacel>=0) return Fyacel; else return -Fyacel; }
81
82  uchar aitype()             { return Aitype; }
83  ushort aistate()           { return Aistate; }
84  ushort aistate_time()      { return Aistate_time; }
85  ushort hp()                { return Hp;         }
86  ushort mp()                { return Mp;         }
87  ushort fmp()               { return Fmp;        }
88  schar fade_dir()           { return Fade_dir;   }
89  schar frame_dir()          { return Frame_dir;  }
90  uchar fade_count()         { return Fade_count; }
91  uchar fade_max()           { return Fade_max;   }
92  uchar total_objects()      { return tobjs;      }
93  uchar total_lights()       { return tlights;    }
94
95  morph_char *morph_status()     { return mc; }
96  light_source *get_light(int x)     
97  { if (x>=tlights) { lbreak("bad x for light\n"); exit(0); } return lights[x]; }
98  game_object *get_object(int x)   
99  { if (x>=tobjs) { lbreak("bad x for object\n"); exit(0); } return objs[x]; }
100  view *controller()             { return Controller; }
101
102  void set_targetable(uchar x)    { targetable_on=x; }
103  void set_flags(uchar f)         { Flags=f; }
104  void set_xvel(long xv)          { Xvel=xv; }
105  void set_yvel(long yv)          { Yvel=yv; }
106  void set_xacel(long xa)         { Xacel=xa; }
107  void set_yacel(long ya)         { Yacel=ya; }
108  void set_fx(uchar x)            { Fx=x; }
109  void set_fy(uchar y)            { Fy=y; }
110  void set_fxvel(uchar xv)        { Fxvel=abs(xv); }
111  void set_fyvel(uchar yv)        { Fyvel=abs(yv); }
112  void set_fxacel(uchar xa)       { Fxacel=abs(xa); }
113  void set_fyacel(uchar ya)       { Fyacel=abs(ya); }
114  void set_aitype(uchar t)        { Aitype=t; }
115  void set_aistate(ushort s)      { Aistate=s; }
116  void set_aistate_time(ushort t) { Aistate_time=t; }
117  void set_hp(ushort h)           { Hp=h; }
118  void set_mp(ushort m)           { Mp=m; }
119  void set_fmp(ushort m)          { Fmp=m; }
120
121
122
123  void set_fade_count(uchar f)          { Fade_count=f; }
124  void set_fade_max(uchar m)            { Fade_max=m;  }
125  void set_fade_dir(schar d)            { Fade_dir=d; }
126
127  void set_frame_dir(schar d)           { Frame_dir=d; }
128  void add_light(light_source *ls);
129  void add_object(game_object *o);
130
131  void remove_object(game_object *o);
132  void remove_light(light_source *ls);
133  void set_morph_status(morph_char *mc);
134  void set_controller(view *v)          { Controller=v; }
135
136  void set_gravity(int x)               { grav_on=x; }
137  void set_floating(int x)
138  { if (x)
139      set_flags(flags()|FLOATING_FLAG);
140    else
141      set_flags(flags()&(0xff-FLOATING_FLAG));
142  }
143
144  void clean_up();
145} ;
146
147
148extern simple_object default_simple;
149
150#endif
151
152
153
154
155
156
157
Note: See TracBrowser for help on using the repository browser.