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

Last change on this file since 481 was 481, checked in by Sam Hocevar, 12 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: 5.9 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 _OBJECTS_HPP_
11#define _OBJECTS_HPP_
12#include "input.h"
13#include "chars.h"
14//#include "sound.h"
15#include "morpher.h"
16#include "loader2.h"
17#include "view.h"
18#include "extend.h"
19
20class view;
21
22extern char **object_names;
23extern int total_objects;
24
25#define NOT_BLOCKED 0
26#define BLOCKED_LEFT 1
27#define BLOCKED_RIGHT 2
28#define BLOCKED_UP 4
29#define BLOCKED_DOWN 8
30
31
32
33#define FIRST_ATTACK atk_fast
34#define LAST_ATTACK attack_special
35
36
37
38
39#define RC_8 0
40#define RC_16 1
41#define RC_32 2
42
43
44
45
46
47#define TOTAL_OBJECT_VARS 28
48struct obj_desc { char const *name; int type; } ;
49extern obj_desc object_descriptions[TOTAL_OBJECT_VARS];
50int RC_type_size(int type);
51//void init_object_offsets();
52
53
54class game_object : public simple_object
55{
56  sequence *current_sequence() { return figures[otype]->get_sequence(state); }
57public :
58  game_object *next,*next_active;
59  int32_t *lvars;
60
61  int size();
62  int decide();        // returns 0 if you want to be deleted
63  int type() { return otype; }
64  ifield *make_fields(int ystart, ifield *Next) { return NULL ; }
65  void gather_input(InputManager *inm) { ; }
66  int hurt_all() { return figures[otype]->get_cflag(CFLAG_HURT_ALL); }
67  int stoppable() { return figures[otype]->get_cflag(CFLAG_STOPPABLE); }
68  int can_block() { return figures[otype]->get_cflag(CFLAG_CAN_BLOCK); }
69
70  int hurtable() { return figures[otype]->get_cflag(CFLAG_HURTABLE); }
71  int pushable() { return figures[otype]->get_cflag(CFLAG_PUSHABLE); }
72
73  void draw();
74  void map_draw();
75  void draw_trans(int count, int max);
76  void draw_tint(int tint_id);
77  void draw_double_tint(int tint_id1, int tint_id2);
78  void draw_predator();
79
80
81  void drawer();
82  void draw_above(view *v);
83  void do_damage(int amount, game_object *from, int32_t hitx, int32_t hity, int32_t push_xvel, int32_t push_yvel);
84  void damage_fun(int amount, game_object *from, int32_t hitx, int32_t hity, int32_t push_xvel, int32_t push_yvel);
85
86
87  void note_attack(game_object *whom);
88  void recieve_signal(long singal) { ; }
89  int push_range();
90  int can_hurt(game_object *who);     // collision checking will ask first to see if you
91                              // can hurt this person before calculating weither you actually do
92
93  void load(int type, bFILE *fp, unsigned char *state_remap);
94  int tick();  // should be called from decide, does the physics on the people, returns blocked status
95  void *float_tick();  // returns T or blocked structure =
96                       // (block_flags 'tile tilex tiley)
97                       // (block_flags 'object obj)
98
99  void next_sequence();
100
101  int facing_attacker(int attackerx);
102  void set_state(character_state s, int frame_direction=1);
103  int has_sequence(character_state s) { return figures[otype]->has_sequence(s); }
104
105  game_object *try_move(int32_t x, int32_t y, int32_t &xv, int32_t &yv, int checks);  // 1=down,2=up,3=both
106  game_object *bmove(int &whit, game_object *exclude);  // ballestic move, return hit object,
107                                                        // or NULL (whit is 1 if hit wall)
108  trans_image *picture() { return current_sequence()->get_frame(current_frame,direction); }
109                                               
110  int next_picture();
111  int32_t x_center();
112  int32_t height();
113
114  void stop_acel() { set_xacel(0);  set_yacel(0); set_fxacel(0); set_fyacel(0); }
115  void stop_vel() {  set_xvel(0);   set_yvel(0); set_fxvel(0);  set_fyvel(0); }
116  void stop_x() {  set_xvel(0);  set_fxvel(0); set_xacel(0); set_fxacel(0); }
117  void stop()
118  { set_xvel(0);   set_yvel(0); set_fxvel(0);  set_fyvel(0);
119    set_xacel(0);  set_yacel(0); set_fxacel(0); set_fyacel(0);
120  }
121
122  int move(int cx, int cy, int button);  // return blocked status
123  int mover(int cx, int cy, int button);
124  figure *current_figure() { return current_sequence()->get_figure(current_frame); }
125  int total_frames() { return current_sequence()->length(); }
126  void picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2);
127  int tx(int x) { if (direction>0) return x-x_center(); else return x_center()-x; }
128  int ty(int y) { return y-picture()->height()+1; }
129  void defaults();
130
131  game_object(int Type, int load=0);
132  ~game_object();
133
134  int is_playable() { return hurtable(); }
135  void add_power(int amount);
136  void add_hp(int amount);
137  int can_morph_into(int type);
138  void morph_into(int type, void (*stat_fun)(int), int anneal, int frames);
139  void do_flinch(game_object *from);
140  void set_aimemory(game_object *p) { add_object(p); p->set_flags(p->flags()|KNOWN_FLAG); }
141  int alive() { if (state==dead || hp()<=0) return 0; else return 1; }
142  void frame_advance();
143  object_node *make_not_list(object_node *first);
144  int reduced_state();
145  void reload_notify();
146
147  void change_type(int new_type);
148  int set_var_by_name(char *name, int32_t value);
149  int32_t get_var_by_name(char *name, int &error);
150  game_object *copy();
151  void change_aitype(int new_type);
152
153  int get_tint() { return _tint; }
154  void set_tint(int tint)
155  {
156    for(int i = 0; i < tobjs; i++)
157      get_object(i)->_tint = tint;
158    _tint = tint;
159  }
160  int get_team() { return _team; }
161  void set_team(int team)
162  {
163    for(int i = 0; i < tobjs; i++)
164      get_object(i)->_team = team;
165    _team = team;
166  }
167} ;
168
169class object_node  // used to create various list of objects
170{
171  public :
172  game_object *me;
173  object_node *next;
174  object_node(game_object *Me, object_node *Next) { me=Me; next=Next; }
175} ;
176
177extern game_object *current_object;
178extern view *current_view;
179game_object *create(int type, int32_t x, int32_t y, int skip_constructor=0, int aitype=0);
180int base_size();
181
182void delete_object_list(object_node *first);
183int          object_to_number_in_list(game_object *who, object_node *list);
184game_object *number_to_object_in_list(int32_t x, object_node *list);
185
186
187#endif
188
189
190
191
Note: See TracBrowser for help on using the repository browser.