commit
c6186acf58
@ -21,6 +21,18 @@ public:
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_ITEM_HEAD, 1, 0));
|
||||
}
|
||||
|
||||
bool TrySpawnWither(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
if (a_BlockY < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO 2014-03-24 xdot
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||
@ -62,6 +74,8 @@ public:
|
||||
cWorld * World = (cWorld *) &a_WorldInterface;
|
||||
World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta);
|
||||
|
||||
TrySpawnWither(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
@ -758,6 +758,7 @@ cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
|
||||
case mtSquid: return mfWater;
|
||||
case mtVillager: return mfPassive;
|
||||
case mtWitch: return mfHostile;
|
||||
case mtWither: return mfHostile;
|
||||
case mtWolf: return mfHostile;
|
||||
case mtZombie: return mfHostile;
|
||||
case mtZombiePigman: return mfHostile;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
|
||||
CLASS_PROTODEF(cVillager);
|
||||
|
||||
// Override functions
|
||||
// cEntity overrides
|
||||
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
|
||||
|
||||
|
@ -2,14 +2,64 @@
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Wither.h"
|
||||
#include "../World.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cWither::cWither(void) :
|
||||
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0)
|
||||
super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
|
||||
m_InvulnerableTicks(220)
|
||||
{
|
||||
SetMaxHealth(300);
|
||||
|
||||
SetHealth(GetMaxHealth() / 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
if (a_TDI.DamageType == dtDrowning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_InvulnerableTicks > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
super::DoTakeDamage(a_TDI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWither::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
super::Tick(a_Dt, a_Chunk);
|
||||
|
||||
if (m_InvulnerableTicks > 0)
|
||||
{
|
||||
unsigned int NewTicks = m_InvulnerableTicks - 1;
|
||||
|
||||
if (NewTicks == 0)
|
||||
{
|
||||
m_World->DoExplosionAt(7.0, GetPosX(), GetPosY(), GetPosZ(), false, esWitherBirth, this);
|
||||
}
|
||||
|
||||
m_InvulnerableTicks = NewTicks;
|
||||
|
||||
if ((NewTicks % 10) == 0)
|
||||
{
|
||||
Heal(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,8 +16,21 @@ public:
|
||||
cWither(void);
|
||||
|
||||
CLASS_PROTODEF(cWither);
|
||||
|
||||
unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; }
|
||||
|
||||
void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; }
|
||||
|
||||
// cEntity overrides
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
|
||||
private:
|
||||
|
||||
/** The number of ticks of invulnerability left after being initially created. Zero once invulnerability has expired. */
|
||||
unsigned int m_InvulnerableTicks;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
20
src/World.h
20
src/World.h
@ -497,16 +497,16 @@ public:
|
||||
|
||||
/** Does an explosion with the specified strength at the specified coordinate
|
||||
a_SourceData exact type depends on the a_Source:
|
||||
| esOther | void * |
|
||||
| esPrimedTNT | cTNTEntity * |
|
||||
| esMonster | cMonster * |
|
||||
| esBed | cVector3i * |
|
||||
| esEnderCrystal | Vector3i * |
|
||||
| esGhastFireball | cGhastFireball * |
|
||||
| esWitherSkullBlack | TBD |
|
||||
| esWitherSkullBlue | TBD |
|
||||
| esWitherBirth | TBD |
|
||||
| esPlugin | void * |
|
||||
| esOther | void * |
|
||||
| esPrimedTNT | cTNTEntity * |
|
||||
| esMonster | cMonster * |
|
||||
| esBed | cVector3i * |
|
||||
| esEnderCrystal | Vector3i * |
|
||||
| esGhastFireball | cGhastFireball * |
|
||||
| esWitherSkullBlack | TBD |
|
||||
| esWitherSkullBlue | TBD |
|
||||
| esWitherBirth | cMonster * |
|
||||
| esPlugin | void * |
|
||||
*/
|
||||
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData); // tolua_export // override, cannot specify due to tolua
|
||||
|
||||
|
@ -141,7 +141,11 @@ bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT)
|
||||
{
|
||||
eDimension Dimension = (eDimension) a_NBT.GetByte(CurrLine);
|
||||
|
||||
ASSERT(Dimension == m_Map->m_World->GetDimension());
|
||||
if (Dimension != m_Map->m_World->GetDimension())
|
||||
{
|
||||
// TODO 2014-03-20 xdot: We should store nether maps in nether worlds, e.t.c.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CurrLine = a_NBT.FindChildByName(Data, "width");
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "../Mobs/Slime.h"
|
||||
#include "../Mobs/Skeleton.h"
|
||||
#include "../Mobs/Villager.h"
|
||||
#include "../Mobs/Wither.h"
|
||||
#include "../Mobs/Wolf.h"
|
||||
#include "../Mobs/Zombie.h"
|
||||
|
||||
@ -422,7 +423,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
|
||||
case cMonster::mtSquid: EntityClass = "Squid"; break;
|
||||
case cMonster::mtVillager: EntityClass = "Villager"; break;
|
||||
case cMonster::mtWitch: EntityClass = "Witch"; break;
|
||||
case cMonster::mtWither: EntityClass = "Wither"; break;
|
||||
case cMonster::mtWither: EntityClass = "WitherBoss"; break;
|
||||
case cMonster::mtWolf: EntityClass = "Wolf"; break;
|
||||
case cMonster::mtZombie: EntityClass = "Zombie"; break;
|
||||
case cMonster::mtZombiePigman: EntityClass = "PigZombie"; break;
|
||||
@ -501,6 +502,11 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
|
||||
m_Writer.AddInt("Profession", ((const cVillager *)a_Monster)->GetVilType());
|
||||
break;
|
||||
}
|
||||
case cMonster::mtWither:
|
||||
{
|
||||
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks());
|
||||
break;
|
||||
}
|
||||
case cMonster::mtWolf:
|
||||
{
|
||||
m_Writer.AddString("Owner", ((const cWolf *)a_Monster)->GetOwner());
|
||||
|
@ -1238,7 +1238,7 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
LoadWitchFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||
}
|
||||
else if (strncmp(a_IDTag, "Wither", a_IDTagLength) == 0)
|
||||
else if (strncmp(a_IDTag, "WitherBoss", a_IDTagLength) == 0)
|
||||
{
|
||||
LoadWitherFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||
}
|
||||
@ -2250,6 +2250,12 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
return;
|
||||
}
|
||||
|
||||
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
|
||||
if (CurrLine > 0)
|
||||
{
|
||||
Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine));
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user