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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#pragma once
#include "AgableMob.h"
#include "Npc.h"
#include "Merchant.h"
#include "ParticleTypes.h"
class Level;
class Village;
class MerchantRecipeList;
class MerchantRecipe;
class Villager : public AgableMob, public Npc, public Merchant
{
public:
eINSTANCEOF GetType() { return eTYPE_VILLAGER; }
static Entity *create(Level *level) { return new Villager(level); }
//public static final String comment = "No, I won't 'fix' these! They're fine!! - Notch";
public:
static const int PROFESSION_FARMER = 0;
static const int PROFESSION_LIBRARIAN = 1;
static const int PROFESSION_PRIEST = 2;
static const int PROFESSION_SMITH = 3;
static const int PROFESSION_BUTCHER = 4;
static const int PROFESSION_MAX = 5;
private:
static const int DATA_PROFESSION_ID = 16;
int villageUpdateInterval;
bool inLove;
bool chasing;
weak_ptr<Village> village;
weak_ptr<Player> tradingPlayer;
MerchantRecipeList *offers;
int updateMerchantTimer;
bool addRecipeOnUpdate;
int riches;
wstring lastPlayerTradeName;
bool rewardPlayersOnFirstVillage;
private:
void _init(int profession);
public:
Villager(Level *level);
Villager(Level *level, int profession);
~Villager();
protected:
virtual void registerAttributes();
public:
virtual bool useNewAi();
protected:
virtual void serverAiMobStep();
public:
virtual bool mobInteract(shared_ptr<Player> player);
protected:
virtual void defineSynchedData();
public:
virtual void addAdditonalSaveData(CompoundTag *tag);
virtual void readAdditionalSaveData(CompoundTag *tag);
protected:
virtual bool removeWhenFarAway();
virtual int getAmbientSound();
virtual int getHurtSound();
virtual int getDeathSound();
public:
void setProfession(int profession);
int getProfession();
bool isInLove();
void setInLove(bool inLove);
void setChasing(bool chasing);
bool isChasing();
void setLastHurtByMob(shared_ptr<LivingEntity> mob);
void die(DamageSource *source);
void handleEntityEvent(byte id);
private:
void addParticlesAroundSelf(ePARTICLE_TYPE particle);
public:
void setTradingPlayer(shared_ptr<Player> player);
shared_ptr<Player> getTradingPlayer();
bool isTrading();
void notifyTrade(MerchantRecipe *activeRecipe);
void notifyTradeUpdated(shared_ptr<ItemInstance> item);
MerchantRecipeList *getOffers(shared_ptr<Player> forPlayer);
private:
float baseRecipeChanceMod;
float getRecipeChance(float baseChance);
void addOffers(int addCount);
public:
void overrideOffers(MerchantRecipeList *recipeList);
private:
static unordered_map<int, pair<int,int> > MIN_MAX_VALUES;
static unordered_map<int, pair<int,int> > MIN_MAX_PRICES;
public:
static void staticCtor();
private:
/**
* Adds a merchant recipe that trades items for a single ruby.
*
* @param list
* @param itemId
* @param random
* @param likelyHood
*/
static void addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *random, float likelyHood);
static shared_ptr<ItemInstance> getItemTradeInValue(int itemId, Random *random);
static int getTradeInValue(int itemId, Random *random);
/**
* Adds a merchant recipe that trades rubies for an item. If the cost is
* negative, one ruby will give several of that item.
*
* @param list
* @param itemId
* @param random
* @param likelyHood
*/
static void addItemForPurchase(MerchantRecipeList *list, int itemId, Random *random, float likelyHood);
static int getPurchaseCost(int itemId, Random *random);
public:
virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
virtual void setRewardPlayersInVillage();
virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target);
virtual bool canBeLeashed();
virtual wstring getDisplayName();
};
|