6 #include "../Blocks/BlockButton.h"
13 Super(pkArrow, a_Creator, a_Pos, a_Speed, 0.5f, 0.5f),
14 m_PickupState(psNoPickup),
23 FLOGD(
"Created arrow {0} with speed {1:.02f} and rot {{{2:.02f}, {3:.02f}}}",
33 cArrowEntity(&a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20))
114 int ExtraDamage =
static_cast<int>(ceil(0.25 * (
PowerLevel + 1)));
115 Damage += ExtraDamage;
118 double Knockback = 10;
121 unsigned int PunchLevelMultiplier = 8;
123 Knockback += PunchLevelMultiplier * PunchLevel;
178 if (
m_Timer > std::chrono::milliseconds(500))
184 else if (
m_Timer > std::chrono::minutes(5))
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
static void OnArrowHit(cWorld &a_World, const Vector3i a_Position, const eBlockFace a_HitFace)
Event handler for an arrow striking a block.
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
double m_DamageCoeff
The coefficient applied to the damage that the arrow will deal, based on the bow enchantment.
bool m_IsCritical
If true, the arrow deals more damage.
ePickupState m_PickupState
Determines when the arrow can be picked up by players.
virtual bool DoesPreventBlockPlacement(void) const override
Returns whether blocks can be placed intersecting this entities' hitbox.
cArrowEntity(cEntity *a_Creator, Vector3d a_Pos, Vector3d a_Speed)
Creates a new arrow with psNoPickup state and default damage modifier coeff.
std::chrono::milliseconds m_Timer
Timer for pickup collection animation or five minute timeout.
bool CanPickup(const cPlayer &a_Player) const
Returns true if the specified player can pick the arrow up.
bool m_bIsCollected
If true, the arrow is in the process of being collected - don't go to anyone else.
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) override
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos) override
Called by the physics blocktracer when the entity hits another entity.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
virtual void CollectedBy(cPlayer &a_Player) override
Called by Chunk when the projectile is eligible for player collection.
static constexpr float ARROW_WATER_FRICTION
Value used to calculate arrow speed in water.
Vector3i m_HitBlockPos
Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air.
const Vector3d & GetSpeed(void) const
Exported in ManualBindings.
virtual bool IsInWater(void) const
Returns true if any part of the entity is in a water block.
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
UInt32 m_UniqueID
The ID of the entity that is guaranteed to be unique within a single run of the server.
void SetGravity(float a_Gravity)
UInt32 GetUniqueID(void) const
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
double GetPitch(void) const
virtual bool IsOnFire(void) const
Vector3d m_Speed
Measured in meters / second (m / s)
void TakeDamage(cEntity &a_Attacker)
Makes this pawn take damage from an attack by a_Attacker.
void SetMass(double a_Mass)
static void ApplyFriction(Vector3d &a_Speed, double a_SlowdownMultiplier, float a_Dt)
Applies friction to an entity.
double GetYaw(void) const
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
void StartBurning(int a_TicksLeftBurning)
Puts the entity on fire for the specified amount of ticks.
cWorld * GetWorld(void) const
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
cInventory & GetInventory(void)
UInt32 GetCreatorUniqueID(void) const
Returns the unique ID of the entity who created this projectile May return an ID <0.
virtual void OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace)
Called by the physics blocktracer when the entity hits a solid block, the hit position and the face h...
CreatorData m_CreatorData
The structure for containing the entity ID and name who has created this projectile The ID and / or n...
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
bool m_IsInGround
True if the projectile has hit the ground and is stuck there.
virtual void OnHitEntity(cEntity &a_EntityHit, Vector3d a_HitPos)
Called by the physics blocktracer when the entity hits another entity.
cEnchantments m_Enchantments
char AddItem(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Adds as many items out of a_ItemStack as can fit.
Vector3< int > Floor(void) const
Returns a new Vector3i with coords set to std::floor() of this vector's coords.
double Length(void) const
UInt32 SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec=80, double a_InitialVelocityCoeff=1, bool a_ShouldPlayFuseSound=true)
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
virtual void BroadcastCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count, const cClientHandle *a_Exclude=nullptr) override
int GetTickRandomNumber(int a_Range)
Returns a random number in range [0 .
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
void SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.