2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
|
|
|
2012-09-23 16:53:08 -04:00
|
|
|
#include "Squid.h"
|
2013-07-01 06:39:56 -04:00
|
|
|
#include "../Chunk.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-22 04:39:13 -05:00
|
|
|
cSquid::cSquid(void) :
|
2020-04-13 12:38:06 -04:00
|
|
|
Super("Squid", mtSquid, "entity.squid.hurt", "entity.squid.death", "entity.squid.ambient", 0.95, 0.95)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-01 06:39:56 -04:00
|
|
|
void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
// Drops 0-3 Ink Sacs
|
2015-05-19 14:32:10 -04:00
|
|
|
unsigned int LootingLevel = 0;
|
2014-10-20 16:55:07 -04:00
|
|
|
if (a_Killer != nullptr)
|
2014-02-23 13:44:58 -05: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 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2015-09-27 12:48:37 -04:00
|
|
|
m_PathfinderActivated = false; // Disable Pathfinding until it's fixed. TODO
|
2015-05-30 03:03:34 -04:00
|
|
|
|
2013-07-07 16:20:18 -04: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 09:06:06 -04:00
|
|
|
Vector3d Pos = GetPosition();
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
// TODO: Not a real behavior, but cool :D
|
2015-05-28 07:29:26 -04:00
|
|
|
int RelY = FloorC(Pos.y);
|
2013-08-09 09:53:43 -04:00
|
|
|
if ((RelY < 0) || (RelY >= cChunkDef::Height))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-08-25 09:44:36 -04:00
|
|
|
|
2018-01-14 13:44:45 -05:00
|
|
|
if (!IsHeadInWater())
|
2017-08-25 09:44:36 -04: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 09:06:06 -04:00
|
|
|
{
|
2017-08-25 09:44:36 -04:00
|
|
|
// Set the air back to maximum
|
|
|
|
m_AirLevel = MAX_AIR_LEVEL;
|
|
|
|
m_AirTickTimer = DROWNING_TICKS;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2013-07-07 16:20:18 -04:00
|
|
|
|
2020-04-13 12:38:06 -04:00
|
|
|
Super::Tick(a_Dt, a_Chunk);
|
2012-12-21 06:04:08 -05:00
|
|
|
}
|