Add back in NPC conversation names
The names of the npc conversations were useful for context. Added them back in.
This commit is contained in:
@@ -463,5 +463,5 @@ server:
|
||||
|
||||
#Any NPC ids that should search for a js override script (useful if they already have wz entries since otherwise they're ignored).
|
||||
NPCS_SCRIPTABLE:
|
||||
#- 9200000 # Cody
|
||||
- 9001105 # Grandpa moon bunny
|
||||
#9200000: Talk to Cody # Cody
|
||||
9001105: Rescue Gaga! # Grandpa moon bunny
|
||||
|
||||
@@ -308,5 +308,5 @@ public class ServerConfig {
|
||||
public long EVENT_END_TIMESTAMP;
|
||||
|
||||
//Custom NPC overrides. List of NPC IDs.
|
||||
public List<Integer> NPCS_SCRIPTABLE = new ArrayList<>();
|
||||
public Map<String, String> NPCS_SCRIPTABLE = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
|
||||
@@ -406,15 +407,20 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
eim.registerPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tell the client to use the custom scripts available for the NPCs provided, instead of the WZ entries.
|
||||
if (YamlConfig.config.server.USE_NPCS_SCRIPTABLE) {
|
||||
|
||||
// Create a set to remove duplicate entries if they exist.
|
||||
Set<Integer> npcsIds = new HashSet<>(YamlConfig.config.server.NPCS_SCRIPTABLE);
|
||||
// Create a copy to prevent always adding entries to the server's list.
|
||||
Map<Integer, String> npcsIds = YamlConfig.config.server.NPCS_SCRIPTABLE
|
||||
.entrySet().stream().collect(Collectors.toMap(
|
||||
entry -> Integer.parseInt(entry.getKey()),
|
||||
Entry::getValue
|
||||
));
|
||||
|
||||
// Any npc be specified as the rebirth npc. Allow the npc to use custom scripts explicitly.
|
||||
if (YamlConfig.config.server.USE_REBIRTH_SYSTEM) {
|
||||
npcsIds.add(YamlConfig.config.server.REBIRTH_NPC_ID);
|
||||
npcsIds.put(YamlConfig.config.server.REBIRTH_NPC_ID, "Rebirth");
|
||||
}
|
||||
|
||||
c.announce(MaplePacketCreator.setNPCScriptable(npcsIds));
|
||||
|
||||
@@ -8326,13 +8326,14 @@ public class MaplePacketCreator {
|
||||
* @param scriptableNpcIds Ids of npcs to enable scripts for.
|
||||
* @return a packet which makes the npc's provided scriptable.
|
||||
*/
|
||||
public static byte[] setNPCScriptable(Set<Integer> scriptableNpcIds) { // thanks to GabrielSin
|
||||
public static byte[] setNPCScriptable(Map<Integer, String> scriptableNpcIds) { // thanks to GabrielSin
|
||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SET_NPC_SCRIPTABLE.getValue());
|
||||
mplew.write(scriptableNpcIds.size());
|
||||
scriptableNpcIds.forEach(id -> {
|
||||
scriptableNpcIds.forEach((id, name) -> {
|
||||
mplew.writeInt(id);
|
||||
mplew.writeMapleAsciiString("NPC " + id); // The client needs a name for the npc, but it doesn't seem to do anything.
|
||||
// The client needs a name for the npc conversation, which is displayed under etc when the npc has a quest available.
|
||||
mplew.writeMapleAsciiString(name);
|
||||
mplew.writeInt(0); // start time
|
||||
mplew.writeInt(Integer.MAX_VALUE); // end time
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user