OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
weapturret.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// weapturret.h: MOH Turret. Usable by sentients and monsters.
24//
25
26#pragma once
27
28#include "weapon.h"
29#include "camera.h"
30
31extern Event EV_Turret_Enter;
32extern Event EV_Turret_Exit;
33extern Event EV_Turret_AI_TurnSpeed;
34extern Event EV_Turret_SetMaxUseAngle;
35
36typedef enum {
37 TURRETAISTATE_DEFAULT,
38 TURRETAISTATE_TRACK,
39 TURRETAISTATE_SUPPRESS,
40 TURRETAISTATE_SUPPRESS_WAIT
41} turretaistate_e;
42
43#define FAKEBULLETS 1
44
45class TurretGun : public Weapon
46{
47 friend class Vehicle;
48
49protected:
50 bool m_bFakeBullets;
51 bool m_bPlayerUsable;
52 bool m_bUsable;
53 bool m_bRestable;
54 Vector m_vIdleCheckOffset;
55 Vector m_vViewOffset;
56 float m_fMaxIdlePitch;
57 float m_fMaxIdleYaw;
58 Vector m_vUserViewAng;
59 Vector m_vUserLastCmdAng;
60 float m_fIdlePitchSpeed;
61 float m_fTurnSpeed;
62 float m_fAIPitchSpeed;
63 float m_fPitchUpCap;
64 float m_fPitchDownCap;
65 float m_fStartYaw;
66 float m_fMaxYawOffset;
67 float m_fUserDistance;
68 float m_fMinBurstTime;
69 float m_fMaxBurstTime;
70 float m_fMinBurstDelay;
71 float m_fMaxBurstDelay;
72 float m_fFireToggleTime;
73 int m_iFiring;
74 int m_iIdleHitCount;
75 CameraPtr m_pUserCamera;
76 float m_fViewJitter;
77 float m_fCurrViewJitter;
78 Vector m_vAIBulletSpread[MAX_FIREMODES];
79 int m_iTargetType;
80 SentientPtr m_pAIEnemy;
81 Vector m_Aim_offset;
82 SafePtr<Animate> m_pViewModel;
83 ScriptThreadLabel m_UseThread;
84
85public:
86 bool m_bHadOwner;
87
88private:
89 int m_iAIState;
90 float m_fAIConvergeTime;
91 int m_iAISuppressTime;
92 int m_iAISuppressWaitTime;
93 int m_iAILastTrackTime;
94 int m_iAIStartSuppressTime;
95 vec3_t m_vDesiredTargetAngles;
96 float m_fAIDesiredTargetSpeed;
97 vec3_t m_vAIDesiredTargetPosition;
98 vec3_t m_vAITargetPosition;
99 vec3_t m_vAICurrentTargetPosition;
100 vec3_t m_vAITargetSpeed;
101 int m_iAINextSuppressTime;
102 float m_fAISuppressWidth;
103 float m_fAISuppressHeight;
104 Vector m_vMuzzlePosition;
105 float m_fMaxUseAngle;
106
107protected:
108 void ThinkIdle();
109 void P_SetTargetAngles(Vector &vTargAngles);
110 virtual void P_ThinkActive();
111
112public:
113 CLASS_PROTOTYPE(TurretGun);
114
115 TurretGun();
116 virtual ~TurretGun();
117
118 // added in 2.0
119 //====
120 void AI_SetTargetAngles(vec3_t vTargAngles, float speed);
121 void AI_SetDesiredTargetAngles(const vec3_t angles, float speed);
122 void AI_DoTargetNone();
123 void AI_MoveToDefaultPosition();
124 void AI_DoTargetAutoDefault();
125 void AI_StartDefault();
126 void AI_StartSuppress();
127 void AI_StartSuppressWait();
128 void AI_StartTrack();
129 void AI_DoTargetAutoTrack();
130 void AI_DoSuppressionAiming();
131 void AI_DoTargetAutoSuppress();
132 void AI_DoTargetAutoSuppressWait();
133 void AI_DoTargetAuto();
134 void AI_DoAiming();
135 void AI_DoFiring();
136 void AI_ThinkActive();
137 //====
138
139 void Think() override;
140
141 void PlaceTurret(Event *ev);
142
143 virtual void P_UserAim(usercmd_t *ucmd);
144 qboolean UserAim(usercmd_t *ucmd);
145 virtual void TurretBeginUsed(Sentient *pEnt);
146 virtual void P_TurretBeginUsed(Player *pEnt);
147 virtual void AI_TurretBeginUsed(Sentient *pEnt); // added in 2.0
148 virtual void TurretEndUsed();
149 virtual void P_TurretEndUsed();
150 virtual void AI_TurretEndUsed(); // added in 2.0
151 void RemoveUserCamera(); // added in 2.0
152 virtual void TurretUsed(Sentient *pEnt);
153 virtual void P_TurretUsed(Player *player);
154
155 void TurretUsed(Event *ev);
156 void P_SetPlayerUsable(Event *ev);
157 void EventSetUsable(Event *ev); // added in 2.0
158 void P_SetViewOffset(Event *ev);
159 void EventMaxIdlePitch(Event *ev); // added in 2.0
160 void EventMaxIdleYaw(Event *ev); // added in 2.0
161 void SetIdleCheckOffset(Event *ev);
162 bool IsFiring();
163 void CalcFiringViewJitter();
164 void P_ApplyFiringViewJitter(Vector& vAng);
165 void AI_TurnSpeed(float speed);
166 void AI_PitchSpeed(float speed);
167 void PitchCaps(float upcap, float downcap);
168 void MaxYawOffset(float max);
169 void YawCenter(float center);
170 void P_UserDistance(float dist);
171 void AI_BurstFireSettings(float min_bursttime, float max_bursttime, float min_burstdelay, float max_burstdelay);
172 void AI_EventSetAimTarget(Event *ev);
173 void AI_EventSetAimOffset(Event *ev);
174 void AI_EventClearAimTarget(Event *ev);
175 void AI_EventStartFiring(Event *ev);
176 void AI_EventStopFiring(Event *ev);
177 void AI_EventTurnSpeed(Event *ev);
178 void AI_EventPitchSpeed(Event *ev); // added in 2.0
179 void EventPitchCaps(Event *ev);
180 void EventMaxYawOffset(Event *ev);
181 void EventYawCenter(Event *ev);
182 void P_EventUserDistance(Event *ev);
183 void P_EventViewJitter(Event *ev);
184 void P_EventDoJitter(Event *ev); // added in 2.0
185 void AI_EventBurstFireSettings(Event *ev);
186 void P_EventSetThread(Event *ev);
187 void P_SetMaxUseAngle(Event *ev); // added in 2.0
188 void P_SetStartYaw(Event *ev); // added in 2.0
189 void P_SetViewangles(Event *ev);
190 void P_SetViewAnglesForTurret(Event *ev);
191 void P_GetViewangles(Event *ev);
192 void P_CreateViewModel();
193 void P_DeleteViewModel();
194
195 qboolean AI_SetWeaponAnim(const char *anim, Event *ev = NULL);
196 qboolean P_SetWeaponAnim(const char *anim, Event *ev = NULL);
197 qboolean SetWeaponAnim(const char *anim, Event *ev = NULL) override;
198 void AI_StopWeaponAnim();
199 void P_StopWeaponAnim();
200 void StopWeaponAnim() override;
201
202 bool AI_CanTarget(const vec3_t org);
203 virtual float FireDelay(firemode_t mode) override;
204 virtual void SetFireDelay(Event *ev) override; // added in 2.0
205 void ShowInfo(float fDot, float fDist) override;
206
207 // added in 2.0
208 //====
209 void AI_EventSetTargetType(Event *ev);
210 void AI_EventGetTargetType(Event *ev);
211 void AI_EventSetConvergeTime(Event *ev);
212 void AI_EventSetSuppressTime(Event *ev);
213 void AI_EventSetSuppressWaitTime(Event *ev);
214 void AI_EventSetSuppressWidth(Event *ev);
215 void AI_EventSetSuppressHeight(Event *ev);
216 void AI_EventSetBulletSpread(Event *ev);
217 void GetMuzzlePosition(
218 vec3_t position, vec3_t vBarrelPos = NULL, vec3_t forward = NULL, vec3_t right = NULL, vec3_t up = NULL
219 ) override;
220 Vector EyePosition();
221 void setAngles(Vector ang) override;
222 //====
223
224 const Vector& GetUserViewAngles() const;
225 void SetUserViewAngles(const Vector& vAngles);
226
227 void Archive(Archiver& arc) override;
228};
Definition archive.h:86
Definition listener.h:246
Definition safeptr.h:160
Definition gamescript.h:165
Definition vector.h:61