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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
private void dropFromMonster(MapleCharacter dropOwner, MapleMonster monster)
{
if ((this.dropsDisabled) || (monster.dropsDisabled())) {
return;
}
final boolean explosive = monster.isExplosive();
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
boolean isBoss = monster.isBoss();
ChannelServer cserv = dropOwner.getClient().getChannelServer();
int maxDrops;
int maxDrops;
if (explosive) {
maxDrops = 10 * cserv.getBossDropRate();
} else {
maxDrops = 4 * cserv.getDropRate();
}
List<Integer> toDrop = new ArrayList();
for (int i = 0; i < maxDrops; i++) {
toDrop.add(Integer.valueOf(monster.getDrop()));
}
if (dropOwner.getEventInstance() == null)
{
Random randomInt = new Random();
int chance = randomInt.nextInt(100);
if (chance <= 10) {
toDrop.add(Integer.valueOf(4000313));
}
}
if (dropOwner.getEventInstance() == null)
{
Random randomInt = new Random();
int chance = randomInt.nextInt(100);
if (chance <= 10) {
toDrop.add(Integer.valueOf(2022065));
}
}
Set<Integer> alreadyDropped = new HashSet();
byte htpendants = 0;byte htstones = 0;byte mesos = 0;
for (int i = 0; i < toDrop.size(); i++) {
if (((Integer)toDrop.get(i)).intValue() == -1)
{
if (!isPQMap()) {
if (alreadyDropped.contains(Integer.valueOf(-1)))
{
if (!explosive)
{
toDrop.remove(i);
i--;
}
else if (mesos < 9)
{
mesos = (byte)(mesos + 1);
}
else
{
toDrop.remove(i);
i--;
}
}
else {
alreadyDropped.add(Integer.valueOf(-1));
}
}
}
else if ((alreadyDropped.contains(toDrop.get(i))) && (!explosive))
{
toDrop.remove(i);
i--;
}
else
{
if (((Integer)toDrop.get(i)).intValue() == 2041200)
{
if (htstones > 2)
{
toDrop.remove(i);
i--;
continue;
}
htstones = (byte)(htstones + 1);
}
else if (((Integer)toDrop.get(i)).intValue() == 1122000)
{
if (htstones > 2)
{
toDrop.remove(i);
i--;
continue;
}
htpendants = (byte)(htpendants + 1);
}
alreadyDropped.add(toDrop.get(i));
}
}
if (toDrop.size() > maxDrops) {
toDrop = toDrop.subList(0, maxDrops);
}
if ((mesos < 7) && (explosive)) {
for (int i = mesos; i < 7; i++) {
toDrop.add(Integer.valueOf(-1));
}
}
int shiftDirection = 0;
int shiftCount = 0;
int curX = Math.min(Math.max(monster.getPosition().x - 25 * (toDrop.size() / 2), this.footholds.getMinDropX() + 25), this.footholds.getMaxDropX() - toDrop.size() * 25);
int curY = Math.max(monster.getPosition().y, this.footholds.getY1());
while ((shiftDirection < 3) && (shiftCount < 1000))
{
if (shiftDirection == 1) {
curX += 25;
} else if (shiftDirection == 2) {
curX -= 25;
}
for (int i = 0; i < toDrop.size(); i++)
{
MapleFoothold wall = this.footholds.findWall(new Point(curX, curY), new Point(curX + toDrop.size() * 25, curY));
if (wall != null)
{
if (wall.getX1() < curX)
{
shiftDirection = 1;
shiftCount++;
break;
}
if (wall.getX1() == curX)
{
if (shiftDirection == 0) {
shiftDirection = 1;
}
shiftCount++;
break;
}
shiftDirection = 2;
shiftCount++;
break;
}
if (i == toDrop.size() - 1) {
shiftDirection = 3;
}
final Point dropPos = calcDropPos(new Point(curX + i * 25, curY), new Point(monster.getPosition()));
final int drop = ((Integer)toDrop.get(i)).intValue();
if (drop == -1)
{
if (monster.isBoss())
{
final int cc = ChannelServer.getInstance(dropOwner.getClient().getChannel()).getMesoRate() + 25;
final MapleMonster dropMonster = monster;
Random r = new Random();
double mesoDecrease = Math.pow(0.9300000000000001D, monster.getExp() / 300.0D);
if (mesoDecrease > 1.0D) {
mesoDecrease = 1.0D;
} else if (mesoDecrease < 0.001D) {
mesoDecrease = 0.005D;
}
int tempmeso = Math.min(30000, (int)(mesoDecrease * monster.getExp() * (1.0D + r.nextInt(20)) / 10.0D));
if (dropOwner.getBuffedValue(MapleBuffStat.MESOUP) != null) {
tempmeso = (int)(tempmeso * dropOwner.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0D);
}
final int dmesos = tempmeso;
if (dmesos > 0)
{
final MapleCharacter dropChar = dropOwner;
final boolean publicLoott = isPQMap();
TimerManager.getInstance().schedule(new Runnable()
{
public void run()
{
MapleMap.this.spawnMesoDrop(dmesos * cc, dmesos, dropPos, dropMonster, dropChar, (explosive) || (publicLoott));
}
}, monster.getAnimationTime("die1"));
}
}
else
{
final int mesoRate = ChannelServer.getInstance(dropOwner.getClient().getChannel()).getMesoRate();
Random r = new Random();
double mesoDecrease = Math.pow(0.9300000000000001D, monster.getExp() / 300.0D);
if (mesoDecrease > 1.0D) {
mesoDecrease = 1.0D;
}
int tempmeso = Math.min(30000, (int)(mesoDecrease * monster.getExp() * (1.0D + r.nextInt(20)) / 10.0D));
if (dropOwner.getBuffedValue(MapleBuffStat.MESOUP) != null) {
tempmeso = (int)(tempmeso * dropOwner.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0D);
}
final int meso = tempmeso;
if (meso > 0)
{
MapleMonster dropMonster = monster;
final MapleCharacter dropChar = dropOwner;
boolean publicLoott = isPQMap();
TimerManager.getInstance().schedule(new Runnable()
{
public void run()
{
dropChar.gainMeso(meso * mesoRate, true, true);
}
}, monster.getAnimationTime("die1"));
}
}
}
else
{
MapleInventoryType type = ii.getInventoryType(drop);
IItem idrop;
IItem idrop;
if (type.equals(MapleInventoryType.EQUIP))
{
Equip nEquip = ii.randomizeStats(dropOwner.getClient(), (Equip)ii.getEquipById(drop));
idrop = nEquip;
}
else
{
idrop = new Item(drop, (byte)0, (short)1);
if ((ii.isArrowForBow(drop)) || (ii.isArrowForCrossBow(drop)))
{
if (dropOwner.getJob().getId() / 100 == 3) {
idrop.setQuantity((short)(int)(1.0D + 100.0D * Math.random()));
}
}
else if ((ii.isThrowingStar(drop)) || (ii.isBullet(drop))) {
idrop.setQuantity((short)1);
}
}
final MapleMapItem mdrop = new MapleMapItem(idrop, dropPos, monster, dropOwner);
final MapleMapObject dropMonster = monster;
final MapleCharacter dropChar = dropOwner;
final TimerManager tMan = TimerManager.getInstance();
tMan.schedule(new Runnable()
{
public void run()
{
MapleMap.this.spawnAndAddRangedMapObject(mdrop, new MapleMap.DelayedPacketCreation()
{
public void sendPackets(MapleClient c)
{
c.getSession().write(MaplePacketCreator.dropItemFromMapObject(MapleMap.3.this.val$drop, MapleMap.3.this.val$mdrop.getObjectId(), MapleMap.3.this.val$dropMonster.getObjectId(), MapleMap.3.this.val$explosive ? 0 : MapleMap.3.this.val$dropChar.getId(), MapleMap.3.this.val$dropMonster.getPosition(), MapleMap.3.this.val$dropPos, (byte)1));
}
}, null);
tMan.schedule(new MapleMap.ExpireMapItemJob(MapleMap.this, mdrop), MapleMap.this.dropLife);
}
}, monster.getAnimationTime("die1"));
}
}
}
}