| 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 |
* Definitions for the laser code. |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include "maths.h" |
| 29 |
#include "vecmat.h" |
| 30 |
|
| 31 |
#include "fwd-segment.h" |
| 32 |
#include "fwd-object.h" |
| 33 |
#include "fwd-player.h" |
| 34 |
#include "fwd-weapon.h" |
| 35 |
#include "weapon_id.h" |
| 36 |
#include "robot.h" |
| 37 |
|
| 38 |
// These are new defines for the value of 'flags' passed to do_laser_firing. |
| 39 |
// The purpose is to collect other flags like QUAD_LASER and Spreadfire_toggle |
| 40 |
// into a single 8-bit quantity so it can be easily used in network mode. |
| 41 |
|
| 42 |
#define LASER_QUAD 1 |
| 43 |
#define LASER_SPREADFIRE_TOGGLED 2 |
| 44 |
|
| 45 |
#define MAX_LASER_LEVEL laser_level::_4 // Note, laser levels are numbered from 0. |
| 46 |
|
| 47 |
#ifdef DXX_BUILD_DESCENT |
| 48 |
#if DXX_BUILD_DESCENT == 1 |
| 49 |
#define DXX_MAXIMUM_LASER_LEVEL laser_level::_4 |
| 50 |
#elif DXX_BUILD_DESCENT == 2 |
| 51 |
#define DXX_MAXIMUM_LASER_LEVEL MAX_SUPER_LASER_LEVEL |
| 52 |
#endif |
| 53 |
#endif |
| 54 |
|
| 55 |
#define MAX_LASER_BITMAPS 6 |
| 56 |
|
| 57 |
// For muzzle firing casting light. |
| 58 |
#define MUZZLE_QUEUE_MAX 8 |
| 59 |
|
| 60 |
// Constants & functions governing homing missile behavior. |
| 61 |
#define NEWHOMER // activates the 30FPS-base capped homing projective code. Remove to restore original behavior. |
| 62 |
#ifdef DXX_BUILD_DESCENT |
| 63 |
#if DXX_BUILD_DESCENT == 1 |
| 64 |
#define HOMING_MIN_TRACKABLE_DOT (3*F1_0/4) |
| 65 |
#elif DXX_BUILD_DESCENT == 2 |
| 66 |
#define HOMING_MIN_TRACKABLE_DOT (7*F1_0/8) |
| 67 |
#endif |
| 68 |
#endif |
| 69 |
#define HOMING_FLY_STRAIGHT_TIME (F1_0/8) |
| 70 |
#ifdef NEWHOMER |
| 71 |
#define HOMING_TURN_TIME (F1_0/30) |
| 72 |
#endif |
| 73 |
|
| 74 |
#ifdef DXX_BUILD_DESCENT |
| 75 |
namespace dcx { |
| 76 |
|
| 77 |
enum class weapon_sound_flag : bool |
| 78 |
{ |
| 79 |
silent, |
| 80 |
audible, |
| 81 |
}; |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
namespace dsx { |
| 86 |
#ifdef NEWHOMER |
| 87 |
void calc_d_homer_tick(); |
| 88 |
#endif |
| 89 |
void Laser_render(grs_canvas &, const object_base &obj); |
| 90 |
imobjptridx_t Laser_player_fire(const d_robot_info_array &Robot_info, vmobjptridx_t obj, weapon_id_type laser_type, player_gun_number gun_num, weapon_sound_flag make_sound, const vms_vector &shot_orientation, icobjidx_t Network_laser_track); |
| 91 |
void Laser_do_weapon_sequence(const d_robot_info_array &Robot_info, vmobjptridx_t obj); |
| 92 |
void Flare_create(vmobjptridx_t obj); |
| 93 |
bool laser_are_related(vcobjptridx_t o1, vcobjptridx_t o2); |
| 94 |
|
| 95 |
void do_laser_firing_player(object &); |
| 96 |
void do_missile_firing(const secondary_weapon_index_t weapon, const vmobjptridx_t plrobjidx); |
| 97 |
|
| 98 |
// Fires a laser-type weapon (a Primary weapon) |
| 99 |
// Fires from object objnum, weapon type weapon_id. |
| 100 |
// Assumes that it is firing from a player object, so it knows which |
| 101 |
// gun to fire from. |
| 102 |
// Returns the number of shots actually fired, which will typically be |
| 103 |
// 1, but could be higher for low frame rates when rapidfire weapons, |
| 104 |
// such as vulcan or plasma are fired. |
| 105 |
int do_laser_firing(vmobjptridx_t objnum, primary_weapon_index_t weapon_id, laser_level level, unsigned flags, vms_vector shot_orientation, icobjidx_t Network_laser_track); |
| 106 |
|
| 107 |
imobjptridx_t Laser_create_new(const vms_vector &direction, const vms_vector &position, vmsegptridx_t segnum, vmobjptridx_t parent, weapon_id_type type, weapon_sound_flag make_sound); |
| 108 |
// Easier to call than Laser_create_new because it determines the |
| 109 |
// segment containing the firing point and deals with it being stuck |
| 110 |
// in an object or through a wall. |
| 111 |
// Fires a laser of type "weapon_type" from an object (parent) in the |
| 112 |
// direction "direction" from the position "position" |
| 113 |
// Returns object number of laser fired or -1 if not possible to fire |
| 114 |
// laser. |
| 115 |
imobjptridx_t Laser_create_new_easy(const d_robot_info_array &Robot_info, const vms_vector &direction, const vms_vector &position, vmobjptridx_t parent, weapon_id_type weapon_type, weapon_sound_flag make_sound); |
| 116 |
|
| 117 |
#if DXX_BUILD_DESCENT == 2 |
| 118 |
// give up control of the guided missile |
| 119 |
void release_local_guided_missile(d_level_unique_object_state &LevelUniqueObjectState, const playernum_t player_num, object &missile); |
| 120 |
void release_remote_guided_missile(d_level_unique_object_state &LevelUniqueObjectState, const playernum_t player_num); |
| 121 |
|
| 122 |
// Omega cannon stuff. |
| 123 |
#define MAX_OMEGA_CHARGE (F1_0) // Maximum charge level for omega cannonw |
| 124 |
// NOTE: OMEGA_CHARGE_SCALE moved to laser.c to avoid long rebuilds if changed |
| 125 |
int ok_to_do_omega_damage(const object &weapon); |
| 126 |
void create_robot_smart_children(vmobjptridx_t objp, uint_fast32_t count); |
| 127 |
#endif |
| 128 |
|
| 129 |
void create_weapon_smart_children(vmobjptridx_t objp); |
| 130 |
int object_to_object_visibility(vcobjptridx_t obj1, const object_base &obj2, int trans_type); |
| 131 |
} |
| 132 |
#endif |
| 133 |
|
| 134 |
namespace dcx { |
| 135 |
|
| 136 |
struct muzzle_info |
| 137 |
{ |
| 138 |
fix64 create_time; |
| 139 |
segnum_t segnum; |
| 140 |
vms_vector pos; |
| 141 |
}; |
| 142 |
|
| 143 |
extern std::array<muzzle_info, MUZZLE_QUEUE_MAX> Muzzle_data; |
| 144 |
} |
| 145 |
|
| 146 |
#ifdef DXX_BUILD_DESCENT |
| 147 |
namespace d1x { |
| 148 |
|
| 149 |
static inline int is_proximity_bomb_or_player_smart_mine(const weapon_id_type id) |
| 150 |
{ |
| 151 |
return id == weapon_id_type::PROXIMITY_ID; |
| 152 |
} |
| 153 |
|
| 154 |
static inline int is_proximity_bomb_or_player_smart_mine_or_placed_mine(const weapon_id_type id) |
| 155 |
{ |
| 156 |
/* Descent 1 has no smart mines or placed mines. */ |
| 157 |
return id == weapon_id_type::PROXIMITY_ID; |
| 158 |
} |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
#if DXX_BUILD_DESCENT == 2 |
| 163 |
namespace dsx { |
| 164 |
// Omega cannon stuff. |
| 165 |
#define MAX_OMEGA_CHARGE (F1_0) // Maximum charge level for omega cannonw |
| 166 |
|
| 167 |
static inline int is_proximity_bomb_or_player_smart_mine(const weapon_id_type id) |
| 168 |
{ |
| 169 |
if (id == weapon_id_type::SUPERPROX_ID) |
| 170 |
return 1; |
| 171 |
return ::d1x::is_proximity_bomb_or_player_smart_mine(id); |
| 172 |
} |
| 173 |
|
| 174 |
static inline int is_proximity_bomb_or_player_smart_mine_or_placed_mine(const weapon_id_type id) |
| 175 |
{ |
| 176 |
if (id == weapon_id_type::PMINE_ID) |
| 177 |
return 1; |
| 178 |
return is_proximity_bomb_or_player_smart_mine(id); |
| 179 |
} |
| 180 |
} |
| 181 |
#endif |
| 182 |
#endif |