mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-10 12:36:38 +03:00
Cleaned up Sentient class
Moved combat stuff to sentient_combat.cpp Formatted source files
This commit is contained in:
parent
f313b6a058
commit
987af7eb81
3 changed files with 3873 additions and 4513 deletions
File diff suppressed because it is too large
Load diff
|
@ -23,8 +23,7 @@ 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.
|
// sentient.h: Base class of entity that can carry other entities, and use weapons.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef __SENTIENT_H__
|
#pragma once
|
||||||
#define __SENTIENT_H__
|
|
||||||
|
|
||||||
#include "g_local.h"
|
#include "g_local.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
@ -109,24 +108,6 @@ class ActiveWeapon : public Class
|
||||||
void Archive(Archiver& arc);
|
void Archive(Archiver& arc);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline ActiveWeapon::ActiveWeapon
|
|
||||||
(
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
hand = WEAPON_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ActiveWeapon::Archive
|
|
||||||
(
|
|
||||||
Archiver &arc
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
arc.ArchiveObjectPointer( ( Class ** )&weapon );
|
|
||||||
ArchiveEnum( hand, weaponhand_t );
|
|
||||||
}
|
|
||||||
|
|
||||||
class Sentient : public Animate
|
class Sentient : public Animate
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -157,10 +138,12 @@ class Sentient : public Animate
|
||||||
bool m_bDontDropWeapons;
|
bool m_bDontDropWeapons;
|
||||||
|
|
||||||
virtual void EventTake(Event *ev);
|
virtual void EventTake(Event *ev);
|
||||||
virtual void EventFreeInventory( Event *ev );
|
|
||||||
virtual void EventGiveAmmo(Event *ev);
|
virtual void EventGiveAmmo(Event *ev);
|
||||||
virtual void EventGiveItem(Event *ev);
|
virtual void EventGiveItem(Event *ev);
|
||||||
|
void EventGiveDynItem(Event *ev);
|
||||||
void SetBloodModel(Event *ev);
|
void SetBloodModel(Event *ev);
|
||||||
|
void EventUseItem(Event *ev);
|
||||||
|
void EventUseWeaponClass(Event *ev);
|
||||||
virtual void EventGiveTargetname(Event *ev);
|
virtual void EventGiveTargetname(Event *ev);
|
||||||
|
|
||||||
void EventGerman(Event *ev);
|
void EventGerman(Event *ev);
|
||||||
|
@ -176,13 +159,6 @@ class Sentient : public Animate
|
||||||
bool WearingHelmet(void);
|
bool WearingHelmet(void);
|
||||||
int CheckHitLocation(int iLocation);
|
int CheckHitLocation(int iLocation);
|
||||||
|
|
||||||
// Squad stuff
|
|
||||||
bool IsTeamMate( Sentient *pOther );
|
|
||||||
void JoinNearbySquads( float fJoinRadius = 1024.0f );
|
|
||||||
void MergeWithSquad( Sentient *pFriendly );
|
|
||||||
void DisbandSquadMate( Sentient *pExFriendly );
|
|
||||||
bool IsSquadMate( Sentient *pFriendly );
|
|
||||||
|
|
||||||
virtual void ArmorDamage(Event *ev);
|
virtual void ArmorDamage(Event *ev);
|
||||||
virtual qboolean CanBlock(int meansofdeath, qboolean full_block);
|
virtual qboolean CanBlock(int meansofdeath, qboolean full_block);
|
||||||
void AddBloodSpurt(Vector direction);
|
void AddBloodSpurt(Vector direction);
|
||||||
|
@ -196,30 +172,24 @@ class Sentient : public Animate
|
||||||
virtual void TurnOnShadow(Event *ev);
|
virtual void TurnOnShadow(Event *ev);
|
||||||
virtual void WeaponKnockedFromHands(void);
|
virtual void WeaponKnockedFromHands(void);
|
||||||
|
|
||||||
void UpdateOffsetColor( Event *ev );
|
|
||||||
|
|
||||||
void DetachAllActiveWeapons( void );
|
|
||||||
void AttachAllActiveWeapons( void );
|
|
||||||
|
|
||||||
void UpdateWeapons( void );
|
|
||||||
qboolean IsActiveWeapon( Weapon *weapon );
|
|
||||||
void ActivateWeapon( Weapon *weapon, weaponhand_t hand );
|
|
||||||
void ActivateNewWeapon( Event *ev );
|
|
||||||
void ActivateNewWeapon( void );
|
|
||||||
void DeactivateWeapon( Weapon *weapon );
|
|
||||||
void DeactivateWeapon( weaponhand_t hand );
|
|
||||||
void DeactivateWeapon( Event *ev );
|
|
||||||
void ActivateLastActiveWeapon( void );
|
|
||||||
void CheckAnimations( Event *ev );
|
|
||||||
void EventActivateLastActiveWeapon( Event *ev );
|
|
||||||
void EventDropItems(Event *ev);
|
void EventDropItems(Event *ev);
|
||||||
void EventDontDropWeapons(Event *ev);
|
void EventDontDropWeapons(Event *ev);
|
||||||
void EventUseItem( Event *ev );
|
void DetachAllActiveWeapons(void);
|
||||||
void EventUseWeaponClass( Event *ev );
|
void AttachAllActiveWeapons(void);
|
||||||
void EventToggleItem( Event *ev );
|
qboolean WeaponsOut(void);
|
||||||
void ReloadWeapon( Event *ev );
|
qboolean IsActiveWeapon(Weapon *weapon);
|
||||||
void GetActiveWeap( Event *ev );
|
void ActivateWeapon(Weapon *weapon, weaponhand_t hand);
|
||||||
void GetNewActiveWeapon( Event *ev );
|
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);
|
||||||
|
void FireWeapon(int number, firemode_t mode);
|
||||||
|
void ReleaseFireWeapon(int number, firemode_t mode);
|
||||||
|
void Link();
|
||||||
|
void Unlink();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vector mTargetPos;
|
Vector mTargetPos;
|
||||||
|
@ -264,32 +234,31 @@ class Sentient : public Animate
|
||||||
|
|
||||||
Sentient();
|
Sentient();
|
||||||
virtual ~Sentient();
|
virtual ~Sentient();
|
||||||
Vector EyePosition( void );
|
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);
|
||||||
|
bool CanSee(Entity *ent, float fov, float vision_distance) override;
|
||||||
virtual Vector GunPosition(void);
|
virtual Vector GunPosition(void);
|
||||||
virtual Vector GunTarget(bool bNoCollision = false);
|
virtual Vector GunTarget(bool bNoCollision = false);
|
||||||
|
void ReloadWeapon(Event *ev);
|
||||||
void FireWeapon(Event *ev);
|
void FireWeapon(Event *ev);
|
||||||
void FireWeapon( int number, firemode_t mode );
|
|
||||||
void StopFireWeapon(Event *ev);
|
void StopFireWeapon(Event *ev);
|
||||||
void ChargeWeapon(Event *ev);
|
void ChargeWeapon(Event *ev);
|
||||||
void ChargeWeapon( weaponhand_t hand, firemode_t mode );
|
|
||||||
void ReleaseFireWeapon(Event *ev);
|
void ReleaseFireWeapon(Event *ev);
|
||||||
void ReleaseFireWeapon( int number, firemode_t mode );
|
|
||||||
void ChangeWeapon(Weapon *weapon, weaponhand_t hand);
|
void ChangeWeapon(Weapon *weapon, weaponhand_t hand);
|
||||||
Weapon *GetActiveWeapon( weaponhand_t hand );
|
Weapon *GetActiveWeapon(weaponhand_t hand) const;
|
||||||
Weapon *BestWeapon( Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0 );
|
|
||||||
Weapon *WorstWeapon(Weapon *ignore = NULL, qboolean bGetItem = false, int iIgnoreClass = 0);
|
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 *NextWeapon(Weapon *weapon);
|
||||||
Weapon *PreviousWeapon(Weapon *weapon);
|
Weapon *PreviousWeapon(Weapon *weapon);
|
||||||
virtual void useWeapon( const char *weaponname, weaponhand_t hand );
|
void useWeapon(const char *weaponname, weaponhand_t hand = WEAPON_MAIN);
|
||||||
virtual void useWeapon( Weapon *weapon, weaponhand_t hand );
|
void useWeapon(Weapon *weapon, weaponhand_t hand = WEAPON_MAIN);
|
||||||
qboolean WeaponsOut( void );
|
void EventUseWeapon(Event *ev);
|
||||||
void Holster( qboolean putaway );
|
void EventDeactivateWeapon(Event *ev);
|
||||||
void SafeHolster( qboolean putaway );
|
|
||||||
bool IsNewActiveWeapon( void );
|
|
||||||
Weapon *GetNewActiveWeapon( void );
|
|
||||||
weaponhand_t GetNewActiveWeaponHand( void );
|
|
||||||
void ClearNewActiveWeapon( void );
|
|
||||||
int NumWeapons(void);
|
int NumWeapons(void);
|
||||||
int AmmoCount(str ammo_type);
|
int AmmoCount(str ammo_type);
|
||||||
int MaxAmmoCount(str ammo_type);
|
int MaxAmmoCount(str ammo_type);
|
||||||
|
@ -309,6 +278,7 @@ class Sentient : public Animate
|
||||||
Item *FindItemByExternalName(const char *externalname);
|
Item *FindItemByExternalName(const char *externalname);
|
||||||
Item *FindItem(const char *itemname);
|
Item *FindItem(const char *itemname);
|
||||||
void FreeInventory(void);
|
void FreeInventory(void);
|
||||||
|
void EventFreeInventory(Event *ev);
|
||||||
qboolean HasItem(const char *itemname);
|
qboolean HasItem(const char *itemname);
|
||||||
qboolean HasWeaponClass(int iWeaponClass);
|
qboolean HasWeaponClass(int iWeaponClass);
|
||||||
qboolean HasPrimaryWeapon(void);
|
qboolean HasPrimaryWeapon(void);
|
||||||
|
@ -319,10 +289,6 @@ class Sentient : public Animate
|
||||||
virtual void DropInventoryItems(void);
|
virtual void DropInventoryItems(void);
|
||||||
void ListInventory(void);
|
void ListInventory(void);
|
||||||
|
|
||||||
bool CanSee( Entity *ent, float fov, float vision_distance ) override;
|
|
||||||
virtual void SetViewAngles( Vector angles );
|
|
||||||
virtual Vector GetViewAngles( void );
|
|
||||||
|
|
||||||
qboolean PowerupActive(void);
|
qboolean PowerupActive(void);
|
||||||
|
|
||||||
void setModel(const char *model) override;
|
void setModel(const char *model) override;
|
||||||
|
@ -338,19 +304,11 @@ class Sentient : public Animate
|
||||||
void StunStart(Event *ev);
|
void StunStart(Event *ev);
|
||||||
void StunEnd(Event *ev);
|
void StunEnd(Event *ev);
|
||||||
void SetAttackBlocked(bool blocked);
|
void SetAttackBlocked(bool blocked);
|
||||||
void SetOffsetColor( float r, float g, float b, float time );
|
|
||||||
virtual void ReceivedItem(Item *item);
|
virtual void ReceivedItem(Item *item);
|
||||||
virtual void RemovedItem(Item *item);
|
virtual void RemovedItem(Item *item);
|
||||||
virtual void AmmoAmountChanged(Ammo *ammo, int inclip = 0);
|
virtual void AmmoAmountChanged(Ammo *ammo, int inclip = 0);
|
||||||
void AmmoAmountInClipChanged(str ammo_type, int amount);
|
void AmmoAmountInClipChanged(str ammo_type, int amount);
|
||||||
|
|
||||||
void PutawayWeapon( Event *ev );
|
|
||||||
void WeaponCommand( Event *ev );
|
|
||||||
|
|
||||||
VehicleTank *GetVehicleTank( void );
|
|
||||||
|
|
||||||
void UpdateFootsteps( void );
|
|
||||||
|
|
||||||
void SetMaxMouthAngle(Event *ev);
|
void SetMaxMouthAngle(Event *ev);
|
||||||
void TryLightOnFire(int meansofdeath, Entity *attacker);
|
void TryLightOnFire(int meansofdeath, Entity *attacker);
|
||||||
void OnFire(Event *ev);
|
void OnFire(Event *ev);
|
||||||
|
@ -359,48 +317,38 @@ class Sentient : public Animate
|
||||||
void SetMaxGibs(Event *ev);
|
void SetMaxGibs(Event *ev);
|
||||||
virtual void GetStateAnims(Container<const char *> *c);
|
virtual void GetStateAnims(Container<const char *> *c);
|
||||||
void SpawnEffect(str modelname, Vector pos);
|
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);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Custom openmohaa stuff
|
||||||
|
//
|
||||||
|
void GetActiveWeap(Event *ev);
|
||||||
|
void GetNewActiveWeapon(Event *ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool Sentient::IsNewActiveWeapon
|
|
||||||
(
|
|
||||||
void
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
return ( newActiveWeapon.weapon != NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline weaponhand_t Sentient::GetNewActiveWeaponHand
|
|
||||||
(
|
|
||||||
void
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
return newActiveWeapon.hand;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Weapon *Sentient::GetNewActiveWeapon
|
|
||||||
(
|
|
||||||
void
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
return newActiveWeapon.weapon;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Sentient::ClearNewActiveWeapon
|
|
||||||
(
|
|
||||||
void
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
|
||||||
newActiveWeapon.weapon.Clear();
|
|
||||||
newActiveWeapon.hand = WEAPON_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef SafePtr<Sentient> SentientPtr;
|
typedef SafePtr<Sentient> SentientPtr;
|
||||||
|
|
||||||
extern Container<Sentient *> SentientList;
|
extern Container<Sentient *> SentientList;
|
||||||
|
|
||||||
#endif /* sentient.h */
|
|
||||||
|
|
1179
code/fgame/sentient_combat.cpp
Normal file
1179
code/fgame/sentient_combat.cpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue