Added the ability to specify a custom rebirth npc id, which is automatically added to the list of scriptable npcs for overriding. Changed scriptable npcs to use config instead of a constants file, so that users can easily modify them without digging into the code and requiring a rebuild.
This commit is contained in:
@@ -461,3 +461,7 @@ server:
|
||||
#Event End Timestamp
|
||||
EVENT_END_TIMESTAMP: 1428897600000
|
||||
|
||||
#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
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package config;
|
||||
|
||||
import tools.Pair;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ServerConfig {
|
||||
//Thread Tracker Configuration
|
||||
public boolean USE_THREAD_TRACKER;
|
||||
@@ -163,7 +167,7 @@ public class ServerConfig {
|
||||
public long NAME_CHANGE_COOLDOWN;
|
||||
public long WORLD_TRANSFER_COOLDOWN=NAME_CHANGE_COOLDOWN;//Cooldown for world tranfers, default is same as name change (30 days).
|
||||
public boolean INSTANT_NAME_CHANGE;
|
||||
public long REBIRTH_NPC_ID;
|
||||
public int REBIRTH_NPC_ID;
|
||||
|
||||
//Dangling Items/Locks Configuration
|
||||
public int ITEM_EXPIRE_TIME ;
|
||||
@@ -305,4 +309,6 @@ public class ServerConfig {
|
||||
//Event End Timestamp
|
||||
public long EVENT_END_TIMESTAMP;
|
||||
|
||||
//Custom NPC overrides. NPC ID to Name pair.
|
||||
public List<Integer> NPCS_SCRIPTABLE = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package constants.game;
|
||||
|
||||
/**
|
||||
* @brief ScriptableNPCConstants
|
||||
* @author GabrielSin <gabrielsin@playellin.net>
|
||||
* @date 16/09/2018
|
||||
*
|
||||
* Adaptations to use Pair and Set, in order to suit a one-packet marshall.
|
||||
* Adapted by Ronan
|
||||
*/
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import tools.Pair;
|
||||
|
||||
public class ScriptableNPCConstants {
|
||||
|
||||
public static final Set<Pair<Integer, String>> SCRIPTABLE_NPCS = new HashSet<Pair<Integer, String>>(){{
|
||||
//add(new Pair<>(9200000, "Cody"));
|
||||
add(new Pair<>(9001105, "Grandpa Moon Bunny"));
|
||||
}};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import client.inventory.*;
|
||||
import client.keybind.MapleKeyBinding;
|
||||
import config.YamlConfig;
|
||||
import constants.game.GameConstants;
|
||||
import constants.game.ScriptableNPCConstants;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import net.server.PlayerBuffValueHolder;
|
||||
import net.server.Server;
|
||||
@@ -409,7 +408,14 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.USE_NPCS_SCRIPTABLE) {
|
||||
c.announce(MaplePacketCreator.setNPCScriptable(ScriptableNPCConstants.SCRIPTABLE_NPCS));
|
||||
List<Integer> npcsIds = YamlConfig.config.server.NPCS_SCRIPTABLE;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
c.announce(MaplePacketCreator.setNPCScriptable(YamlConfig.config.server.NPCS_SCRIPTABLE));
|
||||
}
|
||||
|
||||
if(newcomer) player.setLoginTime(System.currentTimeMillis());
|
||||
|
||||
@@ -8318,17 +8318,24 @@ public class MaplePacketCreator {
|
||||
mplew.writeInt(transition);
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
public static byte[] setNPCScriptable(Set<Pair<Integer, String>> scriptNpcDescriptions) { // thanks to GabrielSin
|
||||
|
||||
/**
|
||||
* Makes the NPCs provided set as scriptable, informing the client to search for js scripts for these NPCs even
|
||||
* if they already have entries within the wz files.
|
||||
*
|
||||
* @param scriptableNpcIds Ids of npcs to enable scripts for.
|
||||
* @return a packet which makes the npc's provided scriptable.
|
||||
*/
|
||||
public static byte[] setNPCScriptable(List<Integer> scriptableNpcIds) { // thanks to GabrielSin
|
||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SET_NPC_SCRIPTABLE.getValue());
|
||||
mplew.write(scriptNpcDescriptions.size());
|
||||
for (Pair<Integer, String> p : scriptNpcDescriptions) {
|
||||
mplew.writeInt(p.getLeft());
|
||||
mplew.writeMapleAsciiString(p.getRight());
|
||||
mplew.write(scriptableNpcIds.size());
|
||||
scriptableNpcIds.forEach(id -> {
|
||||
mplew.writeInt(id);
|
||||
mplew.writeMapleAsciiString("NPC " + id); // The client needs a name for the npc, but it doesn't seem to do anything.
|
||||
mplew.writeInt(0); // start time
|
||||
mplew.writeInt(Integer.MAX_VALUE); // end time
|
||||
}
|
||||
});
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
@@ -8374,17 +8381,17 @@ public class MaplePacketCreator {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.TOURNAMENT_SET_PRIZE.getValue());
|
||||
|
||||
//0 = "You have failed the set the prize. Please check the item number again."
|
||||
//1 = "You have successfully set the prize."
|
||||
mplew.write(bSetPrize);
|
||||
|
||||
mplew.write(bHasPrize);
|
||||
|
||||
if(bHasPrize != 0)
|
||||
{
|
||||
mplew.writeInt(nItemID1);
|
||||
mplew.writeInt(nItemID2);
|
||||
}
|
||||
//0 = "You have failed the set the prize. Please check the item number again."
|
||||
//1 = "You have successfully set the prize."
|
||||
mplew.write(bSetPrize);
|
||||
|
||||
mplew.write(bHasPrize);
|
||||
|
||||
if(bHasPrize != 0)
|
||||
{
|
||||
mplew.writeInt(nItemID1);
|
||||
mplew.writeInt(nItemID2);
|
||||
}
|
||||
|
||||
return mplew.getPacket();
|
||||
}
|
||||
@@ -8393,11 +8400,11 @@ public class MaplePacketCreator {
|
||||
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.TOURNAMENT_UEW.getValue());
|
||||
|
||||
//Is this a bitflag o.o ?
|
||||
//2 = "You have reached the finals by default."
|
||||
//4 = "You have reached the semifinals by default."
|
||||
//8 or 16 = "You have reached the round of %n by default." | Encodes nState as %n ?!
|
||||
mplew.write(nState);
|
||||
//Is this a bitflag o.o ?
|
||||
//2 = "You have reached the finals by default."
|
||||
//4 = "You have reached the semifinals by default."
|
||||
//8 or 16 = "You have reached the round of %n by default." | Encodes nState as %n ?!
|
||||
mplew.write(nState);
|
||||
|
||||
return mplew.getPacket();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user