Reworked Singapore/Malaysia + warp fix

Reworked many aspects of the Malaysia/Singapore region (added DB data,
enabled Latanica & Scarga expedition, fixed maps). Fixed some issues
related with player warping.
This commit is contained in:
ronancpl
2017-07-14 20:40:06 -03:00
parent 7f80f45553
commit 8fab2a6e3e
120 changed files with 17684 additions and 16759 deletions

View File

@@ -89,9 +89,16 @@ public class AbstractPlayerInteraction {
return c.getPlayer().getMap();
}
public int getMarketPortalId(int mapId) {
return getMarketPortalId(getWarpMap(mapId));
}
private int getMarketPortalId(MapleMap map) {
return (map.findMarketPortal() != null) ? map.findMarketPortal().getId() : map.getRandomPlayerSpawnpoint().getId();
}
public void warp(int mapid) {
MapleMap map = getWarpMap(mapid);
getPlayer().changeMap(map, map.getRandomPlayerSpawnpoint());
getPlayer().changeMap(mapid);
}
public void warp(int map, int portal) {
@@ -107,11 +114,20 @@ public class AbstractPlayerInteraction {
}
public void warpParty(int id) {
for (MapleCharacter mc : getPartyMembers()) {
if (id == 925020100) {
mc.setDojoParty(true);
}
mc.changeMap(getWarpMap(id));
if (getPlayer().getParty() != null) {
MaplePartyCharacter leader = getPlayer().getParty().getMemberById(getPlayer().getParty().getLeaderId());
if(leader != null) {
int leaderMapId = leader.getMapId();
for (MapleCharacter mc : getPartyMembers()) {
if(mc.getMapId() == leaderMapId) {
if (id == 925020100) {
mc.setDojoParty(true);
}
mc.changeMap(id);
}
}
}
}
}

View File

@@ -524,12 +524,7 @@ public class EventInstanceManager {
cancelSchedule();
killCount.clear();
if (expedition != null) {
expedition.dispose(true);
em.getChannelServer().getExpeditions().remove(expedition);
expedition = null;
}
disposeExpedition();
if(!eventCleared) em.disposeInstance(name);
em = null;
}
@@ -863,9 +858,19 @@ public class EventInstanceManager {
}
}
private void disposeExpedition() {
if (expedition != null) {
expedition.dispose(eventCleared);
em.getChannelServer().getExpeditions().remove(expedition);
expedition = null;
}
}
public final void setEventCleared() {
eventCleared = true;
em.disposeInstance(name);
disposeExpedition();
}
public final boolean isEventCleared() {

View File

@@ -29,26 +29,34 @@ import java.awt.Point;
import java.util.Iterator;
import java.util.LinkedList;
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 scripting.AbstractPlayerInteraction;
import scripting.event.EventInstanceManager;
import scripting.event.EventManager;
import server.MapleItemInformationProvider;
import server.TimerManager;
import server.life.MapleLifeFactory;
import server.life.MapleNPC;
import server.maps.MapMonitor;
import server.maps.MapleReactor;
import server.maps.ReactorDropEntry;
import tools.MaplePacketCreator;
/**
* @author Lerk
* @author Lerk, Ronan
*/
public class ReactorActionManager extends AbstractPlayerInteraction {
private MapleReactor reactor;
private MapleClient client;
private Invocable iv;
public ReactorActionManager(MapleClient c, MapleReactor reactor) {
public ReactorActionManager(MapleClient c, MapleReactor reactor, Invocable iv) {
super(c);
this.reactor = reactor;
this.client = c;
this.iv = iv;
}
public void dropItems() {
@@ -154,4 +162,32 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
public void spawnFakeMonster(int id) {
reactor.getMap().spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(id), getPosition());
}
public ScheduledFuture<?> schedule(String methodName, long delay) {
return schedule(methodName, null, delay);
}
public ScheduledFuture<?> schedule(final String methodName, final EventInstanceManager eim, long delay) {
return TimerManager.getInstance().schedule(new Runnable() {
public void run() {
try {
iv.invokeFunction(methodName, eim);
} catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}, delay);
}
public ScheduledFuture<?> scheduleAtTimestamp(final String methodName, long timestamp) {
return TimerManager.getInstance().scheduleAtTimestamp(new Runnable() {
public void run() {
try {
iv.invokeFunction(methodName, (Object) null);
} catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}, timestamp);
}
}

View File

@@ -50,11 +50,10 @@ public class ReactorScriptManager extends AbstractScriptManager {
public void onHit(MapleClient c, MapleReactor reactor) {
try {
ReactorActionManager rm = new ReactorActionManager(c, reactor);
Invocable iv = getInvocable("reactor/" + reactor.getId() + ".js", c);
if (iv == null) {
return;
}
if (iv == null) return;
ReactorActionManager rm = new ReactorActionManager(c, reactor, iv);
engine.put("rm", rm);
iv.invokeFunction("hit");
} catch(final NoSuchMethodException e) {
@@ -67,11 +66,10 @@ public class ReactorScriptManager extends AbstractScriptManager {
public void act(MapleClient c, MapleReactor reactor) {
try {
ReactorActionManager rm = new ReactorActionManager(c, reactor);
Invocable iv = getInvocable("reactor/" + reactor.getId() + ".js", c);
if (iv == null) {
return;
}
if (iv == null) return;
ReactorActionManager rm = new ReactorActionManager(c, reactor, iv);
engine.put("rm", rm);
iv.invokeFunction("act");
} catch (final ScriptException | NoSuchMethodException | NullPointerException e) {
@@ -114,11 +112,10 @@ public class ReactorScriptManager extends AbstractScriptManager {
public synchronized void touching(MapleClient c, MapleReactor reactor, boolean touching) {
try {
ReactorActionManager rm = new ReactorActionManager(c, reactor);
Invocable iv = getInvocable("reactor/" + reactor.getId() + ".js", c);
if (iv == null) {
return;
}
if (iv == null) return;
ReactorActionManager rm = new ReactorActionManager(c, reactor, iv);
engine.put("rm", rm);
if (touching) {
iv.invokeFunction("touch");