source: abuse/trunk/src/objects.hpp @ 112

Last change on this file since 112 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: 5.6 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.hpp"
13#include "chars.hpp"
14//#include "sound.hpp"
15#include "morpher.hpp"
16#include "loader2.hpp"
17#include "view.hpp"
18#include "extend.hpp"
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(input_manager *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  game_object(int Type, int load=0);
131  int is_playable() { return hurtable(); }
132  void add_power(int amount);
133  void add_hp(int amount);
134  int can_morph_into(int type); 
135  void morph_into(int type, void (*stat_fun)(int), int anneal, int frames);
136  void do_flinch(game_object *from);
137  void set_aimemory(game_object *p) { add_object(p); p->set_flags(p->flags()|KNOWN_FLAG); }
138  int alive() { if (state==dead || hp()<=0) return 0; else return 1; }
139  void frame_advance();
140  object_node *make_not_list(object_node *first);
141  int reduced_state();
142  void reload_notify();
143
144  void change_type(int new_type);
145  int set_var_by_name(char *name, int32_t value);
146  int32_t get_var_by_name(char *name, int &error);
147  game_object *copy();
148  void change_aitype(int new_type);
149  ~game_object();
150} ;
151
152class object_node  // used to create various list of objects
153{
154  public :
155  game_object *me;
156  object_node *next;
157  object_node(game_object *Me, object_node *Next) { me=Me; next=Next; }
158} ;
159
160extern game_object *current_object;
161extern view *current_view;
162game_object *create(int type, int32_t x, int32_t y, int skip_constructor=0, int aitype=0);
163int base_size();
164
165void delete_object_list(object_node *first);
166int          object_to_number_in_list(game_object *who, object_node *list);
167game_object *number_to_object_in_list(int32_t x, object_node *list);
168
169
170#endif
171
172
173
174
Note: See TracBrowser for help on using the repository browser.