Medal quest system tweak + Proximity check on quests + DB leak fix
Rebalanced the EXTREMELY low level section of the equipment level up system. Added support code for quests on Kerning Square and Mushroom Castle. Added quest scripts for many missing scripted quests. Refactored medal quests, now using a default script system for uncoded medal questid's. Fixed a DB leak regarding quest status and medal maps tables. Added proximity check for NPCs to start/complete quests that doesn't use the lightbulb system. Added "debuff" command, that debuffs people nearby.
This commit is contained in:
@@ -23,6 +23,7 @@ package server.quest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -30,6 +31,7 @@ import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import client.MapleQuestStatus.Status;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Set;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
@@ -41,10 +43,21 @@ import tools.MaplePacketCreator;
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
* @author Ronan (support for medal quests)
|
||||
*/
|
||||
public class MapleQuest {
|
||||
|
||||
private static Map<Integer, MapleQuest> quests = new HashMap<>();
|
||||
private static Map<Short, Integer> medals = new HashMap<>();
|
||||
|
||||
private static final Set<Short> exploitableQuests = new HashSet<>();
|
||||
static {
|
||||
exploitableQuests.add((short) 2338);
|
||||
exploitableQuests.add((short) 3637);
|
||||
exploitableQuests.add((short) 3714);
|
||||
exploitableQuests.add((short) 21752);
|
||||
}
|
||||
|
||||
protected short infoNumber, id;
|
||||
protected int timeLimit, timeLimit2;
|
||||
protected String infoex;
|
||||
@@ -77,6 +90,9 @@ public class MapleQuest {
|
||||
autoStart = MapleDataTool.getInt("autoStart", reqInfo, 0) == 1;
|
||||
autoPreComplete = MapleDataTool.getInt("autoPreComplete", reqInfo, 0) == 1;
|
||||
autoComplete = MapleDataTool.getInt("autoComplete", reqInfo, 0) == 1;
|
||||
|
||||
int medalid = MapleDataTool.getInt("viewMedalItem", reqInfo, 0);
|
||||
if(medalid != 0) medals.put(this.id, medalid);
|
||||
} else {
|
||||
System.out.println("no data " + id);
|
||||
}
|
||||
@@ -209,8 +225,13 @@ public class MapleQuest {
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public boolean canStartWithoutRequirements(MapleCharacter c) {
|
||||
MapleQuestStatus mqs = c.getQuest(this);
|
||||
return !(mqs.getStatus() != Status.NOT_STARTED && !(mqs.getStatus() == Status.COMPLETED && repeatable));
|
||||
}
|
||||
|
||||
public boolean canStart(MapleCharacter c, int npcid) {
|
||||
if (c.getQuest(this).getStatus() != Status.NOT_STARTED && !(c.getQuest(this).getStatus() == Status.COMPLETED && repeatable)) {
|
||||
if (!canStartWithoutRequirements(c)) {
|
||||
return false;
|
||||
}
|
||||
for (MapleQuestRequirement r : startReqs.values()) {
|
||||
@@ -229,7 +250,9 @@ public class MapleQuest {
|
||||
return false;
|
||||
}
|
||||
for (MapleQuestRequirement r : completeReqs.values()) {
|
||||
if (r == null || !r.check(c, npcid)) {
|
||||
if (r == null) {
|
||||
return false;
|
||||
} else if(!r.check(c, npcid)) {
|
||||
if(r.getType() == MapleQuestRequirementType.MESO) { // TODO: find a way to tell the client about the new MESO requirement type.
|
||||
c.dropMessage(5, "You don't have enough mesos to complete this quest.");
|
||||
}
|
||||
@@ -263,10 +286,6 @@ public class MapleQuest {
|
||||
}
|
||||
}
|
||||
|
||||
if (timeLimit > 0) {
|
||||
c.announce(MaplePacketCreator.removeQuestTimeLimit(id));
|
||||
}
|
||||
|
||||
forceComplete(c, npc);
|
||||
for (MapleQuestAction a : completeActs.values()) {
|
||||
a.run(c, selection);
|
||||
@@ -308,6 +327,10 @@ public class MapleQuest {
|
||||
}
|
||||
|
||||
public boolean forceComplete(MapleCharacter c, int npc) {
|
||||
if (timeLimit > 0) {
|
||||
c.announce(MaplePacketCreator.removeQuestTimeLimit(id));
|
||||
}
|
||||
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.COMPLETED, npc);
|
||||
newStatus.setForfeited(c.getQuest(this).getForfeited());
|
||||
newStatus.setCompletionTime(System.currentTimeMillis());
|
||||
@@ -431,6 +454,12 @@ public class MapleQuest {
|
||||
case PET:
|
||||
ret = new PetRequirement(this, data);
|
||||
break;
|
||||
case BUFF:
|
||||
ret = new BuffRequirement(this, data);
|
||||
break;
|
||||
case EXCEPT_BUFF:
|
||||
ret = new BuffExceptRequirement(this, data);
|
||||
break;
|
||||
case SCRIPT:
|
||||
case NORMAL_AUTO_START:
|
||||
case START:
|
||||
@@ -480,7 +509,16 @@ public class MapleQuest {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean isExploitableQuest(short questid) {
|
||||
return exploitableQuests.contains(questid);
|
||||
}
|
||||
|
||||
public int getMedalRequirement() {
|
||||
Integer medalid = medals.get(id);
|
||||
return medalid != null ? medalid : -1;
|
||||
}
|
||||
|
||||
public static void loadAllQuest() {
|
||||
questInfo = questData.getData("QuestInfo.img");
|
||||
questReq = questData.getData("Check.img");
|
||||
|
||||
@@ -26,7 +26,7 @@ package server.quest;
|
||||
* @author Matze
|
||||
*/
|
||||
public enum MapleQuestRequirementType {
|
||||
UNDEFINED(-1), JOB(0), ITEM(1), QUEST(2), MIN_LEVEL(3), MAX_LEVEL(4), END_DATE(5), MOB(6), NPC(7), FIELD_ENTER(8), INTERVAL(9), SCRIPT(10), PET(11), MIN_PET_TAMENESS(12), MONSTER_BOOK(13), NORMAL_AUTO_START(14), INFO_NUMBER(15), INFO_EX(16), COMPLETED_QUEST(17), START(18), END(19), DAY_BY_DAY(20), MESO(21);
|
||||
UNDEFINED(-1), JOB(0), ITEM(1), QUEST(2), MIN_LEVEL(3), MAX_LEVEL(4), END_DATE(5), MOB(6), NPC(7), FIELD_ENTER(8), INTERVAL(9), SCRIPT(10), PET(11), MIN_PET_TAMENESS(12), MONSTER_BOOK(13), NORMAL_AUTO_START(14), INFO_NUMBER(15), INFO_EX(16), COMPLETED_QUEST(17), START(18), END(19), DAY_BY_DAY(20), MESO(21), BUFF(22), EXCEPT_BUFF(23);
|
||||
final byte type;
|
||||
|
||||
private MapleQuestRequirementType(int type) {
|
||||
@@ -77,13 +77,17 @@ public enum MapleQuestRequirementType {
|
||||
} else if (name.equals("questComplete")) {
|
||||
return COMPLETED_QUEST;
|
||||
} else if(name.equals("start")) {
|
||||
return START;
|
||||
return START;
|
||||
} else if(name.equals("end")) {
|
||||
return END;
|
||||
return END;
|
||||
} else if(name.equals("daybyday")) {
|
||||
return DAY_BY_DAY;
|
||||
return DAY_BY_DAY;
|
||||
} else if (name.equals("money")) {
|
||||
return MESO;
|
||||
} else if (name.equals("buff")) {
|
||||
return BUFF;
|
||||
} else if (name.equals("exceptbuff")) {
|
||||
return EXCEPT_BUFF;
|
||||
} else {
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ public class BuffAction extends MapleQuestAction {
|
||||
super(MapleQuestActionType.BUFF, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BuffExceptRequirement extends MapleQuestRequirement {
|
||||
private int buffId = -1;
|
||||
|
||||
public BuffExceptRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.BUFF);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
// item buffs are negative
|
||||
buffId = -1 * Integer.valueOf(MapleDataTool.getString(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return !chr.hasBuffFromSourceid(buffId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class BuffRequirement extends MapleQuestRequirement {
|
||||
private int buffId = 1;
|
||||
|
||||
public BuffRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.BUFF);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
// item buffs are negative
|
||||
buffId = -1 * Integer.valueOf(MapleDataTool.getString(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.hasBuffFromSourceid(buffId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user