Cuberite
A lightweight, fast and extensible game server for Minecraft
Witch.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 "Witch.h"
5 #include "../FastRandom.h"
6 
7 
8 
9 
10 
12  Super("Witch", mtWitch, "entity.witch.hurt", "entity.witch.death", "entity.witch.ambient", 0.6f, 1.95f)
13 {
14 }
15 
16 
17 
18 
19 
20 void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
21 {
22  unsigned int LootingLevel = 0;
23  if (a_Killer != nullptr)
24  {
26  }
27  auto & r1 = GetRandomProvider();
28  int DropTypeCount = r1.RandInt(1, 3);
29  for (int i = 0; i < DropTypeCount; i++)
30  {
31  int DropType = r1.RandInt(6);
32  switch (DropType)
33  {
34  case 0: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLASS_BOTTLE); break;
35  case 1: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLOWSTONE_DUST); break;
36  case 2: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); break;
37  case 3: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_REDSTONE_DUST); break;
38  case 4: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SPIDER_EYE); break;
39  case 5: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STICK); break;
40  case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR); break;
41  }
42  }
43  AddRandomWeaponDropItem(a_Drops, LootingLevel);
44 }
45 
46 
47 
48 
@ E_ITEM_GLASS_BOTTLE
Definition: BlockType.h:420
@ E_ITEM_REDSTONE_DUST
Definition: BlockType.h:375
@ E_ITEM_SUGAR
Definition: BlockType.h:398
@ E_ITEM_STICK
Definition: BlockType.h:324
@ E_ITEM_GUNPOWDER
Definition: BlockType.h:333
@ E_ITEM_GLOWSTONE_DUST
Definition: BlockType.h:393
@ E_ITEM_SPIDER_EYE
Definition: BlockType.h:421
MTRand & GetRandomProvider()
Returns the current thread's random number source.
Definition: FastRandom.cpp:12
@ mtWitch
Definition: MonsterTypes.h:74
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
cEnchantments m_Enchantments
Definition: Item.h:166
This class bridges a vector of cItem for safe access via Lua.
Definition: Item.h:215
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
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
cWitch()
Definition: Witch.cpp:11
virtual void GetDrops(cItems &a_Drops, cEntity *a_Killer=nullptr) override
Returns the list of drops for this pawn when it is killed.
Definition: Witch.cpp:20