Cuberite
A lightweight, fast and extensible game server for Minecraft
ZombiePigman.cpp
Go to the documentation of this file.
1 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
2 
3 #include "ZombiePigman.h"
4 #include "../World.h"
5 #include "../ClientHandle.h"
6 
7 
8 
9 
10 
12  super("ZombiePigman", mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8)
13 {
14 }
15 
16 
17 
18 
19 
20 void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
21 {
22  unsigned int LootingLevel = 0;
23  if (a_Killer != nullptr)
24  {
26  }
27  AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ROTTEN_FLESH);
28  AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GOLD_NUGGET);
29 
30  cItems RareDrops;
31  RareDrops.Add(cItem(E_ITEM_GOLD));
32  AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
33  AddRandomArmorDropItem(a_Drops, LootingLevel);
34  AddRandomWeaponDropItem(a_Drops, LootingLevel);
35 }
36 
37 
38 
39 
40 
41 void cZombiePigman::SpawnOn(cClientHandle & a_ClientHandle)
42 {
43  super::SpawnOn(a_ClientHandle);
44  a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_GOLD_SWORD));
45 }
46 
47 
48 
49 
50 
52 {
53  super::KilledBy(a_TDI);
54 
55  if ((a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPlayer()))
56  {
57  // TODO: Anger all nearby zombie pigmen
58  // TODO: In vanilla, if one player angers ZPs, do they attack any nearby player, or only that one attacker?
59  }
60 }
61 
62 
63 
64 
void AddRandomWeaponDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds weapon that is equipped with the chance saved in m_DropChance... to the drop.
Definition: Monster.cpp:1303
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
void AddRandomArmorDropItem(cItems &a_Drops, unsigned int a_LootingLevel)
Adds armor that is equipped with the chance saved in m_DropChance... to the drop. ...
Definition: Monster.cpp:1260
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
void AddRandomDropItem(cItems &a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth=0)
Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops.
Definition: Monster.cpp:1215
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
void AddRandomRareDropItem(cItems &a_Drops, cItems &a_Items, unsigned int a_LootingLevel)
Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel...
Definition: Monster.cpp:1246
virtual void KilledBy(TakeDamageInfo &a_TDI) override
Called when the health drops below zero.
Definition: Monster.cpp:593
cEnchantments m_Enchantments
Definition: Item.h:212
void Add(const cItem &a_Item)
Definition: Item.h:254
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
Definition: Monster.cpp:166
bool IsPlayer(void) const
Definition: Entity.h:171
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
Definition: Entity.h:346
Definition: Entity.h:73
Definition: Item.h:36
cEntity * Attacker
Definition: Entity.h:60
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:234
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.