Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 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 | #include <type_traits> |
||
29 | #include "game.h" |
||
30 | #include "piggy.h" |
||
31 | |||
32 | #ifdef __cplusplus |
||
33 | #include "dxxsconf.h" |
||
34 | #include "dsx-ns.h" |
||
35 | #include "objnum.h" |
||
36 | #include "pack.h" |
||
37 | #include "fwd-valptridx.h" |
||
38 | #include "fwd-weapon.h" |
||
39 | |||
40 | #ifdef dsx |
||
41 | #include <array> |
||
42 | |||
43 | namespace dsx { |
||
44 | |||
45 | enum laser_level_t : uint8_t |
||
46 | { |
||
47 | LASER_LEVEL_1, |
||
48 | LASER_LEVEL_2, |
||
49 | LASER_LEVEL_3, |
||
50 | LASER_LEVEL_4, |
||
51 | #if defined(DXX_BUILD_DESCENT_II) |
||
52 | LASER_LEVEL_5, |
||
53 | LASER_LEVEL_6, |
||
54 | #endif |
||
55 | }; |
||
56 | |||
57 | class stored_laser_level |
||
58 | { |
||
59 | laser_level_t m_level; |
||
60 | public: |
||
61 | stored_laser_level() = default; |
||
62 | constexpr stored_laser_level(const laser_level_t l) : |
||
63 | m_level(l) |
||
64 | { |
||
65 | } |
||
66 | constexpr explicit stored_laser_level(uint8_t i) : |
||
67 | m_level(static_cast<laser_level_t>(i)) |
||
68 | { |
||
69 | } |
||
70 | operator laser_level_t() const |
||
71 | { |
||
72 | return m_level; |
||
73 | } |
||
74 | /* Assume no overflow/underflow. |
||
75 | * This was never checked when it was a simple ubyte. |
||
76 | */ |
||
77 | stored_laser_level &operator+=(uint8_t i) |
||
78 | { |
||
79 | m_level = static_cast<laser_level_t>(static_cast<uint8_t>(m_level) + i); |
||
80 | return *this; |
||
81 | } |
||
82 | stored_laser_level &operator-=(uint8_t i) |
||
83 | { |
||
84 | m_level = static_cast<laser_level_t>(static_cast<uint8_t>(m_level) - i); |
||
85 | return *this; |
||
86 | } |
||
87 | stored_laser_level &operator++() |
||
88 | { |
||
89 | return *this += 1; |
||
90 | } |
||
91 | stored_laser_level &operator--() |
||
92 | { |
||
93 | return *this -= 1; |
||
94 | } |
||
95 | }; |
||
96 | |||
97 | struct weapon_info : prohibit_void_ptr<weapon_info> |
||
98 | { |
||
99 | sbyte render_type; // How to draw 0=laser, 1=blob, 2=object |
||
100 | #if defined(DXX_BUILD_DESCENT_I) |
||
101 | sbyte model_num; // Model num if rendertype==2. |
||
102 | sbyte model_num_inner; // Model num of inner part if rendertype==2. |
||
103 | sbyte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) |
||
104 | |||
105 | sbyte flash_vclip; // What vclip to use for muzzle flash |
||
106 | short flash_sound; // What sound to play when fired |
||
107 | sbyte robot_hit_vclip; // What vclip for impact with robot |
||
108 | short robot_hit_sound; // What sound for impact with robot |
||
109 | |||
110 | sbyte wall_hit_vclip; // What vclip for impact with wall |
||
111 | short wall_hit_sound; // What sound for impact with wall |
||
112 | sbyte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. |
||
113 | sbyte ammo_usage; // How many units of ammunition it uses. |
||
114 | |||
115 | sbyte weapon_vclip; // Vclip to render for the weapon, itself. |
||
116 | sbyte destroyable; // If !0, this weapon can be destroyed by another weapon. |
||
117 | sbyte matter; // Flag: set if this object is matter (as opposed to energy) |
||
118 | sbyte bounce; // Flag: set if this object bounces off walls |
||
119 | |||
120 | sbyte homing_flag; // Set if this weapon can home in on a target. |
||
121 | sbyte dum1, dum2, dum3; |
||
122 | |||
123 | fix energy_usage; // How much fuel is consumed to fire this weapon. |
||
124 | fix fire_wait; // Time until this weapon can be fired again. |
||
125 | |||
126 | bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. |
||
127 | |||
128 | fix blob_size; // Size of blob if blob type |
||
129 | fix flash_size; // How big to draw the flash |
||
130 | fix impact_size; // How big of an impact |
||
131 | std::array<fix, NDL> strength; // How much damage it can inflict |
||
132 | std::array<fix, NDL> speed; // How fast it can move, difficulty level based. |
||
133 | fix mass; // How much mass it has |
||
134 | fix drag; // How much drag it has |
||
135 | fix thrust; // How much thrust it has |
||
136 | fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) |
||
137 | fix light; // Amount of light this weapon casts. |
||
138 | fix lifetime; // Lifetime in seconds of this weapon. |
||
139 | fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit |
||
140 | //-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit |
||
141 | // damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 |
||
142 | bitmap_index picture; // a picture of the weapon for the cockpit |
||
143 | #elif defined(DXX_BUILD_DESCENT_II) |
||
144 | sbyte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) |
||
145 | short model_num; // Model num if rendertype==2. |
||
146 | short model_num_inner; // Model num of inner part if rendertype==2. |
||
147 | |||
148 | sbyte flash_vclip; // What vclip to use for muzzle flash |
||
149 | sbyte robot_hit_vclip; // What vclip for impact with robot |
||
150 | short flash_sound; // What sound to play when fired |
||
151 | |||
152 | sbyte wall_hit_vclip; // What vclip for impact with wall |
||
153 | sbyte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. |
||
154 | short robot_hit_sound; // What sound for impact with robot |
||
155 | |||
156 | sbyte ammo_usage; // How many units of ammunition it uses. |
||
157 | sbyte weapon_vclip; // Vclip to render for the weapon, itself. |
||
158 | short wall_hit_sound; // What sound for impact with wall |
||
159 | |||
160 | sbyte destroyable; // If !0, this weapon can be destroyed by another weapon. |
||
161 | sbyte matter; // Flag: set if this object is matter (as opposed to energy) |
||
162 | sbyte bounce; // 1==always bounces, 2=bounces twice |
||
163 | sbyte homing_flag; // Set if this weapon can home in on a target. |
||
164 | |||
165 | ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 |
||
166 | |||
167 | ubyte flags; // see values above |
||
168 | |||
169 | sbyte flash; // Flash effect |
||
170 | sbyte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. |
||
171 | |||
172 | /* not present in shareware datafiles */ |
||
173 | weapon_id_type children; // ID of weapon to drop if this contains children. -1 means no children. |
||
174 | |||
175 | fix energy_usage; // How much fuel is consumed to fire this weapon. |
||
176 | fix fire_wait; // Time until this weapon can be fired again. |
||
177 | |||
178 | /* not present in shareware datafiles */ |
||
179 | fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. |
||
180 | |||
181 | bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. |
||
182 | |||
183 | fix blob_size; // Size of blob if blob type |
||
184 | fix flash_size; // How big to draw the flash |
||
185 | fix impact_size; // How big of an impact |
||
186 | std::array<fix, NDL> strength; // How much damage it can inflict |
||
187 | std::array<fix, NDL> speed; // How fast it can move, difficulty level based. |
||
188 | fix mass; // How much mass it has |
||
189 | fix drag; // How much drag it has |
||
190 | fix thrust; // How much thrust it has |
||
191 | fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) |
||
192 | fix light; // Amount of light this weapon casts. |
||
193 | fix lifetime; // Lifetime in seconds of this weapon. |
||
194 | fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit |
||
195 | //-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit |
||
196 | // damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 |
||
197 | bitmap_index picture; // a picture of the weapon for the cockpit |
||
198 | /* not present in shareware datafiles */ |
||
199 | bitmap_index hires_picture; // a hires picture of the above |
||
200 | #endif |
||
201 | }; |
||
202 | |||
203 | enum primary_weapon_index_t : uint8_t |
||
204 | { |
||
205 | LASER_INDEX = 0, |
||
206 | VULCAN_INDEX = 1, |
||
207 | SPREADFIRE_INDEX = 2, |
||
208 | PLASMA_INDEX = 3, |
||
209 | FUSION_INDEX = 4, |
||
210 | #if defined(DXX_BUILD_DESCENT_II) |
||
211 | SUPER_LASER_INDEX = 5, |
||
212 | GAUSS_INDEX = 6, |
||
213 | HELIX_INDEX = 7, |
||
214 | PHOENIX_INDEX = 8, |
||
215 | OMEGA_INDEX = 9, |
||
216 | #endif |
||
217 | }; |
||
218 | |||
219 | enum secondary_weapon_index_t : uint8_t |
||
220 | { |
||
221 | CONCUSSION_INDEX = 0, |
||
222 | HOMING_INDEX = 1, |
||
223 | PROXIMITY_INDEX = 2, |
||
224 | SMART_INDEX = 3, |
||
225 | MEGA_INDEX = 4, |
||
226 | #if defined(DXX_BUILD_DESCENT_II) |
||
227 | SMISSILE1_INDEX = 5, |
||
228 | GUIDED_INDEX = 6, |
||
229 | SMART_MINE_INDEX = 7, |
||
230 | SMISSILE4_INDEX = 8, |
||
231 | SMISSILE5_INDEX = 9, |
||
232 | #endif |
||
233 | }; |
||
234 | |||
235 | struct player_info; |
||
236 | void delayed_autoselect(player_info &); |
||
237 | |||
238 | } |
||
239 | |||
240 | class has_weapon_result |
||
241 | { |
||
242 | uint8_t m_result; |
||
243 | public: |
||
244 | static constexpr auto has_weapon_flag = std::integral_constant<uint8_t, 1>{}; |
||
245 | static constexpr auto has_energy_flag = std::integral_constant<uint8_t, 2>{}; |
||
246 | static constexpr auto has_ammo_flag = std::integral_constant<uint8_t, 4>{}; |
||
247 | has_weapon_result() = default; |
||
248 | constexpr has_weapon_result(uint8_t r) : m_result(r) |
||
249 | { |
||
250 | } |
||
251 | uint8_t has_weapon() const |
||
252 | { |
||
253 | return m_result & has_weapon_flag; |
||
254 | } |
||
255 | uint8_t has_energy() const |
||
256 | { |
||
257 | return m_result & has_energy_flag; |
||
258 | } |
||
259 | uint8_t has_ammo() const |
||
260 | { |
||
261 | return m_result & has_ammo_flag; |
||
262 | } |
||
263 | uint8_t flags() const |
||
264 | { |
||
265 | return m_result; |
||
266 | } |
||
267 | bool has_all() const |
||
268 | { |
||
269 | return m_result == (has_weapon_flag | has_energy_flag | has_ammo_flag); |
||
270 | } |
||
271 | }; |
||
272 | |||
273 | namespace dsx { |
||
274 | //return which bomb will be dropped next time the bomb key is pressed |
||
275 | #if defined(DXX_BUILD_DESCENT_I) |
||
276 | |||
277 | static constexpr int which_bomb() |
||
278 | { |
||
279 | return PROXIMITY_INDEX; |
||
280 | } |
||
281 | |||
282 | static constexpr int weapon_index_uses_vulcan_ammo(const unsigned id) |
||
283 | { |
||
284 | return id == primary_weapon_index_t::VULCAN_INDEX; |
||
285 | } |
||
286 | |||
287 | static constexpr int weapon_index_is_player_bomb(const unsigned id) |
||
288 | { |
||
289 | return id == PROXIMITY_INDEX; |
||
290 | } |
||
291 | |||
292 | //multiply ammo by this before displaying |
||
293 | static constexpr unsigned vulcan_ammo_scale(const unsigned v) |
||
294 | { |
||
295 | return (v * 0xcc180u) >> 16; |
||
296 | } |
||
297 | #elif defined(DXX_BUILD_DESCENT_II) |
||
298 | int which_bomb(void); |
||
299 | |||
300 | static constexpr int weapon_index_uses_vulcan_ammo(const unsigned id) |
||
301 | { |
||
302 | return id == primary_weapon_index_t::VULCAN_INDEX || id == primary_weapon_index_t::GAUSS_INDEX; |
||
303 | } |
||
304 | |||
305 | static constexpr int weapon_index_is_player_bomb(const unsigned id) |
||
306 | { |
||
307 | return id == PROXIMITY_INDEX || id == SMART_MINE_INDEX; |
||
308 | } |
||
309 | |||
310 | //multiply ammo by this before displaying |
||
311 | static constexpr unsigned vulcan_ammo_scale(const unsigned v) |
||
312 | { |
||
313 | return (v * 0xcc163u) >> 16; |
||
314 | } |
||
315 | #endif |
||
316 | } |
||
317 | #endif |
||
318 | |||
319 | #endif |