OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
sentient.h
1/*
2===========================================================================
3Copyright (C) 2015 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// sentient.h: Base class of entity that can carry other entities, and use weapons.
24//
25
26#pragma once
27
28#include "g_local.h"
29#include "container.h"
30#include "animate.h"
31#include "vehicle.h"
32
33extern Event EV_Sentient_Attack;
34extern Event EV_Sentient_Charge;
35extern Event EV_Sentient_ReleaseAttack;
36extern Event EV_Sentient_GiveWeapon;
37extern Event EV_Sentient_GiveAmmo;
38extern Event EV_Sentient_GiveArmor;
39extern Event EV_Sentient_GiveItem;
40extern Event EV_Sentient_GiveTargetname;
41extern Event EV_Sentient_GiveInventoryItem;
42extern Event EV_Sentient_GiveHealth;
43extern Event EV_Sentient_SetBloodModel;
44extern Event EV_Sentient_UselessCheck;
45extern Event EV_Sentient_TurnOffShadow;
46extern Event EV_Sentient_TurnOnShadow;
47extern Event EV_Sentient_UpdateOffsetColor;
48extern Event EV_Sentient_JumpXY;
49extern Event EV_Sentient_MeleeAttackStart;
50extern Event EV_Sentient_MeleeAttackEnd;
51extern Event EV_Sentient_BlockStart;
52extern Event EV_Sentient_BlockEnd;
53extern Event EV_Sentient_SetMouthAngle;
54extern Event EV_Sentient_SpawnBloodyGibs;
55extern Event EV_Sentient_StopOnFire;
56extern Event EV_Sentient_UseItem;
57extern Event EV_Sentient_UseLastWeapon;
58extern Event EV_Sentient_UseWeaponClass;
59extern Event EV_Sentient_ToggleItemUse;
60extern Event EV_Sentient_DontDropWeapons;
61extern Event EV_Sentient_ForceDropWeapon;
62extern Event EV_Sentient_ForceDropHealth;
63extern Event EV_Sentient_GetForceDropHealth;
64extern Event EV_Sentient_GetForceDropWeapon;
65
66// Shutup compiler
67class Weapon;
68class Item;
69class InventoryItem;
70class Ammo;
71class Vehicle;
72class VehicleTank;
73class TurretGun;
74
75#define MAX_ACTIVE_WEAPONS NUM_ACTIVE_WEAPONS
76#define MAX_DAMAGE_MULTIPLIERS 19
77
78#define TEAM_GERMAN 0
79#define TEAM_AMERICAN 1
80
81#define THREATBIAS_IGNOREME 0xFFFFE4C7
82
83typedef SafePtr<Weapon> WeaponPtr;
84
85class ActiveWeapon : public Class
86{
87public:
88 WeaponPtr weapon;
89 weaponhand_t hand;
90 ActiveWeapon();
91 void Archive(Archiver& arc);
92};
93
94class Sentient : public Animate
95{
96protected:
97 Container<int> inventory;
98 Container<Ammo *> ammo_inventory;
99 float LMRF;
100 WeaponPtr newWeapon;
101 int poweruptype;
102 int poweruptimer;
103 Vector offset_color;
104 Vector offset_delta;
105 float charge_start_time;
106 str blood_model;
107 SafePtr<Weapon> activeWeaponList[MAX_ACTIVE_WEAPONS];
108 ActiveWeapon newActiveWeapon;
109 WeaponPtr holsteredWeapon;
110 bool weapons_holstered_by_code;
111 ActiveWeapon lastActiveWeapon;
112 float m_fDamageMultipliers[MAX_DAMAGE_MULTIPLIERS];
113 SafePtr<Vehicle> m_pVehicle;
114 SafePtr<TurretGun> m_pTurret;
115 SafePtr<Entity> m_pLadder;
116 str m_sHelmetSurface1;
117 str m_sHelmetSurface2;
118 str m_sHelmetTiki;
119 float m_fHelmetSpeed;
120 bool m_bDontDropWeapons;
121
122 virtual void EventTake(Event *ev);
123 virtual void EventGiveAmmo(Event *ev);
124 virtual void EventGiveItem(Event *ev);
125 void EventGiveDynItem(Event *ev);
126 void SetBloodModel(Event *ev);
127 void EventUseItem(Event *ev);
128 virtual void EventUseWeaponClass(Event *ev);
129 virtual void EventGiveTargetname(Event *ev);
130
131 void EventGerman(Event *ev);
132 void EventAmerican(Event *ev);
133 void EventGetTeam(Event *ev);
134 virtual void ClearEnemies();
135 void EventGetThreatBias(Event *ev);
136 void EventSetThreatBias(Event *ev);
137 void SetDamageMult(Event *ev);
138 void SetupHelmet(str sHelmetTiki, float fSpeed, float fDamageMult, str sHelmetSurface1, str sHelmetSurface2);
139 void EventSetupHelmet(Event *ev);
140 void EventPopHelmet(Event *ev);
141 bool WearingHelmet(void);
142 int CheckHitLocation(int iLocation);
143
144 virtual void ArmorDamage(Event *ev);
145 virtual qboolean CanBlock(int meansofdeath, qboolean full_block);
146 void AddBloodSpurt(Vector direction);
147 qboolean ShouldBleed(int meansofdeath, qboolean dead);
148 qboolean ShouldGib(int meansofdeath, float damage);
149 str GetBloodSpurtName(void);
150 str GetBloodSplatName(void);
151 float GetBloodSplatSize(void);
152 str GetGibName(void);
153 virtual void TurnOffShadow(Event *ev);
154 virtual void TurnOnShadow(Event *ev);
155 virtual void WeaponKnockedFromHands(void);
156
157 void EventDropItems(Event *ev);
158 void EventDontDropWeapons(Event *ev);
159 void EventForceDropWeapon(Event *ev);
160 void EventForceDropHealth(Event *ev);
161 void EventGetForceDropWeapon(Event *ev);
162 void EventGetForceDropHealth(Event *ev);
163 void DetachAllActiveWeapons(void);
164 void AttachAllActiveWeapons(void);
165 qboolean WeaponsOut(void);
166 qboolean IsActiveWeapon(Weapon *weapon);
167 void ActivateWeapon(Weapon *weapon, weaponhand_t hand);
168 void ActivateLastActiveWeapon(void);
169 void EventActivateLastActiveWeapon(Event *ev);
170 void EventToggleItemUse(Event *ev);
171 void DeactivateWeapon(Weapon *weapon);
172 void DeactivateWeapon(weaponhand_t hand);
173 void CheckAnimations(Event *ev);
174 void ChargeWeapon(weaponhand_t hand, firemode_t mode);
175 virtual void FireWeapon(int number, firemode_t mode);
176 void ReleaseFireWeapon(int number, firemode_t mode);
177 void Link();
178 void Unlink();
179
180public:
181 Vector mTargetPos;
182 float mAccuracy;
183 SafePtr<Sentient> m_pNextSquadMate;
184 SafePtr<Sentient> m_pPrevSquadMate;
185 Sentient *m_NextSentient;
186 Sentient *m_PrevSentient;
187 int m_Team;
188 int m_iAttackerCount;
189 SafePtr<Entity> m_pLastAttacker;
190 SafePtr<Sentient> m_Enemy;
191 float m_fPlayerSightLevel;
192 bool m_bIsDisguised;
193 bool m_bHasDisguise;
194 bool m_bOvercookDied;
195 int m_ShowPapersTime;
196 int m_iLastHitTime;
197 int m_iThreatBias;
198 bool m_bIsAnimal;
199 Vector gunoffset;
200 Vector eyeposition;
201 int viewheight;
202 Vector m_vViewVariation;
203 int means_of_death;
204 bool in_melee_attack;
205 bool in_block;
206 bool in_stun;
207 bool on_fire;
208 float on_fire_stop_time;
209 float next_catch_on_fire_time;
210 int on_fire_tagnums[3];
211 SafePtr<Entity> fire_owner;
212 bool attack_blocked;
213 float attack_blocked_time;
214 float max_mouth_angle;
215 int max_gibs;
216 float next_bleed_time;
217 bool m_bForceDropHealth;
218 bool m_bForceDropWeapon;
219
220 bool m_bFootOnGround_Right;
221 bool m_bFootOnGround_Left;
222 //
223 // Added in OPM
224 //
225 int iNextLandTime;
226
227 CLASS_PROTOTYPE(Sentient);
228
229 Sentient();
230 virtual ~Sentient();
231 virtual Vector EyePosition(void);
232
233 virtual void SetViewAngles(Vector angles);
234 virtual void SetTargetViewAngles(Vector angles);
235 virtual Vector GetViewAngles(void);
236 void AddViewVariation(const Vector &vVariation);
237 void SetMinViewVariation(const Vector &vVariation);
238 void SetHolsteredByCode(bool holstered);
239 bool CanSee(Entity *ent, float fov, float vision_distance, bool bNoEnts) override;
240 bool CanSee(const Vector& org, float fov, float vision_distance, bool bNoEnts) override;
241 virtual Vector GunPosition(void);
242 virtual Vector GunTarget(bool bNoCollision = false, const vec3_t position = NULL, const vec3_t forward = NULL);
243 void ReloadWeapon(Event *ev);
244 void FireWeapon(Event *ev);
245 void StopFireWeapon(Event *ev);
246 void ChargeWeapon(Event *ev);
247 virtual void EventForceLandmineMeasure(Event *ev);
248 void EventSetWeaponIdleState(Event *ev);
249 void EventPingForMines(Event *ev);
250 void ReleaseFireWeapon(Event *ev);
251 void ChangeWeapon(Weapon *weapon, weaponhand_t hand);
252 Weapon *GetActiveWeapon(weaponhand_t hand) const;
253 Weapon *WorstWeapon(Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0);
254 Weapon *BestWeapon(Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0);
255 Weapon *NextWeapon(Weapon *weapon);
256 Weapon *PreviousWeapon(Weapon *weapon);
257 void useWeapon(const char *weaponname, weaponhand_t hand = WEAPON_MAIN);
258 void useWeapon(Weapon *weapon, weaponhand_t hand = WEAPON_MAIN);
259 void EventUseWeapon(Event *ev);
260 void EventDeactivateWeapon(Event *ev);
261 int NumWeapons(void);
262 int AmmoCount(str ammo_type);
263 int MaxAmmoCount(str ammo_type);
264 int AmmoIndex(str ammo_type);
265 int UseAmmo(str ammo_type, int amount);
266 void GiveAmmo(str type, int amount, int max_amount = -1);
267 Ammo *FindAmmoByName(str name);
268 Item *giveItem(str itemname, int amount = 1);
269 void takeItem(const char *itemname);
270 void takeAmmoType(const char *ammoname);
271 void AddItem(Item *object);
272 void RemoveItem(Item *object);
273 void RemoveWeapons(void);
274 Weapon *GetWeapon(int index);
275 Item *FindItemByClassName(const char *classname);
276 Item *FindItemByModelname(const char *modelname);
277 Item *FindItemByExternalName(const char *externalname);
278 Item *FindItem(const char *itemname);
279 void FreeInventory(void);
280 void EventFreeInventory(Event *ev);
281 qboolean HasItem(const char *itemname);
282 qboolean HasWeaponClass(int iWeaponClass);
283 qboolean HasPrimaryWeapon(void);
284 qboolean HasSecondaryWeapon(void);
285 int NumInventoryItems(void);
286 Item *NextItem(Item *item);
287 Item *PrevItem(Item *item);
288 virtual void DropInventoryItems(void);
289 void ListInventory(void);
290
291 qboolean PowerupActive(void);
292
293 void setModel(const char *mdl);
294 void Archive(Archiver &arc) override;
295 void ArchivePersistantData(Archiver &arc);
296 void DoubleArmor(void);
297 virtual qboolean DoGib(int meansofdeath, Entity *inflictor);
298 void JumpXY(Event *ev);
299 void MeleeAttackStart(Event *ev);
300 void MeleeAttackEnd(Event *ev);
301 void BlockStart(Event *ev);
302 void BlockEnd(Event *ev);
303 void StunStart(Event *ev);
304 void StunEnd(Event *ev);
305 void SetAttackBlocked(bool blocked);
306 virtual void ReceivedItem(Item *item);
307 virtual void RemovedItem(Item *item);
308 virtual void AmmoAmountChanged(Ammo *ammo, int inclip = 0);
309 void AmmoAmountInClipChanged(str ammo_type, int amount);
310
311 void SetMaxMouthAngle(Event *ev);
312 void TryLightOnFire(int meansofdeath, Entity *attacker);
313 void OnFire(Event *ev);
314 void StopOnFire(Event *ev);
315 void SpawnBloodyGibs(Event *ev);
316 void SetMaxGibs(Event *ev);
317 virtual void GetStateAnims(Container<const char *> *c);
318 void SpawnEffect(str modelname, Vector pos);
319
320 bool IsNewActiveWeapon(void);
321 Weapon *GetNewActiveWeapon(void);
322 weaponhand_t GetNewActiveWeaponHand(void);
323 void ClearNewActiveWeapon(void);
324 void SetNewActiveWeapon(Weapon* weapon, weaponhand_t hand);
325 void Holster(qboolean putaway);
326 void SafeHolster(qboolean putaway);
327 void ActivateNewWeapon(void);
328 void ActivateNewWeapon(Event *ev);
329 void UpdateWeapons(void);
330 VehicleTank *GetVehicleTank(void);
331 void UpdateFootsteps(void);
332 qboolean AIDontFace() const override;
333 void PutawayWeapon(Event *ev);
334 void WeaponCommand(Event *ev);
335 //
336 // Squad stuff
337 //
338 void AssertValidSquad();
339 bool IsTeamMate(Sentient *pOther);
340 void JoinNearbySquads(float fJoinRadius = 1024.0f);
341 void MergeWithSquad(Sentient *pFriendly);
342 void DisbandSquadMate(Sentient *pExFriendly);
343 bool IsSquadMate(Sentient *pFriendly);
344
345 virtual bool IsDisabled() const; // Added in 2.30
346
347 Vehicle* GetVehicle() const;
348 void SetVehicle(Vehicle* pVehicle);
349
350 TurretGun* GetTurret() const;
351 void SetTurret(TurretGun* pTurret);
352
353 Entity* GetLadder() const; // Added in OPM
354
355 //
356 // Custom openmohaa stuff
357 //
358 void GetActiveWeap(Event *ev);
359 void GetNewActiveWeaponOld(Event *ev);
360 void GetNewActiveWeapon(Event *ev);
361 void GetNewActiveWeaponHand(Event *ev);
362 void EventClientLanding(Event *ev);
363
364 void FootstepMain(trace_t *trace, int iRunning, int iEquipment);
365 void Footstep(const char *szTagName, int iRunning, int iEquipment);
366 void LandingSound(float volume, int iEquipment);
367
368 const Container<int>& getInventory() const;
369 const Container<Ammo*>& getAmmoInventory() const;
370};
371
372typedef SafePtr<Sentient> SentientPtr;
373
374extern Container<Sentient *> SentientList;
Definition sentient.h:86
Definition ammo.h:41
Definition archive.h:86
Definition container.h:85
Definition listener.h:246
Definition inventoryitem.h:31
Definition item.h:47
Definition safeptr.h:160
Definition weapturret.h:46
Definition vector.h:61
Definition vehicle.h:578
Definition vehicle.h:130
Definition weapon.h:99
Definition uiconsole.h:27
Definition str.h:77
Definition q_shared.h:1452