diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-07-16 23:22:48 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2015-07-16 23:22:48 +0200 |
commit | c633dd8cec149565538499b2e50ae97fd15b928c (patch) | |
tree | d109f84a573c4eaeeeb47e474bc2e9268adde90a /src/Mobs/Spider.cpp | |
parent | Merge pull request #2364 from hallucino/ageable-mobs (diff) | |
parent | Improved spider AI (diff) | |
download | cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar.gz cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar.bz2 cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar.lz cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar.xz cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.tar.zst cuberite-c633dd8cec149565538499b2e50ae97fd15b928c.zip |
Diffstat (limited to 'src/Mobs/Spider.cpp')
-rw-r--r-- | src/Mobs/Spider.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp index 184a1d912..a9da28750 100644 --- a/src/Mobs/Spider.cpp +++ b/src/Mobs/Spider.cpp @@ -3,7 +3,8 @@ #include "Spider.h" - +#include "../World.h" +#include "../Entities/Player.h" @@ -33,3 +34,42 @@ void cSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer) + +void cSpider::EventSeePlayer(cEntity * a_Entity) +{ + if (!GetWorld()->IsChunkLighted(GetChunkX(), GetChunkZ())) + { + GetWorld()->QueueLightChunk(GetChunkX(), GetChunkZ()); + return; + } + + if (!static_cast<cPlayer *>(a_Entity)->IsGameModeCreative() && (GetWorld()->GetBlockBlockLight(this->GetPosition()) <= 9)) + { + super::EventSeePlayer(a_Entity); + } +} + + + + + +bool cSpider::DoTakeDamage(TakeDamageInfo & a_TDI) +{ + if (!super::DoTakeDamage(a_TDI)) + { + return false; + } + + // If the source of the damage is not from an pawn entity, switch to idle + if ((a_TDI.Attacker == nullptr) || !a_TDI.Attacker->IsPawn()) + { + m_EMState = IDLE; + } + else + { + // If the source of the damage is from a pawn entity, chase that entity + m_EMState = CHASING; + } + + return true; +} |