summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Rabbit.cpp
blob: 070396ded911ba1f2837a36afbe4f7177792c7e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

#include "Globals.h"  // NOTE: MSVC stupidness requires this to be the same across all modules

#include "Rabbit.h"
#include "../Entities/Player.h"
#include "../World.h"





cRabbit::cRabbit(void) :
	cRabbit(static_cast<eRabbitType>(GetRandomProvider().RandInt<UInt8>(
		static_cast<UInt8>(eRabbitType::SaltAndPepper)  // Max possible Rabbit-Type
	)), 0)
{
	m_EMPersonality = PASSIVE;
	m_BehaviorBreeder.AttachToMonster(*this);
	m_BehaviorCoward.AttachToMonster(*this);
	m_BehaviorItemFollower.AttachToMonster(*this);
	m_BehaviorWanderer.AttachToMonster(*this);
}





cRabbit::cRabbit(eRabbitType Type, int MoreCarrotTicks) :
	super("Rabbit", mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", 0.82, 0.68),
	m_Type(Type),
	m_MoreCarrotTicks(MoreCarrotTicks)
{
}





void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
	unsigned int LootingLevel = 0;
	if (a_Killer != nullptr)
	{
		LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
	}
	AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_RABBIT : E_ITEM_RAW_RABBIT);
	AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RABBIT_HIDE);
	cItems RareDrops;
	RareDrops.Add(cItem(E_ITEM_RABBITS_FOOT));
	AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
}





cBehaviorBreeder * cRabbit::GetBehaviorBreeder()
{
	return &m_BehaviorBreeder;
}





const cBehaviorBreeder * cRabbit::GetBehaviorBreeder() const
{
	return static_cast<const cBehaviorBreeder *>(&m_BehaviorBreeder);
}