SHOW:
|
|
- or go back to the newest paste.
1 | diff --git a/config/CustomMods/Events/PartyFarmEvent.ini b/config/CustomMods/Events/PartyFarmEvent.ini | |
2 | new file mode 100644 | |
3 | index 0000000..4d65252 | |
4 | --- /dev/null | |
5 | +++ b/config/CustomMods/Events/PartyFarmEvent.ini | |
6 | @@ -0,0 +1,86 @@ | |
7 | +#===================================================== | |
8 | +# PARTY FARM EVENT | |
9 | +#===================================================== | |
10 | + | |
11 | +MonsterLoc = -50324, 137542, -2871;\ | |
12 | +-49694, 138843, -2919;\ | |
13 | +-48580, 139801, -2930;\ | |
14 | +-51061, 139072, -2925;\ | |
15 | +-52648, 139600, -2937;\ | |
16 | +-52084, 137211, -2884;\ | |
17 | +-51885, 140437, -2859;\ | |
18 | +-51313, 141965, -2878;\ | |
19 | +-53470, 141986, -2858;\ | |
20 | +-54383, 139210, -2906;\ | |
21 | +-55321, 137909, -2911;\ | |
22 | +-57082, 138361, -2714;\ | |
23 | +-57845, 140766, -2649;\ | |
24 | +-56629, 143361, -2566;\ | |
25 | +-59379, 139309, -2466;\ | |
26 | +-60082, 137623, -2327;\ | |
27 | +-58639, 135770, -2457;\ | |
28 | +-56714, 135084, -2433;\ | |
29 | +-56715, 136673, -2789;\ | |
30 | +-56264, 141358, -2628;\ | |
31 | +-54986, 142629, -2839;\ | |
32 | +-53362, 143202, -2892;\ | |
33 | +-52410, 141770, -2925;\ | |
34 | +-50588, 143081, -2895;\ | |
35 | +-51088, 144450, -2893;\ | |
36 | +-50856, 145485, -2812;\ | |
37 | +-52172, 145466, -2820;\ | |
38 | +-54007, 145158, -2875;\ | |
39 | +-54325, 146502, -2877;\ | |
40 | +-52890, 144172, -2908;\ | |
41 | +-54113, 137140, -2752;\ | |
42 | +-51976, 138979, -2952;\ | |
43 | +-53666, 139817, -2857;\ | |
44 | +-52753, 137986, -2921;\ | |
45 | +-50593, 140423, -2855;\ | |
46 | +-51996, 143661, -2892; | |
47 | + | |
48 | +#========================================================= | |
49 | +# PARTY DROP REWARD | |
50 | +#========================================================= | |
51 | +# Party Zone Monster ID | |
52 | +PartyEventMonster = 50056 | |
53 | + | |
54 | +# Format: itemId,min,max,chance(%);itemId,min,max,(chance(%)(optional));. | |
55 | +# Normal hour reward | |
56 | +PartyZoneReward = 6392,600,900;6393,1,1,30;6577,1,2,70;6578,1,2,70; | |
57 | +#========================================================= | |
58 | +# Tempo em Segundos para o MOB aparecer apos ser morto | |
59 | +# Default: 300 (5 minutos) | |
60 | +MonsterDelay = 10 | |
61 | + | |
62 | +# Id do Mob | |
63 | +MonsterId = 50056 | |
64 | + | |
65 | +# Remover protesao renewal por ip? | |
66 | +# Retail = False (Manter Protesao) | |
67 | +RenewalDualBoxPTFarm = False | |
68 | + | |
69 | +#Ativar o Party Farm Event por tempo igual TvT | |
70 | +PartyFarmEventEnabled = True | |
71 | + | |
72 | +# Iniciar party farm ao ligar o server | |
73 | +StartSpawnPartyFarm = False | |
74 | + | |
75 | +#========================================================= | |
76 | +# CONFIG START TIME EVENT | |
77 | +#========================================================= | |
78 | +# PartyFarmEventEnabled=11:00,15:00,19:00,23:00, | |
79 | +# | |
80 | +# PartyFarm comando spawn manual //ptfarm ou //ptfarm para terminar o evento. | |
81 | +# | |
82 | +EventBestFarmTime = 50 | |
83 | +BestFarmStartTime = 00:45,00:47,21:46, | |
84 | + | |
85 | +# Show screen Party message on character login | |
86 | +# Default: False | |
87 | +ScreenPartyMessageEnable = True | |
88 | + | |
89 | +# Screen Party Farm message text | |
90 | +ScreenPartyFarmMessageText = Party Farm is active | |
91 | +# Show screen PartyFarm message for x seconds. | |
92 | +ScreenPartyFarmMessageTime = 6 | |
93 | diff --git a/java/Dev/Events/PartyFarm/InitialPartyFarm.java b/java/Dev/Events/PartyFarm/InitialPartyFarm.java | |
94 | new file mode 100644 | |
95 | index 0000000..76649a4 | |
96 | --- /dev/null | |
97 | +++ b/java/Dev/Events/PartyFarm/InitialPartyFarm.java | |
98 | @@ -0,0 +1,98 @@ | |
99 | +package Dev.Events.PartyFarm; | |
100 | + | |
101 | +import java.text.SimpleDateFormat; | |
102 | +import java.util.Calendar; | |
103 | +import java.util.logging.Logger; | |
104 | + | |
105 | +import net.sf.l2j.commons.pool.ThreadPool; | |
106 | + | |
107 | +import net.sf.l2j.Config; | |
108 | + | |
109 | +/** | |
110 | + * | |
111 | + * @author Sarada | |
112 | + * | |
113 | + */ | |
114 | + | |
115 | +public class InitialPartyFarm | |
116 | +{ | |
117 | + private static InitialPartyFarm _instance = null; | |
118 | + protected static final Logger _log = Logger.getLogger(InitialPartyFarm.class.getName()); | |
119 | + private Calendar NextEvent; | |
120 | + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm"); | |
121 | + | |
122 | + public static InitialPartyFarm getInstance() | |
123 | + { | |
124 | + if (_instance == null) | |
125 | + { | |
126 | + _instance = new InitialPartyFarm(); | |
127 | + } | |
128 | + return _instance; | |
129 | + } | |
130 | + | |
131 | + public String getRestartNextTime() | |
132 | + { | |
133 | + if (NextEvent.getTime() != null) | |
134 | + { | |
135 | + return format.format(NextEvent.getTime()); | |
136 | + } | |
137 | + return "Erro"; | |
138 | + } | |
139 | + | |
140 | + public void StartCalculationOfNextEventTime() | |
141 | + { | |
142 | + try | |
143 | + { | |
144 | + Calendar currentTime = Calendar.getInstance(); | |
145 | + Calendar testStartTime = null; | |
146 | + long flush2 = 0L; | |
147 | + long timeL = 0L; | |
148 | + int count = 0; | |
149 | + for (String timeOfDay : Config.EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY) | |
150 | + { | |
151 | + testStartTime = Calendar.getInstance(); | |
152 | + testStartTime.setLenient(true); | |
153 | + String[] splitTimeOfDay = timeOfDay.split(":"); | |
154 | + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0])); | |
155 | + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1])); | |
156 | + testStartTime.set(13, 0); | |
157 | + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis()) | |
158 | + { | |
159 | + testStartTime.add(5, 1); | |
160 | + } | |
161 | + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis(); | |
162 | + if (count == 0) | |
163 | + { | |
164 | + flush2 = timeL; | |
165 | + NextEvent = testStartTime; | |
166 | + } | |
167 | + if (timeL < flush2) | |
168 | + { | |
169 | + flush2 = timeL; | |
170 | + NextEvent = testStartTime; | |
171 | + } | |
172 | + count++; | |
173 | + } | |
174 | + _log.info("[Party Farm]: Proximo Evento: " + NextEvent.getTime().toString()); | |
175 | + ThreadPool.schedule(new StartEventTask(), flush2); | |
176 | + } | |
177 | + catch (Exception e) | |
178 | + { | |
179 | + System.out.println("[Party Farm]: Algum erro nas config foi encontrado!"); | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + class StartEventTask implements Runnable | |
184 | + { | |
185 | + StartEventTask() | |
186 | + { | |
187 | + } | |
188 | + | |
189 | + @Override | |
190 | + public void run() | |
191 | + { | |
192 | + InitialPartyFarm._log.info("[Party Farm]: Event Started."); | |
193 | + PartyFarm.bossSpawnMonster(); | |
194 | + } | |
195 | + } | |
196 | +} | |
197 | diff --git a/java/Dev/Events/PartyFarm/PartyFarm.java b/java/Dev/Events/PartyFarm/PartyFarm.java | |
198 | new file mode 100644 | |
199 | index 0000000..f77aa29 | |
200 | --- /dev/null | |
201 | +++ b/java/Dev/Events/PartyFarm/PartyFarm.java | |
202 | @@ -0,0 +1,185 @@ | |
203 | +package Dev.Events.PartyFarm; | |
204 | + | |
205 | +import java.util.ArrayList; | |
206 | + | |
207 | +import net.sf.l2j.Config; | |
208 | +import net.sf.l2j.gameserver.data.sql.SpawnTable; | |
209 | +import net.sf.l2j.gameserver.data.xml.NpcData; | |
210 | +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCustom; | |
211 | +import net.sf.l2j.gameserver.model.World; | |
212 | +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate; | |
213 | +import net.sf.l2j.gameserver.model.spawn.Spawn; | |
214 | +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse; | |
215 | + | |
216 | +/** | |
217 | + * | |
218 | + * @author Sarada | |
219 | + * | |
220 | + */ | |
221 | + | |
222 | + | |
223 | +public class PartyFarm | |
224 | +{ | |
225 | + public static Spawn _monster; | |
226 | + public static int _bossHeading = 0; | |
227 | + public static String _eventName = ""; | |
228 | + public static boolean _started = false; | |
229 | + public static boolean _aborted = false; | |
230 | + protected static boolean _finish = false; | |
231 | + static PartyFarm _instance; | |
232 | + | |
233 | + public static void bossSpawnMonster() | |
234 | + { | |
235 | + spawnMonsters(); | |
236 | + | |
237 | + World.gameAnnounceToOnlinePlayers("Teleport Now!"); | |
238 | + World.gameAnnounceToOnlinePlayers("[Party Farm]: Duration: " + Config.EVENT_BEST_FARM_TIME + " minute(s)!"); | |
239 | + _aborted = false; | |
240 | + _started = true; | |
241 | + | |
242 | + waiter(Config.EVENT_BEST_FARM_TIME * 60 * 1000); | |
243 | + if (!_aborted) | |
244 | + { | |
245 | + Finish_Event(); | |
246 | + } | |
247 | + } | |
248 | + | |
249 | + public static void Finish_Event() | |
250 | + { | |
251 | + unSpawnMonsters(); | |
252 | + | |
253 | + _started = false; | |
254 | + _finish = true; | |
255 | + | |
256 | + World.gameAnnounceToOnlinePlayers("[Party Farm]: Finished!"); | |
257 | + if (!AdminCustom._bestfarm_manual) | |
258 | + { | |
259 | + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime(); | |
260 | + } | |
261 | + else | |
262 | + { | |
263 | + AdminCustom._bestfarm_manual = false; | |
264 | + } | |
265 | + } | |
266 | + | |
267 | + public static void spawnMonsters() | |
268 | + { | |
269 | + for (int i = 0; i < Config.MONSTER_LOCS_COUNT; i++) | |
270 | + { | |
271 | + int[] coord = Config.MONSTER_LOCS[i]; | |
272 | + monsters.add(spawnNPC(coord[0], coord[1], coord[2], Config.monsterId)); | |
273 | + } | |
274 | + } | |
275 | + | |
276 | + public static boolean is_started() | |
277 | + { | |
278 | + return _started; | |
279 | + } | |
280 | + | |
281 | + public static boolean is_finish() | |
282 | + { | |
283 | + return _finish; | |
284 | + } | |
285 | + | |
286 | + protected static Spawn spawnNPC(int xPos, int yPos, int zPos, int npcId) | |
287 | + { | |
288 | + NpcTemplate template = NpcData.getInstance().getTemplate(npcId); | |
289 | + try | |
290 | + { | |
291 | + Spawn spawn = new Spawn(template); | |
292 | + spawn.setLoc(xPos, yPos, zPos, 0); | |
293 | + spawn.setRespawnDelay(Config.PARTY_FARM_MONSTER_DALAY); | |
294 | + | |
295 | + SpawnTable.getInstance().addSpawn(spawn, false); | |
296 | + | |
297 | + spawn.setRespawnState(true); | |
298 | + spawn.doSpawn(false); | |
299 | + spawn.getNpc().isAggressive(); | |
300 | + spawn.getNpc().decayMe(); | |
301 | + spawn.getNpc().spawnMe(spawn.getNpc().getX(), spawn.getNpc().getY(), spawn.getNpc().getZ()); | |
302 | + spawn.getNpc().broadcastPacket(new MagicSkillUse(spawn.getNpc(), spawn.getNpc(), 1034, 1, 1, 1)); | |
303 | + return spawn; | |
304 | + } | |
305 | + catch (Exception e) | |
306 | + { | |
307 | + } | |
308 | + return null; | |
309 | + } | |
310 | + | |
311 | + protected static ArrayList<Spawn> monsters = new ArrayList<>(); | |
312 | + | |
313 | + protected static void unSpawnMonsters() | |
314 | + { | |
315 | + for (Spawn s : monsters) | |
316 | + { | |
317 | + if (s == null) | |
318 | + { | |
319 | + monsters.remove(s); | |
320 | + return; | |
321 | + } | |
322 | + | |
323 | + s.getNpc().deleteMe(); | |
324 | + s.setRespawnState(false); | |
325 | + SpawnTable.getInstance().deleteSpawn(s, true); | |
326 | + | |
327 | + } | |
328 | + } | |
329 | + | |
330 | + protected static void waiter(long interval) | |
331 | + { | |
332 | + long startWaiterTime = System.currentTimeMillis(); | |
333 | + int seconds = (int) (interval / 1000L); | |
334 | + while ((startWaiterTime + interval > System.currentTimeMillis()) && (!_aborted)) | |
335 | + { | |
336 | + seconds--; | |
337 | + switch (seconds) | |
338 | + { | |
339 | + case 3600: | |
340 | + if (_started) | |
341 | + { | |
342 | + | |
343 | + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 / 60 + " hour(s) till event finish!"); | |
344 | + } | |
345 | + break; | |
346 | + case 60: | |
347 | + case 120: | |
348 | + case 180: | |
349 | + case 240: | |
350 | + case 300: | |
351 | + case 600: | |
352 | + case 900: | |
353 | + case 1800: | |
354 | + if (_started) | |
355 | + { | |
356 | + | |
357 | + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds / 60 + " minute(s) till event finish!"); | |
358 | + } | |
359 | + break; | |
360 | + case 1: | |
361 | + case 2: | |
362 | + case 3: | |
363 | + case 10: | |
364 | + case 15: | |
365 | + case 30: | |
366 | + if (_started) | |
367 | + { | |
368 | + World.gameAnnounceToOnlinePlayers("[Party Farm]: " + seconds + " second(s) till event finish!"); | |
369 | + } | |
370 | + break; | |
371 | + } | |
372 | + long startOneSecondWaiterStartTime = System.currentTimeMillis(); | |
373 | + while (startOneSecondWaiterStartTime + 1000L > System.currentTimeMillis()) | |
374 | + { | |
375 | + try | |
376 | + { | |
377 | + Thread.sleep(1L); | |
378 | + } | |
379 | + catch (InterruptedException ie) | |
380 | + { | |
381 | + ie.printStackTrace(); | |
382 | + } | |
383 | + } | |
384 | + } | |
385 | + } | |
386 | + | |
387 | +} | |
388 | diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java | |
389 | index 95c380e..2bf3a7b 100644 | |
390 | --- a/java/net/sf/l2j/Config.java | |
391 | +++ b/java/net/sf/l2j/Config.java | |
392 | @@ -15,6 +15,7 @@ | |
393 | import net.sf.l2j.commons.logging.CLogger; | |
394 | import net.sf.l2j.commons.math.MathUtil; | |
395 | ||
396 | +import net.sf.l2j.gameserver.data.manager.RewardHolder; | |
397 | import net.sf.l2j.gameserver.enums.GeoType; | |
398 | import net.sf.l2j.gameserver.model.holder.IntIntHolder; | |
399 | ||
400 | @@ -45,6 +46,7 @@ | |
401 | public static final String PROTECTION_MODS = "./config/CustomMods/ProtectionMods.ini"; | |
402 | public static final String DONATEMODS = "./config/CustomMods/Donate.ini"; | |
403 | public static final String PCBANGEVENT = "./config/CustomMods/Events/PcBangEvent.ini"; | |
404 | + public static final String PARTYFARMEVENT = "./config/CustomMods/Events/PartyFarmEvent.ini"; | |
405 | // -------------------------------------------------- | |
406 | // Clans settings | |
407 | // -------------------------------------------------- | |
408 | @@ -96,6 +98,21 @@ | |
409 | public static boolean ALLOW_DUALBOX_OLY; | |
410 | public static boolean ALT_GAME_SUBCLASS_EVERYWHERE; | |
411 | public static boolean PLAYERS_CAN_HEAL_RB; | |
412 | + public static int EVENT_BEST_FARM_TIME; | |
413 | + public static String[] EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY; | |
414 | + public static int PARTY_FARM_MONSTER_DALAY; | |
415 | + public static String PARTY_FARM_MESSAGE_TEXT; | |
416 | + public static int PARTY_FARM_MESSAGE_TIME; | |
417 | + public static int monsterId; | |
418 | + public static int MONSTER_LOCS_COUNT; | |
419 | + public static int[][] MONSTER_LOCS; | |
420 | + public static boolean PARTY_MESSAGE_ENABLED; | |
421 | + public static boolean ENABLE_DUALBOX_PARTYFARM; | |
422 | + public static boolean PARTY_FARM_BY_TIME_OF_DAY; | |
423 | + public static boolean START_PARTY; | |
424 | + public static String PART_ZONE_MONSTERS_EVENT; | |
425 | + public static List<Integer> PART_ZONE_MONSTERS_EVENT_ID; | |
426 | + public static List<RewardHolder> PARTY_ZONE_REWARDS = new ArrayList<>(); | |
427 | /** Raid info*/ | |
428 | public static int RAID_BOSS_INFO_PAGE_LIMIT; | |
429 | public static int RAID_BOSS_DROP_PAGE_LIMIT; | |
430 | @@ -1226,6 +1243,61 @@ | |
431 | ||
432 | } | |
433 | ||
434 | + private static final void loadPTFarmConfig() | |
435 | + { | |
436 | + final ExProperties BestFarm = initProperties(PARTYFARMEVENT); | |
437 | + PART_ZONE_MONSTERS_EVENT = BestFarm.getProperty("PartyEventMonster"); | |
438 | + PART_ZONE_MONSTERS_EVENT_ID = new ArrayList<>(); | |
439 | + for (String id : PART_ZONE_MONSTERS_EVENT.split(",")) | |
440 | + PART_ZONE_MONSTERS_EVENT_ID.add(Integer.parseInt(id)); | |
441 | + PARTY_ZONE_REWARDS = parseReward(BestFarm, "PartyZoneReward"); | |
442 | + | |
443 | + PARTY_FARM_MONSTER_DALAY = Integer.parseInt(BestFarm.getProperty("MonsterDelay", "10")); | |
444 | + PARTY_FARM_BY_TIME_OF_DAY = Boolean.parseBoolean(BestFarm.getProperty("PartyFarmEventEnabled", "false")); | |
445 | + START_PARTY = Boolean.parseBoolean(BestFarm.getProperty("StartSpawnPartyFarm", "false")); | |
446 | + ENABLE_DUALBOX_PARTYFARM = Boolean.parseBoolean(BestFarm.getProperty("RenewalDualBoxPTFarm", "false")); | |
447 | + EVENT_BEST_FARM_TIME = Integer.parseInt(BestFarm.getProperty("EventBestFarmTime", "1")); | |
448 | + EVENT_BEST_FARM_INTERVAL_BY_TIME_OF_DAY = BestFarm.getProperty("BestFarmStartTime", "20:00").split(","); | |
449 | + PARTY_MESSAGE_ENABLED = Boolean.parseBoolean(BestFarm.getProperty("ScreenPartyMessageEnable", "false")); | |
450 | + PARTY_FARM_MESSAGE_TEXT = BestFarm.getProperty("ScreenPartyFarmMessageText", "Welcome to l2j server!"); | |
451 | + PARTY_FARM_MESSAGE_TIME = Integer.parseInt(BestFarm.getProperty("ScreenPartyFarmMessageTime", "10")) * 1000; | |
452 | + | |
453 | + String[] monsterLocs2 = BestFarm.getProperty("MonsterLoc", "").split(";"); | |
454 | + String[] locSplit3 = null; | |
455 | + | |
456 | + monsterId = Integer.parseInt(BestFarm.getProperty("MonsterId", "1")); | |
457 | + | |
458 | + MONSTER_LOCS_COUNT = monsterLocs2.length; | |
459 | + MONSTER_LOCS = new int[MONSTER_LOCS_COUNT][3]; | |
460 | + int g; | |
461 | + for (int e = 0; e < MONSTER_LOCS_COUNT; e++) | |
462 | + { | |
463 | + locSplit3 = monsterLocs2[e].split(","); | |
464 | + for (g = 0; g < 3; g++) | |
465 | + { | |
466 | + MONSTER_LOCS[e][g] = Integer.parseInt(locSplit3[g].trim()); | |
467 | + } | |
468 | + } | |
469 | + | |
470 | + } | |
471 | + | |
472 | + public static List<RewardHolder> parseReward(Properties propertie, String configName) | |
473 | + { | |
474 | + List<RewardHolder> auxReturn = new ArrayList<>(); | |
475 | + | |
476 | + String aux = propertie.getProperty(configName).trim(); | |
477 | + for (String randomReward : aux.split(";")) | |
478 | + { | |
479 | + final String[] infos = randomReward.split(","); | |
480 | + | |
481 | + if (infos.length > 3) | |
482 | + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2]), Integer.valueOf(infos[3]))); | |
483 | + else | |
484 | + auxReturn.add(new RewardHolder(Integer.valueOf(infos[0]), Integer.valueOf(infos[1]), Integer.valueOf(infos[2]))); | |
485 | + } | |
486 | + return auxReturn; | |
487 | + } | |
488 | + | |
489 | private static final void loadPcBangConfig() | |
490 | { | |
491 | final ExProperties PcBanG = initProperties(PCBANGEVENT); | |
492 | @@ -1748,6 +1820,7 @@ | |
493 | // NPCs/monsters settings | |
494 | loadNpcs(); | |
495 | loadPcBangConfig(); | |
496 | + loadPTFarmConfig(); | |
497 | loadSpecial(); | |
498 | loadCommands(); | |
499 | loadScheme(); | |
500 | diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java | |
501 | index 4c0ba28..da7c459 100644 | |
502 | --- a/java/net/sf/l2j/gameserver/GameServer.java | |
503 | +++ b/java/net/sf/l2j/gameserver/GameServer.java | |
504 | @@ -38,6 +38,7 @@ | |
505 | import net.sf.l2j.gameserver.data.manager.HeroManager; | |
506 | import net.sf.l2j.gameserver.data.manager.LotteryManager; | |
507 | import net.sf.l2j.gameserver.data.manager.PartyMatchRoomManager; | |
508 | +import net.sf.l2j.gameserver.data.manager.PartyZoneReward; | |
509 | import net.sf.l2j.gameserver.data.manager.PetitionManager; | |
510 | import net.sf.l2j.gameserver.data.manager.RaidBossInfoManager; | |
511 | import net.sf.l2j.gameserver.data.manager.RaidBossManager; | |
512 | @@ -109,6 +110,9 @@ | |
513 | import net.sf.l2j.util.DeadLockDetector; | |
514 | import net.sf.l2j.util.IPv4Filter; | |
515 | ||
516 | +import Dev.Events.PartyFarm.InitialPartyFarm; | |
517 | +import Dev.Events.PartyFarm.PartyFarm; | |
518 | + | |
519 | public class GameServer | |
520 | { | |
521 | private static final CLogger LOGGER = new CLogger(GameServer.class.getName()); | |
522 | @@ -222,6 +226,23 @@ | |
523 | WaterTaskManager.getInstance(); | |
524 | RaidBossInfoManager.getInstance(); | |
525 | IconTable.getInstance(); | |
526 | + PartyZoneReward.getInstance(); | |
527 | + class SpawnMonsters implements Runnable | |
528 | + { | |
529 | + public SpawnMonsters() | |
530 | + { | |
531 | + } | |
532 | + | |
533 | + @Override | |
534 | + public void run() | |
535 | + { | |
536 | + PartyFarm._aborted = false; | |
537 | + PartyFarm._started = true; | |
538 | + | |
539 | + PartyFarm.spawnMonsters(); | |
540 | + } | |
541 | + | |
542 | + } | |
543 | ||
544 | StringUtil.printSection("Events"); | |
545 | if(Config.PCB_ENABLE) | |
546 | @@ -230,6 +251,18 @@ | |
547 | ThreadPool.scheduleAtFixedRate(PcBang.getInstance(), Config.PCB_INTERVAL * 1000, Config.PCB_INTERVAL * 1000); | |
548 | } | |
549 | ||
550 | + StringUtil.printSection("Party Farm Events"); | |
551 | + if ((Config.PARTY_FARM_BY_TIME_OF_DAY) && (!Config.START_PARTY)) | |
552 | + { | |
553 | + InitialPartyFarm.getInstance().StartCalculationOfNextEventTime(); | |
554 | + LOGGER.info("[Party Farm Time]: Enabled"); | |
555 | + } | |
556 | + else if ((Config.START_PARTY) && (!Config.PARTY_FARM_BY_TIME_OF_DAY)) | |
557 | + { | |
558 | + LOGGER.info("[Start Spawn Party Farm]: Enabled"); | |
559 | + ThreadPool.schedule(new SpawnMonsters(), 1000L); | |
560 | + } | |
561 | + | |
562 | StringUtil.printSection("Auto Spawns"); | |
563 | AutoSpawnTable.getInstance(); | |
564 | ||
565 | diff --git a/java/net/sf/l2j/gameserver/data/manager/PartyZoneReward.java b/java/net/sf/l2j/gameserver/data/manager/PartyZoneReward.java | |
566 | new file mode 100644 | |
567 | index 0000000..d1bc44c | |
568 | --- /dev/null | |
569 | +++ b/java/net/sf/l2j/gameserver/data/manager/PartyZoneReward.java | |
570 | @@ -0,0 +1,106 @@ | |
571 | +package net.sf.l2j.gameserver.data.manager; | |
572 | + | |
573 | +import java.util.HashMap; | |
574 | +import java.util.List; | |
575 | +import java.util.logging.Logger; | |
576 | + | |
577 | +import net.sf.l2j.commons.random.Rnd; | |
578 | + | |
579 | +import net.sf.l2j.Config; | |
580 | +import net.sf.l2j.gameserver.model.actor.Creature; | |
581 | +import net.sf.l2j.gameserver.model.actor.Npc; | |
582 | +import net.sf.l2j.gameserver.model.actor.Playable; | |
583 | +import net.sf.l2j.gameserver.model.actor.Player; | |
584 | + | |
585 | +/** | |
586 | + * | |
587 | + * @author Sarada | |
588 | + * | |
589 | + */ | |
590 | + | |
591 | +public class PartyZoneReward | |
592 | +{ | |
593 | + protected static final Logger _log = Logger.getLogger(PartyZoneReward.class.getName()); | |
594 | + | |
595 | + protected PartyZoneReward() | |
596 | + { | |
597 | + } | |
598 | + | |
599 | + private static boolean _canReward = false; | |
600 | + private static HashMap<String, Integer> _playerHwids = new HashMap<>(); | |
601 | + | |
602 | + // Give Reward | |
603 | + public final static void addPartyZoneReward(Creature killer, Npc monster) | |
604 | + { | |
605 | + if (killer instanceof Playable) | |
606 | + { | |
607 | + Player player = killer.getActingPlayer(); | |
608 | + | |
609 | + if (player.isInParty()) | |
610 | + { | |
611 | + List<Player> party = player.getParty().getMembers(); | |
612 | + | |
613 | + for (Player member : party) | |
614 | + { | |
615 | + //String pHwid = member.getHWID(); | |
616 | + String pHwid = member.getClient().getConnection().getInetAddress().getHostAddress(); | |
617 | + if (!_playerHwids.containsKey(pHwid) || Config.ENABLE_DUALBOX_PARTYFARM) | |
618 | + { | |
619 | + _playerHwids.put(pHwid, 1); | |
620 | + _canReward = true; | |
621 | + } | |
622 | + else | |
623 | + { | |
624 | + int count = _playerHwids.get(pHwid); | |
625 | + | |
626 | + if (count < 1) | |
627 | + { | |
628 | + _playerHwids.remove(pHwid); | |
629 | + _playerHwids.put(pHwid, count + 1); | |
630 | + _canReward = true; | |
631 | + } | |
632 | + else | |
633 | + { | |
634 | + member.sendMessage("You are Other PC Reward."); | |
635 | + _canReward = false; | |
636 | + } | |
637 | + } | |
638 | + if (_canReward) | |
639 | + { | |
640 | + if (member.isIn3DRadius(monster.getX(), monster.getY(), monster.getZ(), 1000)) | |
641 | + RandomReward(member); | |
642 | + else | |
643 | + member.sendMessage("You are too far from your party to be rewarded."); | |
644 | + } | |
645 | + } | |
646 | + _playerHwids.clear(); | |
647 | + } | |
648 | + else | |
649 | + RandomReward(player); | |
650 | + } | |
651 | + } | |
652 | + | |
653 | + public static void RandomReward(Player player) | |
654 | + { | |
655 | + for (RewardHolder reward : Config.PARTY_ZONE_REWARDS) | |
656 | + { | |
657 | + if (Rnd.get(100) <= reward.getRewardChance()) | |
658 | + { | |
659 | + //if (player.isVip()) | |
660 | + // player.addItem("Random Reward", reward.getRewardId(), Rnd.get(reward.getRewardMin(), reward.getRewardMax()) * Config.VIP_DROP_RATE, player, true); | |
661 | + //else | |
662 | + player.addItem("Random Reward", reward.getRewardId(), Rnd.get(reward.getRewardMin(), reward.getRewardMax()), player, true); | |
663 | + } | |
664 | + } | |
665 | + } | |
666 | + | |
667 | + public static final PartyZoneReward getInstance() | |
668 | + { | |
669 | + return SingletonHolder._instance; | |
670 | + } | |
671 | + | |
672 | + private static class SingletonHolder | |
673 | + { | |
674 | + protected static final PartyZoneReward _instance = new PartyZoneReward(); | |
675 | + } | |
676 | +} | |
677 | \ No newline at end of file | |
678 | diff --git a/java/net/sf/l2j/gameserver/data/manager/RewardHolder.java b/java/net/sf/l2j/gameserver/data/manager/RewardHolder.java | |
679 | new file mode 100644 | |
680 | index 0000000..66af8aa | |
681 | --- /dev/null | |
682 | +++ b/java/net/sf/l2j/gameserver/data/manager/RewardHolder.java | |
683 | @@ -0,0 +1,76 @@ | |
684 | +package net.sf.l2j.gameserver.data.manager; | |
685 | + | |
686 | +public class RewardHolder | |
687 | +{ | |
688 | + private int _id; | |
689 | + private int _min; | |
690 | + private int _max; | |
691 | + private int _chance; | |
692 | + | |
693 | + /** | |
694 | + * @param rewardId | |
695 | + * @param rewardMin | |
696 | + * @param rewardMax | |
697 | + */ | |
698 | + public RewardHolder(int rewardId, int rewardMin, int rewardMax) | |
699 | + { | |
700 | + _id = rewardId; | |
701 | + _min = rewardMin; | |
702 | + _max = rewardMax; | |
703 | + _chance = 100; | |
704 | + } | |
705 | + | |
706 | + /** | |
707 | + * @param rewardId | |
708 | + * @param rewardMin | |
709 | + * @param rewardMax | |
710 | + * @param rewardChance | |
711 | + */ | |
712 | + public RewardHolder(int rewardId, int rewardMin, int rewardMax, int rewardChance) | |
713 | + { | |
714 | + _id = rewardId; | |
715 | + _min = rewardMin; | |
716 | + _max = rewardMax; | |
717 | + _chance = rewardChance; | |
718 | + } | |
719 | + | |
720 | + public int getRewardId() | |
721 | + { | |
722 | + return _id; | |
723 | + } | |
724 | + | |
725 | + public int getRewardMin() | |
726 | + { | |
727 | + return _min; | |
728 | + } | |
729 | + | |
730 | + public int getRewardMax() | |
731 | + { | |
732 | + return _max; | |
733 | + } | |
734 | + | |
735 | + public int getRewardChance() | |
736 | + { | |
737 | + return _chance; | |
738 | + } | |
739 | + | |
740 | + public void setId(int id) | |
741 | + { | |
742 | + _id = id; | |
743 | + } | |
744 | + | |
745 | + public void setMin(int min) | |
746 | + { | |
747 | + _min = min; | |
748 | + } | |
749 | + | |
750 | + public void setMax(int max) | |
751 | + { | |
752 | + _max = max; | |
753 | + } | |
754 | + | |
755 | + public void setChance(int chance) | |
756 | + { | |
757 | + _chance = chance; | |
758 | + } | |
759 | +} | |
760 | \ No newline at end of file | |
761 | diff --git a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java | |
762 | index 99efa93..ae67764 100644 | |
763 | --- a/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java | |
764 | +++ b/java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java | |
765 | @@ -8,6 +8,7 @@ | |
766 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminBookmark; | |
767 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminClanHall; | |
768 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCursedWeapon; | |
769 | +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCustom; | |
770 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDoor; | |
771 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEditChar; | |
772 | import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEffects; | |
773 | @@ -43,6 +44,7 @@ | |
774 | ||
775 | protected AdminCommandHandler() | |
776 | { | |
777 | + registerHandler(new AdminCustom()); | |
778 | registerHandler(new AdminVip()); | |
779 | registerHandler(new AdminAdmin()); | |
780 | registerHandler(new AdminAnnouncements()); | |
781 | diff --git a/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java | |
782 | new file mode 100644 | |
783 | index 0000000..d5c5894 | |
784 | --- /dev/null | |
785 | +++ b/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCustom.java | |
786 | @@ -0,0 +1,147 @@ | |
787 | +package net.sf.l2j.gameserver.handler.admincommandhandlers; | |
788 | + | |
789 | +import java.util.logging.Logger; | |
790 | + | |
791 | +import net.sf.l2j.commons.pool.ThreadPool; | |
792 | + | |
793 | +import net.sf.l2j.gameserver.handler.IAdminCommandHandler; | |
794 | +import net.sf.l2j.gameserver.model.actor.Player; | |
795 | + | |
796 | +import Dev.Events.PartyFarm.PartyFarm; | |
797 | +//import Dev.Tournament.properties.ArenaTask; | |
798 | + | |
799 | + | |
800 | +public class AdminCustom implements IAdminCommandHandler | |
801 | +{ | |
802 | + | |
803 | + private static final String[] ADMIN_COMMANDS = | |
804 | + { | |
805 | + "admin_tour", | |
806 | + "admin_ptfarm" | |
807 | + | |
808 | + }; | |
809 | + | |
810 | + protected static final Logger _log = Logger.getLogger(AdminCustom.class.getName()); | |
811 | + public static boolean _arena_manual = false; | |
812 | + public static boolean _bestfarm_manual = false; | |
813 | + | |
814 | + @Override | |
815 | + public void useAdminCommand(String command, Player activeChar) | |
816 | + { | |
817 | + | |
818 | + | |
819 | + /*if (command.equals("admin_tour")) | |
820 | + { | |
821 | + if (ArenaTask._started) | |
822 | + { | |
823 | + _log.info("----------------------------------------------------------------------------"); | |
824 | + _log.info("[Tournament]: Event Finished."); | |
825 | + _log.info("----------------------------------------------------------------------------"); | |
826 | + ArenaTask._aborted = true; | |
827 | + finishEventArena(); | |
828 | + _arena_manual = true; | |
829 | + | |
830 | + activeChar.sendMessage("SYS: Voce Finalizou o evento Tournament Manualmente.."); | |
831 | + } | |
832 | + else | |
833 | + { | |
834 | + _log.info("----------------------------------------------------------------------------"); | |
835 | + _log.info("[Tournament]: Event Started."); | |
836 | + _log.info("----------------------------------------------------------------------------"); | |
837 | + initEventArena(); | |
838 | + _arena_manual = true; | |
839 | + activeChar.sendMessage("SYS: Voce ativou o evento Tournament Manualmente.."); | |
840 | + } | |
841 | + | |
842 | + return true; | |
843 | + }*/ | |
844 | + if (command.equals("admin_ptfarm")) | |
845 | + { | |
846 | + if (PartyFarm._started) | |
847 | + { | |
848 | + _log.info("----------------------------------------------------------------------------"); | |
849 | + _log.info("[Party Farm]: Event Finished."); | |
850 | + _log.info("----------------------------------------------------------------------------"); | |
851 | + PartyFarm._aborted = true; | |
852 | + finishEventPartyFarm(); | |
853 | + | |
854 | + activeChar.sendMessage("SYS: Voce Finalizou o Party Farm Manualmente.."); | |
855 | + } | |
856 | + else | |
857 | + { | |
858 | + _log.info("----------------------------------------------------------------------------"); | |
859 | + _log.info("[Party Farm]: Event Started."); | |
860 | + _log.info("----------------------------------------------------------------------------"); | |
861 | + initEventPartyFarm(); | |
862 | + _bestfarm_manual = true; | |
863 | + activeChar.sendMessage("SYS: Voce ativou o Best Farm Manualmente.."); | |
864 | + } | |
865 | + } | |
866 | + return; | |
867 | + | |
868 | + } | |
869 | + | |
870 | + | |
871 | + private static void initEventPartyFarm() | |
872 | + { | |
873 | + ThreadPool.schedule(new Runnable() | |
874 | + { | |
875 | + @Override | |
876 | + public void run() | |
877 | + { | |
878 | + | |
879 | + PartyFarm.bossSpawnMonster(); | |
880 | + } | |
881 | + }, 1L); | |
882 | + } | |
883 | + | |
884 | + private static void finishEventPartyFarm() | |
885 | + { | |
886 | + ThreadPool.schedule(new Runnable() | |
887 | + { | |
888 | + @Override | |
889 | + public void run() | |
890 | + { | |
891 | + | |
892 | + PartyFarm.Finish_Event(); | |
893 | + | |
894 | + } | |
895 | + }, 1L); | |
896 | + } | |
897 | + | |
898 | + /* | |
899 | + private static void initEventArena() | |
900 | + { | |
901 | + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() | |
902 | + { | |
903 | + @Override | |
904 | + public void run() | |
905 | + { | |
906 | + | |
907 | + ArenaTask.SpawnEvent(); | |
908 | + } | |
909 | + }, 10L); | |
910 | + } | |
911 | + | |
912 | + private static void finishEventArena() | |
913 | + { | |
914 | + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() | |
915 | + { | |
916 | + @Override | |
917 | + public void run() | |
918 | + { | |
919 | + | |
920 | + ArenaTask.finishEvent(); | |
921 | + } | |
922 | + }, 10L); | |
923 | + }*/ | |
924 | + | |
925 | + | |
926 | + | |
927 | + | |
928 | + @Override | |
929 | + public String[] getAdminCommandList() | |
930 | + { | |
931 | + return ADMIN_COMMANDS; | |
932 | + } | |
933 | +} | |
934 | \ No newline at end of file | |
935 | diff --git a/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java b/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java | |
936 | index 8663495..39a9186 100644 | |
937 | --- a/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java | |
938 | +++ b/java/net/sf/l2j/gameserver/model/actor/instance/Monster.java | |
939 | @@ -13,6 +13,7 @@ | |
940 | ||
941 | import net.sf.l2j.Config; | |
942 | import net.sf.l2j.gameserver.data.manager.CursedWeaponManager; | |
943 | +import net.sf.l2j.gameserver.data.manager.PartyZoneReward; | |
944 | import net.sf.l2j.gameserver.data.xml.HerbDropData; | |
945 | import net.sf.l2j.gameserver.enums.BossInfoType; | |
946 | import net.sf.l2j.gameserver.geoengine.GeoEngine; | |
947 | @@ -861,7 +862,8 @@ | |
948 | final Player player = creature.getActingPlayer(); | |
949 | if (player == null) | |
950 | return; | |
951 | - | |
952 | + if (Config.PART_ZONE_MONSTERS_EVENT_ID.contains(Integer.valueOf(template.getNpcId()))) | |
953 | + PartyZoneReward.addPartyZoneReward(player, this); | |
954 | // Calculate level modifier. | |
955 | final int levelModifier = calculateLevelModifierForDrop(player); | |
956 | ||
957 | diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java | |
958 | index be4efdf..496642d 100644 | |
959 | --- a/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java | |
960 | +++ b/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java | |
961 | @@ -19,6 +19,7 @@ | |
962 | import net.sf.l2j.gameserver.data.xml.AnnouncementData; | |
963 | import net.sf.l2j.gameserver.data.xml.MapRegionData.TeleportType; | |
964 | import net.sf.l2j.gameserver.enums.CabalType; | |
965 | +import net.sf.l2j.gameserver.enums.SayType; | |
966 | import net.sf.l2j.gameserver.enums.SealType; | |
967 | import net.sf.l2j.gameserver.enums.SiegeSide; | |
968 | import net.sf.l2j.gameserver.enums.ZoneId; | |
969 | @@ -36,6 +37,7 @@ | |
970 | import net.sf.l2j.gameserver.network.GameClient.GameClientState; | |
971 | import net.sf.l2j.gameserver.network.SystemMessageId; | |
972 | import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; | |
973 | +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay; | |
974 | import net.sf.l2j.gameserver.network.serverpackets.Die; | |
975 | import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate; | |
976 | import net.sf.l2j.gameserver.network.serverpackets.ExMailArrived; | |
977 | @@ -59,6 +61,8 @@ | |
978 | import net.sf.l2j.gameserver.skills.L2Skill; | |
979 | import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager; | |
980 | ||
981 | +import Dev.Events.PartyFarm.PartyFarm; | |
982 | + | |
983 | public class EnterWorld extends L2GameClientPacket | |
984 | { | |
985 | @Override | |
986 | @@ -243,6 +247,11 @@ | |
987 | { | |
988 | ShowNextRestart(player); | |
989 | } | |
990 | + if ((PartyFarm.is_started()) && (Config.PARTY_FARM_BY_TIME_OF_DAY)) | |
991 | + { | |
992 | + new CreatureSay(3,SayType.PARTY, ".", "" + Config.PARTY_FARM_MESSAGE_TEXT + ":."); | |
993 | + | |
994 | + } | |
995 | // Means that it's not ok multiBox situation, so logout | |
996 | if (!player.checkMultiBox()) | |
997 | { | |
998 |