Knights' Seal & I. MaxHP + Adherent mob status + Script point-warps
Fixed Seal skill not working for Blaze Wizard. Added a check against Seal skill on bosses. Reviewed improper usage of "random spawn point arrival" at several warps on scripts. Refactored CPQ modules fetching players from the channel storage, this should be unneeded after a recent update on the player object from MPC. Added door objects as a visible map object for the player server-side view component. Fixed a few scenarios where mobs would unexpectedly show up impervious to mob status. Fixed scenario where a player wouldn't receive disease informations from other players after changing maps. Fixed some magic-type skills (such as Magic Claw or Freeze) not displaying damage value for other players when the player is within melee-range from the mob. Added check for whether a given quest is scripted before trying to find the script. Fixed registering items onto MTS leading to loss of a few of its properties (expiration, item level, etc). Fixed "Improved MaxHP" skill gains not working for Thunderbreakers. Refactored pet autopot to also apply on HP/MP consumption by items/skills. Added portal sound effect on Mystic Doors.
This commit is contained in:
@@ -65,9 +65,7 @@ public abstract class AbstractScriptManager {
|
||||
}
|
||||
|
||||
protected NashornScriptEngine getScriptEngine(String path, MapleClient c) {
|
||||
String cachePath = "scripts/" + path;
|
||||
NashornScriptEngine engine = c.getScriptEngine(cachePath);
|
||||
|
||||
NashornScriptEngine engine = c.getScriptEngine("scripts/" + path);
|
||||
if (engine == null) {
|
||||
engine = getScriptEngine(path);
|
||||
c.setScriptEngine(path, engine);
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import constants.ServerConstants;
|
||||
@@ -59,6 +58,7 @@ import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
import net.server.audit.LockCollector;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
@@ -72,7 +72,7 @@ import server.ThreadManager;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class EventManager {
|
||||
private Invocable iv;
|
||||
private NashornScriptEngine iv;
|
||||
private Channel cserv;
|
||||
private World wserv;
|
||||
private Server server;
|
||||
@@ -95,7 +95,7 @@ public class EventManager {
|
||||
|
||||
private static final int maxLobbys = 8; // an event manager holds up to this amount of concurrent lobbys
|
||||
|
||||
public EventManager(Channel cserv, Invocable iv, String name) {
|
||||
public EventManager(Channel cserv, NashornScriptEngine iv, String name) {
|
||||
this.server = Server.getInstance();
|
||||
this.iv = iv;
|
||||
this.cserv = cserv;
|
||||
@@ -256,7 +256,7 @@ public class EventManager {
|
||||
return cserv;
|
||||
}
|
||||
|
||||
public Invocable getIv() {
|
||||
public NashornScriptEngine getIv() {
|
||||
return iv;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
|
||||
import net.server.channel.Channel;
|
||||
import scripting.AbstractScriptManager;
|
||||
@@ -41,11 +41,11 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
|
||||
private class EventEntry {
|
||||
|
||||
public EventEntry(Invocable iv, EventManager em) {
|
||||
public EventEntry(NashornScriptEngine iv, EventManager em) {
|
||||
this.iv = iv;
|
||||
this.em = em;
|
||||
}
|
||||
public Invocable iv;
|
||||
public NashornScriptEngine iv;
|
||||
public EventManager em;
|
||||
}
|
||||
private Map<String, EventEntry> events = new LinkedHashMap<>();
|
||||
@@ -54,7 +54,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
super();
|
||||
for (String script : scripts) {
|
||||
if (!script.equals("")) {
|
||||
Invocable iv = getScriptEngine("event/" + script + ".js");
|
||||
NashornScriptEngine iv = getScriptEngine("event/" + script + ".js");
|
||||
events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script)));
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
public void init() {
|
||||
for (EventEntry entry : events.values()) {
|
||||
try {
|
||||
((ScriptEngine) entry.iv).put("em", entry.em);
|
||||
entry.iv.put("em", entry.em);
|
||||
entry.iv.invokeFunction("init", (Object) null);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(EventScriptManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@@ -88,7 +88,7 @@ public class EventScriptManager extends AbstractScriptManager {
|
||||
Channel cserv = events.values().iterator().next().em.getChannelServer();
|
||||
for (Entry<String, EventEntry> entry : events.entrySet()) {
|
||||
String script = entry.getKey();
|
||||
Invocable iv = getScriptEngine("event/" + script + ".js");
|
||||
NashornScriptEngine iv = getScriptEngine("event/" + script + ".js");
|
||||
events.put(script, new EventEntry(iv, new EventManager(cserv, iv, script)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,23 +21,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package scripting.map;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.script.Compilable;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
import scripting.AbstractScriptManager;
|
||||
import tools.FilePrinter;
|
||||
|
||||
public class MapScriptManager {
|
||||
public class MapScriptManager extends AbstractScriptManager {
|
||||
|
||||
private static MapScriptManager instance = new MapScriptManager();
|
||||
|
||||
@@ -45,7 +41,7 @@ public class MapScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Map<String, Invocable> scripts = new HashMap<>();
|
||||
private Map<String, NashornScriptEngine> scripts = new HashMap<>();
|
||||
private ScriptEngineFactory sef;
|
||||
|
||||
private MapScriptManager() {
|
||||
@@ -57,53 +53,42 @@ public class MapScriptManager {
|
||||
scripts.clear();
|
||||
}
|
||||
|
||||
public boolean scriptExists(String scriptName, boolean firstUser) {
|
||||
File scriptFile = new File("scripts/map/" + (firstUser ? "onFirstUserEnter/" : "onUserEnter/") + scriptName + ".js");
|
||||
return scriptFile.exists();
|
||||
}
|
||||
|
||||
public void runMapScript(MapleClient c, String scriptName, boolean firstUser) {
|
||||
if (scripts.containsKey(scriptName)) {
|
||||
public boolean runMapScript(MapleClient c, String mapScriptPath, boolean firstUser) {
|
||||
if (firstUser) {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
int mapid = chr.getMapId();
|
||||
if (chr.hasEntered(mapScriptPath, mapid)) {
|
||||
return false;
|
||||
} else {
|
||||
chr.enteredScript(mapScriptPath, mapid);
|
||||
}
|
||||
}
|
||||
|
||||
NashornScriptEngine iv = scripts.get(mapScriptPath);
|
||||
if (iv != null) {
|
||||
try {
|
||||
scripts.get(scriptName).invokeFunction("start", new MapScriptMethods(c));
|
||||
iv.invokeFunction("start", new MapScriptMethods(c));
|
||||
return true;
|
||||
} catch (final ScriptException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
String type = firstUser ? "onFirstUserEnter/" : "onUserEnter/";
|
||||
|
||||
File scriptFile = new File("scripts/map/" + type + scriptName + ".js");
|
||||
if (!scriptExists(scriptName, firstUser)) {
|
||||
return;
|
||||
}
|
||||
FileReader fr = null;
|
||||
ScriptEngine se = sef.getScriptEngine();
|
||||
|
||||
try {
|
||||
fr = new FileReader(scriptFile);
|
||||
|
||||
// java 8 support here thanks to Arufonsu
|
||||
if (ServerConstants.JAVA_8){
|
||||
se.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
iv = getScriptEngine("map/" + mapScriptPath + ".js");
|
||||
if (iv == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
((Compilable) se).compile(fr).eval();
|
||||
|
||||
final Invocable script = ((Invocable) se);
|
||||
scripts.put(scriptName, script);
|
||||
script.invokeFunction("start", new MapScriptMethods(c));
|
||||
scripts.put(mapScriptPath, iv);
|
||||
iv.invokeFunction("start", new MapScriptMethods(c));
|
||||
return true;
|
||||
} catch (final UndeclaredThrowableException | ScriptException ute) {
|
||||
FilePrinter.printError(FilePrinter.MAP_SCRIPT + type + scriptName + ".txt", ute);
|
||||
FilePrinter.printError(FilePrinter.MAP_SCRIPT + mapScriptPath + ".txt", ute);
|
||||
} catch (final Exception e) {
|
||||
FilePrinter.printError(FilePrinter.MAP_SCRIPT + type + scriptName + ".txt", e);
|
||||
} finally {
|
||||
if (fr != null) {
|
||||
try {
|
||||
fr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
FilePrinter.printError(FilePrinter.MAP_SCRIPT + mapScriptPath + ".txt", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -679,12 +679,11 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
try {
|
||||
final MapleMap map, mapExit;
|
||||
Channel cs = c.getChannelServer();
|
||||
PlayerStorage ps = cs.getPlayerStorage();
|
||||
|
||||
map = cs.getMapFactory().getMap(980000100 + 100 * field);
|
||||
mapExit = cs.getMapFactory().getMap(980000000);
|
||||
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
|
||||
final MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
final MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setChallenged(false);
|
||||
mc.changeMap(map, map.getPortal(0));
|
||||
@@ -715,9 +714,8 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
|
||||
public void cancelCPQLobby() {
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.clearCpqTimer();
|
||||
}
|
||||
@@ -741,11 +739,11 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
final MapleMap lobbyMap = getPlayer().getMap();
|
||||
if (challenger != null) {
|
||||
if (challenger.getParty() == null) {
|
||||
throw new RuntimeException("Nao existe oponente!");
|
||||
throw new RuntimeException("No opponent found!");
|
||||
}
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
|
||||
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.changeMap(lobbyMap, lobbyMap.getPortal(0));
|
||||
TimerManager tMan = TimerManager.getInstance();
|
||||
@@ -758,7 +756,7 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
TimerManager tMan = TimerManager.getInstance();
|
||||
tMan.schedule(new Runnable() {
|
||||
@@ -776,15 +774,14 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(null);
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(null);
|
||||
}
|
||||
@@ -809,11 +806,11 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
final MapleMap lobbyMap = getPlayer().getMap();
|
||||
if (challenger != null) {
|
||||
if (challenger.getParty() == null) {
|
||||
throw new RuntimeException("Não existe oponente!");
|
||||
throw new RuntimeException("No opponent found!");
|
||||
}
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
|
||||
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.changeMap(lobbyMap, lobbyMap.getPortal(0));
|
||||
mapClock(10);
|
||||
@@ -826,15 +823,14 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
for (MaplePartyCharacter mpc : getPlayer().getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(null);
|
||||
}
|
||||
}
|
||||
for (MaplePartyCharacter mpc : challenger.getParty().getMembers()) {
|
||||
MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setMonsterCarnival(null);
|
||||
}
|
||||
@@ -907,12 +903,11 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
||||
try {
|
||||
final MapleMap map, mapExit;
|
||||
Channel cs = c.getChannelServer();
|
||||
PlayerStorage ps = c.getChannelServer().getPlayerStorage();
|
||||
|
||||
mapExit = cs.getMapFactory().getMap(980030000);
|
||||
map = cs.getMapFactory().getMap(980031000 + 1000 * field);
|
||||
for (MaplePartyCharacter mpc : c.getPlayer().getParty().getMembers()) {
|
||||
final MapleCharacter mc = ps.getCharacterById(mpc.getId());
|
||||
final MapleCharacter mc = mpc.getPlayer();
|
||||
if (mc != null) {
|
||||
mc.setChallenged(false);
|
||||
mc.changeMap(map, map.getPortal(0));
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
@@ -54,10 +52,10 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
private Map<MapleClient, NPCConversationManager> cms = new HashMap<>();
|
||||
private Map<MapleClient, Invocable> scripts = new HashMap<>();
|
||||
private Map<MapleClient, NashornScriptEngine> scripts = new HashMap<>();
|
||||
|
||||
public boolean isNpcScriptAvailable(MapleClient c, String fileName) {
|
||||
Invocable iv = null;
|
||||
NashornScriptEngine iv = null;
|
||||
if (fileName != null) {
|
||||
iv = getScriptEngine("npc/" + fileName + ".js", c);
|
||||
}
|
||||
@@ -96,7 +94,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
NashornScriptEngine iv = getScriptEngine("npc/" + filename + ".js", c);
|
||||
|
||||
if (iv == null) {
|
||||
c.getPlayer().dropMessage(1, npc + "");
|
||||
c.getPlayer().dropMessage(1, "NPC " + npc + " is uncoded.");
|
||||
cm.dispose();
|
||||
return;
|
||||
}
|
||||
@@ -173,7 +171,7 @@ public class NPCScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
public void action(MapleClient c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
NashornScriptEngine iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
c.setClickedNPC();
|
||||
|
||||
@@ -22,23 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package scripting.portal;
|
||||
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.script.Compilable;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.maps.MaplePortal;
|
||||
import tools.FilePrinter;
|
||||
|
||||
public class PortalScriptManager {
|
||||
public class PortalScriptManager extends AbstractScriptManager {
|
||||
|
||||
private static PortalScriptManager instance = new PortalScriptManager();
|
||||
|
||||
@@ -46,7 +40,7 @@ public class PortalScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Map<String, PortalScript> scripts = new HashMap<>();
|
||||
private Map<String, NashornScriptEngine> scripts = new HashMap<>();
|
||||
private ScriptEngineFactory sef;
|
||||
|
||||
private PortalScriptManager() {
|
||||
@@ -54,47 +48,28 @@ public class PortalScriptManager {
|
||||
sef = sem.getEngineByName("javascript").getFactory();
|
||||
}
|
||||
|
||||
private PortalScript getPortalScript(String scriptName) {
|
||||
if (scripts.containsKey(scriptName)) {
|
||||
return scripts.get(scriptName);
|
||||
private NashornScriptEngine getPortalScript(String scriptName) {
|
||||
String scriptPath = "portal/" + scriptName + ".js";
|
||||
NashornScriptEngine iv = scripts.get(scriptPath);
|
||||
if (iv != null) {
|
||||
return iv;
|
||||
}
|
||||
File scriptFile = new File("scripts/portal/" + scriptName + ".js");
|
||||
if (!scriptFile.exists()) {
|
||||
scripts.put(scriptName, null);
|
||||
|
||||
iv = getScriptEngine(scriptPath);
|
||||
if (iv == null) {
|
||||
return null;
|
||||
}
|
||||
FileReader fr = null;
|
||||
ScriptEngine portal = sef.getScriptEngine();
|
||||
try {
|
||||
fr = new FileReader(scriptFile);
|
||||
|
||||
// java 8 support here thanks to Arufonsu
|
||||
if (ServerConstants.JAVA_8){
|
||||
portal.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
|
||||
}
|
||||
|
||||
((Compilable) portal).compile(fr).eval();
|
||||
} catch (ScriptException | IOException | UndeclaredThrowableException e) {
|
||||
FilePrinter.printError(FilePrinter.PORTAL + scriptName + ".txt", e);
|
||||
} finally {
|
||||
if (fr != null) {
|
||||
try {
|
||||
fr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
PortalScript script = ((Invocable) portal).getInterface(PortalScript.class);
|
||||
scripts.put(scriptName, script);
|
||||
return script;
|
||||
|
||||
scripts.put(scriptPath, iv);
|
||||
return iv;
|
||||
}
|
||||
|
||||
public boolean executePortalScript(MaplePortal portal, MapleClient c) {
|
||||
try {
|
||||
PortalScript script = getPortalScript(portal.getScriptName());
|
||||
if (script != null) {
|
||||
return script.enter(new PortalPlayerInteraction(c, portal));
|
||||
NashornScriptEngine iv = getPortalScript(portal.getScriptName());
|
||||
if (iv != null) {
|
||||
boolean couldWarp = (boolean) iv.invokeFunction("enter", new PortalPlayerInteraction(c, portal));
|
||||
return couldWarp;
|
||||
}
|
||||
} catch (UndeclaredThrowableException ute) {
|
||||
FilePrinter.printError(FilePrinter.PORTAL + portal.getScriptName() + ".txt", ute);
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.script.Invocable;
|
||||
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.quest.MapleQuest;
|
||||
@@ -48,7 +46,16 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
private Map<MapleClient, QuestActionManager> qms = new HashMap<>();
|
||||
private Map<MapleClient, Invocable> scripts = new HashMap<>();
|
||||
private Map<MapleClient, NashornScriptEngine> scripts = new HashMap<>();
|
||||
|
||||
private NashornScriptEngine getQuestScriptEngine(MapleClient c, short questid) {
|
||||
NashornScriptEngine iv = getScriptEngine("quest/" + questid + ".js", c);
|
||||
if (iv == null && GameConstants.isMedalQuest(questid)) {
|
||||
iv = getScriptEngine("quest/medalQuest.js", c); // start generic medal quest
|
||||
}
|
||||
|
||||
return iv;
|
||||
}
|
||||
|
||||
public void start(MapleClient c, short questid, int npc) {
|
||||
MapleQuest quest = MapleQuest.getInstance(questid);
|
||||
@@ -63,18 +70,19 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
if(c.canClickNPC()) {
|
||||
qms.put(c, qm);
|
||||
NashornScriptEngine iv = getScriptEngine("quest/" + questid + ".js", c);
|
||||
if (iv == null) {
|
||||
if(GameConstants.isMedalQuest(questid)) { // start generic medal quest
|
||||
iv = getScriptEngine("quest/medalQuest.js", c);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "START Quest " + questid + " is uncoded.");
|
||||
}
|
||||
}
|
||||
if (iv == null || QuestScriptManager.getInstance() == null) {
|
||||
|
||||
if (!quest.hasScriptRequirement(false)) { // lack of scripted quest checks found thanks to Mali, Resinate
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
NashornScriptEngine iv = getQuestScriptEngine(c, questid);
|
||||
if (iv == null) {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "START Quest " + questid + " is uncoded.");
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
iv.put("qm", qm);
|
||||
scripts.put(c, iv);
|
||||
c.setClickedNPC();
|
||||
@@ -90,7 +98,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
public void start(MapleClient c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
NashornScriptEngine iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
c.setClickedNPC();
|
||||
@@ -118,16 +126,19 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
if(c.canClickNPC()){
|
||||
qms.put(c, qm);
|
||||
NashornScriptEngine iv = getScriptEngine("quest/" + questid + ".js", c);
|
||||
if (iv == null) {
|
||||
if(GameConstants.isMedalQuest(questid)) { // start generic medal quest
|
||||
iv = getScriptEngine("quest/medalQuest.js", c);
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "END Quest " + questid + " is uncoded.");
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!quest.hasScriptRequirement(true)) {
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
NashornScriptEngine iv = getQuestScriptEngine(c, questid);
|
||||
if (iv == null) {
|
||||
FilePrinter.printError(FilePrinter.QUEST_UNCODED, "END Quest " + questid + " is uncoded.");
|
||||
qm.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
iv.put("qm", qm);
|
||||
scripts.put(c, iv);
|
||||
c.setClickedNPC();
|
||||
@@ -143,7 +154,7 @@ public class QuestScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
|
||||
public void end(MapleClient c, byte mode, byte type, int selection) {
|
||||
Invocable iv = scripts.get(c);
|
||||
NashornScriptEngine iv = scripts.get(c);
|
||||
if (iv != null) {
|
||||
try {
|
||||
c.setClickedNPC();
|
||||
|
||||
@@ -35,8 +35,8 @@ import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptException;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
import scripting.AbstractPlayerInteraction;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import scripting.event.EventManager;
|
||||
@@ -58,10 +58,10 @@ import tools.MaplePacketCreator;
|
||||
*/
|
||||
public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
private MapleReactor reactor;
|
||||
private Invocable iv;
|
||||
private NashornScriptEngine iv;
|
||||
private ScheduledFuture<?> sprayTask = null;
|
||||
|
||||
public ReactorActionManager(MapleClient c, MapleReactor reactor, Invocable iv) {
|
||||
public ReactorActionManager(MapleClient c, MapleReactor reactor, NashornScriptEngine iv) {
|
||||
super(c);
|
||||
this.reactor = reactor;
|
||||
this.iv = iv;
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngine;
|
||||
|
||||
Reference in New Issue
Block a user