Masteria NPCs & Quests
Added more NPCs for the Phantom Woods and Crimsonwood areas. Enabled more quests on that area.
This commit is contained in:
@@ -28,6 +28,7 @@ import scripting.npc.NPCScriptManager;
|
||||
import server.life.MapleNPC;
|
||||
import server.maps.MapleMapObject;
|
||||
import server.maps.PlayerNPCs;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
|
||||
@@ -38,8 +39,10 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(System.currentTimeMillis() - c.getPlayer().getNpcCooldown() < ServerConstants.BLOCK_NPC_RACE_CONDT)
|
||||
if(System.currentTimeMillis() - c.getPlayer().getNpcCooldown() < ServerConstants.BLOCK_NPC_RACE_CONDT) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
int oid = slea.readInt();
|
||||
MapleMapObject obj = c.getPlayer().getMap().getMapObject(oid);
|
||||
@@ -50,11 +53,6 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
if (npc.getId() == 9010009) { //is duey
|
||||
c.getPlayer().setNpcCooldown(System.currentTimeMillis());
|
||||
c.announce(MaplePacketCreator.sendDuey((byte) 8, DueyHandler.loadItems(c.getPlayer())));
|
||||
} else if (npc.hasShop()) {
|
||||
if (c.getPlayer().getShop() != null) {
|
||||
return;
|
||||
}
|
||||
npc.sendShop(c);
|
||||
} else {
|
||||
if (c.getCM() != null || c.getQM() != null) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
@@ -64,7 +62,18 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
// Custom handling for gachapon scripts to reduce the amount of scripts needed.
|
||||
NPCScriptManager.getInstance().start(c, npc.getId(), "gachapon", null);
|
||||
} else {
|
||||
NPCScriptManager.getInstance().start(c, npc.getId(), null);
|
||||
boolean hasNpcScript = NPCScriptManager.getInstance().start(c, npc.getId(), null);
|
||||
if (!hasNpcScript) {
|
||||
if (!npc.hasShop()) {
|
||||
FilePrinter.printError(FilePrinter.NPC_UNCODED, "NPC " + npc.getName() + "(" + npc.getId() + ") is not coded.\r\n");
|
||||
return;
|
||||
} else if(c.getPlayer().getShop() != null) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
npc.sendShop(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof PlayerNPCs) {
|
||||
|
||||
@@ -233,13 +233,17 @@ public class AbstractPlayerInteraction {
|
||||
c.getPlayer().updateQuest(status);
|
||||
}
|
||||
|
||||
public MapleQuestStatus.Status getQuestStatus(int id) {
|
||||
return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus();
|
||||
public int getQuestStatus(int id) {
|
||||
return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus().getId();
|
||||
}
|
||||
|
||||
|
||||
private MapleQuestStatus.Status getQuestStat(int id) {
|
||||
return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus();
|
||||
}
|
||||
|
||||
public boolean isQuestCompleted(int quest) {
|
||||
try {
|
||||
return getQuestStatus(quest) == MapleQuestStatus.Status.COMPLETED;
|
||||
return getQuestStat(quest) == MapleQuestStatus.Status.COMPLETED;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@@ -252,7 +256,7 @@ public class AbstractPlayerInteraction {
|
||||
|
||||
public boolean isQuestStarted(int quest) {
|
||||
try {
|
||||
return getQuestStatus(quest) == MapleQuestStatus.Status.STARTED;
|
||||
return getQuestStat(quest) == MapleQuestStatus.Status.STARTED;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
||||
@@ -38,6 +38,7 @@ import provider.MapleDataProviderFactory;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.MapleStatEffect;
|
||||
import server.MapleShopFactory;
|
||||
import server.events.gm.MapleEvent;
|
||||
import server.gachapon.MapleGachapon;
|
||||
import server.gachapon.MapleGachapon.MapleGachaponItem;
|
||||
@@ -315,6 +316,10 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
public void resetStats() {
|
||||
getPlayer().resetStats();
|
||||
}
|
||||
|
||||
public void openShopNPC(int id) {
|
||||
MapleShopFactory.getInstance().getShop(id).sendShop(c);
|
||||
}
|
||||
|
||||
public void maxMastery() {
|
||||
for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
|
||||
|
||||
@@ -50,11 +50,11 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void start(MapleClient c, int npc, MapleCharacter chr) {
|
||||
start(c, npc, null, chr);
|
||||
public boolean start(MapleClient c, int npc, MapleCharacter chr) {
|
||||
return start(c, npc, null, chr);
|
||||
}
|
||||
|
||||
public void start(MapleClient c, int npc, String fileName, MapleCharacter chr) {
|
||||
public boolean start(MapleClient c, int npc, String fileName, MapleCharacter chr) {
|
||||
try {
|
||||
NPCConversationManager cm = new NPCConversationManager(c, npc, fileName);
|
||||
if (cms.containsKey(c)) {
|
||||
@@ -69,12 +69,9 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
if (iv == null) {
|
||||
iv = getInvocable("npc/" + npc + ".js", c);
|
||||
}
|
||||
if (iv == null) {
|
||||
FilePrinter.printError(FilePrinter.NPC_UNCODED, "NPC " + MapleLifeFactory.getNPC(npc).getName() + "(" + npc + ") is not coded.\r\n");
|
||||
}
|
||||
if (iv == null || NPCScriptManager.getInstance() == null) {
|
||||
dispose(c);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
engine.put("cm", cm);
|
||||
scripts.put(c, iv);
|
||||
@@ -91,12 +88,18 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (final UndeclaredThrowableException | ScriptException ute) {
|
||||
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", ute);
|
||||
dispose(c);
|
||||
|
||||
return false;
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.NPC + npc + ".txt", e);
|
||||
dispose(c);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,10 +135,10 @@ public class MapleQuest {
|
||||
if (startActData != null) {
|
||||
for (MapleData startAct : startActData.getChildren()) {
|
||||
MapleQuestActionType questActionType = MapleQuestActionType.getByWZName(startAct.getName());
|
||||
MapleQuestAction act = this.getAction(questActionType, startAct);
|
||||
MapleQuestAction act = this.getAction(questActionType, startAct);
|
||||
|
||||
if(act == null)
|
||||
continue;
|
||||
if(act == null)
|
||||
continue;
|
||||
|
||||
startActs.put(questActionType, act);
|
||||
}
|
||||
@@ -146,11 +146,11 @@ public class MapleQuest {
|
||||
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;
|
||||
MapleQuestActionType questActionType = MapleQuestActionType.getByWZName(completeAct.getName());
|
||||
MapleQuestAction act = this.getAction(questActionType, completeAct);
|
||||
|
||||
if(act == null)
|
||||
continue;
|
||||
|
||||
completeActs.put(questActionType, act);
|
||||
}
|
||||
@@ -158,11 +158,11 @@ public class MapleQuest {
|
||||
}
|
||||
|
||||
public boolean isAutoComplete() {
|
||||
return autoPreComplete || autoComplete;
|
||||
return autoPreComplete || autoComplete;
|
||||
}
|
||||
|
||||
public boolean isAutoStart() {
|
||||
return autoStart;
|
||||
return autoStart;
|
||||
}
|
||||
|
||||
public static MapleQuest getInstance(int id) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ItemAction extends MapleQuestAction {
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
Map<Integer, Integer> props = new HashMap<>();
|
||||
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++) {
|
||||
@@ -133,7 +133,7 @@ public class ItemAction extends MapleQuestAction {
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
EnumMap<MapleInventoryType, Integer> props = new EnumMap<>(MapleInventoryType.class);
|
||||
EnumMap<MapleInventoryType, Integer> props = new EnumMap<>(MapleInventoryType.class);
|
||||
List<Pair<Item, MapleInventoryType>> itemList = new ArrayList<>();
|
||||
for(ItemData item : items.values()) {
|
||||
if (!canGetItem(item, chr)) {
|
||||
|
||||
Reference in New Issue
Block a user