source: golgotha/src/golg/objs/stank.hh

Last change on this file 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: 6.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#ifndef G1_PLAYER_PEICE_HH
10#define G1_PLAYER_PEICE_HH
11
12#include "objs/map_piece.hh"
13#include "path.hh"
14#include "sound/sound.hh"
15
16
17extern g1_object_type g1_supertank_type;
18
19class g1_buster_rocket_class;
20class g1_camera_info_struct;       // golg/camera.hh
21
22
23// defines info about the current state of a weapon ammo type for each supertank
24struct g1_stank_ammo_info_struct
25{
26  g1_stank_ammo_type_struct *ammo_type;
27  w16 amount;           // shots remaining
28  w16 delay_remaining;  // delay until next shot
29  w16 refuel_delay_remaining;  // delay till next 'fuel'
30  i4_bool need_refresh; // if border frame should redraw this ammo slot
31 
32  g1_typed_reference_class<g1_object_class> current_target;
33  int ticks_this_has_been_my_current_target;
34 
35  void setup(li_symbol *sym);
36 
37  void save(g1_saver_class *fp);
38  void load(g1_loader_class *fp);
39 
40  // so we can update electric beams & machine gun - continous stream type weapons
41  g1_typed_reference_class<g1_object_class> last_fired_object;
42  g1_stank_ammo_info_struct() { ammo_type=0; amount=0; need_refresh=i4_T; }
43};
44
45
46class g1_player_piece_class : public g1_map_piece_class
47{
48public:
49  void check_for_powerups();
50  void check_for_refuel();
51  void check_if_turret_in_ground();
52  void draw_target_cursors(g1_draw_context_class *context);
53  void look_for_targets();
54 
55  static g1_player_piece_class *cast(g1_object_class *obj)
56  {
57    if (!obj || !obj->get_type()->get_flag(g1_object_definition_class::TO_PLAYER_PIECE))
58      return 0;
59
60    return (g1_player_piece_class*)obj;
61  }
62
63  //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
64  enum { DATA_VERSION=8 };       // main data version
65  enum { BASE_DATA_VERSION=1 };
66  void save_base_info(g1_saver_class *fp);
67  void load_base_info(g1_loader_class *fp);
68  i4_float base_angle, lbase_angle;
69  i4_float strafe_speed;
70  i4_float cur_top_attach;
71  w32      move_tick;       // for vibrating top
72  w32      upgrade_level_when_built;
73  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74
75  // path information
76  enum {NO_PATH, GAME_PATH, FINAL_POINT};
77  g1_path_handle path;
78
79  // user input
80  i4_float accel_ratio;
81  i4_float strafe_accel_ratio;
82  i4_float dtheta;
83  i4_bool fire[3];
84
85  //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
86  enum { MOUSE_LOOK_DATA_VERSION=1 };           
87  void save_mouse_look_info(g1_saver_class *fp);
88  void load_mouse_look_info(g1_loader_class *fp);
89
90  i4_float mouse_look_increment_x,mouse_look_increment_y;
91  i4_float mouse_look_x,mouse_look_y;           
92  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93
94  //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
95  enum { AMMO_DATA_VERSION=3 };
96  void save_ammo_info(g1_saver_class *fp);
97  void load_ammo_info(g1_loader_class *fp);
98 
99  enum { MAX_WEAPONS=4 };
100  g1_stank_ammo_info_struct ammo[MAX_WEAPONS];       // 0=main, 1=missiles, 2=chain
101  void find_weapons();
102
103  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104
105
106  // vvvvvvvvvvvvvvvvvv --- not saved --- vvvvvvvvvvvvvvvvvvvv 
107  i4_float turret_kick, lturret_kick; //just an aesthetic thing, the turret kicks back when fired
108 
109  s1_sound_handle refuel_sound;
110
111  enum { ORIGNAL_RUMBLE_VOLUME=I4_SOUND_VOLUME_LEVELS/8 };
112
113  enum
114  {
115    ST_REFUELING = 1<<0, // set when on refueling pad, will cause blue glow to occur
116    ST_DAMAGED   = 1<<1, // set when damaged, controller will use damage_count to make red
117    ST_GODMODE   = 1<<2, // invulnerable
118    ST_INFLIGHT  = 1<<3, // in the air!
119    ST_SLIDING   = 1<<4, // sliding!
120  };
121         
122  w32 stank_flags;
123
124
125  void toggle_stank_flag(w32 flag)
126  {
127    if (stank_flags & flag)
128      stank_flags &= (~flag);
129    else
130      stank_flags |= flag;
131  }
132
133  i4_bool get_stank_flag(w32 flag)
134  {
135    return stank_flags & flag;
136  }
137
138  void set_stank_flag(w32 flag, i4_bool value=i4_T)
139  {
140    if (value)
141      stank_flags |= flag;
142    else
143      stank_flags &= (~flag);
144  }
145
146  i4_bool strafe_left();
147  i4_bool strafe_right();
148  void turn_right();
149  void turn_left();
150  void accelerate_forward();
151  void accelerate_backward();
152  void track_base(i4_float desired_angle);
153
154
155  // get the position where the bullet where leave the barel and the direction it travels
156  void get_bullet_exit(i4_3d_vector &pos, i4_3d_vector &dir);
157
158  enum find_view_type { USE_SLOP, USE_SCREEN };
159  g1_object_class *find_view_target(const i4_3d_vector &view_pos,
160                                    const i4_3d_vector &view_dir,
161                                    find_view_type type,
162                                    float max_dist);
163
164  i4_bool in_range(int slot_number, g1_object_class *o) const;
165  i4_bool fire_weapon(int slot_number);
166  void save(g1_saver_class *fp);
167
168  virtual void draw(g1_draw_context_class *context);
169  virtual void think();
170  void set_path(g1_path_handle _path);
171  virtual i4_bool deploy_to(float x, float y);
172  w32 follow_path();
173  i4_bool move(i4_float x_amount, i4_float y_amount);
174  i4_bool suggest_move(i4_float &dist,
175                       i4_float &dtheta,
176                       i4_float &dx, i4_float &dy,
177                       i4_float brake_speed=0.1);
178  void lead_target(i4_3d_point_class &lead_point, int slot_number);
179
180  //override the damage so that we can turn on god mode
181  virtual void damage(g1_object_class *obj, int hp, i4_3d_vector damage_dir);
182
183  //override this so we can keep kill / damage stats
184  virtual void notify_damage(g1_object_class *obj, sw32 hp);
185
186  g1_player_piece_class(g1_object_type id, g1_loader_class *fp);
187  ~g1_player_piece_class();
188
189  class g1_mini_object *turret;
190 
191  virtual void calc_action_cam(g1_camera_info_struct &cam, float frame_ratio);
192 
193  //this is the current "lock" target (the one most near the center of view)
194  g1_typed_reference_class<g1_object_class> lock_target;
195
196  g1_typed_reference_class<g1_object_class> laser_target;
197};
198
199#endif
Note: See TracBrowser for help on using the repository browser.