source: golgotha/src/golg/objs/map_piece.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 5.6 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9// Golgatha Map Object Class
10//
11
12#ifndef MAP_PIECE_HH
13#define MAP_PIECE_HH
14
15#include "g1_object.hh"
16#include "sound_man.hh"
17#include "player_type.hh"
18#include "range.hh"
19#include "objs/defaults.hh"
20#include "objs/model_draw.hh"
21#include "objs/model_collide.hh"
22#include "obj3d.hh"
23#include "global_id.hh"
24#include "sound/sfx_id.hh"
25#include "objs/vehic_sounds.hh"
26
27class g1_path_object_class;     // objs/path_object.hh
28
29class g1_map_piece_class : public g1_object_class
30{
31public:
32  void fix_forward_link(g1_object_class *next) { next_object = next; }
33  void fix_previous_link(g1_object_class *prev) { prev_object = prev; }
34protected:
35  friend g1_path_object_class;
36
37  g1_typed_reference_class<g1_object_class> next_object;
38  g1_typed_reference_class<g1_object_class> prev_object;
39  i4_float path_pos, path_len;
40  i4_float path_cos, path_sin, path_tan_phi;
41  i4_float stagger;
42
43  void unlink();
44  void link(g1_object_class *origin);
45public:
46  g1_object_defaults_struct *defaults;
47 
48  i4_float           speed;          // current speed of the piece
49  i4_float           vspeed;         // vertical speed of the piece
50  i4_float           dest_x, dest_y; // if it has a destination, its point & direction is here
51  i4_float           dest_z;         // if it has a destination height
52  i4_float           dest_theta;
53  w16                fire_delay;     // number of game ticks before we can fire again
54
55  g1_id_ref         *path_to_follow;  // null terminated array of global id's
56  g1_id_ref          next_path;
57
58  // calculated values
59  i4_float           tread_pan;      // accumulated tread texture pan based on speed
60  i4_float           terrain_height; // terrain under vehicle
61  i4_float           groundpitch, lgroundpitch;
62  i4_float           groundroll, lgroundroll;
63  i4_float           damping_fraction;
64  w8                 ticks_to_blink;   // when taking damage (not saved)
65
66  w8                 death;          // type of death desired
67
68  i4_3d_vector       damage_direction; //inertia vector of whatever attacked last (or killed us)
69
70  g1_typed_reference_class<g1_object_class> attack_target;  // the thing its targeting
71 
72  g1_map_piece_class(g1_object_type id, g1_loader_class *fp);
73
74  void add_team_flag();
75  i4_bool alive() const { return health>0; }
76
77  virtual void hit_ground();      // when an object falls off a cliff and hits the ground
78  void find_target(i4_bool unfog=i4_T);
79  virtual i4_bool find_target_now() const;
80
81  virtual void damage(g1_object_class *obj, int hp, i4_3d_vector damage_dir);
82
83  void lead_target(i4_3d_point_class &lead_point, i4_float shot_speed=-1);
84 
85  virtual void save(g1_saver_class *fp);
86
87  virtual float detection_range() const { return defaults->detection_range; }
88 
89  virtual i4_bool check_move(i4_float dest_x,i4_float dest_y) const;
90
91  virtual i4_bool check_collision(const i4_3d_vector &start, i4_3d_vector &ray)
92  { return g1_model_collide_radial(this, draw_params, start, ray); }
93
94  virtual void calc_world_transform(i4_float ratio, i4_transform_class *transform=0);
95
96  //Sound Effects
97
98  virtual void set_path(g1_id_ref *path);  // null terminated array of global id's
99
100 
101  g1_rumble_type rumble_type;
102  void init_rumble_sound(g1_rumble_type type);
103
104  virtual void init();
105
106  virtual void think();
107
108
109
110  virtual void draw(g1_draw_context_class *context);
111
112  i4_bool check_turn_radius();
113
114#if 0 //(OLI) kill this soon!
115  //advances a piece one step to its dest_x,dest_y, following general guidelines
116  //for speeding up, slowing down, backing up, etc
117  //returns which direction (-1,0,1) it moved and which direction (-1,0,1) it turned
118  //in arguments ret_direction and ret_dt
119  i4_float advance_to_dest(w32 pathinfo, sw8 &ret_direction, sw8 &ret_dt,
120                           i4_float brake_speed=0.9);
121#endif
122
123  virtual void request_remove();
124
125  void advance_path();
126
127  i4_bool suggest_move(i4_float &dist,
128                       i4_float &dtheta,
129                       i4_float &dx, i4_float &dy,
130                       i4_float brake_speed=0.1,
131                       i4_bool reversible=i4_T);
132 
133  i4_bool suggest_air_move(i4_float &dist,
134                           i4_float &dtheta,
135                           i4_3d_vector &d);
136 
137  //checks the health to make sure the object is still alive
138  //if health is <0, the object is removed from the map, and i4_F returned
139  i4_bool check_life(i4_bool remove_if_dead=i4_T);
140
141  void get_terrain_info();
142  i4_bool occupy_location()
143  {
144    int ret;
145    if (ret = g1_object_class::occupy_location())
146      get_terrain_info();
147    return ret;
148  }
149
150  virtual void grab_old()
151  {
152    g1_object_class::grab_old();
153   
154    lgroundpitch = groundpitch;
155    lgroundroll  = groundroll;
156  }
157
158  // standard movement
159  i4_bool move(i4_float x_amount, i4_float y_amount);
160
161  static g1_map_piece_class *cast(g1_object_class *obj)
162  {
163    if (!obj || !(obj->get_type()->get_flag(g1_object_definition_class::TO_MAP_PIECE)))
164      return 0;
165    return (g1_map_piece_class*)obj;
166  }
167
168  virtual i4_bool can_attack(g1_object_class *who) const;
169  i4_bool in_range(g1_object_class *o) const;
170};
171
172#endif
Note: See TracBrowser for help on using the repository browser.