| 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 DXX_BUILD_DESCENT |
| 41 |
#include <array> |
| 42 |
|
| 43 |
namespace dcx { |
| 44 |
|
| 45 |
enum class laser_level : uint8_t |
| 46 |
{ |
| 47 |
_1, |
| 48 |
_2, |
| 49 |
_3, |
| 50 |
_4, |
| 51 |
/* if DXX_BUILD_DESCENT == 2 */ |
| 52 |
_5, |
| 53 |
_6, |
| 54 |
/* endif */ |
| 55 |
}; |
| 56 |
|
| 57 |
enum class has_primary_weapon_result : uint8_t |
| 58 |
{ |
| 59 |
weapon = 1, |
| 60 |
energy = 2, |
| 61 |
ammo = 4, |
| 62 |
}; |
| 63 |
|
| 64 |
enum class has_secondary_weapon_result : bool |
| 65 |
{ |
| 66 |
absent, |
| 67 |
present, |
| 68 |
}; |
| 69 |
|
| 70 |
static constexpr has_primary_weapon_result operator&(const has_primary_weapon_result r, const has_primary_weapon_result m) |
| 71 |
{ |
| 72 |
return static_cast<has_primary_weapon_result>(static_cast<uint8_t>(r) & static_cast<uint8_t>(m)); |
| 73 |
} |
| 74 |
|
| 75 |
static constexpr has_primary_weapon_result operator|(const has_primary_weapon_result r, const has_primary_weapon_result m) |
| 76 |
{ |
| 77 |
return static_cast<has_primary_weapon_result>(static_cast<uint8_t>(r) | static_cast<uint8_t>(m)); |
| 78 |
} |
| 79 |
|
| 80 |
static constexpr has_primary_weapon_result &operator|=(has_primary_weapon_result &r, const has_primary_weapon_result m) |
| 81 |
{ |
| 82 |
return r = static_cast<has_primary_weapon_result>(static_cast<uint8_t>(r) | static_cast<uint8_t>(m)); |
| 83 |
} |
| 84 |
|
| 85 |
static constexpr uint8_t has_weapon(const has_primary_weapon_result r) |
| 86 |
{ |
| 87 |
return static_cast<uint8_t>(r & has_primary_weapon_result::weapon); |
| 88 |
} |
| 89 |
|
| 90 |
static constexpr bool has_all(const has_primary_weapon_result r) |
| 91 |
{ |
| 92 |
constexpr auto m = has_primary_weapon_result::weapon | has_primary_weapon_result::energy | has_primary_weapon_result::ammo; |
| 93 |
return (r & m) == m; |
| 94 |
} |
| 95 |
|
| 96 |
static constexpr uint8_t has_all(const has_secondary_weapon_result r) |
| 97 |
{ |
| 98 |
return static_cast<uint8_t>(r); |
| 99 |
} |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
namespace dsx { |
| 104 |
|
| 105 |
static inline laser_level &operator+=(laser_level &a, const laser_level b) |
| 106 |
{ |
| 107 |
return (a = static_cast<laser_level>(static_cast<uint8_t>(a) + static_cast<uint8_t>(b))); |
| 108 |
} |
| 109 |
|
| 110 |
static inline laser_level &operator-=(laser_level &a, const laser_level b) |
| 111 |
{ |
| 112 |
return (a = static_cast<laser_level>(static_cast<uint8_t>(a) - static_cast<uint8_t>(b))); |
| 113 |
} |
| 114 |
|
| 115 |
static inline laser_level &operator++(laser_level &a) |
| 116 |
{ |
| 117 |
return (a = static_cast<laser_level>(static_cast<uint8_t>(a) + 1u)); |
| 118 |
} |
| 119 |
|
| 120 |
static inline laser_level &operator--(laser_level &a) |
| 121 |
{ |
| 122 |
return (a = static_cast<laser_level>(static_cast<uint8_t>(a) - 1u)); |
| 123 |
} |
| 124 |
|
| 125 |
struct weapon_info : prohibit_void_ptr<weapon_info> |
| 126 |
{ |
| 127 |
enum class render_type : uint8_t |
| 128 |
{ |
| 129 |
laser, |
| 130 |
blob, |
| 131 |
polymodel, |
| 132 |
vclip, |
| 133 |
None = 0xff, |
| 134 |
}; |
| 135 |
// Flag: set if this object is matter (as opposed to energy) |
| 136 |
enum class matter_flag : bool |
| 137 |
{ |
| 138 |
energy, |
| 139 |
matter, |
| 140 |
}; |
| 141 |
// Flag: set if this object bounces off walls |
| 142 |
enum class bounce_type : uint8_t |
| 143 |
{ |
| 144 |
never, |
| 145 |
always, |
| 146 |
twice, |
| 147 |
}; |
| 148 |
enum class persistence_flag : bool |
| 149 |
{ |
| 150 |
terminate_on_impact, |
| 151 |
persistent, |
| 152 |
}; |
| 153 |
render_type render; // How to draw 0=laser, 1=blob, 2=object |
| 154 |
matter_flag matter; |
| 155 |
bounce_type bounce; |
| 156 |
persistence_flag persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) |
| 157 |
polygon_model_index model_num; // Model num if rendertype==2. |
| 158 |
polygon_model_index model_num_inner;// Model num of inner part if rendertype==2. |
| 159 |
|
| 160 |
vclip_index flash_vclip; // What vclip to use for muzzle flash |
| 161 |
vclip_index robot_hit_vclip; // What vclip for impact with robot |
| 162 |
vclip_index wall_hit_vclip; // What vclip for impact with wall |
| 163 |
sound_effect flash_sound; // What sound to play when fired |
| 164 |
sound_effect robot_hit_sound; // What sound for impact with robot |
| 165 |
sound_effect wall_hit_sound; // What sound for impact with wall |
| 166 |
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. |
| 167 |
sbyte ammo_usage; // How many units of ammunition it uses. |
| 168 |
|
| 169 |
vclip_index weapon_vclip; // Vclip to render for the weapon, itself. |
| 170 |
sbyte destroyable; // If !0, this weapon can be destroyed by another weapon. |
| 171 |
|
| 172 |
sbyte homing_flag; // Set if this weapon can home in on a target. |
| 173 |
|
| 174 |
fix energy_usage; // How much fuel is consumed to fire this weapon. |
| 175 |
fix fire_wait; // Time until this weapon can be fired again. |
| 176 |
|
| 177 |
bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. |
| 178 |
|
| 179 |
fix blob_size; // Size of blob if blob type |
| 180 |
fix flash_size; // How big to draw the flash |
| 181 |
fix impact_size; // How big of an impact |
| 182 |
enumerated_array<fix, NDL, Difficulty_level_type> strength; // How much damage it can inflict |
| 183 |
enumerated_array<fix, NDL, Difficulty_level_type> speed; // How fast it can move, difficulty level based. |
| 184 |
fix mass; // How much mass it has |
| 185 |
fix drag; // How much drag it has |
| 186 |
fix thrust; // How much thrust it has |
| 187 |
fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) |
| 188 |
fix light; // Amount of light this weapon casts. |
| 189 |
fix lifetime; // Lifetime in seconds of this weapon. |
| 190 |
fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit |
| 191 |
#if DXX_BUILD_DESCENT == 1 |
| 192 |
//-- 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 |
| 193 |
// 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 |
| 194 |
bitmap_index picture; // a picture of the weapon for the cockpit |
| 195 |
#elif DXX_BUILD_DESCENT == 2 |
| 196 |
ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 |
| 197 |
|
| 198 |
ubyte flags; // see values above |
| 199 |
|
| 200 |
sbyte flash; // Flash effect |
| 201 |
sbyte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. |
| 202 |
|
| 203 |
/* not present in shareware datafiles */ |
| 204 |
weapon_id_type children; // ID of weapon to drop if this contains children. -1 means no children. |
| 205 |
|
| 206 |
/* not present in shareware datafiles */ |
| 207 |
fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. |
| 208 |
|
| 209 |
//-- 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 |
| 210 |
// 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 |
| 211 |
bitmap_index picture; // a picture of the weapon for the cockpit |
| 212 |
/* not present in shareware datafiles */ |
| 213 |
bitmap_index hires_picture; // a hires picture of the above |
| 214 |
#endif |
| 215 |
}; |
| 216 |
|
| 217 |
enum class primary_weapon_index_t : uint8_t |
| 218 |
{ |
| 219 |
LASER_INDEX = 0, |
| 220 |
VULCAN_INDEX = 1, |
| 221 |
SPREADFIRE_INDEX = 2, |
| 222 |
PLASMA_INDEX = 3, |
| 223 |
FUSION_INDEX = 4, |
| 224 |
#if DXX_BUILD_DESCENT == 2 |
| 225 |
SUPER_LASER_INDEX = 5, |
| 226 |
GAUSS_INDEX = 6, |
| 227 |
HELIX_INDEX = 7, |
| 228 |
PHOENIX_INDEX = 8, |
| 229 |
OMEGA_INDEX = 9, |
| 230 |
#endif |
| 231 |
}; |
| 232 |
|
| 233 |
enum class secondary_weapon_index_t : uint8_t |
| 234 |
{ |
| 235 |
CONCUSSION_INDEX = 0, |
| 236 |
HOMING_INDEX = 1, |
| 237 |
PROXIMITY_INDEX = 2, |
| 238 |
SMART_INDEX = 3, |
| 239 |
MEGA_INDEX = 4, |
| 240 |
#if DXX_BUILD_DESCENT == 2 |
| 241 |
SMISSILE1_INDEX = 5, |
| 242 |
GUIDED_INDEX = 6, |
| 243 |
SMART_MINE_INDEX = 7, |
| 244 |
SMISSILE4_INDEX = 8, |
| 245 |
SMISSILE5_INDEX = 9, |
| 246 |
#endif |
| 247 |
}; |
| 248 |
|
| 249 |
//given a weapon index, return the flag value |
| 250 |
static constexpr unsigned HAS_PRIMARY_FLAG(const primary_weapon_index_t w) |
| 251 |
{ |
| 252 |
return 1 << static_cast<unsigned>(w); |
| 253 |
} |
| 254 |
|
| 255 |
static constexpr unsigned HAS_SECONDARY_FLAG(const secondary_weapon_index_t w) |
| 256 |
{ |
| 257 |
return 1 << static_cast<unsigned>(w); |
| 258 |
} |
| 259 |
|
| 260 |
struct player_info; |
| 261 |
void delayed_autoselect(player_info &, const control_info &Controls); |
| 262 |
|
| 263 |
//return which bomb will be dropped next time the bomb key is pressed |
| 264 |
#if DXX_BUILD_DESCENT == 1 |
| 265 |
static constexpr secondary_weapon_index_t which_bomb(const player_info &) |
| 266 |
{ |
| 267 |
return secondary_weapon_index_t::PROXIMITY_INDEX; |
| 268 |
} |
| 269 |
|
| 270 |
static constexpr int weapon_index_uses_vulcan_ammo(const primary_weapon_index_t id) |
| 271 |
{ |
| 272 |
return id == primary_weapon_index_t::VULCAN_INDEX; |
| 273 |
} |
| 274 |
|
| 275 |
static constexpr int weapon_index_is_player_bomb(const secondary_weapon_index_t id) |
| 276 |
{ |
| 277 |
return id == secondary_weapon_index_t::PROXIMITY_INDEX; |
| 278 |
} |
| 279 |
|
| 280 |
//multiply ammo by this before displaying |
| 281 |
static constexpr unsigned vulcan_ammo_scale(const unsigned v) |
| 282 |
{ |
| 283 |
return (v * 0xcc180u) >> 16; |
| 284 |
} |
| 285 |
#elif DXX_BUILD_DESCENT == 2 |
| 286 |
secondary_weapon_index_t which_bomb(player_info &player_info); |
| 287 |
secondary_weapon_index_t which_bomb(const player_info &player_info); |
| 288 |
|
| 289 |
static constexpr int weapon_index_uses_vulcan_ammo(const primary_weapon_index_t id) |
| 290 |
{ |
| 291 |
return id == primary_weapon_index_t::VULCAN_INDEX || id == primary_weapon_index_t::GAUSS_INDEX; |
| 292 |
} |
| 293 |
|
| 294 |
static constexpr int weapon_index_is_player_bomb(const secondary_weapon_index_t id) |
| 295 |
{ |
| 296 |
return id == secondary_weapon_index_t::PROXIMITY_INDEX || id == secondary_weapon_index_t::SMART_MINE_INDEX; |
| 297 |
} |
| 298 |
|
| 299 |
//multiply ammo by this before displaying |
| 300 |
static constexpr unsigned vulcan_ammo_scale(const unsigned v) |
| 301 |
{ |
| 302 |
return (v * 0xcc163u) >> 16; |
| 303 |
} |
| 304 |
#endif |
| 305 |
} |
| 306 |
#endif |
| 307 |
|
| 308 |
#endif |