diff --git a/docs/mychanges_ptbr.txt b/docs/mychanges_ptbr.txt index 434a5d8587..bb14bc4e37 100644 --- a/docs/mychanges_ptbr.txt +++ b/docs/mychanges_ptbr.txt @@ -757,4 +757,13 @@ Corrigido item megafone permitindo o display de equipamentos n Incrementado portal de MK Castle agora permitindo uso dos 2 itens possíveis. Resolvido alguns logs de erros disparados por mapas nulos no código-fonte. Resolvido pequenos problemas de volatidade (nulos) nas referencias ao jogador em alguns handlers. -Corrigido alguns problemas com copyright em alguns arquivos. \ No newline at end of file +Corrigido alguns problemas com copyright em alguns arquivos. +Corrigido exploit com refinadores de minerais permitindo números iguais ou menores que zero como entrada. + +14 - 15 Janeiro 2018, +Melhorado pet autopot, agora utilizando os outros slots do mesmo item caso o slot alvo tenha sido completamente usado. +Pet autopot agora considera o reuso de pots que fornecem ganho de porcentagem de HP ou MP. +Diminuídas levemente as chances de dropar os itens Moon Rock e Star Rock. +Função de listagem de itens no inventário agora ordena os itens de acordo com posição dos mesmos. +Incrementado diversos aspectos das questlines das doorways em Victoria Island. +Melhorado mecânica de convite para Alliances agora utilizando o balão apropriado, similar aos utilizados para Party e Guild. \ No newline at end of file diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 3287222d26..83e0ef5512 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -2,6 +2,8 @@ - + + file:/C:/Nexon/MapleSolaxia/HeavenMS/scripts/portal/obstacle.js + diff --git a/scripts/map/onUserEnter/677000001.js b/scripts/map/onUserEnter/677000001.js index 0c5832a3e6..4e04309277 100644 --- a/scripts/map/onUserEnter/677000001.js +++ b/scripts/map/onUserEnter/677000001.js @@ -1,8 +1,10 @@ importPackage(Packages.server.life); function start(ms) { - + var pos = new java.awt.Point(461, 61); var mobId = 9400612; + var mobName = "Marbas"; + var player = ms.getPlayer(); var map = player.getMap(); @@ -10,6 +12,6 @@ function start(ms) { return; } - map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), new java.awt.Point(461, 61)); - player.message("Marbas has appeared!"); + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); + player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000003.js b/scripts/map/onUserEnter/677000003.js new file mode 100644 index 0000000000..f4f036aece --- /dev/null +++ b/scripts/map/onUserEnter/677000003.js @@ -0,0 +1,17 @@ +importPackage(Packages.server.life); + +function start(ms) { + var pos = new java.awt.Point(467, 0); + var mobId = 9400610; + var mobName = "Amdusias"; + + var player = ms.getPlayer(); + var map = player.getMap(); + + if(map.getMonsterById(mobId) != null){ + return; + } + + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); + player.message(mobName + " has appeared!"); +} \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000005.js b/scripts/map/onUserEnter/677000005.js new file mode 100644 index 0000000000..81ce286bb8 --- /dev/null +++ b/scripts/map/onUserEnter/677000005.js @@ -0,0 +1,17 @@ +importPackage(Packages.server.life); + +function start(ms) { + var pos = new java.awt.Point(201, 80); + var mobId = 9400609; + var mobName = "Andras"; + + var player = ms.getPlayer(); + var map = player.getMap(); + + if(map.getMonsterById(mobId) != null){ + return; + } + + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); + player.message(mobName + " has appeared!"); +} \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000007.js b/scripts/map/onUserEnter/677000007.js new file mode 100644 index 0000000000..d52195b309 --- /dev/null +++ b/scripts/map/onUserEnter/677000007.js @@ -0,0 +1,17 @@ +importPackage(Packages.server.life); + +function start(ms) { + var pos = new java.awt.Point(171, 50); + var mobId = 9400611; + var mobName = "Crocell"; + + var player = ms.getPlayer(); + var map = player.getMap(); + + if(map.getMonsterById(mobId) != null){ + return; + } + + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); + player.message(mobName + " has appeared!"); +} \ No newline at end of file diff --git a/scripts/map/onUserEnter/677000009.js b/scripts/map/onUserEnter/677000009.js index e0a1df5874..23969e4b4b 100644 --- a/scripts/map/onUserEnter/677000009.js +++ b/scripts/map/onUserEnter/677000009.js @@ -1,13 +1,17 @@ importPackage(Packages.server.life); -function start(ms) { - spawnMob(251, -841, 9400613, ms.getPlayer().getMap()); -} +function start(ms) { + var pos = new java.awt.Point(251, -841); + var mobId = 9400613; + var mobName = "Valefor"; + + var player = ms.getPlayer(); + var map = player.getMap(); -function spawnMob(x, y, id, map) { - if(map.getMonsterById(id) != null) - return; - - var mob = MapleLifeFactory.getMonster(id); - map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(x, y)); + if(map.getMonsterById(mobId) != null){ + return; + } + + map.spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(mobId), pos); + player.message(mobName + " has appeared!"); } \ No newline at end of file diff --git a/scripts/npc/1012002.js b/scripts/npc/1012002.js index f1442956cf..ab5b6d7ae4 100644 --- a/scripts/npc/1012002.js +++ b/scripts/npc/1012002.js @@ -106,7 +106,7 @@ function action(mode, type, selection) { if (selectedType != 4) selectedItem = selection; else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 0) { //bow refine var matSet = [[4003001,4000000],[4011001,4003000],[4003001,4000016],[4011001,4021006,4003000],[4011001,4011006,4021003,4021006,4003000],[4011004,4021000,4021004,4003000],[4021008,4011001,4011006,4003000,4000014]]; var matQtySet = [[5,30],[1,3],[30,50],[2,2,8],[5,5,3,3,30],[7,6,3,35],[1,10,3,40,50]]; diff --git a/scripts/npc/1022003.js b/scripts/npc/1022003.js index 4be7e6998b..735ae2179b 100644 --- a/scripts/npc/1022003.js +++ b/scripts/npc/1022003.js @@ -136,7 +136,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 2){ //helmet refine var itemSet = new Array(1002042,1002041,1002002,1002044,1002003,1002040,1002007,1002052,1002011,1002058,1002009,1002056,1002087,1002088,1002050,1002049,1002047,1002048,1002099,1002098,1002085,1002028,1002022,1002101); diff --git a/scripts/npc/1022004.js b/scripts/npc/1022004.js index 408cd17ca7..c27b169d21 100644 --- a/scripts/npc/1022004.js +++ b/scripts/npc/1022004.js @@ -116,7 +116,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 0){ //glove refine var itemSet = new Array(1082003,1082000,1082004,1082001,1082007,1082008,1082023,1082009,1082059); diff --git a/scripts/npc/1040000.js b/scripts/npc/1040000.js new file mode 100644 index 0000000000..5e3b244b5a --- /dev/null +++ b/scripts/npc/1040000.js @@ -0,0 +1,56 @@ +/* + This file is part of the HeavenMS (MapleSolaxiaV2) MapleStory Server + Copyleft (L) 2017 RonanLana + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation version 3 as published by + the Free Software Foundation. You may not use, modify or distribute + this program under any other version of the GNU Affero General Public + License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +var status; + +function start() { + status = -1; + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == -1) { + cm.dispose(); + } else { + if (mode == 0 && type > 0) { + cm.dispose(); + return; + } + if (mode == 1) + status++; + else + status--; + + if(status == 0) { + if(cm.isQuestStarted(28177) && !cm.haveItem(4032479)) { + if(cm.canHold(4032479)) { + cm.gainItem(4032479, 1); + cm.sendOk("Huh, are you looking for me? Chief Stan sent you here, right? But hey, I am not the suspect you seek. If I have some proof? Here, take this and return it to #b#p1012003##k."); + } else { + cm.sendOk("Hey, make a slot available before talking to me."); + } + } else { + cm.sendOk("Zzzzzz..."); + } + + cm.dispose(); + } + } +} diff --git a/scripts/npc/1052002.js b/scripts/npc/1052002.js index 55ae429e7c..781c7ad785 100644 --- a/scripts/npc/1052002.js +++ b/scripts/npc/1052002.js @@ -138,7 +138,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 0){ //glove refine var itemSet = new Array(1082002,1082029,1082030,1082031,1082032,1082037,1082042,1082046,1082075,1082065,1082092); diff --git a/scripts/npc/1052003.js b/scripts/npc/1052003.js index c2fcf9004e..96e967b04d 100644 --- a/scripts/npc/1052003.js +++ b/scripts/npc/1052003.js @@ -129,7 +129,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); last_use = false; diff --git a/scripts/npc/1091003.js b/scripts/npc/1091003.js index af3900d4bf..d887568ca7 100644 --- a/scripts/npc/1091003.js +++ b/scripts/npc/1091003.js @@ -66,7 +66,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 0){ //Making a Knuckler var itemSet = new Array(1482001, 1482002, 1482003, 1482004, 1482005, 1482006, 1482007); diff --git a/scripts/npc/1092010.js b/scripts/npc/1092010.js index 99f5277ef7..df6d2a2875 100644 --- a/scripts/npc/1092010.js +++ b/scripts/npc/1092010.js @@ -30,6 +30,33 @@ No specific function, useless text. */ function start() { - cm.sendOk("(Scratch scratch...)"); - cm.dispose(); + status = -1; + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == -1) { + cm.dispose(); + } else { + if (mode == 0 && type > 0) { + cm.dispose(); + return; + } + if (mode == 1) + status++; + else + status--; + + if(status == 0) { + if(!cm.haveItem(4220153)) { + cm.sendOk("(Scratch scratch...)"); + cm.dispose(); + } else { + cm.sendYesNo("Hey, nice #bTreasure Map#k you have there? #rCan I keep it#k for the Nautilus crew, if you don't need it any longer?"); + } + } else if(status == 1) { + cm.gainItem(4220153, -1); + cm.dispose(); + } + } } diff --git a/scripts/npc/2020000.js b/scripts/npc/2020000.js index 909e9c6cd7..18a6a38ccc 100644 --- a/scripts/npc/2020000.js +++ b/scripts/npc/2020000.js @@ -182,7 +182,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); if (selectedType == 5){ //arrow refine var itemSet = new Array(2060000,2061000,2060001,2061001,2060002,2061002); diff --git a/scripts/npc/2040016.js b/scripts/npc/2040016.js index 2cb2bd0b3c..ea08cad408 100644 --- a/scripts/npc/2040016.js +++ b/scripts/npc/2040016.js @@ -196,7 +196,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); var prompt = "You want me to make "; if (qty == 1) diff --git a/scripts/npc/2100001.js b/scripts/npc/2100001.js index 312512fd6d..632533d0e7 100644 --- a/scripts/npc/2100001.js +++ b/scripts/npc/2100001.js @@ -120,7 +120,7 @@ function action(mode, type, selection) { qty = 1; } else - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); var prompt = "You want me to make "; if (qty == 1) diff --git a/scripts/npc/2141002.js b/scripts/npc/2141002.js index 6bb9fcc3d6..ac180ce887 100644 --- a/scripts/npc/2141002.js +++ b/scripts/npc/2141002.js @@ -43,7 +43,7 @@ function action(mode, type, selection) { cm.warp(270050000); } else { - cm.sendOk("You cannot receive an event prize without having an empty room in your EQUIP, USE, SET-UP or ETC inventory."); + cm.sendOk("You cannot receive an event prize without having an empty room in your EQUIP, USE, SET-UP and ETC inventory."); } cm.dispose(); diff --git a/scripts/npc/9000017.js b/scripts/npc/9000017.js index e074b84fbc..da34be4d2b 100644 --- a/scripts/npc/9000017.js +++ b/scripts/npc/9000017.js @@ -58,7 +58,7 @@ function action(mode, type, selection) { } else if (status == 3) { - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); last_use = false; var prompt = "You want us to make "; diff --git a/scripts/npc/9201096.js b/scripts/npc/9201096.js index 9e78d57d8d..487c93a296 100644 --- a/scripts/npc/9201096.js +++ b/scripts/npc/9201096.js @@ -58,7 +58,7 @@ function action(mode, type, selection) { } else if (status == 3) { - qty = selection; + qty = (selection > 0) ? selection : (-selection <= 0 ? 1 : -selection); last_use = false; var prompt = "So, you want me to make "; diff --git a/scripts/npc/9201128.js b/scripts/npc/9201128.js new file mode 100644 index 0000000000..64b0c24817 --- /dev/null +++ b/scripts/npc/9201128.js @@ -0,0 +1,30 @@ +var map = 677000004; +var quest = 28179; +var status = -1; + +function start(mode, type, selection) { + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == 1) { + status++; + } else { + cm.dispose(); + return; + } + if (status == 0) { + if (cm.isQuestStarted(quest)) { + cm.sendYesNo("Would you like to move to #b#m" + map + "##k?"); + } else { + cm.sendOk("The entrance is blocked by a strange force."); + cm.dispose(); + } + } else { + if(cm.haveItem(4001341, 1)) cm.gainItem(4001341, -1); + if(cm.haveItem(4032478, 1)) cm.gainItem(4032478, -1); + + cm.warp(map, 0); + cm.dispose(); + } +} \ No newline at end of file diff --git a/scripts/npc/9201129.js b/scripts/npc/9201129.js index 9503c827ef..58d4230c2f 100644 --- a/scripts/npc/9201129.js +++ b/scripts/npc/9201129.js @@ -1,61 +1,27 @@ -/* - Demon's Doorway - Marbas the Demon! Quest - Victoria Road: The Tree That Grew III -*/ +var map = 677000000; +var quest = 28198; +var status = -1; -var status; - -function start(){ - status = -1; +function start(mode, type, selection) { action(1, 0, 0); } -function action(mode, type, selection){ - if (mode == -1){ - cm.dispose(); - } - else{ - if (mode == 0 && status ==0){ - cm.dispose(); - return; - } - - if (mode == 1) - status++; - else - status--; - - if (status == 0){ - cm.sendNext("#r\t[Requirements to Enter]\r\n\r\n\t\t1.#k Job must be Magician or Blaze Wizard.\r\n\t\t#r2.#k Must be under level 40.\r\n\t\t#r3.#k Must have #b#t4032495##k."); - } - else if (status == 1){ - var jobId = cm.getJobId(); - - if ((jobId >= 200 && jobId <= 232) || (jobId >= 1100 && jobId <= 1112)){ - if (cm.getLevel() < 40){ - if (cm.hasItem(4032495)){ - cm.sendYesNo("#kAll conditions have been satisfied. Do you wish to enter?"); - } - else{ - cm.sendOk("\t\tYou do not have #b#t4032495# #i4032495#"); - cm.dispose(); - } - } - else{ - cm.sendOk("\tYour #blevel#k is too high."); - cm.dispose(); - } - } - else{ - cm.sendOk("\tThis is not for you! #rBegone#k you fool!"); - cm.dispose(); - } - } - else if (status == 2){ - cm.warp(677000000, 2); - - cm.dispose(); - } - } +function action(mode, type, selection) { + if (mode == 1) { + status++; + } else { + cm.dispose(); + return; + } + if (status == 0) { + if (cm.isQuestStarted(quest)) { + cm.sendYesNo("Would you like to move to #b#m" + map + "##k?"); + } else { + cm.sendOk("The entrance is blocked by a strange force."); + cm.dispose(); + } + } else { + cm.warp(map, 0); + cm.dispose(); + } } \ No newline at end of file diff --git a/scripts/npc/9201130.js b/scripts/npc/9201130.js index 3769faaef9..797499a0c8 100644 --- a/scripts/npc/9201130.js +++ b/scripts/npc/9201130.js @@ -1,3 +1,5 @@ +var map = 677000008; +var quest = 28219; var status = -1; function start(mode, type, selection) { @@ -12,16 +14,17 @@ function action(mode, type, selection) { return; } if (status == 0) { - if (cm.isQuestStarted(28219)) { - cm.sendYesNo("Would you like to move to Valefor's Strolling Place?"); - } else { - cm.sendOk("The entrance is blocked by a strange force."); - cm.dispose(); - } + if (cm.isQuestStarted(quest)) { + cm.sendYesNo("Would you like to move to #b#m" + map + "##k?"); + } else { + cm.sendOk("The entrance is blocked by a strange force."); + cm.dispose(); + } } else { if(cm.haveItem(4032485, 1)) cm.gainItem(4032485, -1); if(cm.haveItem(4001355, 1)) cm.gainItem(4001355, -1); - cm.warp(677000008,0); + + cm.warp(map, 0); cm.dispose(); } } \ No newline at end of file diff --git a/scripts/npc/9201131.js b/scripts/npc/9201131.js new file mode 100644 index 0000000000..1a1b8efb69 --- /dev/null +++ b/scripts/npc/9201131.js @@ -0,0 +1,31 @@ +var map = 677000002; +var quest = 28238; +var status = -1; + +function start(mode, type, selection) { + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == 1) { + status++; + } else { + cm.dispose(); + return; + } + if (status == 0) { + if (cm.isQuestStarted(quest)) { + cm.sendYesNo("Would you like to move to #b#m" + map + "##k?"); + } else { + cm.sendOk("The entrance is blocked by a strange force."); + cm.dispose(); + } + } else { + if(cm.haveItem(4032481, 1)) cm.gainItem(4032481, -1); + if(cm.haveItem(4032482, 1)) cm.gainItem(4032482, -1); + if(cm.haveItem(4032483, 1)) cm.gainItem(4032483, -1); + + cm.warp(map, 0); + cm.dispose(); + } +} \ No newline at end of file diff --git a/scripts/npc/9201132.js b/scripts/npc/9201132.js new file mode 100644 index 0000000000..4b69ee3774 --- /dev/null +++ b/scripts/npc/9201132.js @@ -0,0 +1,34 @@ +var map = 677000006; +var quest = 28256; +var status = -1; + +function start(mode, type, selection) { + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == 1) { + status++; + } else { + cm.dispose(); + return; + } + if (status == 0) { + if (cm.isQuestStarted(quest)) { + cm.sendYesNo("Would you like to move to #b#m" + map + "##k?"); + } else { + cm.sendOk("The entrance is blocked by a strange force."); + cm.dispose(); + } + } else { + if(cm.haveItem(4001362, 1)) cm.gainItem(4001362, -cm.getItemQuantity(4001362)); + if(cm.haveItem(4001363, 1)) cm.gainItem(4001363, -cm.getItemQuantity(4001363)); + if(cm.haveItem(4032486, 1)) cm.gainItem(4032486, -1); + if(cm.haveItem(4032488, 1)) cm.gainItem(4032488, -1); + if(cm.haveItem(4032489, 1)) cm.gainItem(4032489, -1); + if(cm.haveItem(4220153, 1)) cm.gainItem(4220153, -1); + + cm.warp(map, 0); + cm.dispose(); + } +} \ No newline at end of file diff --git a/scripts/portal/raid_rest.js b/scripts/portal/raid_rest.js index 2a49b8ca9d..3ed68a4213 100644 --- a/scripts/portal/raid_rest.js +++ b/scripts/portal/raid_rest.js @@ -32,12 +32,12 @@ function enter(pi) { return false; } - if(pi.getPlayer().getEventInstance().giveEventReward(pi.getPlayer(), evLevel)) { + if(!pi.getPlayer().getEventInstance().giveEventReward(pi.getPlayer(), evLevel)) { pi.warp(970030000); return true; } else { - pi.message("You cannot receive an event prize without having an empty room in your EQUIP, USE, SET-UP or ETC inventory."); + pi.message("Make a room available on all EQUIP, USE, SET-UP and ETC inventory to claim an event prize."); return false; } } \ No newline at end of file diff --git a/scripts/reactor/1202003.js b/scripts/reactor/1202003.js new file mode 100644 index 0000000000..bbad6f2f1e --- /dev/null +++ b/scripts/reactor/1202003.js @@ -0,0 +1,3 @@ +function act() { + rm.dropItems(); +} diff --git a/scripts/reactor/1202004.js b/scripts/reactor/1202004.js new file mode 100644 index 0000000000..bbad6f2f1e --- /dev/null +++ b/scripts/reactor/1202004.js @@ -0,0 +1,3 @@ +function act() { + rm.dropItems(); +} diff --git a/sql/db_database.sql b/sql/db_database.sql index 777f0eb6f9..fbf92e00c3 100644 --- a/sql/db_database.sql +++ b/sql/db_database.sql @@ -3748,7 +3748,7 @@ INSERT IGNORE INTO `temp_data` (`id`, `dropperid`, `itemid`, `minimum_quantity`, (3530, 4240000, 4004003, 1, 1, 0, 10000), (3531, 4240000, 2043801, 1, 1, 0, 300), (3532, 4240000, 4006001, 1, 1, 0, 10000), -(3533, 4240000, 4021009, 1, 1, 0, 9000), +(3533, 4240000, 4021009, 1, 1, 0, 7000), (3534, 4240000, 1322016, 1, 1, 0, 700), (3535, 4240000, 1041074, 1, 1, 0, 800), (3536, 4240000, 1061069, 1, 1, 0, 800), @@ -4123,7 +4123,7 @@ INSERT IGNORE INTO `temp_data` (`id`, `dropperid`, `itemid`, `minimum_quantity`, (3904, 5120100, 4020001, 1, 1, 0, 90000), (3905, 5120100, 4010006, 1, 1, 0, 90000), (3906, 5120100, 4020007, 1, 1, 0, 90000), -(3907, 5120100, 4011007, 1, 1, 0, 30000), +(3907, 5120100, 4011007, 1, 1, 0, 7000), (3908, 5120100, 2044602, 1, 1, 0, 3000), (3909, 5120100, 1041082, 1, 1, 0, 8000), (3910, 5120100, 1061081, 1, 1, 0, 8000), @@ -16675,8 +16675,8 @@ INSERT INTO `reactordrops` (`reactordropid`, `reactorid`, `itemid`, `chance`, `q (125, 1022001, 4032319, 7, -1), (126, 1022002, 4001340, 1, 28167), (127, 1202000, 4001366, 1, 28194), -(128, 1202003, 4001346, 1, 28225), -(129, 1202004, 4001346, 1, 28225), +(128, 1202003, 4001346, 3, 28225), +(129, 1202004, 4001346, 3, 28225), (130, 1032000, 4032362, 1, 28252), (131, 1032000, 4032363, 1, 28252), (132, 1202004, 4032494, 1, 28255), diff --git a/sql/db_drops.sql b/sql/db_drops.sql index aefef35aa4..f476485896 100644 --- a/sql/db_drops.sql +++ b/sql/db_drops.sql @@ -96,8 +96,8 @@ USE `heavenms`; (9300219, 4000003, 1, 1, 0, 200000), (130100, 4030009, 1, 1, 0, 10000), (9300219, 4030009, 1, 1, 0, 10000), -(130100, 4001358, 1, 1, 0, 7000), -(9300219, 4001358, 1, 1, 0, 7000), +(130100, 4001358, 1, 1, 0, 20000), +(9300219, 4001358, 1, 1, 0, 20000), (130100, 2000000, 1, 1, 0, 40000), (9300219, 2000000, 1, 1, 0, 40000), (130100, 2040402, 1, 1, 0, 750), @@ -130,8 +130,8 @@ USE `heavenms`; (9300219, 1482001, 1, 1, 0, 700), (130101, 4000016, 1, 1, 0, 200000), (9300218, 4000016, 1, 1, 0, 200000), -(130101, 4001359, 1, 1, 0, 7000), -(9300218, 4001359, 1, 1, 0, 7000), +(130101, 4001359, 1, 1, 0, 24000), +(9300218, 4001359, 1, 1, 0, 24000), (130101, 2000000, 1, 1, 0, 40000), (9300218, 2000000, 1, 1, 0, 40000), (130101, 2040502, 1, 1, 0, 750), @@ -568,7 +568,7 @@ USE `heavenms`; (1110101, 4030009, 1, 1, 0, 10000), (1110101, 4001344, 1, 1, 0, 7000), (1110101, 4001356, 1, 1, 0, 7000), -(1110101, 4001360, 1, 1, 0, 7000), +(1110101, 4001360, 1, 1, 0, 12000), (1110101, 2000000, 1, 1, 0, 40000), (1110101, 2040802, 1, 1, 0, 750), (1110101, 2380008, 1, 1, 0, 0), @@ -2064,26 +2064,8 @@ USE `heavenms`; (9300221, 1061054, 1, 1, 0, 700), (2100103, 1072291, 1, 1, 0, 700), (9300221, 1072291, 1, 1, 0, 700), -(9400609, 2000003, 1, 4, 0, 40000), -(9400609, 2000002, 1, 4, 0, 40000), -(9400609, 2002004, 1, 4, 0, 10000), -(9400609, 4010000, 1, 1, 0, 7000), -(9400609, 4010004, 1, 1, 0, 7000), -(9400609, 4010002, 1, 1, 0, 7000), -(9400609, 4010001, 1, 1, 0, 7000), -(9400610, 2000002, 1, 4, 0, 40000), (9400623, 2000002, 1, 4, 0, 40000), -(9400610, 4010002, 1, 1, 0, 7000), (9400623, 4010002, 1, 1, 0, 7000), -(9400612, 4020000, 1, 1, 0, 7000), -(9400612, 4010001, 1, 1, 0, 7000), -(9400612, 4010002, 1, 1, 0, 7000), -(9400612, 2000003, 1, 4, 0, 40000), -(9400612, 2000002, 1, 4, 0, 40000), -(9400612, 4010000, 1, 1, 0, 7000), -(9400612, 1082257, 1, 1, 0, 40000), -(9400612, 1003032, 1, 1, 0, 40000), -(9400612, 1072420, 1, 1, 0, 40000), (2230112, 4000020, 1, 1, 0, 200000), (2230112, 4003004, 1, 1, 0, 7000), (2230112, 4000021, 1, 1, 0, 200000), @@ -7679,10 +7661,10 @@ USE `heavenms`; (9400502, 1072303, 1, 1, 0, 40000), (9500121, 1072303, 1, 1, 0, 700), (9500156, 1072303, 1, 1, 0, 700), -(4240000, 4021009, 1, 1, 0, 7000), -(9300334, 4021009, 1, 1, 0, 7000), -(9500122, 4021009, 1, 1, 0, 7000), -(9500369, 4021009, 1, 1, 0, 7000), +(4240000, 4021009, 1, 1, 0, 5000), +(9300334, 4021009, 1, 1, 0, 5000), +(9500122, 4021009, 1, 1, 0, 5000), +(9500369, 4021009, 1, 1, 0, 5000), (4240000, 4130015, 1, 1, 0, 3000), (9300334, 4130015, 1, 1, 0, 3000), (9500122, 4130015, 1, 1, 0, 3000), @@ -8453,7 +8435,7 @@ USE `heavenms`; (9420505, 1041014, 1, 1, 0, 700), (9420505, 1041065, 1, 1, 0, 700), (9420505, 1061070, 1, 1, 0, 700), -(5120100, 4011007, 1, 1, 0, 7000), +(5120100, 4011007, 1, 1, 0, 5000), (5120100, 2000002, 1, 4, 0, 40000), (5120100, 2000004, 1, 4, 0, 40000), (5120100, 2002010, 1, 4, 0, 10000), @@ -19962,7 +19944,71 @@ USE `heavenms`; (1110100, 4032317, 1, 1, 21717, 20000), (1110130, 4032317, 1, 1, 21717, 20000), (1110100, 4032318, 1, 1, 21718, 20000), -(1110130, 4032318, 1, 1, 21718, 20000); +(1110130, 4032318, 1, 1, 21718, 20000), +(9400204, 4130020, 1, 1, 0, 3000), +(9400614, 4001341, 1, 1, 28172, 15000), +(9400615, 4001341, 1, 1, 28172, 15000), +(9400616, 4001341, 1, 1, 28172, 15000), +(1110101, 4001347, 1, 1, 28229, 80000), +(1110100, 4001348, 1, 1, 28231, 400000), +(1120100, 4001349, 1, 1, 28235, 100000), +(1210101, 4001350, 1, 1, 28235, 100000), +(2220100, 4001351, 1, 1, 28237, 100000), +(9400614, 4001352, 1, 1, 28205, 40000), +(9400615, 4001352, 1, 1, 28205, 40000), +(9400616, 4001352, 1, 1, 28205, 40000), +(9400617, 4001352, 1, 1, 28205, 40000), +(9400617, 4001362, 1, 1, 28252, 40000), +(9400655, 4001362, 1, 1, 28252, 40000), +(9400656, 4001362, 1, 1, 28252, 40000), +(9400617, 4001363, 1, 1, 28252, 40000), +(9400655, 4001363, 1, 1, 28252, 40000), +(9400656, 4001363, 1, 1, 28252, 40000), +(9400609, 2000002, 1, 1, 0, 40000), +(9400609, 2000003, 1, 1, 0, 40000), +(9400609, 2000004, 1, 1, 0, 10000), +(9400609, 4010000, 1, 1, 0, 7000), +(9400609, 4010001, 1, 1, 0, 7000), +(9400609, 4010004, 1, 1, 0, 7000), +(9400609, 4020006, 1, 1, 0, 7000), +(9400609, 1082256, 1, 1, 0, 5000), +(9400609, 1072419, 1, 1, 0, 5000), +(9400610, 2000002, 1, 1, 0, 40000), +(9400610, 2000003, 1, 1, 0, 40000), +(9400610, 2000004, 1, 1, 0, 10000), +(9400610, 4010000, 1, 1, 0, 7000), +(9400610, 4010006, 1, 1, 0, 7000), +(9400610, 4020004, 1, 1, 0, 7000), +(9400610, 4020008, 1, 1, 0, 7000), +(9400610, 1082259, 1, 1, 0, 5000), +(9400610, 1072422, 1, 1, 0, 5000), +(9400611, 2000002, 1, 1, 0, 40000), +(9400611, 2000003, 1, 1, 0, 40000), +(9400611, 2000004, 1, 1, 0, 10000), +(9400611, 4010003, 1, 1, 0, 7000), +(9400611, 4020003, 1, 1, 0, 7000), +(9400611, 4020005, 1, 1, 0, 7000), +(9400611, 4020007, 1, 1, 0, 7000), +(9400611, 1082260, 1, 1, 0, 5000), +(9400611, 1072423, 1, 1, 0, 5000), +(9400612, 2000002, 1, 1, 0, 40000), +(9400612, 2000003, 1, 1, 0, 40000), +(9400612, 2000004, 1, 1, 0, 10000), +(9400612, 4010001, 1, 1, 0, 7000), +(9400612, 4010003, 1, 1, 0, 7000), +(9400612, 4020000, 1, 1, 0, 7000), +(9400612, 4020001, 1, 1, 0, 7000), +(9400612, 1082257, 1, 1, 0, 5000), +(9400612, 1072420, 1, 1, 0, 5000), +(9400613, 2000002, 1, 1, 0, 40000), +(9400613, 2000003, 1, 1, 0, 40000), +(9400613, 2000004, 1, 1, 0, 10000), +(9400613, 4010000, 1, 1, 0, 7000), +(9400613, 4010002, 1, 1, 0, 7000), +(9400613, 4010006, 1, 1, 0, 7000), +(9400613, 4020002, 1, 1, 0, 7000), +(9400613, 1082258, 1, 1, 0, 5000), +(9400613, 1072421, 1, 1, 0, 5000); # (dropperid, itemid, minqty, maxqty, questid, chance) @@ -20101,8 +20147,8 @@ USE `heavenms`; UPDATE drop_data SET questid=28248 WHERE itemid=4001358; UPDATE drop_data SET questid=28248 WHERE itemid=4001359; - UPDATE drop_data SET questid=7777 WHERE itemid=4001342; #id 7777 for ALL "quest items" with no v83 quest. - UPDATE drop_data SET questid=7777 WHERE itemid=4031906; + UPDATE drop_data SET questid=28175 WHERE itemid=4001342; + UPDATE drop_data SET questid=7777 WHERE itemid=4031906; #id 7777 for ALL "quest items" with no v83 quest. UPDATE drop_data SET chance=0 WHERE itemid=2050099; UPDATE drop_data SET chance=40000 WHERE itemid=4031991; UPDATE drop_data SET questid=6191 WHERE itemid=4031477; @@ -21359,7 +21405,6 @@ USE `heavenms`; (9102001, 2020002, 2, -1), (2002018, 4161014, 1, 3099), (1012000, 4032143, 6, 20717), - (1202000, 4001366, 1, 28194), (2402008, 4032512, 5, 3720), (2602000, 4031574, 1, 3935), (2619000, 4031709, 1, 3310), @@ -21826,7 +21871,10 @@ USE `heavenms`; (9400581, 0, 418, 617, 0, 400000), (9400582, 0, 1127, 1583, 0, 400000), (9400609, 0, 204, 1010, 0, 400000), +(9400610, 0, 204, 1010, 0, 400000), +(9400611, 0, 204, 1010, 0, 400000), (9400612, 0, 204, 1010, 0, 400000), +(9400613, 0, 204, 1010, 0, 400000), (9400633, 0, 258, 1270, 0, 400000), (9400644, 0, 42, 61, 0, 400000), (9410014, 0, 493, 728, 0, 400000), diff --git a/src/client/command/Commands.java b/src/client/command/Commands.java index 1db2b3d55c..579224701a 100644 --- a/src/client/command/Commands.java +++ b/src/client/command/Commands.java @@ -345,7 +345,7 @@ public class Commands { public static boolean executeHeavenMsCommandLv0(Channel cserv, Server srv, MapleClient c, String[] sub) { //Player MapleCharacter player = c.getPlayer(); - switch(sub[0]) { + switch(sub[0]) { case "help": case "commands": case "playercommands": diff --git a/src/client/inventory/Item.java b/src/client/inventory/Item.java index 9372e5deaa..84614c2696 100644 --- a/src/client/inventory/Item.java +++ b/src/client/inventory/Item.java @@ -121,13 +121,14 @@ public class Item implements Comparable { this.petid = id; } + @Override public int compareTo(Item other) { if (this.id < other.getItemId()) { return -1; } else if (this.id > other.getItemId()) { return 1; } - return 0; + return 0; } @Override diff --git a/src/client/inventory/MapleInventory.java b/src/client/inventory/MapleInventory.java index 569a7926a3..f7eb7bfcab 100644 --- a/src/client/inventory/MapleInventory.java +++ b/src/client/inventory/MapleInventory.java @@ -24,8 +24,10 @@ package client.inventory; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map.Entry; import java.util.Map; @@ -178,9 +180,36 @@ public class MapleInventory implements Iterable { ret.add(item); } } + if (ret.size() > 1) { - Collections.sort(ret); + Collections.sort(ret, new Comparator() { + @Override + public int compare(Item i1, Item i2) { + return i1.getPosition() - i2.getPosition(); + } + }); } + + return ret; + } + + public List linkedListById(int itemId) { + List ret = new LinkedList<>(); + for (Item item : list()) { + if (item.getItemId() == itemId) { + ret.add(item); + } + } + + if (ret.size() > 1) { + Collections.sort(ret, new Comparator() { + @Override + public int compare(Item i1, Item i2) { + return i1.getPosition() - i2.getPosition(); + } + }); + } + return ret; } diff --git a/src/net/server/channel/handlers/AllianceOperationHandler.java b/src/net/server/channel/handlers/AllianceOperationHandler.java index 99cf50efb4..d884d3d237 100644 --- a/src/net/server/channel/handlers/AllianceOperationHandler.java +++ b/src/net/server/channel/handlers/AllianceOperationHandler.java @@ -35,89 +35,111 @@ import tools.data.output.MaplePacketLittleEndianWriter; /** * - * @author XoticStory + * @author XoticStory, Ronan */ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { @Override public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { MapleAlliance alliance = null; - if (c.getPlayer().getGuild() != null && c.getPlayer().getGuild().getAllianceId() > 0) { - alliance = c.getPlayer().getAlliance(); - } - if (alliance == null) { - c.announce(MaplePacketCreator.enableActions()); - return; - } else if (c.getPlayer().getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(c.getPlayer().getGuildId())) { + MapleCharacter chr = c.getPlayer(); + + if (chr.getGuild() == null) { c.announce(MaplePacketCreator.enableActions()); return; } + if (chr.getGuild().getAllianceId() > 0) { + alliance = chr.getAlliance(); + } + byte b = slea.readByte(); + if (alliance == null) { + if (b != 4) { + c.announce(MaplePacketCreator.enableActions()); + return; + } + } else { + if (b == 4) { + chr.dropMessage("Your guild is already registered on a Guild Alliance."); + c.announce(MaplePacketCreator.enableActions()); + return; + } + + if (chr.getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(chr.getGuildId())) { + c.announce(MaplePacketCreator.enableActions()); + return; + } + } + + // "alliance" is only null at case 0x04 switch (b) { case 0x01: - Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId()), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(chr.getGuild().getAllianceId(), chr.getId()), -1, -1); break; case 0x02: { // Leave Alliance - if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) { + if (chr.getGuild().getAllianceId() == 0 || chr.getGuildId() < 1 || chr.getGuildRank() != 1) { return; } - MapleAlliance.removeGuildFromAlliance(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getGuildId(), c.getPlayer().getWorld()); + MapleAlliance.removeGuildFromAlliance(chr.getGuild().getAllianceId(), chr.getGuildId(), chr.getWorld()); break; } - case 0x03: // send alliance invite... or at least it would be this way if i could find the right way to call it! + case 0x03: // Send Invite String guildName = slea.readMapleAsciiString(); if(alliance.getGuilds().size() == alliance.getCapacity()) { - c.getPlayer().dropMessage("Your alliance can not comport any more guild at the moment."); + chr.dropMessage("Your alliance cannot comport any more guilds at the moment."); } else { MapleGuild mg = Server.getInstance().getGuildByName(guildName); if(mg == null) { - c.getPlayer().dropMessage("The entered guild does not exist."); + chr.dropMessage("The entered guild does not exist."); } else { MapleCharacter victim = mg.getMGC(mg.getLeaderId()).getCharacter(); if (victim == null) { - c.getPlayer().dropMessage("The master of the guild that you offered an invitation is currently not online."); + chr.dropMessage("The master of the guild that you offered an invitation is currently not online."); } else { - // this doesn't seem to work... - //Server.getInstance().allianceMessage(alliance.getId(), sendInvitation(c.getPlayer().getGuild().getAllianceId(), victim.getId(), guildName), -1, -1); - //victim.getClient().announce(sendInvitation(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), guildName)); - - if(!c.getPlayer().isPartyMember(victim)) { - c.getPlayer().dropMessage("The master of the guild that you offered a invitation must be in the same party as yours."); - } - else { - int guildid = victim.getGuildId(); - - Server.getInstance().addGuildtoAlliance(alliance.getId(), guildid); - Server.getInstance().resetAllianceGuildPlayersRank(guildid); - - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.addGuildToAlliance(alliance, guildid, c), -1, -1); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.updateAllianceInfo(alliance, c), -1, -1); - Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1); - victim.getGuild().dropMessage("Your guild has joined the [" + alliance.getName() + "] union."); - } + victim.getClient().announce(MaplePacketCreator.sendAllianceInvitation(alliance.getId(), chr)); } } } break; - case 0x04: { - int guildid = slea.readInt(); -// slea.readMapleAsciiString();//guild name - if (c.getPlayer().getGuild().getAllianceId() != 0 || c.getPlayer().getGuildRank() != 1 || c.getPlayer().getGuildId() < 1) { + case 0x04: { // Accept Invite + if (chr.getGuild().getAllianceId() != 0 || chr.getGuildRank() != 1 || chr.getGuildId() < 1) { return; } - Server.getInstance().allianceMessage(alliance.getId(), sendChangeGuild(guildid, c.getPlayer().getId(), c.getPlayer().getGuildId(), 0), -1, -1); + + int allianceid = slea.readInt(); + //slea.readMapleAsciiString(); //recruiter's guild name + + alliance = Server.getInstance().getAlliance(allianceid); + if (alliance == null) { + return; + } + + int guildid = chr.getGuildId(); + + Server.getInstance().addGuildtoAlliance(alliance.getId(), guildid); + Server.getInstance().resetAllianceGuildPlayersRank(guildid); + + chr.getMGC().setAllianceRank(2); + Server.getInstance().getGuild(chr.getGuildId()).getMGC(chr.getId()).setAllianceRank(2); + chr.saveGuildStatus(); + + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.addGuildToAlliance(alliance, guildid, c), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.updateAllianceInfo(alliance, c), -1, -1); + Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1); + chr.getGuild().dropMessage("Your guild has joined the [" + alliance.getName() + "] union."); + break; } case 0x06: { // Expel Guild int guildid = slea.readInt(); int allianceid = slea.readInt(); - if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuild().getAllianceId() != allianceid) { + if (chr.getGuild().getAllianceId() == 0 || chr.getGuild().getAllianceId() != allianceid) { return; } @@ -132,13 +154,16 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { break; } case 0x07: { // Change Alliance Leader - if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1) { + if (chr.getGuild().getAllianceId() == 0 || chr.getGuildId() < 1) { return; } int victimid = slea.readInt(); MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(victimid); + if (player.getAllianceRank() != 2) { + return; + } - //Server.getInstance().allianceMessage(alliance.getId(), sendChangeLeader(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), slea.readInt()), -1, -1); + //Server.getInstance().allianceMessage(alliance.getId(), sendChangeLeader(chr.getGuild().getAllianceId(), chr.getId(), slea.readInt()), -1, -1); changeLeaderAllianceRank(alliance, player); break; } @@ -154,7 +179,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { int int1 = slea.readInt(); byte byte1 = slea.readByte(); - //Server.getInstance().allianceMessage(alliance.getId(), sendChangeRank(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), int1, byte1), -1, -1); + //Server.getInstance().allianceMessage(alliance.getId(), sendChangeRank(chr.getGuild().getAllianceId(), chr.getId(), int1, byte1), -1, -1); MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(int1); changePlayerAllianceRank(alliance, player, (byte1 > 0)); @@ -168,7 +193,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { alliance.dropMessage(5, "* Alliance Notice : " + notice); break; default: - c.getPlayer().dropMessage("Feature not available"); + chr.dropMessage("Feature not available"); } alliance.saveToDB(); @@ -195,7 +220,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler { chr.saveGuildStatus(); Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getWorld()), -1, -1); - alliance.dropMessage("'" + chr.getName() + "' has been reassigned as '" + alliance.getRankTitle(newRank) + "' in this Alliance."); + alliance.dropMessage("'" + chr.getName() + "' has been reassigned to '" + alliance.getRankTitle(newRank) + "' in this Alliance."); } private static byte[] sendShowInfo(int allianceid, int playerid) { diff --git a/src/net/server/channel/handlers/PetAutoPotHandler.java b/src/net/server/channel/handlers/PetAutoPotHandler.java index 7f63bb92bc..4da5a08956 100644 --- a/src/net/server/channel/handlers/PetAutoPotHandler.java +++ b/src/net/server/channel/handlers/PetAutoPotHandler.java @@ -29,15 +29,27 @@ import net.AbstractMaplePacketHandler; import server.MapleInventoryManipulator; import server.MapleItemInformationProvider; import server.MapleStatEffect; +import tools.Pair; import tools.MaplePacketCreator; import tools.data.input.SeekableLittleEndianAccessor; import constants.ServerConstants; +import java.util.List; /** * * @author Ronan (multi-pot consumption feature) */ public final class PetAutoPotHandler extends AbstractMaplePacketHandler { + short slot; + int itemId; + Item toUse; + List toUseList; + + boolean hasHpGain; + boolean hasMpGain; + short maxHp; + short maxMp; + @Override public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { if (!c.getPlayer().isAlive()) { @@ -45,45 +57,103 @@ public final class PetAutoPotHandler extends AbstractMaplePacketHandler { return; } - MapleCharacter chr = c.getPlayer(); - short maxHp = 0, maxMp = 0; - - if(ServerConstants.USE_EQUIPS_ON_AUTOPOT) { - for(Item i : c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).list()) { - Equip e = (Equip) i; - - maxHp += e.getHp(); - maxMp += e.getMp(); - } - } - - maxHp = (short) Math.min(chr.getMaxHp() + maxHp, 30000); - maxMp = (short) Math.min(chr.getMaxMp() + maxMp, 30000); - slea.readByte(); slea.readLong(); slea.readInt(); - short slot = slea.readShort(); - int itemId = slea.readInt(); - Item toUse = chr.getInventory(MapleInventoryType.USE).getItem(slot); + slot = slea.readShort(); + itemId = slea.readInt(); + + MapleCharacter chr = c.getPlayer(); + toUse = chr.getInventory(MapleInventoryType.USE).getItem(slot); if(toUse != null) { - MapleStatEffect stat = MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId()); - - if (toUse.getQuantity() <= 0 || toUse.getItemId() != itemId) { + if (toUse.getItemId() != itemId) { c.announce(MaplePacketCreator.enableActions()); return; } - do { - MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false); - stat.applyTo(chr); + toUseList = null; + + // from now on, toUse becomes the "cursor" for the current pot being used + if(toUse.getQuantity() <= 0) { + if(!cursorOnNextAvailablePot(chr)) { + c.announce(MaplePacketCreator.enableActions()); + return; + } + } + + MapleStatEffect stat = MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId()); + hasHpGain = stat.getHp() > 0 || stat.getHpRate() > 0.0; + hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0; + + // contabilize the HP and MP gains from equipments on one's effective MaxHP/MaxMP + Pair maxHpMp = calcEffectivePool(chr); + maxHp = maxHpMp.left; + maxMp = maxHpMp.right; + + while(true) { + do { + MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false); + stat.applyTo(chr); - //System.out.println(); - //System.out.println("hp: " + stat.getHp() + " player hp " + c.getPlayer().getHp() + " maxhp " + maxHp); - //System.out.println("mp: " + stat.getMp() + " player mp " + c.getPlayer().getMp() + " maxmp " + maxMp); - //System.out.println("redo? " + (((stat.getHp() > 0 && c.getPlayer().getHp() < ServerConstants.PET_AUTOHP_RATIO * maxHp) || (stat.getMp() > 0 && c.getPlayer().getMp() < ServerConstants.PET_AUTOMP_RATIO * maxMp)) && toUse.getQuantity() > 0)); - } while(((stat.getHp() > 0 && chr.getHp() < ServerConstants.PET_AUTOHP_RATIO * maxHp) || (stat.getMp() > 0 && chr.getMp() < ServerConstants.PET_AUTOMP_RATIO * maxMp)) && toUse.getQuantity() > 0); + //System.out.println(); + //System.out.println("hp: " + hasHpGain + " player hp " + chr.getHp() + " maxhp " + maxHp); + //System.out.println("mp: " + hasMpGain + " player mp " + chr.getMp() + " maxmp " + maxMp); + //System.out.println("redo? " + (shouldReusePot(chr) && toUse.getQuantity() > 0)); + } while(shouldReusePot(chr) && toUse.getQuantity() > 0); + + if(toUse.getQuantity() == 0 && shouldReusePot(chr)) { + // depleted out the current slot, fetch for more + + if(!cursorOnNextAvailablePot(chr)) { + break; // no more pots available + } + } else { + break; // gracefully finished it's job, quit the loop + } + } } } + + private boolean cursorOnNextAvailablePot(MapleCharacter chr) { + if(toUseList == null) { + toUseList = chr.getInventory(MapleInventoryType.USE).linkedListById(itemId); + } + + toUse = null; + while(!toUseList.isEmpty()) { + Item it = toUseList.remove(0); + + if(it.getQuantity() > 0) { + toUse = it; + slot = it.getPosition(); + + return true; + } + } + + return false; + } + + private Pair calcEffectivePool(MapleCharacter chr) { + short hp = 0, mp = 0; + + if(ServerConstants.USE_EQUIPS_ON_AUTOPOT) { + for(Item i : chr.getInventory(MapleInventoryType.EQUIPPED).list()) { + Equip e = (Equip) i; + + hp += e.getHp(); + mp += e.getMp(); + } + } + + hp = (short) Math.min(chr.getMaxHp() + hp, 30000); + mp = (short) Math.min(chr.getMaxMp() + mp, 30000); + + return new Pair<>(hp, mp); + } + + private boolean shouldReusePot(MapleCharacter chr) { + return (hasHpGain && chr.getHp() < ServerConstants.PET_AUTOHP_RATIO * maxHp) || (hasMpGain && chr.getMp() < ServerConstants.PET_AUTOMP_RATIO * maxMp); + } } diff --git a/src/net/server/guild/MapleAlliance.java b/src/net/server/guild/MapleAlliance.java index 29814cddc8..863150e60f 100644 --- a/src/net/server/guild/MapleAlliance.java +++ b/src/net/server/guild/MapleAlliance.java @@ -130,7 +130,6 @@ public class MapleAlliance { Server.getInstance().addAlliance(id, alliance); - System.out.println("\n\n\n\n----"); Server.getInstance().allianceMessage(id, MaplePacketCreator.updateAllianceInfo(alliance, guildMasters.get(0).getClient()), -1, -1); } catch (Exception e) { e.printStackTrace(); diff --git a/src/server/MapleStatEffect.java b/src/server/MapleStatEffect.java index 74dd8e98c1..6b9e42a8af 100644 --- a/src/server/MapleStatEffect.java +++ b/src/server/MapleStatEffect.java @@ -1593,6 +1593,14 @@ public class MapleStatEffect { return mp; } + public double getHpRate() { + return hpR; + } + + public double getMpRate() { + return mpR; + } + public byte getHpR() { return mhpR; } diff --git a/src/server/maps/MapleFoothold.java b/src/server/maps/MapleFoothold.java index 7c79275d79..a59a972cb7 100644 --- a/src/server/maps/MapleFoothold.java +++ b/src/server/maps/MapleFoothold.java @@ -69,6 +69,7 @@ public class MapleFoothold implements Comparable { return (slope * x) + intercept; } + @Override public int compareTo(MapleFoothold o) { MapleFoothold other = o; if (p2.y < other.getY1()) { diff --git a/src/tools/MaplePacketCreator.java b/src/tools/MaplePacketCreator.java index 5570e27b7b..1684d7d4b8 100644 --- a/src/tools/MaplePacketCreator.java +++ b/src/tools/MaplePacketCreator.java @@ -6343,7 +6343,17 @@ public class MaplePacketCreator { mplew.writeInt(alliance); return mplew.getPacket(); } - + + public static byte[] sendAllianceInvitation(int allianceid, MapleCharacter chr) { + final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); + mplew.writeShort(SendOpcode.ALLIANCE_OPERATION.getValue()); + mplew.write(0x03); + mplew.writeInt(allianceid); + mplew.writeMapleAsciiString(chr.getName()); + mplew.writeShort(0); + return mplew.getPacket(); + } + public static byte[] sendMesoLimit() { final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.writeShort(SendOpcode.TRADE_MONEY_LIMIT.getValue()); //Players under level 15 can only trade 1m per day