Cuberite
A lightweight, fast and extensible game server for Minecraft
WitherSkeleton.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
3 
4 #include "WitherSkeleton.h"
5 #include "../World.h"
6 #include "../ClientHandle.h"
7 
8 
9 
10 
12  Super("WitherSkeleton", mtWitherSkeleton, "entity.wither_skeleton.hurt", "entity.wither_skeleton.death", "entity.wither_skeleton.ambient", 0.7f, 2.4f)
13 {
14 }
15 
16 
17 
18 
19 
20 bool cWitherSkeleton::Attack(std::chrono::milliseconds a_Dt)
21 {
22  if (GetTarget() == nullptr)
23  {
24  return false;
25  }
26 
28  return Super::Attack(a_Dt);
29 }
30 
31 
32 
33 
34 
35 void cWitherSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
36 {
37  unsigned int LootingLevel = 0;
38  if (a_Killer != nullptr)
39  {
41  }
42  AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL);
43  AddRandomUncommonDropItem(a_Drops, 8.5f, E_ITEM_STONE_SWORD, GetRandomProvider().RandInt<short>(50));
44 
45  cItems RareDrops;
46  RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1));
47  AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
48 
49  AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
50  AddRandomArmorDropItem(a_Drops, LootingLevel);
51  AddRandomWeaponDropItem(a_Drops, LootingLevel);
52 }
53 
54 
55 
56 
57 
59 {
60  Super::SpawnOn(a_ClientHandle);
61  a_ClientHandle.SendEntityEquipment(*this, 0, cItem(E_ITEM_STONE_SWORD));
62 }
@ E_ITEM_COAL
Definition: BlockType.h:307
@ E_ITEM_HEAD
Definition: BlockType.h:443
@ E_ITEM_STONE_SWORD
Definition: BlockType.h:316
@ E_ITEM_BONE
Definition: BlockType.h:397
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Definition: FastRandom.cpp:12
@ mtWitherSkeleton
Definition: MonsterTypes.h:76
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
unsigned int GetLevel(int a_EnchantmentID) const
Returns the level for the specified enchantment; 0 if not stored.
Definition: Entity.h:76
virtual cItem GetEquippedWeapon(void) const
Returns the curently equipped weapon; empty item if none.
Definition: Entity.h:333
void AddEntityEffect(cEntityEffect::eType a_EffectType, int a_EffectDurationTicks, short a_EffectIntensity, double a_DistanceModifier=1)
Applies an entity effect.
Definition: Pawn.cpp:186
Definition: Item.h:37
cEnchantments m_Enchantments
Definition: Item.h:166
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
void Add(const cItem &a_Item)
Definition: Item.h:233
virtual bool Attack(std::chrono::milliseconds a_Dt)
Try to perform attack returns true if attack was deemed successful (hit player, fired projectile,...
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:167
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:1549
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:1518
cPawn * GetTarget()
Returns the current target.
Definition: Monster.cpp:1243
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:1606
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:1563
void AddRandomUncommonDropItem(cItems &a_Drops, float a_Chance, short a_Item, short a_ItemHealth=0)
Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops.
Definition: Monster.cpp:1537
virtual bool Attack(std::chrono::milliseconds a_Dt) override
Try to perform attack returns true if attack was deemed successful (hit player, fired projectile,...
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
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...