2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Entity.h"
|
2014-06-16 23:22:17 -04:00
|
|
|
#include "EntityEffect.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2016-02-01 15:49:34 -05:00
|
|
|
// fwd cMonster
|
|
|
|
class cMonster;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
// tolua_begin
|
2020-04-13 12:38:06 -04:00
|
|
|
class cPawn:
|
2012-12-21 06:04:08 -05:00
|
|
|
public cEntity
|
2012-12-21 07:21:20 -05:00
|
|
|
{
|
2012-12-21 06:04:08 -05:00
|
|
|
// tolua_end
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cEntity;
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
2020-04-13 12:38:06 -04:00
|
|
|
|
2014-07-22 18:36:13 -04:00
|
|
|
CLASS_PROTODEF(cPawn)
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2021-04-06 11:09:16 -04:00
|
|
|
cPawn(eEntityType a_EntityType, float a_Width, float a_Height);
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2014-07-17 05:07:10 -04:00
|
|
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2015-10-31 11:24:45 -04:00
|
|
|
virtual bool IsFireproof(void) const override;
|
2017-08-01 13:51:43 -04:00
|
|
|
virtual bool IsInvisible() const override;
|
2015-11-01 05:50:03 -05:00
|
|
|
virtual void HandleAir(void) override;
|
2015-11-10 08:02:07 -05:00
|
|
|
virtual void HandleFalling(void);
|
2021-01-02 08:50:34 -05:00
|
|
|
virtual void OnRemoveFromWorld(cWorld & a_World) override;
|
2015-11-10 08:02:07 -05:00
|
|
|
|
2016-02-01 15:49:34 -05:00
|
|
|
/** Tells all pawns which are targeting us to stop targeting us. */
|
|
|
|
void StopEveryoneFromTargetingMe();
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-12 22:50:02 -04:00
|
|
|
// tolua_begin
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2016-07-06 06:39:56 -04:00
|
|
|
/** Applies an entity effect.
|
2014-06-13 06:47:01 -04:00
|
|
|
Checks with plugins if they allow the addition.
|
2016-07-06 06:39:56 -04:00
|
|
|
a_EffectIntensity is the level of the effect (0 = Potion I, 1 = Potion II, etc).
|
|
|
|
a_DistanceModifier is the scalar multiplied to the potion duration (only applies to splash potions).
|
2014-06-13 05:41:43 -04:00
|
|
|
*/
|
2014-07-11 20:27:29 -04:00
|
|
|
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2016-07-06 06:39:56 -04:00
|
|
|
/** Removes a currently applied entity effect. */
|
2014-06-06 03:17:49 -04:00
|
|
|
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2016-07-06 06:39:56 -04:00
|
|
|
/** Returns true, if the entity effect is currently applied. */
|
2015-10-31 11:24:45 -04:00
|
|
|
bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2014-06-07 16:45:00 -04:00
|
|
|
/** Removes all currently applied entity effects (used when drinking milk) */
|
2014-06-13 05:04:16 -04:00
|
|
|
void ClearEntityEffects(void);
|
2015-11-10 08:02:07 -05:00
|
|
|
|
2014-06-12 22:50:02 -04:00
|
|
|
// tolua_end
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2016-07-06 06:39:56 -04:00
|
|
|
/** Remove the monster from the list of monsters targeting this pawn. */
|
2016-02-01 15:49:34 -05:00
|
|
|
void NoLongerTargetingMe(cMonster * a_Monster);
|
|
|
|
|
|
|
|
/** Add the monster to the list of monsters targeting this pawn. (Does not check if already in list!) */
|
|
|
|
void TargetingMe(cMonster * a_Monster);
|
|
|
|
|
2016-11-06 13:30:19 -05:00
|
|
|
/** Returns all entity effects */
|
2020-09-16 18:01:20 -04:00
|
|
|
std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects() const;
|
2016-11-06 13:30:19 -05:00
|
|
|
|
2017-08-01 13:51:43 -04:00
|
|
|
/** Returns the entity effect, if it is currently applied or nullptr if not. */
|
2020-09-16 18:01:20 -04:00
|
|
|
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType) const;
|
2016-11-06 13:30:19 -05:00
|
|
|
|
2021-07-10 16:05:00 -04:00
|
|
|
// tolua_begin
|
|
|
|
|
|
|
|
static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, const Vector3i a_MinBoxCorner, const Vector3i a_MaxBoxCorner);
|
|
|
|
|
|
|
|
static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, const cBoundingBox a_BoundingBox);
|
|
|
|
|
|
|
|
/** Used by enderman and chorus fruit.
|
|
|
|
Checks for valid destinations in a cube of length 2 * a_HalfCubeWidth centred at a_Centre.
|
|
|
|
Returns true and places destination in a_Destination if successful.
|
|
|
|
Returns false if destination could be found after a_NumTries attempts.
|
|
|
|
Details at: https://minecraft.fandom.com/wiki/Enderman#Teleportation. */
|
|
|
|
static bool FindTeleportDestination(cWorld & a_World, const int a_HeightRequired, const unsigned int a_NumTries, Vector3d & a_Destination, Vector3i a_Centre, const int a_HalfCubeWidth);
|
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
protected:
|
2021-01-22 04:05:18 -05:00
|
|
|
|
2017-08-01 13:51:43 -04:00
|
|
|
typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
|
2014-06-07 03:54:03 -04:00
|
|
|
tEffectMap m_EntityEffects;
|
2015-11-10 08:02:07 -05:00
|
|
|
|
|
|
|
double m_LastGroundHeight;
|
|
|
|
bool m_bTouchGround;
|
2016-02-01 15:49:34 -05:00
|
|
|
|
2018-07-23 12:26:48 -04:00
|
|
|
virtual void ResetPosition(Vector3d a_NewPosition) override;
|
|
|
|
|
2016-02-01 15:49:34 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
/** A list of all monsters that are targeting this pawn. */
|
|
|
|
std::vector<cMonster*> m_TargetingMe;
|
2021-01-22 04:05:18 -05:00
|
|
|
|
|
|
|
/** Attempt to activate a Totem of Undying.
|
|
|
|
If activation for the given type of damage was successful, consumes the totem and returns true. */
|
|
|
|
bool DeductTotem(eDamageType a_DamageType);
|
2013-07-01 06:39:56 -04:00
|
|
|
} ; // tolua_export
|