Fix map spawn

Fix map failing to spawn in some cases.
This commit is contained in:
ronancpl
2017-04-06 10:07:14 -03:00
parent 7863994a13
commit 67af338f8a
18 changed files with 155 additions and 50 deletions

View File

@@ -127,4 +127,8 @@ Sparta lv100 n
Diversas alterações corretivas em itens das tabelas drop_data e reactordrops no BD.
04 Abril 2017,
Correção na API sobre progresso das quests.
Correção na API sobre progresso das quests.
06 Abril 2017,
Tentativa de correção em casos de falta de respawn em certas areas do jogo.
Otimização de funções que lidam com popular ou despopular areas.

View File

@@ -3,17 +3,15 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Nexon/MapleSolaxia/src/server/CashShop.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/client/MapleQuestStatus.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/scripting/map/MapScriptMethods.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/scripting/AbstractPlayerInteraction.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/scripting/npc/NPCConversationManager.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/client/MapleClient.java</file>
<file>file:/C:/Nexon/MapleSolaxia/scripts/npc/world0/9201134.js</file>
<file>file:/C:/Nexon/MapleSolaxia/scripts/npc/world0/2030010.js</file>
<file>file:/C:/Nexon/MapleSolaxia/scripts/npc/world0/2091005.js</file>
<file>file:/C:/Nexon/MapleSolaxia/src/server/life/SpawnPoint.java</file>
<file>file:/C:/Nexon/MapleSolaxia/scripts/npc/world0/2012002.js</file>
<file>file:/C:/Nexon/MapleSolaxia/src/server/maps/MapleMapFactory.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/server/life/MapleMonster.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/client/MapleCharacter.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/client/MonsterBook.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/tools/MaplePacketCreator.java</file>
<file>file:/C:/Nexon/MapleSolaxia/src/scripting/event/EventInstanceManager.java</file>
<file>file:/C:/Nexon/MapleSolaxia/scripts/event/Boats.js</file>
<file>file:/C:/Nexon/MapleSolaxia/src/server/maps/MapleMap.java</file>
</group>
</open-files>
</project-private>

View File

View File

View File

@@ -41,9 +41,12 @@ if (mode == 0 && status == 1) {
status++;
else
cm.dispose();
if (status == 1)
if (status == 1) {
cm.sendNext ("Alright, see you next time. Take care.");
else if (status == 2)
}
else if (status == 2) {
cm.warp(200000111, 0);// back to Orbis jetty
cm.dispose();
cm.dispose();
}
}

View File

@@ -26,6 +26,18 @@ var sel;
actionx = {"Mental" : false, "Physical" : false};
function start() {
if(cm.isQuestStarted(6192)) {
if(cm.getWarpMap(921100300).getCharacters().size() > 0)
cm.sendOk("There is someone currently in this map, come back later.");
else {
cm.resetMapObjects(921100300);
cm.warp(921100300);
}
cm.dispose();
return;
}
if (!(cm.getPlayer().getLevel() >= 70 && parseInt(cm.getJobId() / 100) == 1)){
cm.sendNext("Hi there.");
cm.dispose();

View File

@@ -0,0 +1,12 @@
function start() {
cm.sendNext("You did a great job back there, " + cm.getPlayer().getName() + ", well done. Now I will transport you back to El Nath. Have the pendant in your possession and talk to me when you feel ready to receive the new skill.");
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
cm.warp(211000000,"in01");
cm.dispose();
}
}

View File

@@ -22,10 +22,13 @@
function start() {
if(cm.isQuestCompleted(6002))
cm.sendOk("Thanks for saving the pork.");
else if(cm.getClient().getChannelServer().getMapFactory().getMap(923010000).getCharacters().size() > 0)
else if(cm.getWarpMap(923010000).getCharacters().size() > 0)
cm.sendOk("There is currently someone in this map, come back later.");
else if(cm.isQuestStarted(6002))
else if(cm.isQuestStarted(6002)) {
cm.resetMapObjects(923010000);
cm.warp(923010000);
}
else cm.sendSimple("Only few adventurers, from a selected public, are eligible to protect the Watch Hog.");
cm.dispose();
}

View File

@@ -32,7 +32,7 @@ var belts = Array(1132000, 1132001, 1132002, 1132003, 1132004);
var belt_level = Array(25, 35, 45, 60, 75);
/* var belt_points = Array(200, 1800, 4000, 9200, 17000); */
var belt_points = Array(5, 45, 100, 230, 425); /* Watered down version */
var belt_points = Array(10, 90, 200, 460, 850); /* Watered down version */
var status = -1;
var selectedMenu = -1;

View File

@@ -0,0 +1,9 @@
//Author: Ronan
function enter(pi) {
if(pi.hasItem(4031495)) pi.warp(921100301);
else pi.warp(211040100);
pi.getWarpMap(921100300).clearMapObjects();
return true;
}

View File

@@ -25,8 +25,10 @@ function enter(pi) {
pi.removeAll(4031508);
}
if (pi.getClient().getChannelServer().getMapFactory().getMap(923010000).getCharacters().size() < 1)
pi.getClient().getChannelServer().getMapFactory().getMap(923010000).killAllMonsters();
pi.warp(230000003, "out00");
if (pi.getClient().getChannelServer().getMapFactory().getMap(923010000).getCharacters().size() == 0) {
pi.getClient().getChannelServer().getMapFactory().getMap(923010000).clearMapObjects();
}
return true;
}

