forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathNeutronMissileUpdate.h
More file actions
141 lines (114 loc) · 5.46 KB
/
NeutronMissileUpdate.h
File metadata and controls
141 lines (114 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: NeutronMissileUpdate.h
// Author: Michael S. Booth, December 2001
// Desc: Missile behavior
#pragma once
#include "GameClient/RadiusDecal.h"
#include "Common/GameType.h"
#include "Common/GlobalData.h"
#include "GameLogic/Module/UpdateModule.h"
#include "GameLogic/Module/DieModule.h"
#include "Common/INI.h"
#include "WWMath/matrix3d.h"
enum ParticleSystemID CPP_11(: Int);
class FXList;
//-------------------------------------------------------------------------------------------------
class NeutronMissileUpdateModuleData : public UpdateModuleData
{
public:
Real m_initialDist;
Real m_maxTurnRate;
Real m_forwardDamping;
Real m_relativeSpeed;
Real m_targetFromDirectlyAbove; ///< aim first for dest+offset, then dest
Real m_specialAccelFactor;
UnsignedInt m_specialSpeedTime;
Real m_specialSpeedHeight;
Real m_specialJitterDistance;
const FXList* m_launchFX; ///< FXList to do when missile 'launches'
const FXList* m_ignitionFX; ///< FXList to do when missile 'ignites'
RadiusDecalTemplate m_deliveryDecalTemplate;
Real m_deliveryDecalRadius;
NeutronMissileUpdateModuleData();
static void buildFieldParse(MultiIniFieldParse& p);
};
//-------------------------------------------------------------------------------------------------
/**
* This module encapsulates missile behavior.
*/
class NeutronMissileUpdate : public UpdateModule,
public DieModuleInterface,
public ProjectileUpdateInterface
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( NeutronMissileUpdate, "NeutronMissileUpdate" )
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( NeutronMissileUpdate, NeutronMissileUpdateModuleData );
public:
NeutronMissileUpdate( Thing *thing, const ModuleData* moduleData );
static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_DIE); }
// BehaviorModule
virtual DieModuleInterface* getDie() override { return this; }
// DieModuleInterface
virtual void onDie( const DamageInfo *damageInfo ) override;
virtual ProjectileUpdateInterface* getProjectileUpdateInterface() override { return this; }
enum MissileStateType
{
PRELAUNCH,
LAUNCH, ///< released from plane, falling
ATTACK, ///< fly toward victim
DEAD
};
virtual void projectileLaunchAtObjectOrPosition(const Object *victim, const Coord3D* victimPos, const Object *launcher, WeaponSlotType wslot, Int specificBarrelToUse, const WeaponTemplate* detWeap, const ParticleSystemTemplate* exhaustSysOverride) override;
virtual void projectileFireAtObjectOrPosition( const Object *victim, const Coord3D *victimPos, const WeaponTemplate *detWeap, const ParticleSystemTemplate* exhaustSysOverride ) override;
virtual Bool projectileIsArmed() const override { return m_isArmed; } ///< return true if the missile is armed and ready to explode
virtual ObjectID projectileGetLauncherID() const override { return m_launcherID; } ///< Return firer of missile. Returns 0 if not yet fired.
virtual Bool projectileHandleCollision( Object *other ) override;
virtual const Coord3D *getVelocity() const { return &m_vel; } ///< get current velocity
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) override {}
virtual void projectileNowJammed() override {}
virtual const Coord3D* getProjectileLogicVelocity() const override { return &m_logicStepVelocity; }
virtual UpdateSleepTime update() override;
virtual void onDelete() override;
private:
MissileStateType m_state; ///< the behavior state of the missile
Coord3D m_targetPos; ///< the position of the target
Coord3D m_intermedPos;
ObjectID m_launcherID; ///< ID of object that launched us (zero if not yet launched)
WeaponSlotType m_attach_wslot; ///< where to fire the missile from
Int m_attach_specificBarrelToUse; ///< where to fire the missile from
Coord3D m_accel;
Coord3D m_vel;
Coord3D m_logicStepVelocity; ///< Logic frame velocity vector
UnsignedInt m_stateTimestamp; ///< time of state change
Bool m_isLaunched;
Bool m_isArmed; ///< if true, missile will explode on contact
Real m_noTurnDistLeft; ///< when zero, ok to start turning
Bool m_reachedIntermediatePos;
UnsignedInt m_frameAtLaunch;
Real m_heightAtLaunch;
RadiusDecal m_deliveryDecal;
const ParticleSystemTemplate* m_exhaustSysTmpl;
void doLaunch(); ///< implement LAUNCH state
void doAttack(); ///< implement ATTACK state
void detonate(); ///< blow it up. (usually only called by MissileCollide)
};