stank.hh 6.6 KB

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