View File

@@ -124,7 +124,7 @@ public class AbstractPlayerInteraction {
return chars;
}
protected MapleMap getWarpMap(int map) {
public MapleMap getWarpMap(int map) {
MapleMap target;
if (getPlayer().getEventInstance() == null) {
target = c.getChannelServer().getMapFactory().getMap(map);
@@ -137,6 +137,10 @@ public class AbstractPlayerInteraction {
public MapleMap getMap(int map) {
return getWarpMap(map);
}
public void resetMapObjects(int mapid) {
getWarpMap(mapid).resetMapObjects();
}
public EventManager getEventManager(String event) {
return getClient().getEventManager(event);

View File

@@ -439,14 +439,15 @@ public class MapleMonster extends AbstractLoadedMapleLife {
eventInstance.monsterKilled(this);
}
}
// idk V just a troll
MapleCharacter looter = map.getCharacterById(getHighestDamagerId());
return looter != null ? looter : killer;
}
public void dispatchMonsterKilled() {
for (MonsterListener listener : listeners.toArray(new MonsterListener[listeners.size()])) {
listener.monsterKilled(getAnimationTime("die1"));
}
MapleCharacter looter = map.getCharacterById(getHighestDamagerId());
return looter != null ? looter : killer;
}
// should only really be used to determine drop owner

View File

@@ -26,7 +26,6 @@ import java.awt.Point;
import java.util.concurrent.atomic.AtomicInteger;
public class SpawnPoint {
private int monster, mobTime, team, fh, f;
private Point pos;
private long nextPossibleSpawn;
@@ -45,9 +44,17 @@ public class SpawnPoint {
this.mobInterval = mobInterval;
this.nextPossibleSpawn = System.currentTimeMillis();
}
public int getSpawned() {
return spawnedMonsters.intValue();
}
public void denySpawn(boolean val) {
spawnedMonsters.set((val == false) ? 0 : 1);
}
public boolean shouldSpawn() {
if (mobTime < 0 || ((mobTime != 0 || immobile) && spawnedMonsters.get() > 0) || spawnedMonsters.get() > 2) {//lol
if (mobTime < 0 || spawnedMonsters.get() > 0) {
return false;
}
@@ -55,7 +62,7 @@ public class SpawnPoint {
}
public boolean shouldForceSpawn() {
if (mobTime < 0 || ((mobTime != 0 || immobile) && spawnedMonsters.get() > 0) || spawnedMonsters.get() > 2) {//lol
if (mobTime < 0 || spawnedMonsters.get() > 0) {
return false;
}
@@ -98,4 +105,12 @@ public class SpawnPoint {
public final int getFh() {
return fh;
}
public int getMobTime() {
return mobTime;
}
public int getTeam() {
return team;
}
}

View File

@@ -85,6 +85,7 @@ public class MapleMap {
private static final List<MapleMapObjectType> rangedMapobjectTypes = Arrays.asList(MapleMapObjectType.SHOP, MapleMapObjectType.ITEM, MapleMapObjectType.NPC, MapleMapObjectType.MONSTER, MapleMapObjectType.DOOR, MapleMapObjectType.SUMMON, MapleMapObjectType.REACTOR);
private Map<Integer, MapleMapObject> mapobjects = new LinkedHashMap<>();
private Collection<SpawnPoint> monsterSpawn = Collections.synchronizedList(new LinkedList<SpawnPoint>());
private Collection<SpawnPoint> allMonsterSpawn = Collections.synchronizedList(new LinkedList<SpawnPoint>());
private AtomicInteger spawnedMonstersOnMap = new AtomicInteger(0);
private Collection<MapleCharacter> characters = new LinkedHashSet<>();
private Map<Integer, MaplePortal> portals = new HashMap<>();
@@ -672,6 +673,8 @@ public class MapleMap {
}
dropFromMonster(dropOwner, monster);
}
monster.dispatchMonsterKilled();
}
public void killFriendlies(MapleMonster mob) {
@@ -713,20 +716,20 @@ public class MapleMap {
if (monster.getStats().isFriendly()) {
continue;
}
spawnedMonstersOnMap.decrementAndGet();
monster.setHp(0);
broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), true), monster.getPosition());
removeMapObject(monster);
killMonster(monster, null, false, false, 1);
}
}
public void killAllMonsters() {
for (SpawnPoint spawnPoint : monsterSpawn) {
spawnPoint.denySpawn(true);
}
for (MapleMapObject monstermo : getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER))) {
MapleMonster monster = (MapleMonster) monstermo;
spawnedMonstersOnMap.decrementAndGet();
monster.setHp(0);
broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), true), monster.getPosition());
removeMapObject(monster);
killMonster(monster, null, false, false, 1);
}
}
@@ -1032,6 +1035,7 @@ public class MapleMap {
public void spawnMonster(final MapleMonster monster) {
if (mobCapacity != -1 && mobCapacity == spawnedMonstersOnMap.get()) {
System.out.println("got here");
return;//PyPQ
}
monster.setMap(this);
@@ -1050,11 +1054,13 @@ public class MapleMap {
}, null);
updateMonsterController(monster);
if (monster.getDropPeriodTime() > 0) { //9300102 - Watchhog, 9300061 - Moon Bunny (HPQ)
if (monster.getDropPeriodTime() > 0) { //9300102 - Watchhog, 9300061 - Moon Bunny (HPQ), 9300093 - Tylus
if (monster.getId() == 9300102) {
monsterItemDrop(monster, new Item(4031507, (short) 0, (short) 1), monster.getDropPeriodTime());
} else if (monster.getId() == 9300061) {
monsterItemDrop(monster, new Item(4001101, (short) 0, (short) 1), monster.getDropPeriodTime() / 3);
} else if (monster.getId() == 9300093) {
monsterItemDrop(monster, new Item(4031495, (short) 0, (short) 1), monster.getDropPeriodTime());
} else {
FilePrinter.printError(FilePrinter.UNHANDLED_EVENT, "UNCODED TIMED MOB DETECTED: " + monster.getId());
}
@@ -1782,7 +1788,13 @@ public class MapleMap {
if (sp.shouldSpawn() || mobTime == -1) {// -1 does not respawn and should not either but force ONE spawn
spawnMonster(sp.getMonster());
}
}
public void addAllMonsterSpawn(MapleMonster monster, int mobTime, int team) {
Point newpos = calcPointBelow(monster.getPosition());
newpos.y -= 1;
SpawnPoint sp = new SpawnPoint(monster, newpos, !monster.isMobile(), mobTime, mobInterval, team);
allMonsterSpawn.add(sp);
}
public Collection<MapleCharacter> getCharacters() {
@@ -2029,6 +2041,13 @@ public class MapleMap {
}
}
}
public void instanceMapFirstSpawn() {
for(SpawnPoint spawnPoint: allMonsterSpawn) {
if(spawnPoint.getMobTime() == -1) //just those allowed to be spawned only once
spawnMonster(spawnPoint.getMonster());
}
}
public void instanceMapRespawn() {
final int numShouldSpawn = (short) ((monsterSpawn.size() - spawnedMonstersOnMap.get()));//Fking lol'd
@@ -2045,6 +2064,12 @@ public class MapleMap {
}
}
}
public void restoreMapSpawnPoints() {
for (SpawnPoint spawnPoint : monsterSpawn) {
spawnPoint.denySpawn(false);
}
}
public void respawn() {
if (characters.isEmpty()) {
@@ -2059,9 +2084,10 @@ public class MapleMap {
if (spawnPoint.shouldSpawn()) {
spawnMonster(spawnPoint.getMonster());
spawned++;
}
if (spawned >= numShouldSpawn) {
break;
if (spawned >= numShouldSpawn) {
break;
}
}
}
}
@@ -2395,4 +2421,17 @@ public class MapleMap {
public short getMobInterval() {
return mobInterval;
}
public void clearMapObjects() {
clearDrops();
killAllMonsters();
resetReactors();
}
public void resetMapObjects() {
clearMapObjects();
restoreMapSpawnPoints();
instanceMapFirstSpawn();
}
}

View File

@@ -52,7 +52,7 @@ public class MapleMapFactory {
this.world = world;
this.channel = channel;
}
public MapleMap getMap(int mapid) {
Integer omapid = Integer.valueOf(mapid);
MapleMap map = maps.get(omapid);
@@ -148,6 +148,7 @@ public class MapleMapFactory {
} catch (Exception e) {
e.printStackTrace();
}
for (MapleData life : mapData.getChildByPath("life")) {
String id = MapleDataTool.getString(life.getChildByPath("id"));
String type = MapleDataTool.getString(life.getChildByPath("type"));
@@ -164,10 +165,14 @@ public class MapleMapFactory {
} else {
map.addMonsterSpawn(monster, mobTime, team);
}
//should the map be reseted, use allMonsterSpawn list of monsters to spawn them again
map.addAllMonsterSpawn(monster, mobTime, team);
} else {
map.addMapObject(myLife);
}
}
if (mapData.getChildByPath("reactor") != null) {
for (MapleData reactor : mapData.getChildByPath("reactor")) {
String id = MapleDataTool.getString(reactor.getChildByPath("id"));

View File

@@ -4253,15 +4253,12 @@
<string name="tn" value=""/>
</imgdir>
<imgdir name="2">
<string name="pn" value="out00"/>
<int name="pt" value="2"/>
<string name="pn" value="sp"/>
<int name="pt" value="0"/>
<int name="x" value="-364"/>
<int name="y" value="-508"/>
<int name="tm" value="211000000"/>
<string name="tn" value="in01"/>
<string name="script" value=""/>
<int name="hideTooltip" value="0"/>
<int name="delay" value="0"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
</imgdir>
<imgdir name="3">
<string name="pn" value="out01"/>
@@ -4270,7 +4267,7 @@
<int name="y" value="-207"/>
<int name="tm" value="999999999"/>
<string name="tn" value=""/>
<string name="script" value="s4common1_clear"/>
<string name="script" value="s4common1_exit"/>
<int name="hideTooltip" value="0"/>
<int name="delay" value="0"/>
</imgdir>

View File

@@ -17,6 +17,7 @@
<float name="fs" value="10.0"/>
<int name="summonType" value="1"/>
<int name="damagedByMob" value="1"/>
<int name="dropItemPeriod" value="10"/>
</imgdir>
<imgdir name="stand">
<canvas name="0" width="68" height="81">