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

Last change on this file since 555 was 555, checked in by Sam Hocevar, 9 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

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