Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Portions of this file are copyright Rebirth contributors and licensed as
  3.  * described in COPYING.txt.
  4.  * Portions of this file are copyright Parallax Software and licensed
  5.  * according to the Parallax license below.
  6.  * See COPYING.txt for license details.
  7.  
  8. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  9. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  10. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  11. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  12. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  13. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  14. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  15. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  16. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  17. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  18. */
  19.  
  20. /*
  21.  *
  22.  * Protypes for weapon stuff.
  23.  *
  24.  */
  25.  
  26. #pragma once
  27.  
  28. #ifdef __cplusplus
  29. #include "pack.h"
  30. #include "pstypes.h"
  31. #include "maths.h"
  32. #include "dxxsconf.h"
  33. #include "dsx-ns.h"
  34. #include "weapon_id.h"
  35.  
  36. #include "fwd-object.h"
  37. #include "fwd-vclip.h"
  38. #include <array>
  39.  
  40. enum powerup_type_t : uint8_t;
  41.  
  42. #if defined(DXX_BUILD_DESCENT_II)
  43. #define LASER_HELIX_MASK        7   // must match number of bits in flags
  44. #define MAX_SUPER_LASER_LEVEL   LASER_LEVEL_6   // Note, laser levels are numbered from 0.
  45. #endif
  46.  
  47. #if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
  48.  
  49. struct PHYSFS_File;
  50. #if 0
  51. void weapon_info_write(PHYSFS_File *, const weapon_info &);
  52. #endif
  53.  
  54. namespace dsx {
  55. enum laser_level_t : uint8_t;
  56. class stored_laser_level;
  57. struct weapon_info;
  58.  
  59. #define REARM_TIME                  (F1_0)
  60.  
  61. #define WEAPON_DEFAULT_LIFETIME     (F1_0*12)   // Lifetime of an object if a bozo forgets to define it.
  62.  
  63. #define WEAPON_TYPE_WEAK_LASER      0
  64. #define WEAPON_TYPE_STRONG_LASER    1
  65. #define WEAPON_TYPE_CANNON_BALL     2
  66. #define WEAPON_TYPE_MISSILE         3
  67.  
  68. #define WEAPON_RENDER_NONE          -1
  69. #define WEAPON_RENDER_LASER         0
  70. #define WEAPON_RENDER_BLOB          1
  71. #define WEAPON_RENDER_POLYMODEL     2
  72. #define WEAPON_RENDER_VCLIP         3
  73.  
  74. #if defined(DXX_BUILD_DESCENT_I)
  75. constexpr std::integral_constant<unsigned, 30> MAX_WEAPON_TYPES{};
  76.  
  77. constexpr std::integral_constant<unsigned, 5> MAX_PRIMARY_WEAPONS{};
  78. constexpr std::integral_constant<unsigned, 5> MAX_SECONDARY_WEAPONS{};
  79.  
  80. #elif defined(DXX_BUILD_DESCENT_II)
  81. // weapon info flags
  82. #define WIF_PLACABLE        1   // can be placed by level designer
  83. constexpr std::integral_constant<unsigned, 70> MAX_WEAPON_TYPES{};
  84.  
  85. constexpr std::integral_constant<unsigned, 10> MAX_PRIMARY_WEAPONS{};
  86. constexpr std::integral_constant<unsigned, 10> MAX_SECONDARY_WEAPONS{};
  87. #endif
  88.  
  89. extern const std::array<weapon_id_type, MAX_PRIMARY_WEAPONS> Primary_weapon_to_weapon_info;
  90. //for each primary weapon, what kind of powerup gives weapon
  91. extern const std::array<powerup_type_t, MAX_PRIMARY_WEAPONS> Primary_weapon_to_powerup;
  92. extern const std::array<weapon_id_type, MAX_SECONDARY_WEAPONS> Secondary_weapon_to_weapon_info;
  93. //for each Secondary weapon, what kind of powerup gives weapon
  94. extern const std::array<powerup_type_t, MAX_SECONDARY_WEAPONS> Secondary_weapon_to_powerup;
  95. extern const std::array<uint8_t, MAX_SECONDARY_WEAPONS>    Secondary_ammo_max;
  96. /*
  97.  * reads n weapon_info structs from a PHYSFS_File
  98.  */
  99. using weapon_info_array = std::array<weapon_info, MAX_WEAPON_TYPES>;
  100. extern weapon_info_array Weapon_info;
  101. void weapon_info_read_n(weapon_info_array &wi, std::size_t count, PHYSFS_File *fp, int file_version, std::size_t offset = 0);
  102.  
  103. //given a weapon index, return the flag value
  104. #define  HAS_PRIMARY_FLAG(index)  (1<<(index))
  105. #define  HAS_SECONDARY_FLAG(index)  (1<<(index))
  106.  
  107. // Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon
  108. #define HAS_LASER_FLAG      HAS_PRIMARY_FLAG(primary_weapon_index_t::LASER_INDEX)
  109. #define HAS_VULCAN_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::VULCAN_INDEX)
  110. #define HAS_SPREADFIRE_FLAG HAS_PRIMARY_FLAG(primary_weapon_index_t::SPREADFIRE_INDEX)
  111. #define HAS_PLASMA_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::PLASMA_INDEX)
  112. #define HAS_FUSION_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::FUSION_INDEX)
  113.  
  114. enum primary_weapon_index_t : uint8_t;
  115. enum secondary_weapon_index_t : uint8_t;
  116.  
  117. #define NUM_SMART_CHILDREN  6   // Number of smart children created by default.
  118. #if defined(DXX_BUILD_DESCENT_I)
  119. #define NUM_SHAREWARE_WEAPONS   3               //in shareware, old get first 3 of each
  120. #elif defined(DXX_BUILD_DESCENT_II)
  121. #define HAS_SUPER_LASER_FLAG    HAS_PRIMARY_FLAG(primary_weapon_index_t::SUPER_LASER_INDEX)
  122. #define HAS_GAUSS_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::GAUSS_INDEX)
  123. #define HAS_HELIX_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::HELIX_INDEX)
  124. #define HAS_PHOENIX_FLAG   HAS_PRIMARY_FLAG(primary_weapon_index_t::PHOENIX_INDEX)
  125. #define HAS_OMEGA_FLAG     HAS_PRIMARY_FLAG(primary_weapon_index_t::OMEGA_INDEX)
  126. #define SUPER_WEAPON        5
  127. //flags whether the last time we use this weapon, it was the 'super' version
  128. #endif
  129. //for each Secondary weapon, which gun it fires out of
  130. extern const std::array<uint8_t, MAX_SECONDARY_WEAPONS> Secondary_weapon_to_gun_num;
  131. }
  132.  
  133. namespace dcx {
  134. extern unsigned N_weapon_types;
  135. template <typename T>
  136. class player_selected_weapon : public prohibit_void_ptr<player_selected_weapon<T>>
  137. {
  138.         T active, delayed;
  139. public:
  140.         operator T() const
  141.         {
  142.                 return get_active();
  143.         }
  144.         T get_active() const
  145.         {
  146.                 return active;
  147.         }
  148.         T get_delayed() const
  149.         {
  150.                 return delayed;
  151.         }
  152.         player_selected_weapon &operator=(T v)
  153.         {
  154.                 active = v;
  155.                 set_delayed(v);
  156.                 return *this;
  157.         }
  158.         void set_delayed(T v)
  159.         {
  160.                 delayed = v;
  161.         }
  162. };
  163.  
  164. }
  165. #ifdef dsx
  166. namespace dsx {
  167.  
  168. struct player_info;
  169. void do_primary_weapon_select(player_info &, uint_fast32_t weapon_num);
  170. void do_secondary_weapon_select(player_info &, secondary_weapon_index_t weapon_num);
  171. void auto_select_primary_weapon(player_info &);
  172. void auto_select_secondary_weapon(player_info &);
  173. void set_primary_weapon(player_info &, uint_fast32_t weapon_num);
  174. void select_primary_weapon(player_info &, const char *weapon_name, uint_fast32_t weapon_num, int wait_for_rearm);
  175. void set_secondary_weapon_to_concussion(player_info &);
  176. void select_secondary_weapon(player_info &, const char *weapon_name, uint_fast32_t weapon_num, int wait_for_rearm);
  177.  
  178. }
  179. #endif
  180. class has_weapon_result;
  181.  
  182. //-----------------------------------------------------------------------------
  183. // Return:
  184. // Bits set:
  185. //      HAS_WEAPON_FLAG
  186. //      HAS_ENERGY_FLAG
  187. //      HAS_AMMO_FLAG
  188. #ifdef dsx
  189. namespace dsx {
  190. has_weapon_result player_has_primary_weapon(const player_info &, int weapon_num);
  191. has_weapon_result player_has_secondary_weapon(const player_info &, secondary_weapon_index_t weapon_num);
  192.  
  193. //called when one of these weapons is picked up
  194. //when you pick up a secondary, you always get the weapon & ammo for it
  195. int pick_up_primary(player_info &, int weapon_index);
  196. int pick_up_secondary(player_info &, int weapon_index,int count);
  197.  
  198. //called when a primary weapon is picked up
  199. //returns true if actually picked up
  200. }
  201. #endif
  202.  
  203. //called when ammo (for the vulcan cannon) is picked up
  204.  
  205. namespace dsx {
  206. int pick_up_vulcan_ammo(player_info &player_info, uint_fast32_t ammo_count, bool change_weapon = true);
  207. //this function is for when the player intentionally drops a powerup
  208. imobjptridx_t spit_powerup(const d_vclip_array &Vclip, const object_base &spitter, unsigned id, unsigned seed);
  209.  
  210. #if defined(DXX_BUILD_DESCENT_II)
  211. int attempt_to_steal_item(vmobjptridx_t objp, vmobjptr_t playerobjp);
  212.  
  213. #define SMEGA_ID    40
  214.  
  215. void weapons_homing_all();
  216. void weapons_homing_all_reset();
  217.  
  218. extern void rock_the_mine_frame(void);
  219. extern void smega_rock_stuff(void);
  220. extern void init_smega_detonates(void);
  221. #endif
  222. }
  223. #endif
  224.  
  225. #ifdef dsx
  226. namespace dsx {
  227. void InitWeaponOrdering();
  228. void CyclePrimary(player_info &);
  229. void CycleSecondary(player_info &);
  230. }
  231. #endif
  232. void ReorderPrimary();
  233. void ReorderSecondary();
  234. #ifdef dsx
  235. namespace dsx {
  236. #if defined(DXX_BUILD_DESCENT_II)
  237. void check_to_use_primary_super_laser(player_info &player_info);
  238. void init_seismic_disturbances(void);
  239. void process_super_mines_frame(void);
  240. void do_seismic_stuff();
  241. #endif
  242. void DropCurrentWeapon(player_info &);
  243. void DropSecondaryWeapon(player_info &);
  244. }
  245. #endif
  246.  
  247. #endif
  248.