WSF
WsfWeaponEffects.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFWEAPONEFFECTS_HPP
13#define WSFWEAPONEFFECTS_HPP
14
15#include "wsf_mil_export.h"
16
17#include <vector>
18
19class UtInput;
20class UtScript;
21#include "WsfCategoryList.hpp"
22#include "WsfObject.hpp"
23class WsfPlatform;
25class WsfWeapon;
27
28namespace WsfPk
29{
30class Table;
31}
32
46
47class WSF_MIL_EXPORT WsfWeaponEffects : public WsfObject
48{
49public:
51
52 static const char* cTYPE_KIND;
54 static const double cUNHARMED;
55
58 static const double cMORTALLY_WOUNDED;
59
69
70 WsfWeaponEffects(WsfScenario& aScenario);
71 ~WsfWeaponEffects() override;
72
75 WsfWeaponEffects* Clone() const override = 0;
76
77 virtual bool PreInitialize();
78 bool ProcessInput(UtInput& aInput) override;
79 virtual bool Initialize(double aSimTime, const WsfWeaponEngagement* aEngagementPtr);
80
81 UtScriptContext* GetScriptAccessibleContext() const override { return &mContextPtr->GetContext(); }
82
84
85 virtual void ProcessEffectExplicit(double aSimTime);
86 virtual void ProcessEffectImplicit(double aSimTime);
87 virtual void Terminate(double aSimTime);
88
92 void Defeat() { mDefeated = true; }
94
98
99 void SetIncidentalDamageAllowed(bool aIncidentalDamageAllowed)
100 {
101 mIncidentalDamageAllowed = aIncidentalDamageAllowed;
102 }
103
108
109 void SetParentDamageAllowed(bool aParentDamageAllowed) { mParentDamageAllowed = aParentDamageAllowed; }
111
112 // Deprecated form (use GetIncidentalDamageAllowed);
113 // bool AllowIncidentalDamage() const { return mIncidentalDamageAllowed; }
114
117 Result GetTargetResult() const { return mTargetResult; }
118
121 Result GetIncidentalResult() const { return mIncidentalResult; }
122
125 Result GetTotalResult() const { return (mTargetResult > mIncidentalResult) ? mTargetResult : mIncidentalResult; }
126
129 static std::string GetResultString(WsfWeaponEffects::Result aResult);
130
135 bool UseLaunchPk() const { return mUseLaunchPk; }
136
141 bool UseInterceptPk() const { return !mUseLaunchPk; }
142
144 double GetPkDegrade() const { return mPkDegrade; }
145
150 double GetPkConstraint() const { return mPkDegrade * ((mUseLaunchPk) ? mLaunchPk : mInterceptPk); }
151
153 void SetInvincibleIndex(unsigned int aPlatformID) { mInvincibleIndex = aPlatformID; }
154
156 unsigned int GetInvincibleIndex() const { return mInvincibleIndex; }
157
159 void SetDamageRadius(double aDamageRadius) { mDamageRadius = aDamageRadius; }
160
162 double GetDamageRadius() const { return mDamageRadius; }
163
165 double GetLaunchPk() const { return mLaunchPk; }
166
168 double GetInterceptPk() const { return mInterceptPk; }
169
171 bool DrawEndgamePk() { return mDrawEndgamePk; }
172
174 virtual double GetCEP() const { return mCEP; }
175
178 void SetCEP(double aValue) { mCEP = aValue; }
179
182 void SetPkDegrade(double aPkDegrade) { mPkDegrade = aPkDegrade; }
183
185 virtual double GetPkDrawn() const { return mPkDrawn; }
186
188 bool DebugEnabled() const { return mDebugEnabled; }
189
191 void SetDebugEnabled(bool aDebugEnabled) { mDebugEnabled = aDebugEnabled; }
192
194 unsigned int KilledPlatformCount() const { return static_cast<unsigned int>(mKilledPlatformIndices.size()); }
195
197 bool IsKilledPlatform(size_t aPlatformIndex) const;
198
199 WsfPk::Table* GetPkTable() { return mPkTablePtr; }
200
201 WsfScenario& GetScenario() { return *mScenarioPtr; }
202
203protected:
206
207 virtual void ApplyEffectIncrement(double aSimTime, WsfPlatform* aOtherPlatformPtr, double aDamageAmount);
208 virtual void ApplyEffectTo(double aSimTime, WsfPlatform* aOtherPlatformPtr);
209 virtual void ApplyDamageResultToOtherPlatform(double aSimTime, WsfPlatform* aOtherPlatformPtr, double aDamage, Result aResult);
210
211 virtual void CalcLaunchPk(double aSimTime);
212 virtual void CalcPkDegradation(double aSimTime, WsfPlatform* aTargetPtr);
213 virtual void CalcInterceptPk(double aSimTime, WsfPlatform* aTargetPtr);
214 virtual void CalcPkParameters(WsfPlatform* aTargetPtr,
215 double& aAzimuth,
216 double& aElevation,
217 double& aMissileSpeed,
218 double& aTargetSpeed);
219
221 void AddToKilledPlatforms(unsigned int aKilledIndex);
222
223 double DrawUniformPk();
224 virtual bool IsVulnerable(WsfPlatform* aOtherPlatformPtr);
225 void ProcessEffectCommon(double aSimTime, WsfPlatform* aRefPlatformPtr);
226
228 bool Defeated() const { return mDefeated; }
229
231 const WsfWeaponEngagement* GetEngagement() const { return mEngagementPtr; }
232
234 void SetUseLaunchPk() { mUseLaunchPk = true; }
235
237 void SetUseInterceptPk() { mUseLaunchPk = false; }
238
241 void SetLaunchPk(double aValue) { mLaunchPk = aValue; }
242
245 void SetInterceptPk(double aValue) { mInterceptPk = aValue; }
246
248 void SetPkDrawn(double aValue) { mPkDrawn = aValue; }
249
250 void SetIncidentalResult(const WsfWeaponEffects::Result& aResult);
251 void SetTargetResult(const WsfWeaponEffects::Result& aResult);
252 void SetResult(const WsfWeaponEffects::Result& aResult, bool aIsIntended);
253
255 size_t KilledPlatform(size_t aIndex) { return mKilledPlatformIndices[aIndex]; }
256
257 const WsfWeaponEngagement* GetEngagementPtr() const { return mEngagementPtr; }
258
259 WsfSimulation* GetSimulation() const;
260
261 WsfScriptContext* GetScriptContext() const { return mContextPtr; }
262
263private:
264 WsfScriptContext* mContextPtr;
265
266 unsigned int mInvincibleIndex;
267 WsfCategoryList mInvincibleCats;
268
269 union
270 {
271 struct
272 {
274 bool mDefeated : 1;
277 bool mUseLaunchPk : 1; // if false, use intercept Pk
279 bool mDrawEndgamePk : 1; // Force a pk draw for an external platform
280 };
281 unsigned short mFlags;
282 };
283
284 double mLaunchPk;
285 double mInterceptPk;
286 double mPkDegrade;
287 double mPkDrawn;
288 double mCEP;
289 double mDamageRadius;
290 WsfScenario* mScenarioPtr;
291 const WsfWeaponEngagement* mEngagementPtr;
292 std::vector<size_t> mKilledPlatformIndices;
293 Result mTargetResult;
294 Result mIncidentalResult;
295
296 WsfPk::Table* mPkTablePtr;
297 WsfStringId mPkTableNameId;
298
299 UtScript* mOnTargetDamagedPtr;
300 UtScript* mOnTargetKilledPtr;
301
302 UtScriptData* mDamageVarPtr;
303};
304
305#endif
ut::script::Data UtScriptData
Definition WsfScriptContext.hpp:47
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Contains the 'categories' to which an object belongs.
Definition WsfCategoryList.hpp:34
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
virtual bool ProcessInput(UtInput &aInput)
Definition WsfObject.cpp:140
Definition WsfPkTable.hpp:78
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfScriptContext.hpp:71
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfWeaponEffects.hpp:48
virtual void CalcInterceptPk(double aSimTime, WsfPlatform *aTargetPtr)
Definition WsfWeaponEffects.cpp:640
virtual void ApplyEffectTo(double aSimTime, WsfPlatform *aOtherPlatformPtr)
Definition WsfWeaponEffects.cpp:549
const WsfWeaponEngagement * GetEngagement() const
Return the Engagement that this effect was instantiated to support.
Definition WsfWeaponEffects.hpp:231
static WsfStringId GetWeaponEffectsType(WsfPlatform &aPlatform)
Return the weapon effects type for the associated platform.
Definition WsfWeaponEffects.cpp:45
void SetPkDegrade(double aPkDegrade)
Definition WsfWeaponEffects.hpp:182
double GetDamageRadius() const
Return the maximum lethal damage radius for this effect.
Definition WsfWeaponEffects.hpp:162
virtual void CalcPkParameters(WsfPlatform *aTargetPtr, double &aAzimuth, double &aElevation, double &aMissileSpeed, double &aTargetSpeed)
Definition WsfWeaponEffects.cpp:886
static const char * cTYPE_KIND
Definition WsfWeaponEffects.hpp:52
void SetLaunchPk(double aValue)
Definition WsfWeaponEffects.hpp:241
Result
Definition WsfWeaponEffects.hpp:63
@ cDAMAGED
Did apply some incremental damage to the intended platform (a 'hit').
Definition WsfWeaponEffects.hpp:66
@ cMISSED
Did not result in any damage to the intended target platform (a 'miss').
Definition WsfWeaponEffects.hpp:65
@ cKILLED
Did result in total damage (kill) to the intended platform (a 'hit').
Definition WsfWeaponEffects.hpp:67
@ cINVALID
The effect has not yet been exercised in the engagement (no detonation yet).
Definition WsfWeaponEffects.hpp:64
virtual void ApplyEffectIncrement(double aSimTime, WsfPlatform *aOtherPlatformPtr, double aDamageAmount)
Definition WsfWeaponEffects.cpp:482
static const double cMORTALLY_WOUNDED
Definition WsfWeaponEffects.hpp:58
virtual void CalcPkDegradation(double aSimTime, WsfPlatform *aTargetPtr)
Definition WsfWeaponEffects.cpp:632
bool UseInterceptPk() const
Definition WsfWeaponEffects.hpp:141
bool mUseLaunchPk
Definition WsfWeaponEffects.hpp:277
void SetInterceptPk(double aValue)
Definition WsfWeaponEffects.hpp:245
UtScriptContext * GetScriptAccessibleContext() const override
Definition WsfWeaponEffects.hpp:81
void SetPkDrawn(double aValue)
Set the Pk value used in the intended target hit assessment.
Definition WsfWeaponEffects.hpp:248
WsfWeaponEffects & operator=(const WsfWeaponEffects &aRhs)
virtual bool IsVulnerable(WsfPlatform *aOtherPlatformPtr)
Definition WsfWeaponEffects.cpp:670
bool mDebugEnabled
Definition WsfWeaponEffects.hpp:273
void SetParentDamageAllowed(bool aParentDamageAllowed)
Definition WsfWeaponEffects.hpp:109
virtual void CalcLaunchPk(double aSimTime)
Definition WsfWeaponEffects.cpp:608
double GetPkConstraint() const
Definition WsfWeaponEffects.hpp:150
void SetDamageRadius(double aDamageRadius)
Set the maximum lethal damage radius for this effect.
Definition WsfWeaponEffects.hpp:159
void SetCEP(double aValue)
Definition WsfWeaponEffects.hpp:178
void SetUseInterceptPk()
Indicate that you wish to use the Intercept Pk value (in lieu of the Launch Pk value).
Definition WsfWeaponEffects.hpp:237
bool UseLaunchPk() const
Definition WsfWeaponEffects.hpp:135
void SetInvincibleIndex(unsigned int aPlatformID)
Set the ID of a platform which shall not be damaged. (Usually the launching entity....
Definition WsfWeaponEffects.hpp:153
bool DebugEnabled() const
Returns 'true' if debugging is enabled for this instance.
Definition WsfWeaponEffects.hpp:188
Result GetTotalResult() const
Definition WsfWeaponEffects.hpp:125
unsigned int GetInvincibleIndex() const
Get the ID of a platform which will not be damaged.
Definition WsfWeaponEffects.hpp:156
double GetPkDegrade() const
Return the current Pk degrade factor.
Definition WsfWeaponEffects.hpp:144
virtual void ApplyDamageResultToOtherPlatform(double aSimTime, WsfPlatform *aOtherPlatformPtr, double aDamage, Result aResult)
Definition WsfWeaponEffects.cpp:428
Result GetIncidentalResult() const
Definition WsfWeaponEffects.hpp:121
size_t KilledPlatform(size_t aIndex)
Method returns an index of one of the platforms killed during this engagement.
Definition WsfWeaponEffects.hpp:255
void SetDebugEnabled(bool aDebugEnabled)
Enable or disable debugging for this instance.
Definition WsfWeaponEffects.hpp:191
bool GetParentDamageAllowed() const
Definition WsfWeaponEffects.hpp:107
virtual double GetCEP() const
Access the value for engagement Circular Error Probable (CEP).
Definition WsfWeaponEffects.hpp:174
virtual bool Initialize(double aSimTime, const WsfWeaponEngagement *aEngagementPtr)
Definition WsfWeaponEffects.cpp:150
bool IsIntendedTargetValid()
This protected method assures that a specified target index does exist.
Definition WsfWeaponEffects.cpp:645
WsfScriptContext * GetScriptContext() const
Definition WsfWeaponEffects.hpp:261
Result GetTargetResult() const
Definition WsfWeaponEffects.hpp:117
bool mDefeated
Definition WsfWeaponEffects.hpp:274
double GetLaunchPk() const
Get the Launch Pk.
Definition WsfWeaponEffects.hpp:165
static const double cUNHARMED
Value indicating no damage to a player, the weapon had no effect.
Definition WsfWeaponEffects.hpp:54
double DrawUniformPk()
Draw a uniform value for Pk determination.
Definition WsfWeaponEffects.cpp:653
void AddToKilledPlatforms(unsigned int aKilledIndex)
Definition WsfWeaponEffects.cpp:585
bool DrawEndgamePk()
Force a pk draw for an external platform target.
Definition WsfWeaponEffects.hpp:171
virtual double GetPkDrawn() const
Access the Pk value drawn for the (intended) target hit assessment.
Definition WsfWeaponEffects.hpp:185
const WsfWeaponEngagement * GetEngagementPtr() const
Definition WsfWeaponEffects.hpp:257
WsfPk::Table * GetPkTable()
Definition WsfWeaponEffects.hpp:199
unsigned int KilledPlatformCount() const
Method returns the count of platforms killed during this engagement.
Definition WsfWeaponEffects.hpp:194
WsfWeaponEffects * Clone() const override=0
virtual bool PreInitialize()
Definition WsfWeaponEffects.cpp:125
void SetUseLaunchPk()
Indicate that you wish to use the Launch Pk value (in lieu of the Intercept Pk value).
Definition WsfWeaponEffects.hpp:234
bool mRemoveWeaponPlatform
Definition WsfWeaponEffects.hpp:278
bool mDrawEndgamePk
Definition WsfWeaponEffects.hpp:279
void ProcessEffectCommon(double aSimTime, WsfPlatform *aRefPlatformPtr)
Definition WsfWeaponEffects.cpp:698
bool mParentDamageAllowed
Definition WsfWeaponEffects.hpp:276
WsfWeaponEffects(WsfScenario &aScenario)
Definition WsfWeaponEffects.cpp:51
bool mIncidentalDamageAllowed
Definition WsfWeaponEffects.hpp:275
void Defeat()
Definition WsfWeaponEffects.hpp:92
bool GetIncidentalDamageAllowed() const
Definition WsfWeaponEffects.hpp:97
double GetInterceptPk() const
Get the Intercept Pk.
Definition WsfWeaponEffects.hpp:168
void SetIncidentalDamageAllowed(bool aIncidentalDamageAllowed)
Definition WsfWeaponEffects.hpp:99
bool Defeated() const
Return a flag to indicate that this effect has been annulled by outside influences.
Definition WsfWeaponEffects.hpp:228
unsigned short mFlags
Definition WsfWeaponEffects.hpp:281
WsfScenario & GetScenario()
Definition WsfWeaponEffects.hpp:201
Definition WsfWeaponEngagement.hpp:43
Definition WsfWeapon.hpp:63
Definition WsfMil.hpp:58
Copyrights Multiple, All Rights Reserved