2016-03-27 11:49:47 +02:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 2015 the OpenMoHAA team
|
|
|
|
|
|
|
|
This file is part of OpenMoHAA source code.
|
|
|
|
|
|
|
|
OpenMoHAA source code 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 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
// sentient.h: Base class of entity that can carry other entities, and use weapons.
|
|
|
|
//
|
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
#pragma once
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
#include "g_local.h"
|
|
|
|
#include "container.h"
|
|
|
|
#include "animate.h"
|
2018-08-29 14:41:48 +02:00
|
|
|
#include "vehicle.h"
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
extern Event EV_Sentient_Attack;
|
|
|
|
extern Event EV_Sentient_Charge;
|
|
|
|
extern Event EV_Sentient_ReleaseAttack;
|
|
|
|
extern Event EV_Sentient_GiveWeapon;
|
|
|
|
extern Event EV_Sentient_GiveAmmo;
|
|
|
|
extern Event EV_Sentient_GiveArmor;
|
|
|
|
extern Event EV_Sentient_GiveItem;
|
|
|
|
extern Event EV_Sentient_GiveTargetname;
|
|
|
|
extern Event EV_Sentient_GiveInventoryItem;
|
|
|
|
extern Event EV_Sentient_GiveHealth;
|
|
|
|
extern Event EV_Sentient_SetBloodModel;
|
|
|
|
extern Event EV_Sentient_UselessCheck;
|
|
|
|
extern Event EV_Sentient_TurnOffShadow;
|
|
|
|
extern Event EV_Sentient_TurnOnShadow;
|
|
|
|
extern Event EV_Sentient_UpdateOffsetColor;
|
|
|
|
extern Event EV_Sentient_JumpXY;
|
|
|
|
extern Event EV_Sentient_MeleeAttackStart;
|
|
|
|
extern Event EV_Sentient_MeleeAttackEnd;
|
|
|
|
extern Event EV_Sentient_BlockStart;
|
|
|
|
extern Event EV_Sentient_BlockEnd;
|
|
|
|
extern Event EV_Sentient_SetMouthAngle;
|
|
|
|
extern Event EV_Sentient_SpawnBloodyGibs;
|
|
|
|
extern Event EV_Sentient_StopOnFire;
|
|
|
|
extern Event EV_Sentient_UseItem;
|
|
|
|
extern Event EV_Sentient_UseLastWeapon;
|
|
|
|
extern Event EV_Sentient_UseWeaponClass;
|
|
|
|
extern Event EV_Sentient_ToggleItemUse;
|
2023-08-14 19:00:16 +02:00
|
|
|
extern Event EV_Sentient_DontDropWeapons;
|
|
|
|
extern Event EV_Sentient_ForceDropWeapon;
|
|
|
|
extern Event EV_Sentient_ForceDropHealth;
|
|
|
|
extern Event EV_Sentient_GetForceDropHealth;
|
|
|
|
extern Event EV_Sentient_GetForceDropWeapon;
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
// Shutup compiler
|
|
|
|
class Weapon;
|
|
|
|
class Item;
|
|
|
|
class InventoryItem;
|
|
|
|
class Ammo;
|
|
|
|
class Vehicle;
|
2018-09-05 16:55:10 +02:00
|
|
|
class VehicleTank;
|
2016-03-27 11:49:47 +02:00
|
|
|
class TurretGun;
|
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
#define MAX_ACTIVE_WEAPONS NUM_ACTIVE_WEAPONS
|
2016-03-27 11:49:47 +02:00
|
|
|
#define MAX_DAMAGE_MULTIPLIERS 19
|
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
#define TEAM_GERMAN 0
|
|
|
|
#define TEAM_AMERICAN 1
|
2016-03-27 11:49:47 +02:00
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
#define THREATBIAS_IGNOREME 0xFFFFE4C7
|
2018-09-05 16:55:10 +02:00
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
typedef SafePtr<Weapon> WeaponPtr;
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
class ActiveWeapon : public Class
|
2023-08-09 19:45:39 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
WeaponPtr weapon;
|
|
|
|
weaponhand_t hand;
|
|
|
|
ActiveWeapon();
|
|
|
|
void Archive(Archiver& arc);
|
|
|
|
};
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
class Sentient : public Animate
|
2023-08-09 19:45:39 +02:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Container<int> inventory;
|
|
|
|
Container<Ammo *> ammo_inventory;
|
|
|
|
float LMRF;
|
|
|
|
WeaponPtr newWeapon;
|
|
|
|
int poweruptype;
|
|
|
|
int poweruptimer;
|
|
|
|
Vector offset_color;
|
|
|
|
Vector offset_delta;
|
|
|
|
float charge_start_time;
|
|
|
|
str blood_model;
|
|
|
|
SafePtr<Weapon> activeWeaponList[MAX_ACTIVE_WEAPONS];
|
|
|
|
ActiveWeapon newActiveWeapon;
|
|
|
|
WeaponPtr holsteredWeapon;
|
|
|
|
bool weapons_holstered_by_code;
|
|
|
|
ActiveWeapon lastActiveWeapon;
|
|
|
|
float m_fDamageMultipliers[MAX_DAMAGE_MULTIPLIERS];
|
2023-09-24 00:27:51 +02:00
|
|
|
SafePtr<Vehicle> m_pVehicle;
|
2023-08-09 19:45:39 +02:00
|
|
|
SafePtr<TurretGun> m_pTurret;
|
|
|
|
SafePtr<Entity> m_pLadder;
|
|
|
|
str m_sHelmetSurface1;
|
|
|
|
str m_sHelmetSurface2;
|
|
|
|
str m_sHelmetTiki;
|
|
|
|
float m_fHelmetSpeed;
|
|
|
|
bool m_bDontDropWeapons;
|
|
|
|
|
|
|
|
virtual void EventTake(Event *ev);
|
|
|
|
virtual void EventGiveAmmo(Event *ev);
|
|
|
|
virtual void EventGiveItem(Event *ev);
|
|
|
|
void EventGiveDynItem(Event *ev);
|
|
|
|
void SetBloodModel(Event *ev);
|
|
|
|
void EventUseItem(Event *ev);
|
2023-08-10 01:42:06 +02:00
|
|
|
virtual void EventUseWeaponClass(Event *ev);
|
2023-08-09 19:45:39 +02:00
|
|
|
virtual void EventGiveTargetname(Event *ev);
|
|
|
|
|
|
|
|
void EventGerman(Event *ev);
|
|
|
|
void EventAmerican(Event *ev);
|
|
|
|
void EventGetTeam(Event *ev);
|
|
|
|
virtual void ClearEnemies();
|
|
|
|
void EventGetThreatBias(Event *ev);
|
|
|
|
void EventSetThreatBias(Event *ev);
|
|
|
|
void SetDamageMult(Event *ev);
|
|
|
|
void SetupHelmet(str sHelmetTiki, float fSpeed, float fDamageMult, str sHelmetSurface1, str sHelmetSurface2);
|
|
|
|
void EventSetupHelmet(Event *ev);
|
|
|
|
void EventPopHelmet(Event *ev);
|
|
|
|
bool WearingHelmet(void);
|
|
|
|
int CheckHitLocation(int iLocation);
|
|
|
|
|
|
|
|
virtual void ArmorDamage(Event *ev);
|
|
|
|
virtual qboolean CanBlock(int meansofdeath, qboolean full_block);
|
|
|
|
void AddBloodSpurt(Vector direction);
|
|
|
|
qboolean ShouldBleed(int meansofdeath, qboolean dead);
|
|
|
|
qboolean ShouldGib(int meansofdeath, float damage);
|
|
|
|
str GetBloodSpurtName(void);
|
|
|
|
str GetBloodSplatName(void);
|
|
|
|
float GetBloodSplatSize(void);
|
|
|
|
str GetGibName(void);
|
|
|
|
virtual void TurnOffShadow(Event *ev);
|
|
|
|
virtual void TurnOnShadow(Event *ev);
|
|
|
|
virtual void WeaponKnockedFromHands(void);
|
|
|
|
|
2023-08-12 00:48:35 +02:00
|
|
|
void EventDropItems(Event *ev);
|
|
|
|
void EventDontDropWeapons(Event *ev);
|
|
|
|
void EventForceDropWeapon(Event *ev);
|
|
|
|
void EventForceDropHealth(Event *ev);
|
|
|
|
void EventGetForceDropWeapon(Event *ev);
|
|
|
|
void EventGetForceDropHealth(Event *ev);
|
|
|
|
void DetachAllActiveWeapons(void);
|
|
|
|
void AttachAllActiveWeapons(void);
|
|
|
|
qboolean WeaponsOut(void);
|
|
|
|
qboolean IsActiveWeapon(Weapon *weapon);
|
|
|
|
void ActivateWeapon(Weapon *weapon, weaponhand_t hand);
|
|
|
|
void ActivateLastActiveWeapon(void);
|
|
|
|
void EventActivateLastActiveWeapon(Event *ev);
|
|
|
|
void EventToggleItemUse(Event *ev);
|
|
|
|
void DeactivateWeapon(Weapon *weapon);
|
|
|
|
void DeactivateWeapon(weaponhand_t hand);
|
|
|
|
void CheckAnimations(Event *ev);
|
|
|
|
void ChargeWeapon(weaponhand_t hand, firemode_t mode);
|
|
|
|
virtual void FireWeapon(int number, firemode_t mode);
|
|
|
|
void ReleaseFireWeapon(int number, firemode_t mode);
|
|
|
|
void Link();
|
|
|
|
void Unlink();
|
2023-08-09 19:45:39 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Vector mTargetPos;
|
|
|
|
float mAccuracy;
|
|
|
|
SafePtr<Sentient> m_pNextSquadMate;
|
|
|
|
SafePtr<Sentient> m_pPrevSquadMate;
|
|
|
|
Sentient *m_NextSentient;
|
|
|
|
Sentient *m_PrevSentient;
|
|
|
|
int m_Team;
|
|
|
|
int m_iAttackerCount;
|
|
|
|
SafePtr<Entity> m_pLastAttacker;
|
|
|
|
SafePtr<Sentient> m_Enemy;
|
|
|
|
float m_fPlayerSightLevel;
|
|
|
|
bool m_bIsDisguised;
|
|
|
|
bool m_bHasDisguise;
|
|
|
|
bool m_bOvercookDied;
|
|
|
|
int m_ShowPapersTime;
|
|
|
|
int m_iLastHitTime;
|
|
|
|
int m_iThreatBias;
|
2023-08-12 00:48:35 +02:00
|
|
|
bool m_bIsAnimal;
|
2023-08-09 19:45:39 +02:00
|
|
|
Vector gunoffset;
|
|
|
|
Vector eyeposition;
|
|
|
|
int viewheight;
|
|
|
|
Vector m_vViewVariation;
|
|
|
|
int means_of_death;
|
|
|
|
bool in_melee_attack;
|
|
|
|
bool in_block;
|
|
|
|
bool in_stun;
|
|
|
|
bool on_fire;
|
|
|
|
float on_fire_stop_time;
|
|
|
|
float next_catch_on_fire_time;
|
|
|
|
int on_fire_tagnums[3];
|
|
|
|
SafePtr<Entity> fire_owner;
|
|
|
|
bool attack_blocked;
|
|
|
|
float attack_blocked_time;
|
|
|
|
float max_mouth_angle;
|
|
|
|
int max_gibs;
|
|
|
|
float next_bleed_time;
|
2023-08-12 00:48:35 +02:00
|
|
|
bool m_bForceDropHealth;
|
|
|
|
bool m_bForceDropWeapon;
|
2023-09-03 22:13:03 +02:00
|
|
|
|
2023-09-17 16:27:18 +02:00
|
|
|
bool m_bFootOnGround_Right;
|
|
|
|
bool m_bFootOnGround_Left;
|
2023-11-27 20:06:19 +01:00
|
|
|
//
|
2023-12-28 20:34:49 +01:00
|
|
|
// Added in OPM
|
2023-11-27 20:06:19 +01:00
|
|
|
//
|
2023-09-17 16:27:18 +02:00
|
|
|
int iNextLandTime;
|
2023-08-09 19:45:39 +02:00
|
|
|
|
|
|
|
CLASS_PROTOTYPE(Sentient);
|
|
|
|
|
|
|
|
Sentient();
|
|
|
|
virtual ~Sentient();
|
|
|
|
virtual Vector EyePosition(void);
|
|
|
|
|
|
|
|
virtual void SetViewAngles(Vector angles);
|
|
|
|
virtual void SetTargetViewAngles(Vector angles);
|
|
|
|
virtual Vector GetViewAngles(void);
|
|
|
|
void AddViewVariation(const Vector &vVariation);
|
|
|
|
void SetMinViewVariation(const Vector &vVariation);
|
2023-09-17 16:27:18 +02:00
|
|
|
void SetHolsteredByCode(bool holstered);
|
2023-08-09 23:09:09 +02:00
|
|
|
bool CanSee(Entity *ent, float fov, float vision_distance, bool bNoEnts) override;
|
2023-10-21 16:50:26 +02:00
|
|
|
bool CanSee(const Vector& org, float fov, float vision_distance, bool bNoEnts) override;
|
2023-08-09 19:45:39 +02:00
|
|
|
virtual Vector GunPosition(void);
|
2023-10-17 19:45:22 +02:00
|
|
|
virtual Vector GunTarget(bool bNoCollision = false, const vec3_t position = NULL, const vec3_t forward = NULL);
|
2023-08-09 19:45:39 +02:00
|
|
|
void ReloadWeapon(Event *ev);
|
|
|
|
void FireWeapon(Event *ev);
|
|
|
|
void StopFireWeapon(Event *ev);
|
|
|
|
void ChargeWeapon(Event *ev);
|
2023-08-12 00:48:35 +02:00
|
|
|
virtual void EventForceLandmineMeasure(Event *ev);
|
|
|
|
void EventSetWeaponIdleState(Event *ev);
|
|
|
|
void EventPingForMines(Event *ev);
|
2023-08-09 19:45:39 +02:00
|
|
|
void ReleaseFireWeapon(Event *ev);
|
|
|
|
void ChangeWeapon(Weapon *weapon, weaponhand_t hand);
|
|
|
|
Weapon *GetActiveWeapon(weaponhand_t hand) const;
|
|
|
|
Weapon *WorstWeapon(Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0);
|
|
|
|
Weapon *BestWeapon(Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0);
|
|
|
|
Weapon *NextWeapon(Weapon *weapon);
|
|
|
|
Weapon *PreviousWeapon(Weapon *weapon);
|
|
|
|
void useWeapon(const char *weaponname, weaponhand_t hand = WEAPON_MAIN);
|
|
|
|
void useWeapon(Weapon *weapon, weaponhand_t hand = WEAPON_MAIN);
|
|
|
|
void EventUseWeapon(Event *ev);
|
|
|
|
void EventDeactivateWeapon(Event *ev);
|
|
|
|
int NumWeapons(void);
|
|
|
|
int AmmoCount(str ammo_type);
|
|
|
|
int MaxAmmoCount(str ammo_type);
|
|
|
|
int AmmoIndex(str ammo_type);
|
|
|
|
int UseAmmo(str ammo_type, int amount);
|
|
|
|
void GiveAmmo(str type, int amount, int max_amount = -1);
|
|
|
|
Ammo *FindAmmoByName(str name);
|
|
|
|
Item *giveItem(str itemname, int amount = 1);
|
|
|
|
void takeItem(const char *itemname);
|
|
|
|
void takeAmmoType(const char *ammoname);
|
|
|
|
void AddItem(Item *object);
|
|
|
|
void RemoveItem(Item *object);
|
|
|
|
void RemoveWeapons(void);
|
|
|
|
Weapon *GetWeapon(int index);
|
|
|
|
Item *FindItemByClassName(const char *classname);
|
|
|
|
Item *FindItemByModelname(const char *modelname);
|
|
|
|
Item *FindItemByExternalName(const char *externalname);
|
|
|
|
Item *FindItem(const char *itemname);
|
|
|
|
void FreeInventory(void);
|
|
|
|
void EventFreeInventory(Event *ev);
|
|
|
|
qboolean HasItem(const char *itemname);
|
|
|
|
qboolean HasWeaponClass(int iWeaponClass);
|
|
|
|
qboolean HasPrimaryWeapon(void);
|
|
|
|
qboolean HasSecondaryWeapon(void);
|
|
|
|
int NumInventoryItems(void);
|
|
|
|
Item *NextItem(Item *item);
|
|
|
|
Item *PrevItem(Item *item);
|
|
|
|
virtual void DropInventoryItems(void);
|
|
|
|
void ListInventory(void);
|
|
|
|
|
|
|
|
qboolean PowerupActive(void);
|
|
|
|
|
2023-08-12 00:48:35 +02:00
|
|
|
void setModel(const char *mdl);
|
2023-08-09 19:45:39 +02:00
|
|
|
void Archive(Archiver &arc) override;
|
|
|
|
void ArchivePersistantData(Archiver &arc);
|
|
|
|
void DoubleArmor(void);
|
|
|
|
virtual qboolean DoGib(int meansofdeath, Entity *inflictor);
|
|
|
|
void JumpXY(Event *ev);
|
|
|
|
void MeleeAttackStart(Event *ev);
|
|
|
|
void MeleeAttackEnd(Event *ev);
|
|
|
|
void BlockStart(Event *ev);
|
|
|
|
void BlockEnd(Event *ev);
|
|
|
|
void StunStart(Event *ev);
|
|
|
|
void StunEnd(Event *ev);
|
|
|
|
void SetAttackBlocked(bool blocked);
|
|
|
|
virtual void ReceivedItem(Item *item);
|
|
|
|
virtual void RemovedItem(Item *item);
|
|
|
|
virtual void AmmoAmountChanged(Ammo *ammo, int inclip = 0);
|
|
|
|
void AmmoAmountInClipChanged(str ammo_type, int amount);
|
|
|
|
|
|
|
|
void SetMaxMouthAngle(Event *ev);
|
|
|
|
void TryLightOnFire(int meansofdeath, Entity *attacker);
|
|
|
|
void OnFire(Event *ev);
|
|
|
|
void StopOnFire(Event *ev);
|
|
|
|
void SpawnBloodyGibs(Event *ev);
|
|
|
|
void SetMaxGibs(Event *ev);
|
|
|
|
virtual void GetStateAnims(Container<const char *> *c);
|
|
|
|
void SpawnEffect(str modelname, Vector pos);
|
|
|
|
|
|
|
|
bool IsNewActiveWeapon(void);
|
|
|
|
Weapon *GetNewActiveWeapon(void);
|
|
|
|
weaponhand_t GetNewActiveWeaponHand(void);
|
|
|
|
void ClearNewActiveWeapon(void);
|
|
|
|
void Holster(qboolean putaway);
|
|
|
|
void SafeHolster(qboolean putaway);
|
|
|
|
void ActivateNewWeapon(void);
|
|
|
|
void ActivateNewWeapon(Event *ev);
|
|
|
|
void UpdateWeapons(void);
|
|
|
|
VehicleTank *GetVehicleTank(void);
|
|
|
|
void UpdateFootsteps(void);
|
|
|
|
qboolean AIDontFace() const override;
|
|
|
|
void PutawayWeapon(Event *ev);
|
|
|
|
void WeaponCommand(Event *ev);
|
|
|
|
//
|
|
|
|
// Squad stuff
|
|
|
|
//
|
|
|
|
void AssertValidSquad();
|
|
|
|
bool IsTeamMate(Sentient *pOther);
|
|
|
|
void JoinNearbySquads(float fJoinRadius = 1024.0f);
|
|
|
|
void MergeWithSquad(Sentient *pFriendly);
|
|
|
|
void DisbandSquadMate(Sentient *pExFriendly);
|
|
|
|
bool IsSquadMate(Sentient *pFriendly);
|
|
|
|
|
2023-10-12 19:04:47 +02:00
|
|
|
virtual bool IsDisabled() const; // Added in 2.30
|
|
|
|
|
2023-09-24 00:27:51 +02:00
|
|
|
Vehicle* GetVehicle() const;
|
2023-10-02 18:09:55 +02:00
|
|
|
void SetVehicle(Vehicle* pVehicle);
|
|
|
|
|
|
|
|
TurretGun* GetTurret() const;
|
|
|
|
void SetTurret(TurretGun* pTurret);
|
2023-09-24 00:27:51 +02:00
|
|
|
|
2024-10-08 21:52:49 +02:00
|
|
|
Entity* GetLadder() const; // Added in OPM
|
|
|
|
|
2023-08-09 19:45:39 +02:00
|
|
|
//
|
|
|
|
// Custom openmohaa stuff
|
|
|
|
//
|
|
|
|
void GetActiveWeap(Event *ev);
|
|
|
|
void GetNewActiveWeapon(Event *ev);
|
2023-09-03 22:13:03 +02:00
|
|
|
void EventClientLanding(Event *ev);
|
|
|
|
|
2023-09-17 16:27:18 +02:00
|
|
|
void FootstepMain(trace_t *trace, int iRunning, int iEquipment);
|
|
|
|
void Footstep(const char *szTagName, int iRunning, int iEquipment);
|
2023-09-03 22:13:03 +02:00
|
|
|
void LandingSound(float volume, int iEquipment);
|
2023-08-09 19:45:39 +02:00
|
|
|
};
|
2016-03-27 11:49:47 +02:00
|
|
|
|
|
|
|
typedef SafePtr<Sentient> SentientPtr;
|
|
|
|
|
|
|
|
extern Container<Sentient *> SentientList;
|