CWKPQ inclusion
Added some CWKPQ imports for the server. Enabled basic mechanics for a run, but still WIP.
This commit is contained in:
@@ -674,6 +674,10 @@ public class AbstractPlayerInteraction {
|
||||
c.announce(MaplePacketCreator.disableMinimap());
|
||||
}
|
||||
|
||||
public boolean isAllReactorState(final int reactorId, final int state) {
|
||||
return c.getPlayer().getMap().isAllReactorState(reactorId, state);
|
||||
}
|
||||
|
||||
public void resetMap(int mapid) {
|
||||
getMap(mapid).resetReactors();
|
||||
getMap(mapid).killAllMonsters();
|
||||
|
||||
@@ -24,6 +24,7 @@ package scripting.event;
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import tools.Pair;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -103,7 +104,7 @@ public class EventInstanceManager {
|
||||
private Map<Integer, Integer> playerGrid = new HashMap<>();
|
||||
|
||||
// registers all opened gates on the event. Will help late characters to encounter next stages gates already opened
|
||||
private Set<Integer> openedGates = new HashSet<>();
|
||||
private Map<Integer, Pair<String, Integer>> openedGates = new HashMap<>();
|
||||
|
||||
// forces deletion of items not supposed to be held outside of the event, dealt on a player's leaving moment.
|
||||
private Set<Integer> exclusiveItems = new HashSet<>();
|
||||
@@ -698,6 +699,10 @@ public class EventInstanceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public MapleMonster getMonster(int mid) {
|
||||
return(MapleLifeFactory.getMonster(mid));
|
||||
}
|
||||
|
||||
private List<Integer> convertToIntegerArray(List<Double> list) {
|
||||
List<Integer> intList = new ArrayList<>();
|
||||
for(Double d: list) intList.add(d.intValue());
|
||||
@@ -981,14 +986,22 @@ public class EventInstanceManager {
|
||||
}
|
||||
|
||||
public final void showClearEffect(boolean hasGate, int mapId) {
|
||||
showClearEffect(hasGate, mapId, "gate", 2);
|
||||
}
|
||||
|
||||
public final void showClearEffect(int mapId, String mapObj, int newState) {
|
||||
showClearEffect(true, mapId, mapObj, newState);
|
||||
}
|
||||
|
||||
public final void showClearEffect(boolean hasGate, int mapId, String mapObj, int newState) {
|
||||
MapleMap map = getMapInstance(mapId);
|
||||
map.broadcastMessage(MaplePacketCreator.showEffect("quest/party/clear"));
|
||||
map.broadcastMessage(MaplePacketCreator.playSound("Party1/Clear"));
|
||||
if(hasGate) {
|
||||
map.broadcastMessage(MaplePacketCreator.environmentChange("gate", 2));
|
||||
map.broadcastMessage(MaplePacketCreator.environmentChange(mapObj, newState));
|
||||
wL.lock();
|
||||
try {
|
||||
openedGates.add(map.getId());
|
||||
openedGates.put(map.getId(), new Pair<>(mapObj, newState));
|
||||
} finally {
|
||||
wL.unlock();
|
||||
}
|
||||
@@ -998,8 +1011,9 @@ public class EventInstanceManager {
|
||||
public final void recoverOpenedGate(MapleCharacter chr, int thisMapId) {
|
||||
rL.lock();
|
||||
try {
|
||||
if(openedGates.contains(thisMapId)) {
|
||||
chr.announce(MaplePacketCreator.environmentChange("gate", 2));
|
||||
if(openedGates.containsKey(thisMapId)) {
|
||||
Pair<String, Integer> gateData = openedGates.get(thisMapId);
|
||||
chr.announce(MaplePacketCreator.environmentChange(gateData.getLeft(), gateData.getRight()));
|
||||
}
|
||||
} finally {
|
||||
rL.unlock();
|
||||
|
||||
@@ -184,15 +184,19 @@ public class EventManager {
|
||||
public void setProperty(String key, String value) {
|
||||
props.setProperty(key, value);
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return props.getProperty(key);
|
||||
|
||||
public void setIntProperty(String key, int value) {
|
||||
setProperty(key, value);
|
||||
}
|
||||
|
||||
public void setProperty(String key, int value) {
|
||||
props.setProperty(key, value + "");
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return props.getProperty(key);
|
||||
}
|
||||
|
||||
public int getIntProperty(String key) {
|
||||
return Integer.parseInt(props.getProperty(key));
|
||||
}
|
||||
@@ -279,7 +283,7 @@ public class EventManager {
|
||||
startLobbyInstance(lobbyId);
|
||||
}
|
||||
|
||||
EventInstanceManager eim = (EventInstanceManager) (iv.invokeFunction("setup", leader.getId()));
|
||||
EventInstanceManager eim = (EventInstanceManager) (iv.invokeFunction("setup", leader.getClient().getChannel()));
|
||||
if(eim == null) {
|
||||
if(lobbyId > -1) setLockLobby(lobbyId, false);
|
||||
return false;
|
||||
|
||||
@@ -178,7 +178,12 @@ public class MapleMonsterInformationProvider {
|
||||
try
|
||||
{
|
||||
return MapleLifeFactory.getMonster(id).getName();
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
return null; //nonexistant mob
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.err.println("Nonexistant mob id " + id);
|
||||
|
||||
@@ -276,6 +276,17 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAllReactorState(final int reactorId, final int state) {
|
||||
for (MapleMapObject mo : getReactors()) {
|
||||
MapleReactor r = (MapleReactor) mo;
|
||||
|
||||
if (r.getId() == reactorId && r.getState() != state) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getForcedReturnId() {
|
||||
return forcedReturnMap;
|
||||
}
|
||||
@@ -955,6 +966,41 @@ public class MapleMap {
|
||||
mr.setPosition(points.remove(points.size() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public final void shuffleReactors(List<Object> list) {
|
||||
List<Point> points = new ArrayList<>();
|
||||
List<MapleMapObject> listObjects = new ArrayList<>();
|
||||
|
||||
List<MapleMapObject> reactors = getReactors();
|
||||
List<MapleMapObject> targets = new LinkedList<>();
|
||||
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (Object obj : list) {
|
||||
if(obj instanceof MapleMapObject) {
|
||||
MapleMapObject mmo = (MapleMapObject) obj;
|
||||
|
||||
if(mapobjects.containsValue(mmo)) {
|
||||
listObjects.add(mmo);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
objectRLock.unlock();
|
||||
}
|
||||
|
||||
for (MapleMapObject obj : listObjects) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
|
||||
points.add(mr.getPosition());
|
||||
targets.add(obj);
|
||||
}
|
||||
Collections.shuffle(points);
|
||||
for (MapleMapObject obj : targets) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
mr.setPosition(points.remove(points.size() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automagically finds a new controller for the given monster from the chars
|
||||
@@ -1480,6 +1526,10 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeEnvironment(String mapObj, int newState) {
|
||||
broadcastMessage(MaplePacketCreator.environmentChange(mapObj, newState));
|
||||
}
|
||||
|
||||
public void startMapEffect(String msg, int itemId) {
|
||||
startMapEffect(msg, itemId, 30000);
|
||||
@@ -2105,7 +2155,7 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public final void moveEnvironment(final String ms, final int type) {
|
||||
broadcastMessage(MaplePacketCreator.environmentChange(ms, type));
|
||||
broadcastMessage(MaplePacketCreator.environmentMove(ms, type));
|
||||
environment.put(ms, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -3682,6 +3682,16 @@ public class MaplePacketCreator {
|
||||
mplew.writeMapleAsciiString(env);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
public static byte[] environmentMove(String env, int mode) {
|
||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
|
||||
mplew.writeShort(SendOpcode.FIELD_EFFECT.getValue());
|
||||
mplew.write(mode);
|
||||
mplew.writeMapleAsciiString(env);
|
||||
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
public static byte[] startMapEffect(String msg, int itemid, boolean active) {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
|
||||
Reference in New Issue
Block a user