Quest progress overview + Raise UI scripting + Shelved events loadout
Performed a syllabus over quest progress tracking. Quests that were supposed to show up as startable/completable upon achieved progress should be able to do so. Reviewed progress tracking on scripts to adequate to this scenario. Fixed some scenarios on where quest dialog popups would appear when updating a quest progress. Fixed some scripts not using updated package addresses after the recent package refactor. Reviewed Raise UI, no longer rendering players unable to access CS/MTS in certain scenarios. Fixed a check of available space in inventory, when trying to obtain items from quests, not informing the player it happened due to a one-of-a-kind item already present. Fixed quest dialog (feature present in many quests) not showing to players when completing it. Fixed several issues with the Cygnus 1st job advancement quests. Added scripting within Raise UI open action. Mimiana egg uses this to keep track of player's EXP progress. Fixed pets not getting despawned as expiration takes place. Fixed hidden players being able to control mobs when either entering map or hidden state. Fixed estimated HP/MP alert not taking bonuses (such as from buffs or equipments) into account. Fixed Energy Charge refreshing buff time upon touching mobs, skewing the uptime of the skill's stat buffs. Switched SnakeYaml for YamlBeans, which makes up for a single JAR artifact. Refactored a channel's event scripts loadout, now taking place after the server bootup phase.
This commit is contained in:
@@ -365,28 +365,7 @@ public class AbstractPlayerInteraction {
|
||||
NPCScriptManager.getInstance().start(c, npcid, script, null);
|
||||
}
|
||||
|
||||
public void updateQuest(int questid, int data) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(questid));
|
||||
updateQuest(questid, status.getAnyProgressKey(), data);
|
||||
}
|
||||
|
||||
public void updateQuest(int questid, String data) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(questid));
|
||||
updateQuest(questid, status.getAnyProgressKey(), data);
|
||||
}
|
||||
|
||||
public void updateQuest(int questid, int pid, int data) {
|
||||
updateQuest(questid, pid, String.valueOf(data));
|
||||
}
|
||||
|
||||
public void updateQuest(int questid, int pid, String data) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(questid));
|
||||
status.setStatus(MapleQuestStatus.Status.STARTED);
|
||||
status.setProgress(pid, data);//override old if exists
|
||||
c.getPlayer().updateQuest(status);
|
||||
}
|
||||
|
||||
public int getQuestStatus(int id) {
|
||||
public int getQuestStatus(int id) {
|
||||
return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus().getId();
|
||||
}
|
||||
|
||||
@@ -394,75 +373,93 @@ public class AbstractPlayerInteraction {
|
||||
return c.getPlayer().getQuest(MapleQuest.getInstance(id)).getStatus();
|
||||
}
|
||||
|
||||
public boolean isQuestCompleted(int quest) {
|
||||
public boolean isQuestCompleted(int id) {
|
||||
try {
|
||||
return getQuestStat(quest) == MapleQuestStatus.Status.COMPLETED;
|
||||
return getQuestStat(id) == MapleQuestStatus.Status.COMPLETED;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isQuestActive(int quest) {
|
||||
return isQuestStarted(quest);
|
||||
public boolean isQuestActive(int id) {
|
||||
return isQuestStarted(id);
|
||||
}
|
||||
|
||||
public boolean isQuestStarted(int quest) {
|
||||
public boolean isQuestStarted(int id) {
|
||||
try {
|
||||
return getQuestStat(quest) == MapleQuestStatus.Status.STARTED;
|
||||
return getQuestStat(id) == MapleQuestStatus.Status.STARTED;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuestProgress(int qid, int progress) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(qid));
|
||||
status.setProgress(status.getAnyProgressKey(), String.valueOf(progress));
|
||||
public void setQuestProgress(int id, String progress) {
|
||||
setQuestProgress(id, 0, progress);
|
||||
}
|
||||
|
||||
public void setQuestProgress(int qid, int pid, int progress) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(qid));
|
||||
status.setProgress(pid, String.valueOf(progress));
|
||||
}
|
||||
|
||||
public void setStringQuestProgress(int qid, int pid, String progress) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(qid));
|
||||
status.setProgress(pid, progress);
|
||||
public void setQuestProgress(int id, int progress) {
|
||||
setQuestProgress(id, 0, "" + progress);
|
||||
}
|
||||
|
||||
public int getQuestProgress(int qid) {
|
||||
MapleQuestStatus status = c.getPlayer().getQuest(MapleQuest.getInstance(qid));
|
||||
String progress = status.getProgress(status.getAnyProgressKey());
|
||||
|
||||
if (progress.isEmpty()) {
|
||||
public void setQuestProgress(int id, int infoNumber, int progress) {
|
||||
setQuestProgress(id, infoNumber, "" + progress);
|
||||
}
|
||||
|
||||
public void setQuestProgress(int id, int infoNumber, String progress) {
|
||||
c.getPlayer().setQuestProgress(id, infoNumber, progress);
|
||||
}
|
||||
|
||||
public String getQuestProgress(int id) {
|
||||
return getQuestProgress(id, 0);
|
||||
}
|
||||
|
||||
public String getQuestProgress(int id, int infoNumber) {
|
||||
MapleQuestStatus qs = getPlayer().getQuest(MapleQuest.getInstance(id));
|
||||
|
||||
if (qs.getInfoNumber() == infoNumber && infoNumber > 0) {
|
||||
qs = getPlayer().getQuest(MapleQuest.getInstance(infoNumber));
|
||||
infoNumber = 0;
|
||||
}
|
||||
|
||||
if (qs != null) {
|
||||
return qs.getProgress(infoNumber);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public int getQuestProgressInt(int id) {
|
||||
try {
|
||||
return Integer.valueOf(getQuestProgress(id));
|
||||
} catch (NumberFormatException nfe) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(progress);
|
||||
}
|
||||
|
||||
public int getQuestProgress(int qid, int pid) {
|
||||
if (getPlayer().getQuest(MapleQuest.getInstance(qid)).getProgress(pid).isEmpty()) {
|
||||
return 0;
|
||||
public int getQuestProgressInt(int id, int infoNumber) {
|
||||
try {
|
||||
return Integer.valueOf(getQuestProgress(id, infoNumber));
|
||||
} catch (NumberFormatException nfe) {
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(getPlayer().getQuest(MapleQuest.getInstance(qid)).getProgress(pid));
|
||||
}
|
||||
}
|
||||
|
||||
public String getStringQuestProgress(int qid, int pid) {
|
||||
if (getPlayer().getQuest(MapleQuest.getInstance(qid)).getProgress(pid).isEmpty()) {
|
||||
return "";
|
||||
public void resetAllQuestProgress(int id) {
|
||||
MapleQuestStatus qs = getPlayer().getQuest(MapleQuest.getInstance(id));
|
||||
if (qs != null) {
|
||||
qs.resetAllProgress();
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, qs, false);
|
||||
}
|
||||
return getPlayer().getQuest(MapleQuest.getInstance(qid)).getProgress(pid);
|
||||
}
|
||||
|
||||
public void resetAllQuestProgress(int qid) {
|
||||
getPlayer().getQuest(MapleQuest.getInstance(qid)).resetAllProgress();
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, getPlayer().getQuest(MapleQuest.getInstance(qid)), false);
|
||||
}
|
||||
|
||||
public void resetQuestProgress(int qid, int pid) {
|
||||
getPlayer().getQuest(MapleQuest.getInstance(qid)).resetProgress(pid);
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, getPlayer().getQuest(MapleQuest.getInstance(qid)), false);
|
||||
public void resetQuestProgress(int id, int infoNumber) {
|
||||
MapleQuestStatus qs = getPlayer().getQuest(MapleQuest.getInstance(id));
|
||||
if (qs != null) {
|
||||
qs.resetProgress(infoNumber);
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, qs, false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean forceStartQuest(int id) {
|
||||
@@ -497,26 +494,26 @@ public class AbstractPlayerInteraction {
|
||||
return completeQuest(id, 9010000);
|
||||
}
|
||||
|
||||
public boolean startQuest(short id, int npcId) {
|
||||
return startQuest((int) id, npcId);
|
||||
public boolean startQuest(short id, int npc) {
|
||||
return startQuest((int) id, npc);
|
||||
}
|
||||
|
||||
public boolean completeQuest(short id, int npcId) {
|
||||
return completeQuest((int) id, npcId);
|
||||
public boolean completeQuest(short id, int npc) {
|
||||
return completeQuest((int) id, npc);
|
||||
}
|
||||
|
||||
public boolean startQuest(int id, int npcId) {
|
||||
public boolean startQuest(int id, int npc) {
|
||||
try {
|
||||
return MapleQuest.getInstance(id).forceStart(getPlayer(), npcId);
|
||||
return MapleQuest.getInstance(id).forceStart(getPlayer(), npc);
|
||||
} catch (NullPointerException ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean completeQuest(int id, int npcId) {
|
||||
public boolean completeQuest(int id, int npc) {
|
||||
try {
|
||||
return MapleQuest.getInstance(id).forceComplete(getPlayer(), npcId);
|
||||
return MapleQuest.getInstance(id).forceComplete(getPlayer(), npc);
|
||||
} catch (NullPointerException ex) {
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
@@ -682,6 +679,10 @@ public class AbstractPlayerInteraction {
|
||||
public void message(String message) {
|
||||
getPlayer().message(message);
|
||||
}
|
||||
|
||||
public void dropMessage(int type, String message) {
|
||||
getPlayer().dropMessage(type, message);
|
||||
}
|
||||
|
||||
public void mapMessage(int type, String message) {
|
||||
getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(type, message));
|
||||
|
||||
@@ -898,7 +898,7 @@ public class EventInstanceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchUpdateQuestMobCount(int mobid, int mapid) {
|
||||
public void dispatchRaiseQuestMobCount(int mobid, int mapid) {
|
||||
Map<Integer, MapleCharacter> mapChars = getInstanceMap(mapid).getMapPlayers();
|
||||
if(!mapChars.isEmpty()) {
|
||||
List<MapleCharacter> eventMembers = getPlayers();
|
||||
@@ -907,7 +907,7 @@ public class EventInstanceManager {
|
||||
MapleCharacter chr = mapChars.get(evChr.getId());
|
||||
|
||||
if(chr != null && chr.isLoggedinWorld()) {
|
||||
chr.updateQuestMobCount(mobid);
|
||||
chr.raiseQuestMobCount(mobid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
|
||||
import net.server.channel.Channel;
|
||||
@@ -48,7 +47,9 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
public NashornScriptEngine iv;
|
||||
public EventManager em;
|
||||
}
|
||||
|
||||
private Map<String, EventEntry> events = new LinkedHashMap<>();
|
||||
private boolean active = false;
|
||||
|
||||
public EventScriptManager(Channel cserv, String[] scripts) {
|
||||
super();
|
||||
@@ -67,6 +68,10 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
return entry.em;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
for (EventEntry entry : events.values()) {
|
||||
@@ -78,6 +83,8 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
System.out.println("Error on script: " + entry.em.getName());
|
||||
}
|
||||
}
|
||||
|
||||
active = true;
|
||||
}
|
||||
|
||||
private void reloadScripts() {
|
||||
@@ -100,6 +107,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
active = false;
|
||||
for (EventEntry entry : events.values()) {
|
||||
entry.em.cancel();
|
||||
}
|
||||
|
||||
@@ -94,13 +94,13 @@ public class MapScriptMethods extends AbstractPlayerInteraction {
|
||||
return;
|
||||
}
|
||||
}
|
||||
MapleQuestStatus q = getPlayer().getQuest(quest);
|
||||
if (!q.addMedalMap(getPlayer().getMapId())) {
|
||||
MapleQuestStatus qs = getPlayer().getQuest(quest);
|
||||
if (!qs.addMedalMap(getPlayer().getMapId())) {
|
||||
return;
|
||||
}
|
||||
String status = Integer.toString(q.getMedalProgress());
|
||||
String infoex = quest.getInfoEx();
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, q, true);
|
||||
String status = Integer.toString(qs.getMedalProgress());
|
||||
String infoex = qs.getInfoEx(0);
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, qs, true);
|
||||
StringBuilder smp = new StringBuilder();
|
||||
StringBuilder etm = new StringBuilder();
|
||||
if (status.equals(infoex)) {
|
||||
@@ -123,15 +123,15 @@ public class MapScriptMethods extends AbstractPlayerInteraction {
|
||||
return;
|
||||
}
|
||||
}
|
||||
MapleQuestStatus q = getPlayer().getQuest(quest);
|
||||
if (!q.addMedalMap(getPlayer().getMapId())) {
|
||||
MapleQuestStatus qs = getPlayer().getQuest(quest);
|
||||
if (!qs.addMedalMap(getPlayer().getMapId())) {
|
||||
return;
|
||||
}
|
||||
String status = Integer.toString(q.getMedalProgress());
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, q, true);
|
||||
String status = Integer.toString(qs.getMedalProgress());
|
||||
getPlayer().announceUpdateQuest(DelayedQuestUpdate.UPDATE, qs, true);
|
||||
getPlayer().announce(MaplePacketCreator.earnTitleMessage(status + "/5 Completed"));
|
||||
getPlayer().announce(MaplePacketCreator.earnTitleMessage("The One Who's Touched the Sky title in progress."));
|
||||
if (Integer.toString(q.getMedalProgress()).equals(quest.getInfoEx())) {
|
||||
if (Integer.toString(qs.getMedalProgress()).equals(qs.getInfoEx(0))) {
|
||||
showInfoText("The One Who's Touched the Sky" + rewardstring);
|
||||
getPlayer().announce(MaplePacketCreator.getShowQuestCompletion(quest.getId()));
|
||||
} else {
|
||||
|
||||
@@ -579,7 +579,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
return itemid != baseid && itemExists(baseid) ? baseid : -1;
|
||||
}
|
||||
|
||||
private int getEquippedItemid(int itemid) {
|
||||
private int getEquippedCosmeticid(int itemid) {
|
||||
if (itemid < 30000) {
|
||||
return getPlayer().getFace();
|
||||
} else {
|
||||
@@ -588,7 +588,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public boolean isCosmeticEquipped(int itemid) {
|
||||
return getEquippedItemid(itemid) == itemid;
|
||||
return getEquippedCosmeticid(itemid) == itemid;
|
||||
}
|
||||
|
||||
public boolean isUsingOldPqNpcStyle() {
|
||||
|
||||
@@ -59,10 +59,6 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
|
||||
public void start(MapleClient c, short questid, int npc) {
|
||||
MapleQuest quest = MapleQuest.getInstance(questid);
|
||||
if (!quest.canStartWithoutRequirements(c.getPlayer())) {
|
||||
dispose(c);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||
if (qms.containsKey(c)) {
|
||||
@@ -169,6 +165,36 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void raiseOpen(MapleClient c, short questid, int npc) {
|
||||
try {
|
||||
QuestActionManager qm = new QuestActionManager(c, questid, npc, true);
|
||||
if (qms.containsKey(c)) {
|
||||
return;
|
||||
}
|
||||
if(c.canClickNPC()) {
|
||||
qms.put(c, qm);
|
||||
|
||||
NashornScriptEngine iv = getQuestScriptEngine(c, questid);
|
||||
if (iv == null) {
|
||||
//FilePrinter.printError(FilePrinter.QUEST_UNCODED, "RAISE Quest " + questid + " is uncoded.");
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
iv.put("qm", qm);
|
||||
scripts.put(c, iv);
|
||||
c.setClickedNPC();
|
||||
iv.invokeFunction("raiseOpen");
|
||||
}
|
||||
} catch (final UndeclaredThrowableException ute) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
|
||||
dispose(c);
|
||||
} catch (final Throwable t) {
|
||||
FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
|
||||
dispose(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose(QuestActionManager qm, MapleClient c) {
|
||||
qms.remove(c);
|
||||
scripts.remove(c);
|
||||
|
||||
Reference in New Issue
Block a user