Switch to Maven file structure
This commit is contained in:
684
src/main/java/server/quest/MapleQuest.java
Normal file
684
src/main/java/server/quest/MapleQuest.java
Normal file
@@ -0,0 +1,684 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import client.MapleQuestStatus.Status;
|
||||
import config.YamlConfig;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.actions.*;
|
||||
import server.quest.requirements.*;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.StringUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
* @author Ronan - support for medal quests
|
||||
*/
|
||||
public class MapleQuest {
|
||||
|
||||
private static Map<Integer, MapleQuest> quests = new HashMap<>();
|
||||
private static Map<Integer, Integer> infoNumberQuests = new HashMap<>();
|
||||
private static Map<Short, Integer> medals = new HashMap<>();
|
||||
|
||||
private static final Set<Short> exploitableQuests = new HashSet<>();
|
||||
static {
|
||||
exploitableQuests.add((short) 2338); // there are a lot more exploitable quests, they need to be nit-picked
|
||||
exploitableQuests.add((short) 3637);
|
||||
exploitableQuests.add((short) 3714);
|
||||
exploitableQuests.add((short) 21752);
|
||||
}
|
||||
|
||||
protected short id;
|
||||
protected int timeLimit, timeLimit2;
|
||||
protected Map<MapleQuestRequirementType, MapleQuestRequirement> startReqs = new EnumMap<>(MapleQuestRequirementType.class);
|
||||
protected Map<MapleQuestRequirementType, MapleQuestRequirement> completeReqs = new EnumMap<>(MapleQuestRequirementType.class);
|
||||
protected Map<MapleQuestActionType, MapleQuestAction> startActs = new EnumMap<>(MapleQuestActionType.class);
|
||||
protected Map<MapleQuestActionType, MapleQuestAction> completeActs = new EnumMap<>(MapleQuestActionType.class);
|
||||
protected List<Integer> relevantMobs = new LinkedList<>();
|
||||
private boolean autoStart;
|
||||
private boolean autoPreComplete, autoComplete;
|
||||
private boolean repeatable = false;
|
||||
private String name = "", parent = "";
|
||||
private final static MapleDataProvider questData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Quest.wz"));
|
||||
private final static MapleData questInfo = questData.getData("QuestInfo.img");
|
||||
private final static MapleData questAct = questData.getData("Act.img");
|
||||
private final static MapleData questReq = questData.getData("Check.img");
|
||||
|
||||
private MapleQuest(int id) {
|
||||
this.id = (short) id;
|
||||
|
||||
MapleData reqData = questReq.getChildByPath(String.valueOf(id));
|
||||
if (reqData == null) {//most likely infoEx
|
||||
return;
|
||||
}
|
||||
|
||||
if(questInfo != null) {
|
||||
MapleData reqInfo = questInfo.getChildByPath(String.valueOf(id));
|
||||
if(reqInfo != null) {
|
||||
name = MapleDataTool.getString("name", reqInfo, "");
|
||||
parent = MapleDataTool.getString("parent", reqInfo, "");
|
||||
|
||||
timeLimit = MapleDataTool.getInt("timeLimit", reqInfo, 0);
|
||||
timeLimit2 = MapleDataTool.getInt("timeLimit2", reqInfo, 0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
MapleData startReqData = reqData.getChildByPath("0");
|
||||
if (startReqData != null) {
|
||||
for (MapleData startReq : startReqData.getChildren()) {
|
||||
MapleQuestRequirementType type = MapleQuestRequirementType.getByWZName(startReq.getName());
|
||||
if (type.equals(MapleQuestRequirementType.INTERVAL)) {
|
||||
repeatable = true;
|
||||
} else if (type.equals(MapleQuestRequirementType.MOB)) {
|
||||
for (MapleData mob : startReq.getChildren()) {
|
||||
relevantMobs.add(MapleDataTool.getInt(mob.getChildByPath("id")));
|
||||
}
|
||||
}
|
||||
|
||||
MapleQuestRequirement req = this.getRequirement(type, startReq);
|
||||
if (req == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
startReqs.put(type, req);
|
||||
}
|
||||
}
|
||||
|
||||
MapleData completeReqData = reqData.getChildByPath("1");
|
||||
if (completeReqData != null) {
|
||||
for (MapleData completeReq : completeReqData.getChildren()) {
|
||||
MapleQuestRequirementType type = MapleQuestRequirementType.getByWZName(completeReq.getName());
|
||||
|
||||
MapleQuestRequirement req = this.getRequirement(type, completeReq);
|
||||
if (req == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.equals(MapleQuestRequirementType.MOB)) {
|
||||
for (MapleData mob : completeReq.getChildren()) {
|
||||
relevantMobs.add(MapleDataTool.getInt(mob.getChildByPath("id")));
|
||||
}
|
||||
}
|
||||
completeReqs.put(type, req);
|
||||
}
|
||||
}
|
||||
MapleData actData = questAct.getChildByPath(String.valueOf(id));
|
||||
if (actData == null) {
|
||||
return;
|
||||
}
|
||||
final MapleData startActData = actData.getChildByPath("0");
|
||||
if (startActData != null) {
|
||||
for (MapleData startAct : startActData.getChildren()) {
|
||||
MapleQuestActionType questActionType = MapleQuestActionType.getByWZName(startAct.getName());
|
||||
MapleQuestAction act = this.getAction(questActionType, startAct);
|
||||
|
||||
if(act == null)
|
||||
continue;
|
||||
|
||||
startActs.put(questActionType, act);
|
||||
}
|
||||
}
|
||||
MapleData completeActData = actData.getChildByPath("1");
|
||||
if (completeActData != null) {
|
||||
for (MapleData completeAct : completeActData.getChildren()) {
|
||||
MapleQuestActionType questActionType = MapleQuestActionType.getByWZName(completeAct.getName());
|
||||
MapleQuestAction act = this.getAction(questActionType, completeAct);
|
||||
|
||||
if(act == null)
|
||||
continue;
|
||||
|
||||
completeActs.put(questActionType, act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAutoComplete() {
|
||||
return autoPreComplete || autoComplete;
|
||||
}
|
||||
|
||||
public boolean isAutoStart() {
|
||||
return autoStart;
|
||||
}
|
||||
|
||||
public static MapleQuest getInstance(int id) {
|
||||
MapleQuest ret = quests.get(id);
|
||||
if (ret == null) {
|
||||
ret = new MapleQuest(id);
|
||||
quests.put(id, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static MapleQuest getInstanceFromInfoNumber(int infoNumber) {
|
||||
Integer id = infoNumberQuests.get(infoNumber);
|
||||
if (id == null) {
|
||||
id = infoNumber;
|
||||
}
|
||||
|
||||
return getInstance(id);
|
||||
}
|
||||
|
||||
public boolean isSameDayRepeatable() {
|
||||
if(!repeatable) return false;
|
||||
|
||||
IntervalRequirement ir = (IntervalRequirement) startReqs.get(MapleQuestRequirementType.INTERVAL);
|
||||
return ir.getInterval() < YamlConfig.config.server.QUEST_POINT_REPEATABLE_INTERVAL * 60 * 60 * 1000;
|
||||
}
|
||||
|
||||
public boolean canStartQuestByStatus(MapleCharacter chr) {
|
||||
MapleQuestStatus mqs = chr.getQuest(this);
|
||||
return !(!mqs.getStatus().equals(Status.NOT_STARTED) && !(mqs.getStatus().equals(Status.COMPLETED) && repeatable));
|
||||
}
|
||||
|
||||
public boolean canQuestByInfoProgress(MapleCharacter chr) {
|
||||
MapleQuestStatus mqs = chr.getQuest(this);
|
||||
List<String> ix = mqs.getInfoEx();
|
||||
if (!ix.isEmpty()) {
|
||||
short questid = mqs.getQuestID();
|
||||
short infoNumber = mqs.getInfoNumber();
|
||||
if (infoNumber <= 0) {
|
||||
infoNumber = questid; // on default infoNumber mimics questid
|
||||
}
|
||||
|
||||
int ixSize = ix.size();
|
||||
for (int i = 0; i < ixSize; i++) {
|
||||
String progress = chr.getAbstractPlayerInteraction().getQuestProgress(infoNumber, i);
|
||||
String ixProgress = ix.get(i);
|
||||
|
||||
if (!progress.contentEquals(ixProgress)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canStart(MapleCharacter chr, int npcid) {
|
||||
if (!canStartQuestByStatus(chr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MapleQuestRequirement r : startReqs.values()) {
|
||||
if (!r.check(chr, npcid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canQuestByInfoProgress(chr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canComplete(MapleCharacter chr, Integer npcid) {
|
||||
MapleQuestStatus mqs = chr.getQuest(this);
|
||||
if (!mqs.getStatus().equals(Status.STARTED)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MapleQuestRequirement r : completeReqs.values()) {
|
||||
if (!r.check(chr, npcid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canQuestByInfoProgress(chr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start(MapleCharacter chr, int npc) {
|
||||
if (autoStart || canStart(chr, npc)) {
|
||||
Collection<MapleQuestAction> acts = startActs.values();
|
||||
for (MapleQuestAction a : acts) {
|
||||
if (!a.check(chr, null)) { // would null be good ?
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (MapleQuestAction a : acts) {
|
||||
a.run(chr, null);
|
||||
}
|
||||
forceStart(chr, npc);
|
||||
}
|
||||
}
|
||||
|
||||
public void complete(MapleCharacter chr, int npc) {
|
||||
complete(chr, npc, null);
|
||||
}
|
||||
|
||||
public void complete(MapleCharacter chr, int npc, Integer selection) {
|
||||
if (autoPreComplete || canComplete(chr, npc)) {
|
||||
Collection<MapleQuestAction> acts = completeActs.values();
|
||||
for (MapleQuestAction a : acts) {
|
||||
if (!a.check(chr, selection)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
forceComplete(chr, npc);
|
||||
for (MapleQuestAction a : acts) {
|
||||
a.run(chr, selection);
|
||||
}
|
||||
if (!this.hasNextQuestAction()) {
|
||||
chr.announceUpdateQuest(MapleCharacter.DelayedQuestUpdate.INFO, chr.getQuest(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(MapleCharacter chr) {
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.NOT_STARTED);
|
||||
chr.updateQuestStatus(newStatus);
|
||||
}
|
||||
|
||||
public boolean forfeit(MapleCharacter chr) {
|
||||
if (!chr.getQuest(this).getStatus().equals(Status.STARTED)) {
|
||||
return false;
|
||||
}
|
||||
if (timeLimit > 0) {
|
||||
chr.announce(MaplePacketCreator.removeQuestTimeLimit(id));
|
||||
}
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.NOT_STARTED);
|
||||
newStatus.setForfeited(chr.getQuest(this).getForfeited() + 1);
|
||||
chr.updateQuestStatus(newStatus);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean forceStart(MapleCharacter chr, int npc) {
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.STARTED, npc);
|
||||
|
||||
MapleQuestStatus oldStatus = chr.getQuest(this.getId());
|
||||
for (Entry<Integer, String> e : oldStatus.getProgress().entrySet()) {
|
||||
newStatus.setProgress(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
if(id / 100 == 35 && YamlConfig.config.server.TOT_MOB_QUEST_REQUIREMENT > 0) {
|
||||
int setProg = 999 - Math.min(999, YamlConfig.config.server.TOT_MOB_QUEST_REQUIREMENT);
|
||||
|
||||
for(Integer pid : newStatus.getProgress().keySet()) {
|
||||
if(pid >= 8200000 && pid <= 8200012) {
|
||||
String pr = StringUtil.getLeftPaddedStr(Integer.toString(setProg), '0', 3);
|
||||
newStatus.setProgress(pid, pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newStatus.setForfeited(chr.getQuest(this).getForfeited());
|
||||
newStatus.setCompleted(chr.getQuest(this).getCompleted());
|
||||
|
||||
if (timeLimit > 0) {
|
||||
newStatus.setExpirationTime(System.currentTimeMillis() + (timeLimit * 1000));
|
||||
chr.questTimeLimit(this, timeLimit);
|
||||
}
|
||||
if (timeLimit2 > 0) {
|
||||
newStatus.setExpirationTime(System.currentTimeMillis() + timeLimit2);
|
||||
chr.questTimeLimit2(this, newStatus.getExpirationTime());
|
||||
}
|
||||
|
||||
chr.updateQuestStatus(newStatus);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean forceComplete(MapleCharacter chr, int npc) {
|
||||
if (timeLimit > 0) {
|
||||
chr.announce(MaplePacketCreator.removeQuestTimeLimit(id));
|
||||
}
|
||||
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.COMPLETED, npc);
|
||||
newStatus.setForfeited(chr.getQuest(this).getForfeited());
|
||||
newStatus.setCompleted(chr.getQuest(this).getCompleted());
|
||||
newStatus.setCompletionTime(System.currentTimeMillis());
|
||||
chr.updateQuestStatus(newStatus);
|
||||
|
||||
chr.announce(MaplePacketCreator.showSpecialEffect(9)); // Quest completion
|
||||
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showForeignEffect(chr.getId(), 9), false); //use 9 instead of 12 for both
|
||||
return true;
|
||||
}
|
||||
|
||||
public short getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Integer> getRelevantMobs() {
|
||||
return relevantMobs;
|
||||
}
|
||||
|
||||
public int getStartItemAmountNeeded(int itemid) {
|
||||
MapleQuestRequirement req = startReqs.get(MapleQuestRequirementType.ITEM);
|
||||
if(req == null)
|
||||
return Integer.MIN_VALUE;
|
||||
|
||||
ItemRequirement ireq = (ItemRequirement) req;
|
||||
return ireq.getItemAmountNeeded(itemid, false);
|
||||
}
|
||||
|
||||
public int getCompleteItemAmountNeeded(int itemid) {
|
||||
MapleQuestRequirement req = completeReqs.get(MapleQuestRequirementType.ITEM);
|
||||
if(req == null)
|
||||
return Integer.MAX_VALUE;
|
||||
|
||||
ItemRequirement ireq = (ItemRequirement) req;
|
||||
return ireq.getItemAmountNeeded(itemid, true);
|
||||
}
|
||||
|
||||
public int getMobAmountNeeded(int mid) {
|
||||
MapleQuestRequirement req = completeReqs.get(MapleQuestRequirementType.MOB);
|
||||
if(req == null)
|
||||
return 0;
|
||||
|
||||
MobRequirement mreq = (MobRequirement) req;
|
||||
|
||||
return mreq.getRequiredMobCount(mid);
|
||||
}
|
||||
|
||||
public short getInfoNumber(Status qs) {
|
||||
boolean checkEnd = qs.equals(Status.STARTED);
|
||||
Map<MapleQuestRequirementType, MapleQuestRequirement> reqs = !checkEnd ? startReqs : completeReqs;
|
||||
|
||||
MapleQuestRequirement req = reqs.get(MapleQuestRequirementType.INFO_NUMBER);
|
||||
if (req != null) {
|
||||
InfoNumberRequirement inReq = (InfoNumberRequirement) req;
|
||||
return inReq.getInfoNumber();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInfoEx(Status qs, int index) {
|
||||
boolean checkEnd = qs.equals(Status.STARTED);
|
||||
Map<MapleQuestRequirementType, MapleQuestRequirement> reqs = !checkEnd ? startReqs : completeReqs;
|
||||
try {
|
||||
MapleQuestRequirement req = reqs.get(MapleQuestRequirementType.INFO_EX);
|
||||
InfoExRequirement ixReq = (InfoExRequirement) req;
|
||||
return ixReq.getInfo().get(index);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getInfoEx(Status qs) {
|
||||
boolean checkEnd = qs.equals(Status.STARTED);
|
||||
Map<MapleQuestRequirementType, MapleQuestRequirement> reqs = !checkEnd ? startReqs : completeReqs;
|
||||
try {
|
||||
MapleQuestRequirement req = reqs.get(MapleQuestRequirementType.INFO_EX);
|
||||
InfoExRequirement ixReq = (InfoExRequirement) req;
|
||||
return ixReq.getInfo();
|
||||
} catch (Exception e) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getTimeLimit() {
|
||||
return timeLimit;
|
||||
}
|
||||
|
||||
public static void clearCache(int quest) {
|
||||
if(quests.containsKey(quest)){
|
||||
quests.remove(quest);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
quests.clear();
|
||||
}
|
||||
|
||||
private MapleQuestRequirement getRequirement(MapleQuestRequirementType type, MapleData data) {
|
||||
MapleQuestRequirement ret = null;
|
||||
switch(type) {
|
||||
case END_DATE:
|
||||
ret = new EndDateRequirement(this, data);
|
||||
break;
|
||||
case JOB:
|
||||
ret = new JobRequirement(this, data);
|
||||
break;
|
||||
case QUEST:
|
||||
ret = new QuestRequirement(this, data);
|
||||
break;
|
||||
case FIELD_ENTER:
|
||||
ret = new FieldEnterRequirement(this, data);
|
||||
break;
|
||||
case INFO_NUMBER:
|
||||
ret = new InfoNumberRequirement(this, data);
|
||||
break;
|
||||
case INFO_EX:
|
||||
ret = new InfoExRequirement(this, data);
|
||||
break;
|
||||
case INTERVAL:
|
||||
ret = new IntervalRequirement(this, data);
|
||||
break;
|
||||
case COMPLETED_QUEST:
|
||||
ret = new CompletedQuestRequirement(this, data);
|
||||
break;
|
||||
case ITEM:
|
||||
ret = new ItemRequirement(this, data);
|
||||
break;
|
||||
case MAX_LEVEL:
|
||||
ret = new MaxLevelRequirement(this, data);
|
||||
break;
|
||||
case MESO:
|
||||
ret = new MesoRequirement(this, data);
|
||||
break;
|
||||
case MIN_LEVEL:
|
||||
ret = new MinLevelRequirement(this, data);
|
||||
break;
|
||||
case MIN_PET_TAMENESS:
|
||||
ret = new MinTamenessRequirement(this, data);
|
||||
break;
|
||||
case MOB:
|
||||
ret = new MobRequirement(this, data);
|
||||
break;
|
||||
case MONSTER_BOOK:
|
||||
ret = new MonsterBookCountRequirement(this, data);
|
||||
break;
|
||||
case NPC:
|
||||
ret = new NpcRequirement(this, data);
|
||||
break;
|
||||
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:
|
||||
ret = new ScriptRequirement(this, data);
|
||||
break;
|
||||
case NORMAL_AUTO_START:
|
||||
case START:
|
||||
case END:
|
||||
break;
|
||||
default:
|
||||
//FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Unhandled Requirement Type: " + type.toString() + " QuestID: " + this.getId());
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private MapleQuestAction getAction(MapleQuestActionType type, MapleData data) {
|
||||
MapleQuestAction ret = null;
|
||||
switch(type) {
|
||||
case BUFF:
|
||||
ret = new BuffAction(this, data);
|
||||
break;
|
||||
case EXP:
|
||||
ret = new ExpAction(this, data);
|
||||
break;
|
||||
case FAME:
|
||||
ret = new FameAction(this, data);
|
||||
break;
|
||||
case ITEM:
|
||||
ret = new ItemAction(this, data);
|
||||
break;
|
||||
case MESO:
|
||||
ret = new MesoAction(this, data);
|
||||
break;
|
||||
case NEXTQUEST:
|
||||
ret = new NextQuestAction(this, data);
|
||||
break;
|
||||
case PETSKILL:
|
||||
ret = new PetSkillAction(this, data);
|
||||
break;
|
||||
case QUEST:
|
||||
ret = new QuestAction(this, data);
|
||||
break;
|
||||
case SKILL:
|
||||
ret = new SkillAction(this, data);
|
||||
break;
|
||||
case PETTAMENESS:
|
||||
ret = new PetTamenessAction(this, data);
|
||||
break;
|
||||
case PETSPEED:
|
||||
ret = new PetSpeedAction(this, data);
|
||||
break;
|
||||
case INFO:
|
||||
ret = new InfoAction(this, data);
|
||||
break;
|
||||
default:
|
||||
//FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Unhandled Action Type: " + type.toString() + " QuestID: " + this.getId());
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
|
||||
if (chr.getQuest(this).getStatus().equals(MapleQuestStatus.Status.STARTED)) {
|
||||
ItemAction itemAct = (ItemAction) startActs.get(MapleQuestActionType.ITEM);
|
||||
if (itemAct != null) {
|
||||
return itemAct.restoreLostItem(chr, itemid);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getMedalRequirement() {
|
||||
Integer medalid = medals.get(id);
|
||||
return medalid != null ? medalid : -1;
|
||||
}
|
||||
|
||||
public int getNpcRequirement(boolean checkEnd) {
|
||||
Map<MapleQuestRequirementType, MapleQuestRequirement> reqs = !checkEnd ? startReqs : completeReqs;
|
||||
MapleQuestRequirement mqr = reqs.get(MapleQuestRequirementType.NPC);
|
||||
if (mqr != null) {
|
||||
return ((NpcRequirement) mqr).get();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasScriptRequirement(boolean checkEnd) {
|
||||
Map<MapleQuestRequirementType, MapleQuestRequirement> reqs = !checkEnd ? startReqs : completeReqs;
|
||||
MapleQuestRequirement mqr = reqs.get(MapleQuestRequirementType.SCRIPT);
|
||||
|
||||
if (mqr != null) {
|
||||
return ((ScriptRequirement) mqr).get();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasNextQuestAction() {
|
||||
Map<MapleQuestActionType, MapleQuestAction> acts = completeActs;
|
||||
MapleQuestAction mqa = acts.get(MapleQuestActionType.NEXTQUEST);
|
||||
|
||||
return mqa != null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static boolean isExploitableQuest(short questid) {
|
||||
return exploitableQuests.contains(questid);
|
||||
}
|
||||
|
||||
public static List<MapleQuest> getMatchedQuests(String search) {
|
||||
List<MapleQuest> ret = new LinkedList<>();
|
||||
|
||||
search = search.toLowerCase();
|
||||
for (MapleQuest mq : quests.values()) {
|
||||
if (mq.name.toLowerCase().contains(search) || mq.parent.toLowerCase().contains(search)) {
|
||||
ret.add(mq);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void loadAllQuest() {
|
||||
try {
|
||||
for(MapleData quest : questInfo.getChildren()) {
|
||||
int questID = Integer.parseInt(quest.getName());
|
||||
|
||||
MapleQuest q = new MapleQuest(questID);
|
||||
quests.put(questID, q);
|
||||
|
||||
int infoNumber;
|
||||
|
||||
infoNumber = q.getInfoNumber(Status.STARTED);
|
||||
if (infoNumber > 0) {
|
||||
infoNumberQuests.put(infoNumber, questID);
|
||||
}
|
||||
|
||||
infoNumber = q.getInfoNumber(Status.COMPLETED);
|
||||
if (infoNumber > 0) {
|
||||
infoNumberQuests.put(infoNumber, questID);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
75
src/main/java/server/quest/MapleQuestActionType.java
Normal file
75
src/main/java/server/quest/MapleQuestActionType.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
*/
|
||||
public enum MapleQuestActionType {
|
||||
UNDEFINED(-1), EXP(0), ITEM(1), NEXTQUEST(2), MESO(3), QUEST(4), SKILL(5), FAME(6), BUFF(7), PETSKILL(8), YES(9), NO(10), NPC(11), MIN_LEVEL(12), NORMAL_AUTO_START(13), PETTAMENESS(14), PETSPEED(15), INFO(16), ZERO(16);
|
||||
final byte type;
|
||||
|
||||
private MapleQuestActionType(int type) {
|
||||
this.type = (byte) type;
|
||||
}
|
||||
|
||||
public static MapleQuestActionType getByWZName(String name) {
|
||||
if (name.equals("exp")) {
|
||||
return EXP;
|
||||
} else if (name.equals("money")) {
|
||||
return MESO;
|
||||
} else if (name.equals("item")) {
|
||||
return ITEM;
|
||||
} else if (name.equals("skill")) {
|
||||
return SKILL;
|
||||
} else if (name.equals("nextQuest")) {
|
||||
return NEXTQUEST;
|
||||
} else if (name.equals("pop")) {
|
||||
return FAME;
|
||||
} else if (name.equals("buffItemID")) {
|
||||
return BUFF;
|
||||
} else if (name.equals("petskill")) {
|
||||
return PETSKILL;
|
||||
} else if (name.equals("no")) {
|
||||
return NO;
|
||||
} else if (name.equals("yes")) {
|
||||
return YES;
|
||||
} else if (name.equals("npc")) {
|
||||
return NPC;
|
||||
} else if (name.equals("lvmin")) {
|
||||
return MIN_LEVEL;
|
||||
} else if (name.equals("normalAutoStart")) {
|
||||
return NORMAL_AUTO_START;
|
||||
} else if (name.equals("pettameness")) {
|
||||
return PETTAMENESS;
|
||||
} else if (name.equals("petspeed")) {
|
||||
return PETSPEED;
|
||||
} else if (name.equals("info")) {
|
||||
return INFO;
|
||||
} else if (name.equals("0")) {
|
||||
return ZERO;
|
||||
} else {
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
95
src/main/java/server/quest/MapleQuestRequirementType.java
Normal file
95
src/main/java/server/quest/MapleQuestRequirementType.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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), BUFF(22), EXCEPT_BUFF(23);
|
||||
final byte type;
|
||||
|
||||
private MapleQuestRequirementType(int type) {
|
||||
this.type = (byte) type;
|
||||
}
|
||||
|
||||
public byte getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static MapleQuestRequirementType getByWZName(String name) {
|
||||
if (name.equals("job")) {
|
||||
return JOB;
|
||||
} else if (name.equals("quest")) {
|
||||
return QUEST;
|
||||
} else if (name.equals("item")) {
|
||||
return ITEM;
|
||||
} else if (name.equals("lvmin")) {
|
||||
return MIN_LEVEL;
|
||||
} else if (name.equals("lvmax")) {
|
||||
return MAX_LEVEL;
|
||||
} else if (name.equals("end")) {
|
||||
return END_DATE;
|
||||
} else if (name.equals("mob")) {
|
||||
return MOB;
|
||||
} else if (name.equals("npc")) {
|
||||
return NPC;
|
||||
} else if (name.equals("fieldEnter")) {
|
||||
return FIELD_ENTER;
|
||||
} else if (name.equals("interval")) {
|
||||
return INTERVAL;
|
||||
} else if (name.equals("startscript")) {
|
||||
return SCRIPT;
|
||||
} else if (name.equals("endscript")) {
|
||||
return SCRIPT;
|
||||
} else if (name.equals("pet")) {
|
||||
return PET;
|
||||
} else if (name.equals("pettamenessmin")) {
|
||||
return MIN_PET_TAMENESS;
|
||||
} else if (name.equals("mbmin")) {
|
||||
return MONSTER_BOOK;
|
||||
} else if (name.equals("normalAutoStart")) {
|
||||
return NORMAL_AUTO_START;
|
||||
} else if (name.equals("infoNumber")) {
|
||||
return INFO_NUMBER;
|
||||
} else if (name.equals("infoex")) {
|
||||
return INFO_EX;
|
||||
} else if (name.equals("questComplete")) {
|
||||
return COMPLETED_QUEST;
|
||||
} else if(name.equals("start")) {
|
||||
return START;
|
||||
/*} else if(name.equals("end")) { already coded
|
||||
return END;*/
|
||||
} else if(name.equals("daybyday")) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/main/java/server/quest/actions/BuffAction.java
Normal file
57
src/main/java/server/quest/actions/BuffAction.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class BuffAction extends MapleQuestAction {
|
||||
int itemEffect;
|
||||
|
||||
public BuffAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.BUFF, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
itemEffect = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider.getInstance().getItemEffect(itemEffect).applyTo(chr);
|
||||
}
|
||||
}
|
||||
61
src/main/java/server/quest/actions/ExpAction.java
Normal file
61
src/main/java/server/quest/actions/ExpAction.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import config.YamlConfig;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ExpAction extends MapleQuestAction {
|
||||
int exp;
|
||||
|
||||
public ExpAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.EXP, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
exp = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
runAction(chr, exp);
|
||||
}
|
||||
|
||||
public static void runAction(MapleCharacter chr, int gain) {
|
||||
if (!YamlConfig.config.server.USE_QUEST_RATE) {
|
||||
chr.gainExp(gain * chr.getExpRate(), true, true);
|
||||
} else {
|
||||
chr.gainExp(gain * chr.getQuestExpRate(), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/main/java/server/quest/actions/FameAction.java
Normal file
53
src/main/java/server/quest/actions/FameAction.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class FameAction extends MapleQuestAction {
|
||||
int fame;
|
||||
|
||||
public FameAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.FAME, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
fame = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.gainFame(fame);
|
||||
}
|
||||
}
|
||||
55
src/main/java/server/quest/actions/InfoAction.java
Normal file
55
src/main/java/server/quest/actions/InfoAction.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class InfoAction extends MapleQuestAction {
|
||||
|
||||
private String info;
|
||||
private int questID;
|
||||
|
||||
public InfoAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.INFO, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
info = MapleDataTool.getString(data, "");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.getAbstractPlayerInteraction().setQuestProgress(questID, info);
|
||||
}
|
||||
|
||||
}
|
||||
365
src/main/java/server/quest/actions/ItemAction.java
Normal file
365
src/main/java/server/quest/actions/ItemAction.java
Normal file
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import constants.inventory.ItemConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
* @author Ronan
|
||||
*/
|
||||
public class ItemAction extends MapleQuestAction {
|
||||
List<ItemData> items = new ArrayList<>();
|
||||
|
||||
public ItemAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.ITEM, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData iEntry : data.getChildren()) {
|
||||
int id = MapleDataTool.getInt(iEntry.getChildByPath("id"));
|
||||
int count = MapleDataTool.getInt(iEntry.getChildByPath("count"), 1);
|
||||
int period = MapleDataTool.getInt(iEntry.getChildByPath("period"), 0);
|
||||
|
||||
Integer prop = null;
|
||||
MapleData propData = iEntry.getChildByPath("prop");
|
||||
if(propData != null)
|
||||
prop = MapleDataTool.getInt(propData);
|
||||
|
||||
int gender = 2;
|
||||
if (iEntry.getChildByPath("gender") != null)
|
||||
gender = MapleDataTool.getInt(iEntry.getChildByPath("gender"));
|
||||
|
||||
int job = -1;
|
||||
if (iEntry.getChildByPath("job") != null)
|
||||
job = MapleDataTool.getInt(iEntry.getChildByPath("job"));
|
||||
|
||||
items.add(new ItemData(Integer.parseInt(iEntry.getName()), id, count, prop, job, gender, period));
|
||||
}
|
||||
|
||||
Collections.sort(items, new Comparator<ItemData>()
|
||||
{
|
||||
@Override
|
||||
public int compare( ItemData o1, ItemData o2 )
|
||||
{
|
||||
return o1.map - o2.map;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
List<ItemData> takeItem = new LinkedList<>();
|
||||
List<ItemData> giveItem = new LinkedList<>();
|
||||
|
||||
int props = 0, rndProps = 0, accProps = 0;
|
||||
for(ItemData item : items) {
|
||||
if(item.getProp() != null && item.getProp() != -1 && canGetItem(item, chr)) {
|
||||
props += item.getProp();
|
||||
}
|
||||
}
|
||||
|
||||
int extNum = 0;
|
||||
if (props > 0) {
|
||||
rndProps = Randomizer.nextInt(props);
|
||||
}
|
||||
for (ItemData iEntry : items) {
|
||||
if (!canGetItem(iEntry, chr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(iEntry.getProp() != null) {
|
||||
if(iEntry.getProp() == -1) {
|
||||
if(extSelection != extNum++)
|
||||
continue;
|
||||
} else {
|
||||
accProps += iEntry.getProp();
|
||||
|
||||
if(accProps <= rndProps) {
|
||||
continue;
|
||||
} else {
|
||||
accProps = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(iEntry.getCount() < 0) { // Remove Item
|
||||
takeItem.add(iEntry);
|
||||
} else { // Give Item
|
||||
giveItem.add(iEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// must take all needed items before giving others
|
||||
|
||||
for(ItemData iEntry: takeItem) {
|
||||
int itemid = iEntry.getId(), count = iEntry.getCount();
|
||||
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(itemid);
|
||||
int quantity = count * -1; // Invert
|
||||
if(type.equals(MapleInventoryType.EQUIP)) {
|
||||
if(chr.getInventory(type).countById(itemid) < quantity) {
|
||||
// Not enough in the equip inventoty, so check Equipped...
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(itemid) > quantity) {
|
||||
// Found it equipped, so change the type to equipped.
|
||||
type = MapleInventoryType.EQUIPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapleInventoryManipulator.removeById(chr.getClient(), type, itemid, quantity, true, false);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(itemid, (short) count, true));
|
||||
}
|
||||
|
||||
for(ItemData iEntry: giveItem) {
|
||||
int itemid = iEntry.getId(), count = iEntry.getCount(), period = iEntry.getPeriod(); // thanks Vcoc for noticing quest milestone item not getting removed from inventory after a while
|
||||
|
||||
MapleInventoryManipulator.addById(chr.getClient(), itemid, (short) count, "", -1, period > 0 ? (System.currentTimeMillis() + period * 60 * 1000) : -1);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(itemid, (short) count, true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
List<Pair<Item, MapleInventoryType>> gainList = new LinkedList<>();
|
||||
List<Pair<Item, MapleInventoryType>> selectList = new LinkedList<>();
|
||||
List<Pair<Item, MapleInventoryType>> randomList = new LinkedList<>();
|
||||
|
||||
List<Integer> allSlotUsed = new ArrayList(5);
|
||||
for(byte i = 0; i < 5; i++) allSlotUsed.add(0);
|
||||
|
||||
for(ItemData item : items) {
|
||||
if (!canGetItem(item, chr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MapleInventoryType type = ItemConstants.getInventoryType(item.getId());
|
||||
if(item.getProp() != null) {
|
||||
Item toItem = new Item(item.getId(), (short) 0, (short) item.getCount());
|
||||
|
||||
if(item.getProp() < 0) {
|
||||
selectList.add(new Pair<>(toItem, type));
|
||||
} else {
|
||||
randomList.add(new Pair<>(toItem, type));
|
||||
}
|
||||
|
||||
} else {
|
||||
// Make sure they can hold the item.
|
||||
Item toItem = new Item(item.getId(), (short) 0, (short) item.getCount());
|
||||
gainList.add(new Pair<>(toItem, type));
|
||||
|
||||
if(item.getCount() < 0) {
|
||||
// Make sure they actually have the item.
|
||||
int quantity = item.getCount() * -1;
|
||||
|
||||
int freeSlotCount = chr.getInventory(type).freeSlotCountById(item.getId(), quantity);
|
||||
if(freeSlotCount == -1) {
|
||||
if(type.equals(MapleInventoryType.EQUIP) && chr.getInventory(MapleInventoryType.EQUIPPED).countById(item.getId()) > quantity)
|
||||
continue;
|
||||
|
||||
announceInventoryLimit(Collections.singletonList(item.getId()), chr);
|
||||
return false;
|
||||
} else {
|
||||
int idx = type.getType() - 1; // more slots available from the given items!
|
||||
allSlotUsed.set(idx, allSlotUsed.get(idx) - freeSlotCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!randomList.isEmpty()) {
|
||||
int result;
|
||||
MapleClient c = chr.getClient();
|
||||
|
||||
List<Integer> rndUsed = new ArrayList(5);
|
||||
for(byte i = 0; i < 5; i++) rndUsed.add(allSlotUsed.get(i));
|
||||
|
||||
for(Pair<Item, MapleInventoryType> it: randomList) {
|
||||
int idx = it.getRight().getType() - 1;
|
||||
|
||||
result = MapleInventoryManipulator.checkSpaceProgressively(c, it.getLeft().getItemId(), it.getLeft().getQuantity(), "", rndUsed.get(idx), false);
|
||||
if(result % 2 == 0) {
|
||||
announceInventoryLimit(Collections.singletonList(it.getLeft().getItemId()), chr);
|
||||
return false;
|
||||
}
|
||||
|
||||
allSlotUsed.set(idx, Math.max(allSlotUsed.get(idx), result >> 1));
|
||||
}
|
||||
}
|
||||
|
||||
if(!selectList.isEmpty()) {
|
||||
Pair<Item, MapleInventoryType> selected = selectList.get(extSelection);
|
||||
gainList.add(selected);
|
||||
}
|
||||
|
||||
if (!canHold(chr, gainList)) {
|
||||
List<Integer> gainItemids = new LinkedList<>();
|
||||
for (Pair<Item, MapleInventoryType> it : gainList) {
|
||||
gainItemids.add(it.getLeft().getItemId());
|
||||
}
|
||||
|
||||
announceInventoryLimit(gainItemids, chr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void announceInventoryLimit(List<Integer> itemids, MapleCharacter chr) {
|
||||
for (Integer id : itemids) {
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(id) && chr.haveItemWithId(id, true)) {
|
||||
chr.dropMessage(1, "Please check if you already have a similar one-of-a-kind item in your inventory.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
|
||||
}
|
||||
|
||||
private boolean canHold(MapleCharacter chr, List<Pair<Item, MapleInventoryType>> gainList) {
|
||||
List<Integer> toAddItemids = new LinkedList<>();
|
||||
List<Integer> toAddQuantity = new LinkedList<>();
|
||||
List<Integer> toRemoveItemids = new LinkedList<>();
|
||||
List<Integer> toRemoveQuantity = new LinkedList<>();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> item : gainList) {
|
||||
Item it = item.getLeft();
|
||||
|
||||
if (it.getQuantity() > 0) {
|
||||
toAddItemids.add(it.getItemId());
|
||||
toAddQuantity.add((int) it.getQuantity());
|
||||
} else {
|
||||
toRemoveItemids.add(it.getItemId());
|
||||
toRemoveQuantity.add(-1 * ((int) it.getQuantity()));
|
||||
}
|
||||
}
|
||||
|
||||
// thanks onechord for noticing quests unnecessarily giving out "full inventory" from quests that also takes items from players
|
||||
return chr.getAbstractPlayerInteraction().canHoldAllAfterRemoving(toAddItemids, toAddQuantity, toRemoveItemids, toRemoveQuantity);
|
||||
}
|
||||
|
||||
private boolean canGetItem(ItemData item, MapleCharacter chr) {
|
||||
if (item.getGender() != 2 && item.getGender() != chr.getGender()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.job > 0) {
|
||||
final List<Integer> code = getJobBy5ByteEncoding(item.getJob());
|
||||
boolean jobFound = false;
|
||||
for (int codec : code) {
|
||||
if (codec / 100 == chr.getJob().getId() / 100) {
|
||||
jobFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return jobFound;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean restoreLostItem(MapleCharacter chr, int itemid) {
|
||||
if (!MapleItemInformationProvider.getInstance().isQuestItem(itemid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// thanks danielktran (MapleHeroesD)
|
||||
for (ItemData item : items) {
|
||||
if (item.getId() == itemid) {
|
||||
int missingQty = item.getCount() - chr.countItem(itemid);
|
||||
if (missingQty > 0) {
|
||||
if (!chr.canHold(itemid, missingQty)) {
|
||||
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MapleInventoryManipulator.addById(chr.getClient(), item.getId(), (short) missingQty);
|
||||
FilePrinter.print(FilePrinter.QUEST_RESTORE_ITEM, chr + " obtained " + itemid + " qty. " + missingQty + " from quest " + questID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private class ItemData {
|
||||
private final int map, id, count, job, gender, period;
|
||||
private final Integer prop;
|
||||
|
||||
public ItemData(int map, int id, int count, Integer prop, int job, int gender, int period) {
|
||||
this.map = map;
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
this.prop = prop;
|
||||
this.job = job;
|
||||
this.gender = gender;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public Integer getProp() {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public int getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public int getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
}
|
||||
}
|
||||
132
src/main/java/server/quest/actions/MapleQuestAction.java
Normal file
132
src/main/java/server/quest/actions/MapleQuestAction.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
This file is part of the MapleSolaxia Maple Story Server
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public abstract class MapleQuestAction {
|
||||
private final MapleQuestActionType type;
|
||||
protected int questID;
|
||||
|
||||
public MapleQuestAction(MapleQuestActionType action, MapleQuest quest) {
|
||||
this.type = action;
|
||||
this.questID = quest.getId();
|
||||
}
|
||||
|
||||
public abstract void run(MapleCharacter chr, Integer extSelection);
|
||||
public abstract void processData(MapleData data);
|
||||
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public MapleQuestActionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static List<Integer> getJobBy5ByteEncoding(int encoded) {
|
||||
List<Integer> ret = new ArrayList<Integer>();
|
||||
if ((encoded & 0x1) != 0) {
|
||||
ret.add(0);
|
||||
}
|
||||
if ((encoded & 0x2) != 0) {
|
||||
ret.add(100);
|
||||
}
|
||||
if ((encoded & 0x4) != 0) {
|
||||
ret.add(200);
|
||||
}
|
||||
if ((encoded & 0x8) != 0) {
|
||||
ret.add(300);
|
||||
}
|
||||
if ((encoded & 0x10) != 0) {
|
||||
ret.add(400);
|
||||
}
|
||||
if ((encoded & 0x20) != 0) {
|
||||
ret.add(500);
|
||||
}
|
||||
if ((encoded & 0x400) != 0) {
|
||||
ret.add(1000);
|
||||
}
|
||||
if ((encoded & 0x800) != 0) {
|
||||
ret.add(1100);
|
||||
}
|
||||
if ((encoded & 0x1000) != 0) {
|
||||
ret.add(1200);
|
||||
}
|
||||
if ((encoded & 0x2000) != 0) {
|
||||
ret.add(1300);
|
||||
}
|
||||
if ((encoded & 0x4000) != 0) {
|
||||
ret.add(1400);
|
||||
}
|
||||
if ((encoded & 0x8000) != 0) {
|
||||
ret.add(1500);
|
||||
}
|
||||
if ((encoded & 0x20000) != 0) {
|
||||
ret.add(2001); //im not sure of this one
|
||||
ret.add(2200);
|
||||
}
|
||||
if ((encoded & 0x100000) != 0) {
|
||||
ret.add(2000);
|
||||
ret.add(2001); //?
|
||||
}
|
||||
if ((encoded & 0x200000) != 0) {
|
||||
ret.add(2100);
|
||||
}
|
||||
if ((encoded & 0x400000) != 0) {
|
||||
ret.add(2001); //?
|
||||
ret.add(2200);
|
||||
}
|
||||
|
||||
if ((encoded & 0x40000000) != 0) { //i haven't seen any higher than this o.o
|
||||
ret.add(3000);
|
||||
ret.add(3200);
|
||||
ret.add(3300);
|
||||
ret.add(3500);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<Integer> getJobBySimpleEncoding(int encoded) {
|
||||
List<Integer> ret = new ArrayList<Integer>();
|
||||
if ((encoded & 0x1) != 0) {
|
||||
ret.add(200);
|
||||
}
|
||||
if ((encoded & 0x2) != 0) {
|
||||
ret.add(300);
|
||||
}
|
||||
if ((encoded & 0x4) != 0) {
|
||||
ret.add(400);
|
||||
}
|
||||
if ((encoded & 0x8) != 0) {
|
||||
ret.add(500);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
66
src/main/java/server/quest/actions/MesoAction.java
Normal file
66
src/main/java/server/quest/actions/MesoAction.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import config.YamlConfig;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MesoAction extends MapleQuestAction {
|
||||
int mesos;
|
||||
|
||||
public MesoAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.MESO, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
mesos = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
runAction(chr, mesos);
|
||||
}
|
||||
|
||||
public static void runAction(MapleCharacter chr, int gain) {
|
||||
if (gain < 0) {
|
||||
chr.gainMeso(gain, true, false, true);
|
||||
} else {
|
||||
if (!YamlConfig.config.server.USE_QUEST_RATE) {
|
||||
chr.gainMeso(gain * chr.getMesoRate(), true, false, true);
|
||||
} else {
|
||||
chr.gainMeso(gain * chr.getQuestMesoRate(), true, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/main/java/server/quest/actions/NextQuestAction.java
Normal file
55
src/main/java/server/quest/actions/NextQuestAction.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class NextQuestAction extends MapleQuestAction {
|
||||
int nextQuest;
|
||||
|
||||
public NextQuestAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.NEXTQUEST, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
nextQuest = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
chr.announce(MaplePacketCreator.updateQuestFinish((short) questID, status.getNpc(), (short) nextQuest));
|
||||
}
|
||||
}
|
||||
64
src/main/java/server/quest/actions/PetSkillAction.java
Normal file
64
src/main/java/server/quest/actions/PetSkillAction.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import constants.inventory.ItemConstants;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class PetSkillAction extends MapleQuestAction {
|
||||
int flag;
|
||||
|
||||
public PetSkillAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.PETSKILL, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
flag = MapleDataTool.getInt("petskill", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
if(!(status.getStatus() == MapleQuestStatus.Status.NOT_STARTED && status.getForfeited() > 0))
|
||||
return false;
|
||||
|
||||
return chr.getPet(0) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.getPet(0).setFlag((byte) ItemConstants.getFlagByInt(flag));
|
||||
}
|
||||
}
|
||||
60
src/main/java/server/quest/actions/PetSpeedAction.java
Normal file
60
src/main/java/server/quest/actions/PetSpeedAction.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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.actions;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PetSpeedAction extends MapleQuestAction {
|
||||
|
||||
public PetSpeedAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.PETTAMENESS, quest);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleClient c = chr.getClient();
|
||||
|
||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain owner speed
|
||||
if(pet == null) return;
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
pet.addPetFlag(c.getPlayer(), MaplePet.PetFlag.OWNER_SPEED);
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
63
src/main/java/server/quest/actions/PetTamenessAction.java
Normal file
63
src/main/java/server/quest/actions/PetTamenessAction.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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.actions;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.MaplePet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class PetTamenessAction extends MapleQuestAction {
|
||||
int tameness;
|
||||
|
||||
public PetTamenessAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.PETTAMENESS, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
tameness = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleClient c = chr.getClient();
|
||||
|
||||
MaplePet pet = chr.getPet(0); // assuming here only the pet leader will gain tameness
|
||||
if(pet == null) return;
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
pet.gainClosenessFullness(chr, tameness, 0, 0);
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
64
src/main/java/server/quest/actions/QuestAction.java
Normal file
64
src/main/java/server/quest/actions/QuestAction.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class QuestAction extends MapleQuestAction {
|
||||
int mesos;
|
||||
Map<Integer, Integer> quests = new HashMap<>();
|
||||
|
||||
public QuestAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.QUEST, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData qEntry : data) {
|
||||
int questid = MapleDataTool.getInt(qEntry.getChildByPath("id"));
|
||||
int stat = MapleDataTool.getInt(qEntry.getChildByPath("state"));
|
||||
quests.put(questid, stat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
for(Integer questID : quests.keySet()) {
|
||||
int stat = quests.get(questID);
|
||||
chr.updateQuestStatus(new MapleQuestStatus(MapleQuest.getInstance(questID), MapleQuestStatus.Status.getById(stat)));
|
||||
}
|
||||
}
|
||||
}
|
||||
122
src/main/java/server/quest/actions/SkillAction.java
Normal file
122
src/main/java/server/quest/actions/SkillAction.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
import client.Skill;
|
||||
import client.SkillFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class SkillAction extends MapleQuestAction {
|
||||
int itemEffect;
|
||||
Map<Integer, SkillData> skillData = new HashMap<>();
|
||||
|
||||
public SkillAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.SKILL, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData sEntry : data) {
|
||||
byte skillLevel = 0;
|
||||
int skillid = MapleDataTool.getInt(sEntry.getChildByPath("id"));
|
||||
MapleData skillLevelData = sEntry.getChildByPath("skillLevel");
|
||||
if(skillLevelData != null)
|
||||
skillLevel = (byte) MapleDataTool.getInt(skillLevelData);
|
||||
int masterLevel = MapleDataTool.getInt(sEntry.getChildByPath("masterLevel"));
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
MapleData applicableJobs = sEntry.getChildByPath("job");
|
||||
if(applicableJobs != null) {
|
||||
for (MapleData applicableJob : applicableJobs.getChildren()) {
|
||||
jobs.add(MapleDataTool.getInt(applicableJob));
|
||||
}
|
||||
}
|
||||
|
||||
skillData.put(skillid, new SkillData(skillid, skillLevel, masterLevel, jobs));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
for(SkillData skill : skillData.values()) {
|
||||
Skill skillObject = SkillFactory.getSkill(skill.getId());
|
||||
if(skillObject == null) continue;
|
||||
|
||||
boolean shouldLearn = false;
|
||||
|
||||
if(skill.jobsContains(chr.getJob()) || skillObject.isBeginnerSkill())
|
||||
shouldLearn = true;
|
||||
|
||||
byte skillLevel = (byte) Math.max(skill.getLevel(), chr.getSkillLevel(skillObject));
|
||||
int masterLevel = Math.max(skill.getMasterLevel(), chr.getMasterLevel(skillObject));
|
||||
if (shouldLearn) {
|
||||
chr.changeSkillLevel(skillObject, skillLevel, masterLevel, -1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class SkillData {
|
||||
protected int id, level, masterLevel;
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
public SkillData(int id, int level, int masterLevel, List<Integer> jobs) {
|
||||
this.id = id;
|
||||
this.level = level;
|
||||
this.masterLevel = masterLevel;
|
||||
this.jobs = jobs;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getMasterLevel() {
|
||||
return masterLevel;
|
||||
}
|
||||
|
||||
public boolean jobsContains(MapleJob job) {
|
||||
return jobs.contains(job.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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);
|
||||
}
|
||||
}
|
||||
50
src/main/java/server/quest/requirements/BuffRequirement.java
Normal file
50
src/main/java/server/quest/requirements/BuffRequirement.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class CompletedQuestRequirement extends MapleQuestRequirement {
|
||||
private int reqQuest;
|
||||
|
||||
|
||||
public CompletedQuestRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.COMPLETED_QUEST);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqQuest = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getCompletedQuests().size() >= reqQuest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 java.util.Calendar;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class EndDateRequirement extends MapleQuestRequirement {
|
||||
private String timeStr;
|
||||
|
||||
|
||||
public EndDateRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.END_DATE);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
timeStr = MapleDataTool.getString(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Integer.parseInt(timeStr.substring(0, 4)), Integer.parseInt(timeStr.substring(4, 6)), Integer.parseInt(timeStr.substring(6, 8)), Integer.parseInt(timeStr.substring(8, 10)), 0);
|
||||
return cal.getTimeInMillis() >= System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class FieldEnterRequirement extends MapleQuestRequirement {
|
||||
private int mapId = -1;
|
||||
|
||||
|
||||
public FieldEnterRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.FIELD_ENTER);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
MapleData zeroField = data.getChildByPath("0");
|
||||
if (zeroField != null) {
|
||||
mapId = MapleDataTool.getInt(zeroField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return mapId == chr.getMapId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class InfoExRequirement extends MapleQuestRequirement {
|
||||
private List<String> infoExpected = new ArrayList<>();
|
||||
private int questID;
|
||||
|
||||
|
||||
public InfoExRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.INFO_EX);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
// Because we have to...
|
||||
for(MapleData infoEx : data.getChildren()) {
|
||||
MapleData value = infoEx.getChildByPath("value");
|
||||
infoExpected.add(MapleDataTool.getString(value, ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getInfo() {
|
||||
return infoExpected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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 InfoNumberRequirement extends MapleQuestRequirement {
|
||||
|
||||
private short infoNumber;
|
||||
private int questID;
|
||||
|
||||
public InfoNumberRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.INFO_NUMBER);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
infoNumber = (short) MapleDataTool.getIntConvert(data, 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public short getInfoNumber() {
|
||||
return infoNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class IntervalRequirement extends MapleQuestRequirement {
|
||||
private int interval = -1;
|
||||
private int questID;
|
||||
|
||||
public IntervalRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.INTERVAL);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
public int getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
interval = MapleDataTool.getInt(data) * 60 * 1000;
|
||||
}
|
||||
|
||||
private static String getIntervalTimeLeft(MapleCharacter chr, IntervalRequirement r) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
long futureTime = chr.getQuest(MapleQuest.getInstance(r.questID)).getCompletionTime() + r.getInterval();
|
||||
long leftTime = futureTime - System.currentTimeMillis();
|
||||
|
||||
byte mode = 0;
|
||||
if(leftTime / (60*1000) > 0) {
|
||||
mode++; //counts minutes
|
||||
|
||||
if(leftTime / (60*60*1000) > 0)
|
||||
mode++; //counts hours
|
||||
}
|
||||
|
||||
switch(mode) {
|
||||
case 2:
|
||||
int hours = (int) ((leftTime / (1000*60*60)));
|
||||
str.append(hours + " hours, ");
|
||||
|
||||
case 1:
|
||||
int minutes = (int) ((leftTime / (1000*60)) % 60);
|
||||
str.append(minutes + " minutes, ");
|
||||
|
||||
default:
|
||||
int seconds = (int) (leftTime / 1000) % 60 ;
|
||||
str.append(seconds + " seconds");
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
boolean check = !chr.getQuest(MapleQuest.getInstance(questID)).getStatus().equals(MapleQuestStatus.Status.COMPLETED);
|
||||
boolean check2 = chr.getQuest(MapleQuest.getInstance(questID)).getCompletionTime() <= System.currentTimeMillis() - interval;
|
||||
|
||||
if (check || check2) {
|
||||
return true;
|
||||
} else {
|
||||
chr.message("This quest will become available again in approximately " + getIntervalTimeLeft(chr, this) + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
src/main/java/server/quest/requirements/ItemRequirement.java
Normal file
107
src/main/java/server/quest/requirements/ItemRequirement.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import constants.inventory.ItemConstants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ItemRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> items = new HashMap<>();
|
||||
|
||||
|
||||
public ItemRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.ITEM);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData itemEntry : data.getChildren()) {
|
||||
int itemId = MapleDataTool.getInt(itemEntry.getChildByPath("id"));
|
||||
int count = MapleDataTool.getInt(itemEntry.getChildByPath("count"), 0);
|
||||
|
||||
items.put(itemId, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
for(Integer itemId : items.keySet()) {
|
||||
int countNeeded = items.get(itemId);
|
||||
int count = 0;
|
||||
|
||||
MapleInventoryType iType = ItemConstants.getInventoryType(itemId);
|
||||
|
||||
if (iType.equals(MapleInventoryType.UNDEFINED)) {
|
||||
return false;
|
||||
}
|
||||
for (Item item : chr.getInventory(iType).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
//Weird stuff, nexon made some quests only available when wearing gm clothes. This enables us to accept it ><
|
||||
if (iType.equals(MapleInventoryType.EQUIP) && !ItemConstants.isMedal(itemId)) {
|
||||
if(chr.isGM()) {
|
||||
for (Item item : chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
} else {
|
||||
if(count < countNeeded) {
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(itemId) + count >= countNeeded) {
|
||||
chr.dropMessage(5, "Unequip the required " + ii.getName(itemId) + " before trying this quest operation.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count < countNeeded || countNeeded <= 0 && count > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getItemAmountNeeded(int itemid, boolean complete) {
|
||||
Integer amount = items.get(itemid);
|
||||
if (amount != null) {
|
||||
return amount;
|
||||
} else {
|
||||
return complete ? Integer.MAX_VALUE : Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
src/main/java/server/quest/requirements/JobRequirement.java
Normal file
67
src/main/java/server/quest/requirements/JobRequirement.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class JobRequirement extends MapleQuestRequirement {
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
public JobRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.JOB);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData jobEntry : data.getChildren()) {
|
||||
jobs.add(MapleDataTool.getInt(jobEntry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(Integer job : jobs) {
|
||||
if (chr.getJob().equals(MapleJob.getById(job)) || chr.isGM()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 provider.MapleData;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
|
||||
/**
|
||||
* Base class for a Quest Requirement. Quest system uses it for all requirements.
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public abstract class MapleQuestRequirement {
|
||||
private final MapleQuestRequirementType type;
|
||||
|
||||
public MapleQuestRequirement(MapleQuestRequirementType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the requirement to see if the player currently meets it.
|
||||
* @param chr The {@link MapleCharacter} to check on.
|
||||
* @param npcid The NPC ID it was called from.
|
||||
* @return boolean If the check was passed or not.
|
||||
*/
|
||||
public abstract boolean check(MapleCharacter chr, Integer npcid);
|
||||
|
||||
/**
|
||||
* Processes the data and stores it in the class for future use.
|
||||
* @param data The data to process.
|
||||
*/
|
||||
public abstract void processData(MapleData data);
|
||||
|
||||
public MapleQuestRequirementType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class MaxLevelRequirement extends MapleQuestRequirement {
|
||||
private int maxLevel;
|
||||
|
||||
|
||||
public MaxLevelRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MAX_LEVEL);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
maxLevel = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return maxLevel >= chr.getLevel();
|
||||
}
|
||||
}
|
||||
55
src/main/java/server/quest/requirements/MesoRequirement.java
Normal file
55
src/main/java/server/quest/requirements/MesoRequirement.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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 provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MesoRequirement extends MapleQuestRequirement {
|
||||
private int meso = 0;
|
||||
|
||||
public MesoRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MESO);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
meso = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
if (chr.getMeso() >= meso) {
|
||||
return true;
|
||||
} else {
|
||||
chr.dropMessage(5, "You don't have enough mesos to complete this quest.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class MinLevelRequirement extends MapleQuestRequirement {
|
||||
private int minLevel;
|
||||
|
||||
|
||||
public MinLevelRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MIN_LEVEL);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
minLevel = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getLevel() >= minLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 client.inventory.MaplePet;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MinTamenessRequirement extends MapleQuestRequirement {
|
||||
private int minTameness;
|
||||
|
||||
|
||||
public MinTamenessRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MIN_PET_TAMENESS);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
minTameness = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
int curCloseness = 0;
|
||||
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
if(pet == null) continue;
|
||||
|
||||
if(pet.getCloseness() > curCloseness)
|
||||
curCloseness = pet.getCloseness();
|
||||
}
|
||||
|
||||
return curCloseness >= minTameness;
|
||||
}
|
||||
}
|
||||
89
src/main/java/server/quest/requirements/MobRequirement.java
Normal file
89
src/main/java/server/quest/requirements/MobRequirement.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import tools.FilePrinter;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MobRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> mobs = new HashMap<>();
|
||||
private int questID;
|
||||
|
||||
public MobRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MOB);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData questEntry : data.getChildren()) {
|
||||
int mobID = MapleDataTool.getInt(questEntry.getChildByPath("id"));
|
||||
int countReq = MapleDataTool.getInt(questEntry.getChildByPath("count"));
|
||||
mobs.put(mobID, countReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
for(Integer mobID : mobs.keySet()) {
|
||||
int countReq = mobs.get(mobID);
|
||||
int progress;
|
||||
|
||||
try {
|
||||
progress = Integer.parseInt(status.getProgress(mobID));
|
||||
} catch (NumberFormatException ex) {
|
||||
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, ex, "Mob: " + mobID + " Quest: " + questID + "CID: " + chr.getId() + " Progress: " + status.getProgress(mobID));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(progress < countReq)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRequiredMobCount(int mobid) {
|
||||
if(mobs.containsKey(mobid)) {
|
||||
return mobs.get(mobid);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class MonsterBookCountRequirement extends MapleQuestRequirement {
|
||||
private int reqCards;
|
||||
|
||||
|
||||
public MonsterBookCountRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MONSTER_BOOK);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqCards = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getMonsterBook().getTotalCards() >= reqCards;
|
||||
}
|
||||
}
|
||||
56
src/main/java/server/quest/requirements/NpcRequirement.java
Normal file
56
src/main/java/server/quest/requirements/NpcRequirement.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 Tyler (Twdtwd)
|
||||
*/
|
||||
public class NpcRequirement extends MapleQuestRequirement {
|
||||
private int reqNPC;
|
||||
|
||||
public NpcRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.NPC);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqNPC = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return npcid != null && npcid == reqNPC;
|
||||
}
|
||||
|
||||
public int get() {
|
||||
return reqNPC;
|
||||
}
|
||||
}
|
||||
66
src/main/java/server/quest/requirements/PetRequirement.java
Normal file
66
src/main/java/server/quest/requirements/PetRequirement.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
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 client.inventory.MaplePet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class PetRequirement extends MapleQuestRequirement {
|
||||
List<Integer> petIDs = new ArrayList<>();
|
||||
|
||||
|
||||
public PetRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.PET);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for(MapleData petData : data.getChildren()) {
|
||||
petIDs.add(MapleDataTool.getInt(petData.getChildByPath("id")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(MaplePet pet : chr.getPets()) {
|
||||
if(pet == null) continue; // thanks Arufonsu for showing a NPE occurring here
|
||||
|
||||
if(petIDs.contains(pet.getItemId()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
This file is part of the MapleSolaxia Maple Story Server
|
||||
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class QuestRequirement extends MapleQuestRequirement {
|
||||
Map<Integer, Integer> quests = new HashMap<>();
|
||||
|
||||
public QuestRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.QUEST);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData questEntry : data.getChildren()) {
|
||||
int questID = MapleDataTool.getInt(questEntry.getChildByPath("id"));
|
||||
int stateReq = MapleDataTool.getInt(questEntry.getChildByPath("state"));
|
||||
quests.put(questID, stateReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
for(Integer questID : quests.keySet()) {
|
||||
int stateReq = quests.get(questID);
|
||||
MapleQuestStatus qs = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
|
||||
if(qs == null && MapleQuestStatus.Status.getById(stateReq).equals(MapleQuestStatus.Status.NOT_STARTED))
|
||||
continue;
|
||||
|
||||
if(qs == null || !qs.getStatus().equals(MapleQuestStatus.Status.getById(stateReq))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2019 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 ScriptRequirement extends MapleQuestRequirement {
|
||||
private boolean reqScript;
|
||||
|
||||
public ScriptRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.BUFF);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqScript = !MapleDataTool.getString(data, "").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean get() {
|
||||
return reqScript;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user