Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Weapon.h
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: Weapon.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Weapon (gun or missile launcher) class
13
*/
14
15
#ifndef Weapon_h
16
#define Weapon_h
17
18
#include "
Types.h
"
19
#include "
SimObject.h
"
20
#include "
System.h
"
21
#include "
WeaponDesign.h
"
22
#include "
Geometry.h
"
23
#include "
text.h
"
24
25
// +--------------------------------------------------------------------+
26
27
class
Weapon
;
28
class
Ship
;
29
class
Shot
;
30
31
class
Solid
;
32
33
// +--------------------------------------------------------------------+
34
35
class
Weapon
:
public
System
,
public
SimObserver
36
{
37
public
:
38
static
const
char
*
TYPENAME
() {
return
"Weapon"
; }
39
40
enum
Constants
{
MAX_BARRELS
=8 };
41
enum
Orders
{
MANUAL
,
AUTO
,
POINT_DEFENSE
};
42
enum
Control
{
SINGLE_FIRE
,
RIPPLE_FIRE
,
SALVO_FIRE
};
43
enum
Sweep
{
SWEEP_NONE
,
SWEEP_TIGHT
,
SWEEP_WIDE
};
44
45
Weapon
(
WeaponDesign
* d,
int
nmuz,
Vec3
* muzzles,
double
az=0,
double
el=0);
46
Weapon
(
const
Weapon
& rhs);
47
virtual
~Weapon
();
48
49
int
operator==
(
const
Weapon
& w)
const
{
return
this
== &w; }
50
51
int
Track
(
SimObject
* targ,
System
* sub);
52
Shot
*
Fire
();
53
Shot
*
NetFirePrimary
(
SimObject
* targ,
System
* sub,
int
count);
54
Shot
*
NetFireSecondary
(
SimObject
* targ,
System
* sub, DWORD objid);
55
void
SetTarget
(
SimObject
* t,
System
* sub);
56
void
SelectTarget
();
57
bool
CanTarget
(DWORD classification)
const
;
58
SimObject
*
GetTarget
()
const
{
return
target
; }
59
System
*
GetSubTarget
()
const
{
return
subtarget
; }
60
void
SetFiringOrders
(
int
o);
61
int
GetFiringOrders
()
const
{
return
orders
; }
62
void
SetControlMode
(
int
m);
63
int
GetControlMode
()
const
{
return
control
; }
64
void
SetSweep
(
int
s);
65
int
GetSweep
()
const
{
return
sweep
; }
66
67
void
Enable
() {
enabled
=
true
; }
68
void
Disable
() {
enabled
=
false
; }
69
70
const
WeaponDesign
*
Design
()
const
{
return
design
; }
71
const
char
*
Group
()
const
{
return
group
; }
72
int
Enabled
()
const
{
return
enabled
; }
73
int
Ammo
()
const
{
return
ammo
; }
74
int
Guided
()
const
{
return
guided
; }
75
int
Locked
()
const
{
return
locked
; }
76
float
Velocity
()
const
{
return
shot_speed
; }
77
float
Mass
()
const
{
return
mass
*
ammo
; }
78
float
Resistance
()
const
{
return
resist
*
ammo
; }
79
Shot
*
GetBeam
(
int
i);
80
81
// needed to set proper ammo level when joining multiplayer in progress:
82
void
SetAmmo
(
int
a);
83
84
bool
IsPrimary
()
const
;
85
bool
IsDrone
()
const
;
86
bool
IsDecoy
()
const
;
87
bool
IsProbe
()
const
;
88
bool
IsMissile
()
const
;
89
bool
IsBeam
()
const
;
90
91
virtual
void
ExecFrame
(
double
factor);
92
virtual
void
Orient
(
const
Physical
* rep);
93
virtual
void
Distribute
(
double
delivered_energy,
double
seconds);
94
95
const
Ship
*
Owner
()
const
{
return
ship
; }
96
void
SetOwner
(
Ship
*
ship
);
97
int
GetIndex
()
const
{
return
index
; }
98
void
SetIndex
(
int
n) {
index
= n; }
99
100
Point
GetAimVector
()
const
{
return
aim_cam
.
vpn
(); }
101
void
SetAzimuth
(
double
a) {
aim_azimuth
= (float) a; }
102
double
GetAzimuth
()
const
{
return
aim_azimuth
; }
103
void
SetElevation
(
double
e) {
aim_elevation
= (float) e; }
104
double
GetElevation
()
const
{
return
aim_elevation
; }
105
106
void
SetRestAzimuth
(
double
a) {
aim_az_rest
= (float) a; }
107
double
GetRestAzimuth
()
const
{
return
aim_az_rest
; }
108
void
SetRestElevation
(
double
e) {
aim_el_rest
= (float) e; }
109
double
GetRestElevation
()
const
{
return
aim_el_rest
; }
110
111
void
SetAzimuthMax
(
double
a) {
aim_az_max
= (float) a; }
112
double
GetAzimuthMax
()
const
{
return
aim_az_max
; }
113
void
SetAzimuthMin
(
double
a) {
aim_az_min
= (float) a; }
114
double
GetAzimuthMin
()
const
{
return
aim_az_min
; }
115
116
void
SetElevationMax
(
double
e) {
aim_el_max
= (float) e; }
117
double
GetElevationMax
()
const
{
return
aim_el_max
; }
118
void
SetElevationMin
(
double
e) {
aim_el_min
= (float) e; }
119
double
GetElevationMin
()
const
{
return
aim_el_min
; }
120
121
void
SetGroup
(
const
char
* n) {
group
= n; }
122
123
bool
IsBlockedFriendly
()
const
{
return
blocked
; }
124
void
SetBlockedFriendly
(
bool
b) {
blocked
= b; }
125
126
Solid
*
GetTurret
();
127
Solid
*
GetTurretBase
();
128
Solid
*
GetVisibleStore
(
int
i);
129
130
virtual
bool
Update
(
SimObject
* obj);
131
virtual
const
char
*
GetObserverName
()
const
;
132
133
protected
:
134
Shot
*
FireBarrel
(
int
n);
135
Shot
*
CreateShot
(
const
Point
& loc,
const
Camera
& cam,
WeaponDesign
* dsn,
const
Ship
* owner);
136
137
void
SetBeamPoints
(
bool
aim=
false
);
138
void
Aim
();
139
void
AimTurret
(
double
az,
double
el);
140
void
ZeroAim
();
141
void
FindObjective
();
142
Point
Transform
(
const
Point
& pt);
143
bool
CanLockPoint
(
const
Point
& test,
double
& az,
double
& el,
Point
* obj=0);
144
145
// data members:
146
WeaponDesign
*
design
;
147
Text
group
;
148
Point
muzzle_pts
[
MAX_BARRELS
];
149
Point
rel_pts
[
MAX_BARRELS
];
150
Solid
*
turret
;
151
Solid
*
turret_base
;
152
Solid
*
visible_stores
[
MAX_BARRELS
];
153
int
nbarrels
;
154
int
active_barrel
;
155
156
float
refire
;
157
int
ammo
;
158
int
ripple_count
;
159
160
// carrying costs per shot:
161
float
mass
;
162
float
resist
;
163
164
// for targeting computer:
165
int
guided
;
166
bool
enabled
;
167
bool
locked
;
168
bool
centered
;
169
bool
firing
;
170
bool
blocked
;
171
float
shot_speed
;
172
173
int
index
;
174
175
int
orders
;
176
int
control
;
177
int
sweep
;
178
179
SimObject
*
target
;
180
System
*
subtarget
;
181
182
Point
objective
;
183
Point
obj_w
;
184
Camera
aim_cam
;
185
float
aim_azimuth
;
186
float
aim_elevation
;
187
float
old_azimuth
;
188
float
old_elevation
;
189
190
// auto-aiming arc
191
float
aim_az_max
;
// maximum deflection in azimuth
192
float
aim_az_min
;
// minimum deflection in azimuth
193
float
aim_az_rest
;
// azimuth of turret at rest
194
float
aim_el_max
;
// maximum deflection in elevation
195
float
aim_el_min
;
// minimum deflection in elevation
196
float
aim_el_rest
;
// elevation of turret at rest
197
198
DWORD
aim_time
;
199
200
Shot
**
beams
;
201
};
202
203
#endif Weapon_h
204
Stars45
Weapon.h
Generated on Tue Jun 5 2012 20:47:16 for Starshatter_Open by
1.8.1