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:
@@ -288,6 +288,8 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
private long petLootCd;
|
||||
private long lastHpDec = 0;
|
||||
private int newWarpMap = -1;
|
||||
private boolean canWarpMap = true; //only one "warp" must be used per call, and this will define the right one.
|
||||
private int canWarpCounter = 0; //counts how many times "inner warps" have been called.
|
||||
|
||||
private MapleCharacter() {
|
||||
useCS = false;
|
||||
@@ -1141,6 +1143,12 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
private void eventChangedMap(int map) {
|
||||
if (getEventInstance() != null) getEventInstance().changedMap(this, map);
|
||||
}
|
||||
|
||||
public void changeMapBanish(int mapid, String portal, String msg) {
|
||||
dropMessage(5, msg);
|
||||
MapleMap map_ = client.getChannelServer().getMapFactory().getMap(mapid);
|
||||
changeMap(map_, map_.getPortal(portal));
|
||||
}
|
||||
|
||||
public void changeMap(int map) {
|
||||
MapleMap warpMap;
|
||||
@@ -1190,21 +1198,31 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
changeMap(to, to.getPortal(0));
|
||||
}
|
||||
|
||||
public void changeMap(final MapleMap to, final MaplePortal pto) {
|
||||
eventChangedMap(to.getId());
|
||||
// not always the MapleMap target will be the map the player will be inserted, why would this even exist? Whatever.
|
||||
public void changeMap(final MapleMap target, final MaplePortal pto) {
|
||||
canWarpCounter++;
|
||||
|
||||
eventChangedMap(target.getId()); // player can be dropped from an event here, hence the new warping target.
|
||||
MapleMap to = getWarpMap(target.getId());
|
||||
changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this));
|
||||
canWarpMap = false;
|
||||
|
||||
canWarpCounter--;
|
||||
if(canWarpCounter == 0) canWarpMap = true;
|
||||
}
|
||||
|
||||
public void changeMap(final MapleMap to, final Point pos) {
|
||||
public void changeMap(final MapleMap target, final Point pos) {
|
||||
canWarpCounter++;
|
||||
|
||||
eventChangedMap(target.getId());
|
||||
MapleMap to = getWarpMap(target.getId());
|
||||
changeMapInternal(to, pos, MaplePacketCreator.getWarpToMap(to, 0x80, this));//Position :O (LEFT)
|
||||
canWarpMap = false;
|
||||
|
||||
canWarpCounter--;
|
||||
if(canWarpCounter == 0) canWarpMap = true;
|
||||
}
|
||||
|
||||
public void changeMapBanish(int mapid, String portal, String msg) {
|
||||
dropMessage(5, msg);
|
||||
MapleMap map_ = client.getChannelServer().getMapFactory().getMap(mapid);
|
||||
changeMap(map_, map_.getPortal(portal));
|
||||
}
|
||||
|
||||
|
||||
private boolean buffMapProtection() {
|
||||
for(Entry<MapleBuffStat, MapleBuffStatValueHolder> mbs : effects.entrySet()) {
|
||||
if(mbs.getKey() == MapleBuffStat.MAP_PROTECTION) {
|
||||
@@ -1226,8 +1244,9 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
}
|
||||
|
||||
private void changeMapInternal(final MapleMap to, final Point pos, final byte[] warpPacket) {
|
||||
this.closePlayerInteractions();
|
||||
if(!canWarpMap) return;
|
||||
|
||||
this.closePlayerInteractions();
|
||||
client.announce(warpPacket);
|
||||
map.removePlayer(this);
|
||||
if (client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) {
|
||||
@@ -1249,6 +1268,8 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
|
||||
//alas, new map has been specified when a warping was being processed...
|
||||
if(newWarpMap != -1) {
|
||||
canWarpMap = true;
|
||||
|
||||
int temp = newWarpMap;
|
||||
newWarpMap = -1;
|
||||
changeMap(temp);
|
||||
|
||||
@@ -1041,11 +1041,10 @@ public class Commands {
|
||||
return true;
|
||||
}
|
||||
if (player.getEventInstance() != null) {
|
||||
player.getEventInstance().removePlayer(player);
|
||||
player.getEventInstance().leftParty(player);
|
||||
}
|
||||
player.changeMap(target, target.getPortal(0));
|
||||
player.changeMap(target, target.getRandomPlayerSpawnpoint());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
player.yellowMessage("Map ID " + sub[1] + " is invalid.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -561,7 +561,6 @@ public class MapleItemInformationProvider {
|
||||
Map<String, Integer> stats = this.getEquipStats(scrollId);
|
||||
Map<String, Integer> eqstats = this.getEquipStats(equip.getItemId());
|
||||
|
||||
System.out.println("GM: " + isGM + "\tWS: " + usingWhiteScroll + "\tITEM: " + scrollId);
|
||||
if (((nEquip.getUpgradeSlots() > 0 || isCleanSlate(scrollId))) || isGM) {
|
||||
if(isGM || rollSuccessChance((double)stats.get("success"))) {
|
||||
short flag = nEquip.getFlag();
|
||||
|
||||
@@ -861,7 +861,7 @@ public class MapleStatEffect {
|
||||
door.getTown().spawnDoor(door.getTownDoor());
|
||||
} else {
|
||||
if(door.getOwnerId() == -1) applyto.dropMessage(5, "There are no door portals available for the town at this moment. Try again later.");
|
||||
else applyto.dropMessage(5, "This position is not suitable for a Mystic Door, try elsewhere.");
|
||||
else applyto.dropMessage(5, "Mystic Door cannot be cast on a slope, try elsewhere.");
|
||||
|
||||
applyto.cancelBuffStats(MapleBuffStat.SOULARROW); // cancel door buff
|
||||
}
|
||||
|
||||
@@ -111,9 +111,8 @@ public class MapleExpedition {
|
||||
leader.getClient().getChannelServer().getExpeditions().remove(exped);
|
||||
startMap.broadcastMessage(MaplePacketCreator.serverNotice(6, "Time limit has been reached. Expedition has been disbanded."));
|
||||
|
||||
broadcastExped(MaplePacketCreator.removeClock());
|
||||
dispose(false);
|
||||
}
|
||||
dispose(false);
|
||||
}
|
||||
}, type.getRegistrationTime() * 60 * 1000);
|
||||
}
|
||||
|
||||
@@ -1604,7 +1604,7 @@ public class MapleMap {
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(final MapleCharacter chr) {
|
||||
chrWLock.lock();
|
||||
try {
|
||||
@@ -1849,6 +1849,16 @@ public class MapleMap {
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
public MaplePortal findMarketPortal() {
|
||||
for (MaplePortal portal : portals.values()) {
|
||||
String ptScript = portal.getScriptName();
|
||||
if(ptScript != null && ptScript.contains("market")) {
|
||||
return portal;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<MaplePortal> getPortals() {
|
||||
return Collections.unmodifiableCollection(portals.values());
|
||||
@@ -2769,7 +2779,7 @@ public class MapleMap {
|
||||
private boolean specialEquip() {//Maybe I shouldn't use fieldType :\
|
||||
return fieldType == 4 || fieldType == 19;
|
||||
}
|
||||
|
||||
|
||||
public void setCoconut(MapleCoconut nut) {
|
||||
this.coconut = nut;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public enum MapleMiniDungeon {
|
||||
THE_RESTORING_MEMORY(240040511, 240040800, 19),
|
||||
NEWT_SECURED_ZONE(240040520, 240040900, 19),
|
||||
PILLAGE_OF_TREASURE_ISLAND(251010402, 251010410, 30),
|
||||
;
|
||||
LONGEST_RIDE_ON_BYEBYE_STATION(551030000, 551030001, 19);
|
||||
|
||||
private int baseId;
|
||||
private int dungeonId;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventory;
|
||||
import client.inventory.MapleInventoryType;
|
||||
@@ -43,10 +42,10 @@ import tools.Randomizer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
* @author Tyler (Twdtwd), Ronan
|
||||
*/
|
||||
public class ItemAction extends MapleQuestAction {
|
||||
Map<Integer, ItemData> items = new HashMap<>();
|
||||
List<ItemData> items = new ArrayList<>();
|
||||
|
||||
public ItemAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.ITEM, quest);
|
||||
@@ -73,27 +72,25 @@ public class ItemAction extends MapleQuestAction {
|
||||
if (iEntry.getChildByPath("job") != null)
|
||||
job = MapleDataTool.getInt(iEntry.getChildByPath("job"));
|
||||
|
||||
items.put(id, new ItemData(id, count, prop, job, gender));
|
||||
items.add(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()) {
|
||||
int props = 0, rndProps = 0, accProps = 0;
|
||||
for(ItemData item : items) {
|
||||
if(item.getProp() != null && item.getProp() != -1 && canGetItem(item, chr)) {
|
||||
for (int i = 0; i < item.getProp(); i++) {
|
||||
props.put(props.size(), item.getId());
|
||||
}
|
||||
props += item.getProp();
|
||||
}
|
||||
}
|
||||
int selection = 0;
|
||||
|
||||
int extNum = 0;
|
||||
if (props.size() > 0) {
|
||||
selection = props.get(Randomizer.nextInt(props.size()));
|
||||
if (props > 0) {
|
||||
rndProps = Randomizer.nextInt(props);
|
||||
}
|
||||
for (ItemData iEntry : items.values()) {
|
||||
for (ItemData iEntry : items) {
|
||||
if (!canGetItem(iEntry, chr)) {
|
||||
continue;
|
||||
}
|
||||
@@ -101,8 +98,15 @@ public class ItemAction extends MapleQuestAction {
|
||||
if(iEntry.getProp() == -1) {
|
||||
if(extSelection != extNum++)
|
||||
continue;
|
||||
} else if(iEntry.getId() != selection)
|
||||
continue;
|
||||
} else {
|
||||
accProps += iEntry.getProp();
|
||||
|
||||
if(accProps <= rndProps) {
|
||||
continue;
|
||||
} else {
|
||||
accProps = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(iEntry.getCount() < 0) { // Remove Items
|
||||
@@ -135,7 +139,7 @@ public class ItemAction extends MapleQuestAction {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
EnumMap<MapleInventoryType, Integer> props = new EnumMap<>(MapleInventoryType.class);
|
||||
List<Pair<Item, MapleInventoryType>> itemList = new ArrayList<>();
|
||||
for(ItemData item : items.values()) {
|
||||
for(ItemData item : items) {
|
||||
if (!canGetItem(item, chr)) {
|
||||
continue;
|
||||
}
|
||||
@@ -188,17 +192,6 @@ public class ItemAction extends MapleQuestAction {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (!jobFound && item.jobEx > 0) {
|
||||
final List<Integer> codeEx = getJobBySimpleEncoding(item.jobEx);
|
||||
for (int codec : codeEx) {
|
||||
if ((codec / 100 % 10) == (chr.getJob().getId() / 100 % 10)) {
|
||||
jobFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return jobFound;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user