Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

NPC's not showing on certain maps

Joined
Apr 13, 2009
Messages
592
Reaction score
141
Hi,

I'm trying to add NPC's to these two maps; 552000040, and 931030000 using the NPC ids 9010026, and 9010024 respectively. My issue is that no matter how i add them, they both don't show up when I use PNPC or add through XML.

If I use the PNPC method, the NPC's save in the database under custom_mylife and displays on the map. However, after a server restart, they just disappear on 552000040 or 931030000. The PNPC method found in JudoMS does seem to work on other maps such as henesys or FM.

When I manually edit the XML using the code below, the NPC does not show up on 552000040. Interestingly, if I add the code to 552000030(similar to 552000040 but with NPC's pre-defined), the NPC actually appears.

Code:
		<imgdir name="life">
		<imgdir name="0">
			<string name="type" value="n"/>
			<string name="id" value="9010026"/>
			<int name="x" value="-423"/>
			<int name="y" value="21"/>
			<int name="mobTime" value="0"/>
			<int name="f" value="0"/>
			<int name="hide" value="0"/>
			<int name="fh" value="51"/>
			<int name="cy" value="21"/>
			<int name="rx0" value="-423"/>
			<int name="rx1" value="-423"/>
		</imgdir>
	</imgdir>

Help would be appreciated, this problem kinda stumped me :/.

Thanks.
 
Last edited:
Skilled Illusionist
Joined
Jul 17, 2010
Messages
333
Reaction score
165
Hi,

I'm trying to add NPC's to these two maps; 552000040, and 931030000 using the NPC ids 9010026, and 9010024 respectively. My issue is that no matter how i add them, they both don't show up when I use PNPC or add through XML.

If I use the PNPC method, the NPC's save in the database under custom_mylife and displays on the map. However, after a server restart, they just disappear on 552000040 or 931030000. The PNPC method found in JudoMS does seem to work on other maps such as henesys or FM.

That's because your custom-life-loader is in a for-loop for some reason.
Code:
                [B]for [/B](MapleData life : mapData.getChildByPath([B]"life"[/B])) [B]{[/B]
                    type = MapleDataTool.getString(life.getChildByPath("type"));
                    limited = MapleDataTool.getString("limitedname", life, "");
                    if ((npcs || !type.equals("n")) && !limited.equals("Stage0")) { //alien pq stuff
                        myLife = loadLife(life, MapleDataTool.getString(life.getChildByPath("id")), type);

                        if (myLife instanceof MapleMonster && !GameConstants.isNoSpawn(mapid)) {
                            final MapleMonster mob = (MapleMonster) myLife;

                            herbRocks.add(map.addMonsterSpawn(mob,
                                    MapleDataTool.getInt("mobTime", life, 0),
                                    (byte) MapleDataTool.getInt("team", life, -1),
                                    mob.getId() == bossid ? msg : null).getPosition());
                            if (mob.getStats().getLevel() > highestLevel && !mob.getStats().isBoss()) {
                                highestLevel = mob.getStats().getLevel();
                            }
                            if (mob.getStats().getLevel() < lowestLevel && !mob.getStats().isBoss()) {
                                lowestLevel = mob.getStats().getLevel();
                            }
                        } else if (myLife instanceof MapleNPC) {
                            map.addMapObject(myLife);
                        }
                    }
                    [B]final List<AbstractLoadedMapleLife> custom = customLife.get(mapid);[/B]
                    if (custom != null) {
                        for (AbstractLoadedMapleLife n : custom) {
                            if (n.getCType().equals("n")) {
                                map.addMapObject(n);
                            } else if (n.getCType().equals("m")) {
                                final MapleMonster monster = (MapleMonster) n;
                                map.addMonsterSpawn(monster, n.getMTime(), (byte) -1, null);
                            }
                        }
                    }
                [B]}[/B]
 
Upvote 0
Joined
Apr 13, 2009
Messages
592
Reaction score
141
Sorry could you elaborate a little more as to why it doesn't function correctly Yuuroido? Here is my pNPC loader

Code:
    public static int loadCustomLife() {
        customLife.clear(); // init
        try {
            Connection con = (Connection) DatabaseConnection.getConnection();
            java.sql.PreparedStatement ps = con.prepareStatement("SELECT * FROM `wz_customlife`");
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                final int mapid = rs.getInt("mid");
                final AbstractLoadedMapleLife myLife = loadLife(rs.getInt("dataid"), rs.getInt("f"), rs.getByte("hide") > 0, rs.getInt("fh"), rs.getInt("cy"), rs.getInt("rx0"), rs.getInt("rx1"), rs.getInt("x"), rs.getInt("y"), rs.getString("type"), rs.getInt("mobtime"));
                if (myLife == null) {
                    continue;
                }
                final List<AbstractLoadedMapleLife> entries = customLife.get(mapid);
                final List<AbstractLoadedMapleLife> collections = new ArrayList<>();
                if (entries == null) {
                    collections.add(myLife);
                    customLife.put(mapid, collections);
                } else {
                    collections.addAll(entries); // Re-add
                    collections.add(myLife);
                    customLife.put(mapid, collections);
                }
            }
            rs.close();
            ps.close();
            return customLife.size();
            //System.out.println("Successfully loaded " + customLife.size() + " maps with custom life.");
        } catch (SQLException e) {
            System.out.println("Error loading custom life..." + e);
        }
        return -1;
    }
 
