Implemented CWKPQ
Made CWKPQ fully-functional, using the Expedition system (won't work with the lobby system).
This commit is contained in:
@@ -87,7 +87,7 @@ public class MapleExpedition {
|
||||
public MapleExpedition(MapleCharacter player, MapleExpeditionType met) {
|
||||
leader = player;
|
||||
members.add(leader);
|
||||
startMap = player.getMap();
|
||||
startMap = player.getMap();
|
||||
type = met;
|
||||
bossLogs = new ArrayList<String>();
|
||||
beginRegistration();
|
||||
@@ -95,19 +95,23 @@ public class MapleExpedition {
|
||||
|
||||
private void beginRegistration() {
|
||||
registering = true;
|
||||
startMap.broadcastMessage(MaplePacketCreator.getClock(type.getRegistrationTime() * 60));
|
||||
leader.announce(MaplePacketCreator.getClock(type.getRegistrationTime() * 60));
|
||||
startMap.broadcastMessage(MaplePacketCreator.serverNotice(6, leader.getName() + " has been declared the expedition captain. Please register for the expedition."));
|
||||
scheduleRegistrationEnd();
|
||||
}
|
||||
|
||||
private void scheduleRegistrationEnd() {
|
||||
final MapleExpedition exped = this;
|
||||
startTime = System.currentTimeMillis() + type.getRegistrationTime() * 60 * 1000;
|
||||
|
||||
schedule = TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (registering){
|
||||
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);
|
||||
}
|
||||
@@ -115,7 +119,9 @@ public class MapleExpedition {
|
||||
}
|
||||
|
||||
public void dispose(boolean log){
|
||||
if (schedule != null){
|
||||
broadcastExped(MaplePacketCreator.removeClock());
|
||||
|
||||
if (schedule != null){
|
||||
schedule.cancel(false);
|
||||
}
|
||||
if (log && !registering){
|
||||
@@ -125,7 +131,7 @@ public class MapleExpedition {
|
||||
|
||||
public void start(){
|
||||
registering = false;
|
||||
startMap.broadcastMessage(MaplePacketCreator.removeClock());
|
||||
broadcastExped(MaplePacketCreator.removeClock());
|
||||
broadcastExped(MaplePacketCreator.serverNotice(6, "The expedition has started! Good luck, brave heroes!"));
|
||||
startTime = System.currentTimeMillis();
|
||||
Server.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, type.toString() + " Expedition started with leader: " + leader.getName()));
|
||||
@@ -142,6 +148,7 @@ public class MapleExpedition {
|
||||
return "Sorry, this expedition is full!";
|
||||
}
|
||||
if (members.add(player)){
|
||||
player.announce(MaplePacketCreator.getClock((int)(startTime - System.currentTimeMillis()) / 1000));
|
||||
broadcastExped(MaplePacketCreator.serverNotice(6, player.getName() + " has joined the expedition!"));
|
||||
return "You have registered for the expedition successfully!";
|
||||
}
|
||||
@@ -156,6 +163,7 @@ public class MapleExpedition {
|
||||
|
||||
public boolean removeMember(MapleCharacter chr) {
|
||||
if(members.remove(chr)) {
|
||||
chr.announce(MaplePacketCreator.removeClock());
|
||||
broadcastExped(MaplePacketCreator.serverNotice(6, chr.getName() + " has left the expedition."));
|
||||
chr.dropMessage(6, "You have left this expedition.");
|
||||
return true;
|
||||
@@ -175,6 +183,10 @@ public class MapleExpedition {
|
||||
public MapleCharacter getLeader(){
|
||||
return leader;
|
||||
}
|
||||
|
||||
public MapleMap getRecruitingMap() {
|
||||
return startMap;
|
||||
}
|
||||
|
||||
public boolean contains(MapleCharacter player) {
|
||||
for (MapleCharacter member : members){
|
||||
|
||||
@@ -61,7 +61,6 @@ public class SpawnPoint {
|
||||
if (denySpawn || mobTime < 0 || spawnedMonsters.get() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return nextPossibleSpawn <= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -100,6 +99,10 @@ public class SpawnPoint {
|
||||
}
|
||||
return mob;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return monster;
|
||||
}
|
||||
|
||||
public Point getPosition() {
|
||||
return pos;
|
||||
|
||||
@@ -1216,10 +1216,8 @@ public class MapleMap {
|
||||
|
||||
public void spawnAllMonsterIdFromMapSpawnList(int id, int difficulty, boolean isPq) {
|
||||
for(SpawnPoint sp: allMonsterSpawn) {
|
||||
MapleMonster mm = sp.getMonster();
|
||||
|
||||
if(mm.getId() == id) {
|
||||
spawnMonster(mm, difficulty, isPq);
|
||||
if(sp.getMonsterId() == id) {
|
||||
spawnMonster(sp.getMonster(), difficulty, isPq);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1230,8 +1228,7 @@ public class MapleMap {
|
||||
|
||||
public void spawnAllMonstersFromMapSpawnList(int difficulty, boolean isPq) {
|
||||
for(SpawnPoint sp: allMonsterSpawn) {
|
||||
MapleMonster mm = sp.getMonster();
|
||||
spawnMonster(mm, difficulty, isPq);
|
||||
spawnMonster(sp.getMonster(), difficulty, isPq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2065,6 +2062,13 @@ public class MapleMap {
|
||||
SpawnPoint sp = new SpawnPoint(monster, newpos, !monster.isMobile(), mobTime, mobInterval, team);
|
||||
allMonsterSpawn.add(sp);
|
||||
}
|
||||
|
||||
public void reportMonsterSpawnPoints(MapleCharacter chr) {
|
||||
chr.dropMessage(6, "Mob spawnpoints on map " + getId() + ", with available Mob SPs " + monsterSpawn.size() + ", used " + spawnedMonstersOnMap.get() + ":");
|
||||
for(SpawnPoint sp: allMonsterSpawn) {
|
||||
chr.dropMessage(6, " id: " + sp.getMonsterId() + " canSpawn: " + !sp.getDenySpawn() + " numSpawned: " + sp.getSpawned() + " x: " + sp.getPosition().getX() + " y: " + sp.getPosition().getY() + " time: " + sp.getMobTime() + " team: " + sp.getTeam());
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<MapleCharacter> getCharacters() {
|
||||
chrRLock.lock();
|
||||
@@ -2144,11 +2148,11 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
// \/\/\/\/\/\/ CWKPQ things \/\/\/\/\/\/
|
||||
|
||||
public final void toggleEnvironment(final String ms) {
|
||||
if (environment.containsKey(ms)) {
|
||||
moveEnvironment(ms, environment.get(ms) == 1 ? 2 : 1);
|
||||
Map<String, Integer> env = getEnvironment();
|
||||
|
||||
if (env.containsKey(ms)) {
|
||||
moveEnvironment(ms, env.get(ms) == 1 ? 2 : 1);
|
||||
} else {
|
||||
moveEnvironment(ms, 1);
|
||||
}
|
||||
@@ -2156,14 +2160,23 @@ public class MapleMap {
|
||||
|
||||
public final void moveEnvironment(final String ms, final int type) {
|
||||
broadcastMessage(MaplePacketCreator.environmentMove(ms, type));
|
||||
environment.put(ms, type);
|
||||
|
||||
objectWLock.lock();
|
||||
try {
|
||||
environment.put(ms, type);
|
||||
} finally {
|
||||
objectWLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public final Map<String, Integer> getEnvironment() {
|
||||
return environment;
|
||||
objectRLock.lock();
|
||||
try {
|
||||
return Collections.unmodifiableMap(environment);
|
||||
} finally {
|
||||
objectRLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// /\/\/\/\/\/\/\ CWKPQ things /\/\/\/\/\/\
|
||||
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
@@ -2352,8 +2365,7 @@ public class MapleMap {
|
||||
public void instanceMapFirstSpawn(int difficulty, boolean isPq) {
|
||||
for(SpawnPoint spawnPoint: allMonsterSpawn) {
|
||||
if(spawnPoint.getMobTime() == -1) { //just those allowed to be spawned only once
|
||||
MapleMonster monst = spawnPoint.getMonster();
|
||||
spawnMonster(monst);
|
||||
spawnMonster(spawnPoint.getMonster());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,32 +67,34 @@ public class MapleMapFactory {
|
||||
}
|
||||
String mapName = getMapName(mapid);
|
||||
MapleData mapData = source.getData(mapName);
|
||||
String link = MapleDataTool.getString(mapData.getChildByPath("info/link"), "");
|
||||
MapleData infoData = mapData.getChildByPath("info");
|
||||
|
||||
String link = MapleDataTool.getString(infoData.getChildByPath("link"), "");
|
||||
if (!link.equals("")) { //nexon made hundreds of dojo maps so to reduce the size they added links.
|
||||
mapName = getMapName(Integer.parseInt(link));
|
||||
mapData = source.getData(mapName);
|
||||
}
|
||||
float monsterRate = 0;
|
||||
MapleData mobRate = mapData.getChildByPath("info/mobRate");
|
||||
MapleData mobRate = infoData.getChildByPath("mobRate");
|
||||
if (mobRate != null) {
|
||||
monsterRate = ((Float) mobRate.getData()).floatValue();
|
||||
}
|
||||
map = new MapleMap(mapid, world, channel, MapleDataTool.getInt("info/returnMap", mapData), monsterRate);
|
||||
map = new MapleMap(mapid, world, channel, MapleDataTool.getInt("returnMap", infoData), monsterRate);
|
||||
map.setEventInstance(event);
|
||||
|
||||
String onFirstEnter = MapleDataTool.getString(mapData.getChildByPath("info/onFirstUserEnter"), String.valueOf(mapid));
|
||||
String onFirstEnter = MapleDataTool.getString(infoData.getChildByPath("onFirstUserEnter"), String.valueOf(mapid));
|
||||
map.setOnFirstUserEnter(onFirstEnter.equals("") ? String.valueOf(mapid) : onFirstEnter);
|
||||
|
||||
String onEnter = MapleDataTool.getString(mapData.getChildByPath("info/onUserEnter"), String.valueOf(mapid));
|
||||
String onEnter = MapleDataTool.getString(infoData.getChildByPath("onUserEnter"), String.valueOf(mapid));
|
||||
map.setOnUserEnter(onEnter.equals("") ? String.valueOf(mapid) : onEnter);
|
||||
|
||||
map.setFieldLimit(MapleDataTool.getInt(mapData.getChildByPath("info/fieldLimit"), 0));
|
||||
map.setMobInterval((short) MapleDataTool.getInt(mapData.getChildByPath("info/createMobInterval"), 5000));
|
||||
map.setFieldLimit(MapleDataTool.getInt(infoData.getChildByPath("fieldLimit"), 0));
|
||||
map.setMobInterval((short) MapleDataTool.getInt(infoData.getChildByPath("createMobInterval"), 5000));
|
||||
PortalFactory portalFactory = new PortalFactory();
|
||||
for (MapleData portal : mapData.getChildByPath("portal")) {
|
||||
map.addPortal(portalFactory.makePortal(MapleDataTool.getInt(portal.getChildByPath("pt")), portal));
|
||||
}
|
||||
MapleData timeMob = mapData.getChildByPath("info/timeMob");
|
||||
MapleData timeMob = infoData.getChildByPath("timeMob");
|
||||
if (timeMob != null) {
|
||||
map.timeMob(MapleDataTool.getInt(timeMob.getChildByPath("id")),
|
||||
MapleDataTool.getString(timeMob.getChildByPath("message")));
|
||||
@@ -198,15 +200,15 @@ public class MapleMapFactory {
|
||||
}
|
||||
|
||||
map.setClock(mapData.getChildByPath("clock") != null);
|
||||
map.setEverlast(mapData.getChildByPath("info/everlast") != null);
|
||||
map.setTown(mapData.getChildByPath("info/town") != null);
|
||||
map.setHPDec(MapleDataTool.getIntConvert("info/decHP", mapData, 0));
|
||||
map.setHPDecProtect(MapleDataTool.getIntConvert("info/protectItem", mapData, 0));
|
||||
map.setForcedReturnMap(MapleDataTool.getInt(mapData.getChildByPath("info/forcedReturn"), 999999999));
|
||||
map.setEverlast(infoData.getChildByPath("everlast") != null);
|
||||
map.setTown(infoData.getChildByPath("town") != null);
|
||||
map.setHPDec(MapleDataTool.getIntConvert("decHP", infoData, 0));
|
||||
map.setHPDecProtect(MapleDataTool.getIntConvert("protectItem", infoData, 0));
|
||||
map.setForcedReturnMap(MapleDataTool.getInt(infoData.getChildByPath("forcedReturn"), 999999999));
|
||||
map.setBoat(mapData.getChildByPath("shipObj") != null);
|
||||
map.setTimeLimit(MapleDataTool.getIntConvert("timeLimit", mapData.getChildByPath("info"), -1));
|
||||
map.setFieldType(MapleDataTool.getIntConvert("info/fieldType", mapData, 0));
|
||||
map.setMobCapacity(MapleDataTool.getIntConvert("fixedMobCapacity", mapData.getChildByPath("info"), 500));//Is there a map that contains more than 500 mobs?
|
||||
map.setTimeLimit(MapleDataTool.getIntConvert("timeLimit", infoData, -1));
|
||||
map.setFieldType(MapleDataTool.getIntConvert("fieldType", infoData, 0));
|
||||
map.setMobCapacity(MapleDataTool.getIntConvert("fixedMobCapacity", infoData, 500));//Is there a map that contains more than 500 mobs?
|
||||
|
||||
HashMap<Integer, Integer> backTypes = new HashMap<>();
|
||||
try {
|
||||
@@ -292,7 +294,7 @@ public class MapleMapFactory {
|
||||
builder.append("MasteriaGL");
|
||||
} else if (mapid >= 677000000 && mapid < 677100000) {
|
||||
builder.append("Episode1GL");
|
||||
} else if (mapid >= 670000000 && mapid < 690000000) {
|
||||
} else if (mapid >= 670000000 && mapid < 682000000) {
|
||||
builder.append("weddingGL");
|
||||
} else if (mapid >= 682000000 && mapid < 683000000) {
|
||||
builder.append("HalloweenGL");
|
||||
|
||||
Reference in New Issue
Block a user