commit
98244e96d1
@ -63,7 +63,7 @@ public:
|
||||
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) = 0;
|
||||
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) = 0;
|
||||
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) = 0;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) = 0;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0;
|
||||
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) = 0;
|
||||
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0;
|
||||
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
||||
|
@ -575,14 +575,14 @@ bool cPluginLua::OnHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper,
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer)
|
||||
bool cPluginLua::OnKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_KILLING];
|
||||
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||
{
|
||||
m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, cLuaState::Return, res);
|
||||
m_LuaState.Call((int)(**itr), &a_Victim, a_Killer, &a_TDI, cLuaState::Return, res);
|
||||
if (res)
|
||||
{
|
||||
return true;
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
|
||||
virtual bool OnHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum) override;
|
||||
virtual bool OnHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum) override;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer) override;
|
||||
virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override;
|
||||
virtual bool OnLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username) override;
|
||||
virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override;
|
||||
virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
||||
|
@ -588,14 +588,14 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
|
||||
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI)
|
||||
{
|
||||
FIND_HOOK(HOOK_KILLING);
|
||||
VERIFY_HOOK;
|
||||
|
||||
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->OnKilling(a_Victim, a_Killer))
|
||||
if ((*itr)->OnKilling(a_Victim, a_Killer, a_TDI))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public: // tolua_export
|
||||
bool CallHookHandshake (cClientHandle * a_ClientHandle, const AString & a_Username);
|
||||
bool CallHookHopperPullingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum);
|
||||
bool CallHookHopperPushingItem (cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum);
|
||||
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer);
|
||||
bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI);
|
||||
bool CallHookLogin (cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username);
|
||||
bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation);
|
||||
bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
|
@ -42,9 +42,9 @@ void cEnderCrystal::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
void cEnderCrystal::KilledBy(cEntity * a_Killer)
|
||||
void cEnderCrystal::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
|
||||
m_World->DoExplosionAt(6.0, GetPosX(), GetPosY(), GetPosZ(), true, esEnderCrystal, this);
|
||||
|
||||
|
@ -24,7 +24,7 @@ private:
|
||||
// cEntity overrides:
|
||||
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
}; // tolua_export
|
||||
|
||||
|
@ -368,7 +368,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
if (m_Health <= 0)
|
||||
{
|
||||
KilledBy(a_TDI.Attacker);
|
||||
KilledBy(a_TDI);
|
||||
|
||||
if (a_TDI.Attacker != NULL)
|
||||
{
|
||||
@ -524,11 +524,11 @@ double cEntity::GetKnockbackAmountAgainst(const cEntity & a_Receiver)
|
||||
|
||||
|
||||
|
||||
void cEntity::KilledBy(cEntity * a_Killer)
|
||||
void cEntity::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
m_Health = 0;
|
||||
|
||||
cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_Killer);
|
||||
cRoot::Get()->GetPluginManager()->CallHookKilling(*this, a_TDI.Attacker, a_TDI);
|
||||
|
||||
if (m_Health > 0)
|
||||
{
|
||||
@ -538,7 +538,7 @@ void cEntity::KilledBy(cEntity * a_Killer)
|
||||
|
||||
// Drop loot:
|
||||
cItems Drops;
|
||||
GetDrops(Drops, a_Killer);
|
||||
GetDrops(Drops, a_TDI.Attacker);
|
||||
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
|
||||
|
||||
m_World->BroadcastEntityStatus(*this, esGenericDead);
|
||||
|
@ -309,7 +309,7 @@ public:
|
||||
virtual cItem GetEquippedBoots(void) const { return cItem(); }
|
||||
|
||||
/// Called when the health drops below zero. a_Killer may be NULL (environmental damage)
|
||||
virtual void KilledBy(cEntity * a_Killer);
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI);
|
||||
|
||||
/// Called when the entity kills another entity
|
||||
virtual void Killed(cEntity * a_Victim) {}
|
||||
|
@ -51,17 +51,17 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
|
||||
|
||||
|
||||
|
||||
void cItemFrame::KilledBy(cEntity * a_Killer)
|
||||
void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
if (m_Item.IsEmpty())
|
||||
{
|
||||
SetHealth(0);
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
|
||||
if ((a_TDI.Attacker != NULL) && a_TDI.Attacker->IsPlayer() && !((cPlayer *)a_TDI.Attacker)->IsGameModeCreative())
|
||||
{
|
||||
cItems Item;
|
||||
Item.push_back(m_Item);
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
private:
|
||||
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
||||
|
||||
cItem m_Item;
|
||||
|
@ -26,9 +26,9 @@ private:
|
||||
virtual void SpawnOn(cClientHandle & a_Client) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
@ -885,9 +885,9 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
|
||||
|
||||
void cPlayer::KilledBy(cEntity * a_Killer)
|
||||
void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
|
||||
if (m_Health > 0)
|
||||
{
|
||||
@ -911,19 +911,40 @@ void cPlayer::KilledBy(cEntity * a_Killer)
|
||||
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
|
||||
SaveToDisk(); // Save it, yeah the world is a tough place !
|
||||
|
||||
if (a_Killer == NULL)
|
||||
if (a_TDI.Attacker == NULL)
|
||||
{
|
||||
GetWorld()->BroadcastChatDeath(Printf("%s was killed by environmental damage", GetName().c_str()));
|
||||
AString DamageText;
|
||||
switch (a_TDI.DamageType)
|
||||
{
|
||||
case dtRangedAttack: DamageText = "was shot"; break;
|
||||
case dtLightning: DamageText = "was plasmified by lightining"; break;
|
||||
case dtFalling: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "fell to death" : "hit the ground too hard"; break;
|
||||
case dtDrowning: DamageText = "drowned"; break;
|
||||
case dtSuffocating: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "git merge'd into a block" : "fused with a block"; break;
|
||||
case dtStarving: DamageText = "forgot the importance of food"; break;
|
||||
case dtCactusContact: DamageText = "was impaled on a cactus"; break;
|
||||
case dtLavaContact: DamageText = "was melted by lava"; break;
|
||||
case dtPoisoning: DamageText = "died from septicaemia"; break;
|
||||
case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break;
|
||||
case dtFireContact: DamageText = "burnt themselves to death"; break;
|
||||
case dtInVoid: DamageText = "somehow fell out of the world"; break;
|
||||
case dtPotionOfHarming: DamageText = "was magicked to death"; break;
|
||||
case dtEnderPearl: DamageText = "misused an ender pearl"; break;
|
||||
case dtAdmin: DamageText = "was administrator'd"; break;
|
||||
case dtExplosion: DamageText = "blew up"; break;
|
||||
default: DamageText = "died, somehow; we've no idea how though"; break;
|
||||
}
|
||||
GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
|
||||
}
|
||||
else if (a_Killer->IsPlayer())
|
||||
else if (a_TDI.Attacker->IsPlayer())
|
||||
{
|
||||
cPlayer * Killer = (cPlayer *)a_Killer;
|
||||
cPlayer * Killer = (cPlayer *)a_TDI.Attacker;
|
||||
|
||||
GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
AString KillerClass = a_Killer->GetClass();
|
||||
AString KillerClass = a_TDI.Attacker->GetClass();
|
||||
KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
|
||||
|
||||
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
|
||||
|
@ -324,7 +324,7 @@ public:
|
||||
/** Aborts the current eating operation */
|
||||
void AbortEating(void);
|
||||
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
virtual void Killed(cEntity * a_Victim) override;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
|
||||
// Iron golems do not drown
|
||||
// Iron golems do not drown nor float
|
||||
virtual void HandleAir(void) override {}
|
||||
virtual void SetSwimState(cChunk & a_Chunk) override {}
|
||||
} ;
|
||||
|
@ -492,9 +492,9 @@ bool cMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
|
||||
|
||||
|
||||
|
||||
void cMonster::KilledBy(cEntity * a_Killer)
|
||||
void cMonster::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
if (m_SoundHurt != "")
|
||||
{
|
||||
m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);
|
||||
@ -558,7 +558,7 @@ void cMonster::KilledBy(cEntity * a_Killer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((a_Killer != NULL) && (!IsBaby()))
|
||||
if ((a_TDI.Attacker != NULL) && (!IsBaby()))
|
||||
{
|
||||
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
|
||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
virtual void MoveToPosition(const Vector3f & a_Position);
|
||||
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
|
||||
|
@ -103,9 +103,9 @@ void cWither::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
|
||||
|
||||
void cWither::KilledBy(cEntity * a_Killer)
|
||||
void cWither::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
|
||||
class cPlayerCallback : public cPlayerListCallback
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -37,11 +37,11 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
|
||||
|
||||
void cZombiePigman::KilledBy(cEntity * a_Killer)
|
||||
void cZombiePigman::KilledBy(TakeDamageInfo & a_TDI)
|
||||
{
|
||||
super::KilledBy(a_Killer);
|
||||
super::KilledBy(a_TDI);
|
||||
|
||||
if ((a_Killer != NULL) && (a_Killer->IsPlayer()))
|
||||
if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer()))
|
||||
{
|
||||
// TODO: Anger all nearby zombie pigmen
|
||||
// TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
CLASS_PROTODEF(cZombiePigman);
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
||||
} ;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user