Upvote 0
Skilled Illusionist
Joined
Jul 17, 2010
Messages
333
Reaction score
165
@Baha
Oh sorry, I referred to the following lines of code as custom-life-loader.
Code:
final List<AbstractLoadedMapleLife> custom = customLife.get(mapid);
if (custom != null) {
    for (AbstractLoadedMapleLife n : custom) {
        if (n.getCType().equals("n")) {
            map.addMapObject(n);
        } else if (n.getCType().equals("m")) {
            final MapleMonster monster = (MapleMonster) n;
            map.addMonsterSpawn(monster, n.getMTime(), (byte) -1, null);
        } 
    }
}
As you can see, it's in a for-loop in MapleMapFactory#getMap
Code:
for (MapleData life : mapData.getChildByPath("[B]life[/B]")) [B]{[/B]
    //snip
    final List<AbstractLoadedMapleLife> custom = customLife.get(mapid);
    if (custom != null) {
        for (AbstractLoadedMapleLife n : custom) {
            if (n.getCType().equals("n")) {
                map.addMapObject(n);
            } else if (n.getCType().equals("m")) {
                final MapleMonster monster = (MapleMonster) n;
                map.addMonsterSpawn(monster, n.getMTime(), (byte) -1, null);
            }
        }
    }
[B]}[/B]
Therefore, if there are no entries in a "life" node, it won't load any custom life, or, conversely, if there's more than one entry in a "life" node, multiple duplicated creatures will spawn in a map.
 
Upvote 0
Joined
Apr 13, 2009
Messages
592
Reaction score
141
Baha
Oh sorry, I referred to the following lines of code as custom-life-loader.
Code:
final List<AbstractLoadedMapleLife> custom = customLife.get(mapid);
if (custom != null) {
    for (AbstractLoadedMapleLife n : custom) {
        if (n.getCType().equals("n")) {
            map.addMapObject(n);
        } else if (n.getCType().equals("m")) {
            final MapleMonster monster = (MapleMonster) n;
            map.addMonsterSpawn(monster, n.getMTime(), (byte) -1, null);
        } 
    }
}
As you can see, it's in a for-loop in MapleMapFactory#getMap
Code:
for (MapleData life : mapData.getChildByPath("[B]life[/B]")) [B]{[/B]
    //snip
    final List<AbstractLoadedMapleLife> custom = customLife.get(mapid);
    if (custom != null) {
        for (AbstractLoadedMapleLife n : custom) {
            if (n.getCType().equals("n")) {
                map.addMapObject(n);
            } else if (n.getCType().equals("m")) {
                final MapleMonster monster = (MapleMonster) n;
                map.addMonsterSpawn(monster, n.getMTime(), (byte) -1, null);
            }
        }
    }
[B]}[/B]
Therefore, if there are no entries in a "life" node, it won't load any custom life, or, conversely, if there's more than one entry in a "life" node, multiple duplicated creatures will spawn in a map.

Thanks for the reply, I see that the maps I picked don't have a "life" node and that's why they aren't loading the custom NPC's.
Just one last thing, how come if I add the life node in XML it still doesn't load? Do I also have to throw that copy of the edited map into my actual map.wz to apply the changes?
 
Upvote 0
Skilled Illusionist
Joined
Jul 17, 2010
Messages
333
Reaction score
165
Thanks for the reply, I see that the maps I picked don't have a "life" node and that's why they aren't loading the custom NPC's.
Just one last thing, how come if I add the life node in XML it still doesn't load? Do I also have to throw that copy of the edited map into my actual map.wz to apply the changes?
Yeah, so you need to put it outside of the for-loop.

Well, maybe you have added duplicated "life" node in the file. Because there was already an empty "life" node, it might read the empty one instead of new one you added, and caused that error.
 
Upvote 0
Joined
Apr 13, 2009
Messages
592
Reaction score
141
Yeah, so you need to put it outside of the for-loop.

Well, maybe you have added duplicated "life" node in the file. Because there was already an empty "life" node, it might read the empty one instead of new one you added, and caused that error.

I didn't see the double no life node. Removing that made the NPC's start loading. I'll also try removing the for loop to stop the double loading and such. Thanks!! =)
 
Upvote 0
Back
Top