source
Source for my MapleSolaxiaV2 (v83 MapleStory).
This commit is contained in:
441
src/server/quest/MapleQuest.java
Normal file
441
src/server/quest/MapleQuest.java
Normal file
@@ -0,0 +1,441 @@
|
||||
/*
|
||||
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.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import client.MapleQuestStatus.Status;
|
||||
import java.util.EnumMap;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.actions.*;
|
||||
import server.quest.requirements.*;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
*/
|
||||
public class MapleQuest {
|
||||
|
||||
private static Map<Integer, MapleQuest> quests = new HashMap<>();
|
||||
protected short infoNumber, id;
|
||||
protected int timeLimit, timeLimit2;
|
||||
protected String infoex;
|
||||
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 final static MapleDataProvider questData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Quest.wz"));
|
||||
private static MapleData questInfo;
|
||||
private static MapleData questAct;
|
||||
private static MapleData questReq;
|
||||
|
||||
private MapleQuest(int id) {
|
||||
this.id = (short) id;
|
||||
|
||||
if(questInfo != null) {
|
||||
timeLimit = MapleDataTool.getInt("timeLimit", questInfo, 0);
|
||||
timeLimit2 = MapleDataTool.getInt("timeLimit2", questInfo, 0);
|
||||
autoStart = MapleDataTool.getInt("autoStart", questInfo, 0) == 1;
|
||||
autoPreComplete = MapleDataTool.getInt("autoPreComplete", questInfo, 0) == 1;
|
||||
autoComplete = MapleDataTool.getInt("autoComplete", questInfo, 0) == 1;
|
||||
}
|
||||
|
||||
MapleData reqData = questReq.getChildByPath(String.valueOf(id));
|
||||
if (reqData == null) {//most likely infoEx
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if (type.equals(MapleQuestRequirementType.INFO_NUMBER)) {
|
||||
infoNumber = (short) MapleDataTool.getInt(startReq, 0);
|
||||
}
|
||||
|
||||
MapleQuestRequirement req = this.getRequirement(type, startReq);
|
||||
|
||||
if(req == null)
|
||||
continue;
|
||||
|
||||
if (type.equals(MapleQuestRequirementType.MOB)) {
|
||||
for (MapleData mob : startReq.getChildren()) {
|
||||
relevantMobs.add(MapleDataTool.getInt(mob.getChildByPath("id")));
|
||||
}
|
||||
}
|
||||
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.INFO_NUMBER)) {
|
||||
infoNumber = (short) MapleDataTool.getInt(completeReq, 0);
|
||||
}
|
||||
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) {
|
||||
questInfo = questData.getData("QuestInfo.img");
|
||||
questReq = questData.getData("Check.img");
|
||||
questAct = questData.getData("Act.img");
|
||||
|
||||
ret = new MapleQuest(id);
|
||||
quests.put(id, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean canStart(MapleCharacter c, int npcid) {
|
||||
if (c.getQuest(this).getStatus() != Status.NOT_STARTED && !(c.getQuest(this).getStatus() == Status.COMPLETED && repeatable)) {
|
||||
return false;
|
||||
}
|
||||
for (MapleQuestRequirement r : startReqs.values()) {
|
||||
if (!r.check(c, npcid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canComplete(MapleCharacter c, Integer npcid) {
|
||||
if (!c.getQuest(this).getStatus().equals(Status.STARTED)) {
|
||||
return false;
|
||||
}
|
||||
for (MapleQuestRequirement r : completeReqs.values()) {
|
||||
if (r == null || !r.check(c, npcid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start(MapleCharacter c, int npc) {
|
||||
if (autoStart || canStart(c, npc)) {
|
||||
for (MapleQuestAction a : startActs.values()) {
|
||||
if (!a.check(c, null)) { // would null be good ?
|
||||
return;
|
||||
}
|
||||
a.run(c, null);
|
||||
}
|
||||
forceStart(c, npc);
|
||||
}
|
||||
}
|
||||
|
||||
public void complete(MapleCharacter c, int npc) {
|
||||
complete(c, npc, null);
|
||||
}
|
||||
|
||||
public void complete(MapleCharacter c, int npc, Integer selection) {
|
||||
if (autoPreComplete || canComplete(c, npc)) {
|
||||
for (MapleQuestAction a : completeActs.values()) {
|
||||
if (!a.check(c, selection)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
forceComplete(c, npc);
|
||||
for (MapleQuestAction a : completeActs.values()) {
|
||||
a.run(c, selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reset(MapleCharacter c) {
|
||||
c.updateQuest(new MapleQuestStatus(this, MapleQuestStatus.Status.NOT_STARTED));
|
||||
}
|
||||
|
||||
public void forfeit(MapleCharacter c) {
|
||||
if (!c.getQuest(this).getStatus().equals(Status.STARTED)) {
|
||||
return;
|
||||
}
|
||||
if (timeLimit > 0) {
|
||||
c.announce(MaplePacketCreator.removeQuestTimeLimit(id));
|
||||
}
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.NOT_STARTED);
|
||||
newStatus.setForfeited(c.getQuest(this).getForfeited() + 1);
|
||||
c.updateQuest(newStatus);
|
||||
}
|
||||
|
||||
public boolean forceStart(MapleCharacter c, int npc) {
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.STARTED, npc);
|
||||
newStatus.setForfeited(c.getQuest(this).getForfeited());
|
||||
|
||||
if (timeLimit > 0) {
|
||||
c.questTimeLimit(this, 30000);//timeLimit * 1000
|
||||
}
|
||||
if (timeLimit2 > 0) {//=\
|
||||
|
||||
}
|
||||
c.updateQuest(newStatus);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean forceComplete(MapleCharacter c, int npc) {
|
||||
MapleQuestStatus newStatus = new MapleQuestStatus(this, MapleQuestStatus.Status.COMPLETED, npc);
|
||||
newStatus.setForfeited(c.getQuest(this).getForfeited());
|
||||
newStatus.setCompletionTime(System.currentTimeMillis());
|
||||
c.updateQuest(newStatus);
|
||||
return true;
|
||||
}
|
||||
|
||||
public short getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Integer> getRelevantMobs() {
|
||||
return relevantMobs;
|
||||
}
|
||||
|
||||
public int getItemAmountNeeded(int itemid) {
|
||||
MapleQuestRequirement req = completeReqs.get(MapleQuestRequirementType.ITEM);
|
||||
if(req == null)
|
||||
return 0;
|
||||
|
||||
ItemRequirement ireq = (ItemRequirement) req;
|
||||
|
||||
return ireq.getItemAmountNeeded(itemid);
|
||||
}
|
||||
|
||||
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() {
|
||||
return infoNumber;
|
||||
}
|
||||
|
||||
public String getInfoEx() {
|
||||
MapleQuestRequirement req = startReqs.get(MapleQuestRequirementType.INFO_EX);
|
||||
String ret = "";
|
||||
if(req != null) {
|
||||
InfoExRequirement ireq = (InfoExRequirement) req;
|
||||
ret = ireq.getFirstInfo();
|
||||
} else { // Check complete requirements.
|
||||
req = completeReqs.get(MapleQuestRequirementType.INFO_EX);
|
||||
if(req != null) {
|
||||
InfoExRequirement ireq = (InfoExRequirement) req;
|
||||
ret = ireq.getFirstInfo();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
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_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 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 SCRIPT:
|
||||
case NORMAL_AUTO_START:
|
||||
case START:
|
||||
case END:
|
||||
case INFO_NUMBER:
|
||||
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;
|
||||
default:
|
||||
//FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Unhandled Action Type: " + type.toString() + " QuestID: " + this.getId());
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void loadAllQuest() {
|
||||
questInfo = questData.getData("QuestInfo.img");
|
||||
questReq = questData.getData("Check.img");
|
||||
questAct = questData.getData("Act.img");
|
||||
|
||||
try {
|
||||
for(MapleData quest : questInfo.getChildren()) {
|
||||
int questID = Integer.parseInt(quest.getName());
|
||||
|
||||
quests.put(questID, new MapleQuest(questID));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
69
src/server/quest/MapleQuestActionType.java
Normal file
69
src/server/quest/MapleQuestActionType.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
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), ZERO(14);
|
||||
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("0")) {
|
||||
return ZERO;
|
||||
} else {
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
89
src/server/quest/MapleQuestRequirementType.java
Normal file
89
src/server/quest/MapleQuestRequirementType.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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
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")) {
|
||||
return END;
|
||||
} else if(name.equals("daybyday")) {
|
||||
return DAY_BY_DAY;
|
||||
} else {
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/server/quest/actions/BuffAction.java
Normal file
53
src/server/quest/actions/BuffAction.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.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 void processData(MapleData data) {
|
||||
itemEffect = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider.getInstance().getItemEffect(itemEffect).applyTo(chr);
|
||||
}
|
||||
}
|
||||
56
src/server/quest/actions/ExpAction.java
Normal file
56
src/server/quest/actions/ExpAction.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.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
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) {
|
||||
if (chr.isBeginnerJob()) {
|
||||
chr.gainExp(exp, true, true);
|
||||
} else {
|
||||
chr.gainExp(exp * chr.getExpRate(), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/server/quest/actions/FameAction.java
Normal file
57
src/server/quest/actions/FameAction.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 client.MapleStat;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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.addFame(fame);
|
||||
chr.updateSingleStat(MapleStat.FAME, chr.getFame());
|
||||
chr.announce(MaplePacketCreator.getShowFameGain(fame));
|
||||
}
|
||||
}
|
||||
224
src/server/quest/actions/ItemAction.java
Normal file
224
src/server/quest/actions/ItemAction.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
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.inventory.Item;
|
||||
import client.inventory.MapleInventory;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ItemAction extends MapleQuestAction {
|
||||
Map<Integer, ItemData> items = new HashMap<>();
|
||||
|
||||
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);
|
||||
|
||||
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.put(id, new ItemData(id, count, prop, job, gender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
Map<Integer, Integer> props = new HashMap<>();
|
||||
for(ItemData item : items.values()) {
|
||||
if(item.getProp() != null && item.getProp() != -1 && canGetItem(item, chr)) {
|
||||
for (int i = 0; i < item.getProp(); i++) {
|
||||
props.put(props.size(), item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
int selection = 0;
|
||||
int extNum = 0;
|
||||
if (props.size() > 0) {
|
||||
selection = props.get(Randomizer.nextInt(props.size()));
|
||||
}
|
||||
for (ItemData iEntry : items.values()) {
|
||||
if (!canGetItem(iEntry, chr)) {
|
||||
continue;
|
||||
}
|
||||
if(iEntry.getProp() != null) {
|
||||
if(iEntry.getProp() == -1) {
|
||||
if(extSelection != extNum++)
|
||||
continue;
|
||||
} else if(iEntry.getId() != selection)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(iEntry.getCount() < 0) { // Remove Items
|
||||
MapleInventoryType type = ii.getInventoryType(iEntry.getId());
|
||||
int quantity = iEntry.getCount() * -1; // Invert
|
||||
if(type.equals(MapleInventoryType.EQUIP)) {
|
||||
if(chr.getInventory(type).countById(iEntry.getId()) < quantity) {
|
||||
// Not enough in the equip inventoty, so check Equipped...
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(iEntry.getId()) > quantity) {
|
||||
// Found it equipped, so change the type to equipped.
|
||||
type = MapleInventoryType.EQUIPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
MapleInventoryManipulator.removeById(chr.getClient(), type, iEntry.getId(), quantity, true, false);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getId(), (short) iEntry.getCount(), true));
|
||||
} else {
|
||||
if (chr.getInventory(MapleItemInformationProvider.getInstance().getInventoryType(iEntry.getId())).getNextFreeSlot() > -1) {
|
||||
MapleInventoryManipulator.addById(chr.getClient(), iEntry.getId(), (short) iEntry.getCount());
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getId(), (short) iEntry.getCount(), true));
|
||||
} else {
|
||||
chr.dropMessage(1, "Inventory Full");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
EnumMap<MapleInventoryType, Integer> props = new EnumMap<>(MapleInventoryType.class);
|
||||
List<Pair<Item, MapleInventoryType>> itemList = new ArrayList<>();
|
||||
for(ItemData item : items.values()) {
|
||||
if (!canGetItem(item, chr)) {
|
||||
continue;
|
||||
}
|
||||
MapleInventoryType type = ii.getInventoryType(item.getId());
|
||||
if(item.getProp() != null) {
|
||||
if(!props.containsKey(type)) {
|
||||
props.put(type, item.getId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item.getCount() > 0) {
|
||||
// Make sure they can hold the item.
|
||||
Item toItem = new Item(item.getId(), (short) 0, (short) item.getCount());
|
||||
itemList.add(new Pair<>(toItem, type));
|
||||
} else {
|
||||
// Make sure they actually have the item.
|
||||
int quantity = item.getCount() * -1;
|
||||
if(chr.getInventory(type).countById(item.getId()) < quantity) {
|
||||
if(type.equals(MapleInventoryType.EQUIP) && chr.getInventory(MapleInventoryType.EQUIPPED).countById(item.getId()) > quantity)
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Integer itemID : props.values()) {
|
||||
MapleInventoryType type = ii.getInventoryType(itemID);
|
||||
Item toItem = new Item(itemID, (short) 0, (short) 1);
|
||||
itemList.add(new Pair<>(toItem, type));
|
||||
}
|
||||
|
||||
if (!MapleInventory.checkSpots(chr, itemList)) {
|
||||
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canGetItem(ItemData item, MapleCharacter chr) {
|
||||
if (item.getGender() != 2 && item.getGender() != chr.getGender()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(item.getJob() != -1) {
|
||||
if (item.getJob() != chr.getJob().getId()) {
|
||||
return false;
|
||||
} else if (MapleJob.getBy5ByteEncoding(item.getJob()).getId() / 100 != chr.getJob().getId() / 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private class ItemData {
|
||||
private final int id, count, job, gender;
|
||||
private final Integer prop;
|
||||
|
||||
public ItemData(int id, int count, Integer prop, int job, int gender) {
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
this.prop = prop;
|
||||
this.job = job;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/server/quest/actions/MapleQuestAction.java
Normal file
39
src/server/quest/actions/MapleQuestAction.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
return !(status.getStatus() == MapleQuestStatus.Status.NOT_STARTED && status.getForfeited() > 0);
|
||||
}
|
||||
|
||||
public MapleQuestActionType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
53
src/server/quest/actions/MesoAction.java
Normal file
53
src/server/quest/actions/MesoAction.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 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) {
|
||||
chr.gainMeso(mesos < 0 ? mesos : mesos * chr.getMesoRate(), true, false, true);
|
||||
}
|
||||
}
|
||||
55
src/server/quest/actions/NextQuestAction.java
Normal file
55
src/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/server/quest/actions/PetSkillAction.java
Normal file
64
src/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.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));
|
||||
}
|
||||
}
|
||||
64
src/server/quest/actions/QuestAction.java
Normal file
64
src/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.updateQuest(new MapleQuestStatus(MapleQuest.getInstance(questID), MapleQuestStatus.Status.getById(stat)));
|
||||
}
|
||||
}
|
||||
}
|
||||
120
src/server/quest/actions/SkillAction.java
Normal file
120
src/server/quest/actions/SkillAction.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
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());
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
53
src/server/quest/requirements/CompletedQuestRequirement.java
Normal file
53
src/server/quest/requirements/CompletedQuestRequirement.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.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;
|
||||
}
|
||||
}
|
||||
60
src/server/quest/requirements/EndDateRequirement.java
Normal file
60
src/server/quest/requirements/EndDateRequirement.java
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
56
src/server/quest/requirements/FieldEnterRequirement.java
Normal file
56
src/server/quest/requirements/FieldEnterRequirement.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 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();
|
||||
}
|
||||
}
|
||||
71
src/server/quest/requirements/InfoExRequirement.java
Normal file
71
src/server/quest/requirements/InfoExRequirement.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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 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);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
@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) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
return infoExpected.contains(status.getInfo());
|
||||
}
|
||||
|
||||
public List<String> getInfo() {
|
||||
return infoExpected;
|
||||
}
|
||||
|
||||
public String getFirstInfo() {
|
||||
return !infoExpected.isEmpty() ? infoExpected.get(0) : "";
|
||||
}
|
||||
}
|
||||
58
src/server/quest/requirements/IntervalRequirement.java
Normal file
58
src/server/quest/requirements/IntervalRequirement.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
interval = MapleDataTool.getInt(data) * 60 * 1000;
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
return check || check2;
|
||||
}
|
||||
}
|
||||
96
src/server/quest/requirements/ItemRequirement.java
Normal file
96
src/server/quest/requirements/ItemRequirement.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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 = ii.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)) {
|
||||
for (Item item : chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemId)) {
|
||||
count += item.getQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
if(count < countNeeded || countNeeded <= 0 && count > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getItemAmountNeeded(int itemid) {
|
||||
if(items.containsKey(itemid)) {
|
||||
return items.get(itemid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
67
src/server/quest/requirements/JobRequirement.java
Normal file
67
src/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;
|
||||
}
|
||||
}
|
||||
56
src/server/quest/requirements/MapleQuestRequirement.java
Normal file
56
src/server/quest/requirements/MapleQuestRequirement.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 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;
|
||||
}
|
||||
}
|
||||
57
src/server/quest/requirements/MaxLevelRequirement.java
Normal file
57
src/server/quest/requirements/MaxLevelRequirement.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.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();
|
||||
}
|
||||
}
|
||||
54
src/server/quest/requirements/MinLevelRequirement.java
Normal file
54
src/server/quest/requirements/MinLevelRequirement.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
67
src/server/quest/requirements/MinTamenessRequirement.java
Normal file
67
src/server/quest/requirements/MinTamenessRequirement.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 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/server/quest/requirements/MobRequirement.java
Normal file
89
src/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);
|
||||
processData(data);
|
||||
questID = quest.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
55
src/server/quest/requirements/NpcRequirement.java
Normal file
55
src/server/quest/requirements/NpcRequirement.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.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;
|
||||
private final boolean autoComplete, autoStart;
|
||||
|
||||
public NpcRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.NPC);
|
||||
processData(data);
|
||||
this.autoComplete = quest.isAutoComplete();
|
||||
this.autoStart = quest.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
reqNPC = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return npcid != null && npcid == reqNPC && (autoComplete || autoStart || chr.getMap().containsNPC(npcid));
|
||||
}
|
||||
}
|
||||
64
src/server/quest/requirements/PetRequirement.java
Normal file
64
src/server/quest/requirements/PetRequirement.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.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(petIDs.contains(pet.getItemId()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
60
src/server/quest/requirements/QuestRequirement.java
Normal file
60
src/server/quest/requirements/QuestRequirement.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
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 q = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
|
||||
if(q == null && MapleQuestStatus.Status.getById(stateReq).equals(MapleQuestStatus.Status.NOT_STARTED))
|
||||
continue;
|
||||
|
||||
if(q == null || !q.getStatus().equals(MapleQuestStatus.Status.getById(stateReq))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user