Wither invulnerability
This commit is contained in:
parent
b370cacf0c
commit
6b77dc74ad
@ -22,6 +22,18 @@ public:
|
|||||||
a_Pickups.push_back(cItem(E_ITEM_HEAD, 1, 0));
|
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(
|
virtual void OnPlacedByPlayer(
|
||||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player,
|
||||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||||
@ -62,6 +74,8 @@ public:
|
|||||||
cWorld * World = (cWorld *) &a_WorldInterface;
|
cWorld * World = (cWorld *) &a_WorldInterface;
|
||||||
World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
|
World->DoWithMobHeadAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
|
||||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta);
|
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 mtSquid: return mfWater;
|
||||||
case mtVillager: return mfPassive;
|
case mtVillager: return mfPassive;
|
||||||
case mtWitch: return mfHostile;
|
case mtWitch: return mfHostile;
|
||||||
|
case mtWither: return mfHostile;
|
||||||
case mtWolf: return mfHostile;
|
case mtWolf: return mfHostile;
|
||||||
case mtZombie: return mfHostile;
|
case mtZombie: return mfHostile;
|
||||||
case mtZombiePigman: return mfHostile;
|
case mtZombiePigman: return mfHostile;
|
||||||
|
@ -2,14 +2,64 @@
|
|||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
#include "Wither.h"
|
#include "Wither.h"
|
||||||
|
#include "../World.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cWither::cWither(void) :
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,21 @@ public:
|
|||||||
|
|
||||||
CLASS_PROTODEF(cWither);
|
CLASS_PROTODEF(cWither);
|
||||||
|
|
||||||
|
unsigned int GetNumInvulnerableTicks(void) const { return m_InvulnerableTicks; }
|
||||||
|
|
||||||
|
void SetNumInvulnerableTicks(unsigned int a_Ticks) { m_InvulnerableTicks = a_Ticks; }
|
||||||
|
|
||||||
|
// Override functions
|
||||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
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;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ public:
|
|||||||
| esGhastFireball | cGhastFireball * |
|
| esGhastFireball | cGhastFireball * |
|
||||||
| esWitherSkullBlack | TBD |
|
| esWitherSkullBlack | TBD |
|
||||||
| esWitherSkullBlue | TBD |
|
| esWitherSkullBlue | TBD |
|
||||||
| esWitherBirth | TBD |
|
| esWitherBirth | cWither * |
|
||||||
| esPlugin | void * |
|
| 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
|
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);
|
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");
|
CurrLine = a_NBT.FindChildByName(Data, "width");
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "../Mobs/Slime.h"
|
#include "../Mobs/Slime.h"
|
||||||
#include "../Mobs/Skeleton.h"
|
#include "../Mobs/Skeleton.h"
|
||||||
#include "../Mobs/Villager.h"
|
#include "../Mobs/Villager.h"
|
||||||
|
#include "../Mobs/Wither.h"
|
||||||
#include "../Mobs/Wolf.h"
|
#include "../Mobs/Wolf.h"
|
||||||
#include "../Mobs/Zombie.h"
|
#include "../Mobs/Zombie.h"
|
||||||
|
|
||||||
@ -422,7 +423,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
|
|||||||
case cMonster::mtSquid: EntityClass = "Squid"; break;
|
case cMonster::mtSquid: EntityClass = "Squid"; break;
|
||||||
case cMonster::mtVillager: EntityClass = "Villager"; break;
|
case cMonster::mtVillager: EntityClass = "Villager"; break;
|
||||||
case cMonster::mtWitch: EntityClass = "Witch"; 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::mtWolf: EntityClass = "Wolf"; break;
|
||||||
case cMonster::mtZombie: EntityClass = "Zombie"; break;
|
case cMonster::mtZombie: EntityClass = "Zombie"; break;
|
||||||
case cMonster::mtZombiePigman: EntityClass = "PigZombie"; 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());
|
m_Writer.AddInt("Profession", ((const cVillager *)a_Monster)->GetVilType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case cMonster::mtWither:
|
||||||
|
{
|
||||||
|
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetNumInvulnerableTicks());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case cMonster::mtWolf:
|
case cMonster::mtWolf:
|
||||||
{
|
{
|
||||||
m_Writer.AddString("Owner", ((const cWolf *)a_Monster)->GetOwner());
|
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);
|
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);
|
LoadWitherFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
|
||||||
}
|
}
|
||||||
@ -2250,6 +2250,12 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
|
||||||
|
if (CurrLine > 0)
|
||||||
|
{
|
||||||
|
Monster->SetNumInvulnerableTicks(a_NBT.GetInt(CurrLine));
|
||||||
|
}
|
||||||
|
|
||||||
a_Entities.push_back(Monster.release());
|
a_Entities.push_back(Monster.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user