2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2012-09-23 20:53:08 +00:00
|
|
|
#include "Squid.h"
|
2013-07-01 10:39:56 +00:00
|
|
|
#include "../Chunk.h"
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-22 09:39:13 +00:00
|
|
|
cSquid::cSquid(void) :
|
2020-04-13 16:38:06 +00:00
|
|
|
Super("Squid", mtSquid, "entity.squid.hurt", "entity.squid.death", "entity.squid.ambient", 0.95, 0.95)
|
2012-06-14 13:06:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-21 11:04:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-01 10:39:56 +00:00
|
|
|
void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
2012-06-14 13:06:06 +00:00
|
|
|
{
|
|
|
|
// Drops 0-3 Ink Sacs
|
2015-05-19 18:32:10 +00:00
|
|
|
unsigned int LootingLevel = 0;
|
2014-10-20 20:55:07 +00:00
|
|
|
if (a_Killer != nullptr)
|
2014-02-23 18:44:58 +00:00
|
|
|
{
|
|
|
|
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
|
|
|
}
|
|
|
|
AddRandomDropItem(a_Drops, 0, 3 + LootingLevel, E_ITEM_DYE, E_META_DYE_BLACK);
|
2012-06-14 13:06:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-11 21:12:26 +00:00
|
|
|
void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
2012-06-14 13:06:06 +00:00
|
|
|
{
|
2015-09-27 16:48:37 +00:00
|
|
|
m_PathfinderActivated = false; // Disable Pathfinding until it's fixed. TODO
|
2015-05-30 07:03:34 +00:00
|
|
|
|
2013-07-07 20:20:18 +00:00
|
|
|
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
|
|
|
|
// that is not where the entity currently resides (FS #411)
|
2012-06-14 13:06:06 +00:00
|
|
|
Vector3d Pos = GetPosition();
|
|
|
|
|
2012-12-21 11:04:08 +00:00
|
|
|
// TODO: Not a real behavior, but cool :D
|
2015-05-28 11:29:26 +00:00
|
|
|
int RelY = FloorC(Pos.y);
|
2013-08-09 13:53:43 +00:00
|
|
|
if ((RelY < 0) || (RelY >= cChunkDef::Height))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-08-25 13:44:36 +00:00
|
|
|
|
2018-01-14 18:44:45 +00:00
|
|
|
if (!IsHeadInWater())
|
2017-08-25 13:44:36 +00:00
|
|
|
{
|
|
|
|
if (m_AirLevel <= 0)
|
|
|
|
{
|
|
|
|
// Runs the air tick timer to check whether the squid should be damaged
|
|
|
|
if (m_AirTickTimer <= 0)
|
|
|
|
{
|
|
|
|
// Damage squid
|
|
|
|
TakeDamage(dtSuffocating, nullptr, 1, 1, 0);
|
|
|
|
// Reset timer
|
|
|
|
m_AirTickTimer = DROWNING_TICKS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_AirTickTimer--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reduce air supply
|
|
|
|
m_AirLevel--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-06-14 13:06:06 +00:00
|
|
|
{
|
2017-08-25 13:44:36 +00:00
|
|
|
// Set the air back to maximum
|
|
|
|
m_AirLevel = MAX_AIR_LEVEL;
|
|
|
|
m_AirTickTimer = DROWNING_TICKS;
|
2012-06-14 13:06:06 +00:00
|
|
|
}
|
2013-07-07 20:20:18 +00:00
|
|
|
|
2020-04-13 16:38:06 +00:00
|
|
|
Super::Tick(a_Dt, a_Chunk);
|
2012-12-21 11:04:08 +00:00
|
|
|
}
|