2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 22:09:57 +00:00
|
|
|
#include "Entity.h"
|
2014-06-17 03:22:17 +00:00
|
|
|
#include "EntityEffect.h"
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2016-02-01 20:49:34 +00:00
|
|
|
// fwd cMonster
|
|
|
|
class cMonster;
|
|
|
|
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-21 11:04:08 +00:00
|
|
|
// tolua_begin
|
2020-04-13 16:38:06 +00:00
|
|
|
class cPawn:
|
2012-12-21 11:04:08 +00:00
|
|
|
public cEntity
|
2012-12-21 12:21:20 +00:00
|
|
|
{
|
2012-12-21 11:04:08 +00:00
|
|
|
// tolua_end
|
2020-04-13 16:38:06 +00:00
|
|
|
using Super = cEntity;
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2012-06-14 13:06:06 +00:00
|
|
|
public:
|
2020-04-13 16:38:06 +00:00
|
|
|
|
2014-07-22 22:36:13 +00:00
|
|
|
CLASS_PROTODEF(cPawn)
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2021-04-06 15:09:16 +00:00
|
|
|
cPawn(eEntityType a_EntityType, float a_Width, float a_Height);
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2015-01-11 21:12:26 +00:00
|
|
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2014-07-17 09:07:10 +00:00
|
|
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2015-10-31 15:24:45 +00:00
|
|
|
virtual bool IsFireproof(void) const override;
|
2017-08-01 17:51:43 +00:00
|
|
|
virtual bool IsInvisible() const override;
|
2015-11-01 10:50:03 +00:00
|
|
|
virtual void HandleAir(void) override;
|
2015-11-10 13:02:07 +00:00
|
|
|
virtual void HandleFalling(void);
|
2021-01-02 13:50:34 +00:00
|
|
|
virtual void OnRemoveFromWorld(cWorld & a_World) override;
|
2015-11-10 13:02:07 +00:00
|
|
|
|
2016-02-01 20:49:34 +00:00
|
|
|
/** Tells all pawns which are targeting us to stop targeting us. */
|
|
|
|
void StopEveryoneFromTargetingMe();
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-13 02:50:02 +00:00
|
|
|
// tolua_begin
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2016-07-06 10:39:56 +00:00
|
|
|
/** Applies an entity effect.
|
2014-06-13 10:47:01 +00:00
|
|
|
Checks with plugins if they allow the addition.
|
2016-07-06 10:39:56 +00: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 09:41:43 +00:00
|
|
|
*/
|
2014-07-12 00:27:29 +00:00
|
|
|
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier = 1);
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2016-07-06 10:39:56 +00:00
|
|
|
/** Removes a currently applied entity effect. */
|
2014-06-06 07:17:49 +00:00
|
|
|
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2016-07-06 10:39:56 +00:00
|
|
|
/** Returns true, if the entity effect is currently applied. */
|
2015-10-31 15:24:45 +00:00
|
|
|
bool HasEntityEffect(cEntityEffect::eType a_EffectType) const;
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2014-06-07 20:45:00 +00:00
|
|
|
/** Removes all currently applied entity effects (used when drinking milk) */
|
2014-06-13 09:04:16 +00:00
|
|
|
void ClearEntityEffects(void);
|
2015-11-10 13:02:07 +00:00
|
|
|
|
2014-06-13 02:50:02 +00:00
|
|
|
// tolua_end
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2016-07-06 10:39:56 +00:00
|
|
|
/** Remove the monster from the list of monsters targeting this pawn. */
|
2016-02-01 20:49:34 +00: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 18:30:19 +00:00
|
|
|
/** Returns all entity effects */
|
2020-09-16 22:01:20 +00:00
|
|
|
std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects() const;
|
2016-11-06 18:30:19 +00:00
|
|
|
|
2017-08-01 17:51:43 +00:00
|
|
|
/** Returns the entity effect, if it is currently applied or nullptr if not. */
|
2020-09-16 22:01:20 +00:00
|
|
|
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType) const;
|
2016-11-06 18:30:19 +00:00
|
|
|
|
2021-07-10 20:05:00 +00: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 13:06:06 +00:00
|
|
|
protected:
|
2021-01-22 09:05:18 +00:00
|
|
|
|
2017-08-01 17:51:43 +00:00
|
|
|
typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
|
2014-06-07 07:54:03 +00:00
|
|
|
tEffectMap m_EntityEffects;
|
2015-11-10 13:02:07 +00:00
|
|
|
|
|
|
|
double m_LastGroundHeight;
|
|
|
|
bool m_bTouchGround;
|
2016-02-01 20:49:34 +00:00
|
|
|
|
2018-07-23 16:26:48 +00:00
|
|
|
virtual void ResetPosition(Vector3d a_NewPosition) override;
|
|
|
|
|
2016-02-01 20:49:34 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/** A list of all monsters that are targeting this pawn. */
|
|
|
|
std::vector<cMonster*> m_TargetingMe;
|
2021-01-22 09:05:18 +00: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 10:39:56 +00:00
|
|
|
} ; // tolua_export
|