From 45ca7009c8322bed2951409fe16c9ec4415fd423 Mon Sep 17 00:00:00 2001 From: James McDowell Date: Sun, 16 May 2021 10:32:51 +1000 Subject: [PATCH] Updated to allow a generic rebirth npc id to be passed through and used for rebirthing if it's enabled. --- config.yaml | 1 + scripts/npc/9010021.js | 46 ++----------- scripts/npc/rebirth.js | 66 +++++++++++++++++++ src/main/java/config/ServerConfig.java | 1 + .../channel/handlers/NPCTalkHandler.java | 2 + 5 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 scripts/npc/rebirth.js diff --git a/config.yaml b/config.yaml index 34a13ef794..e3a5fc5f2f 100644 --- a/config.yaml +++ b/config.yaml @@ -319,6 +319,7 @@ server: NAME_CHANGE_COOLDOWN: 2592000000 # (30*24*60*60*1000) Cooldown for name changes, default (GMS) is 30 days. WORLD_TRANSFER_COOLDOWN: 2592000000 # (30*24*60*60*1000) Cooldown for world tranfers, default is same as name change (30 days). INSTANT_NAME_CHANGE: false #Whether or not to wait for server restart to apply name changes. Does on reconnect otherwise (requires queries on every login). + REBIRTH_NPC_ID: 9010021 #ID of the NPC that should be replaced with the rebirth mechanic, if enabled. #Dangling Items/Locks Configuration ITEM_EXPIRE_TIME: 180000 # (3 * 60 * 1000) Time before items start disappearing. Recommended to be set up to 3 minutes. diff --git a/scripts/npc/9010021.js b/scripts/npc/9010021.js index 0abd074218..8899b84e00 100644 --- a/scripts/npc/9010021.js +++ b/scripts/npc/9010021.js @@ -21,47 +21,9 @@ */ /* 9010021 - Wolf Spirit Ryko @author Ronan - */ - var status; - + @author wejrox +*/ function start() { - status = -1; - if (!Packages.config.YamlConfig.config.server.USE_REBIRTH_SYSTEM) { - cm.sendOk("... I came from distant planes to assist the fight against the #rBlack Magician#k. Right now I search my master, have you seen him?"); - cm.dispose(); - return; - } - action(1, 0, 0); -} - -function action(mode, type, selection) { - if (mode == 1) { - status++; - } else { - cm.dispose(); - return; - } - if (status == 0) { - cm.sendNext("Come to me when you want to be reborn again. You currently have a total of #r" + cm.getChar().getReborns() + " #krebirths."); - } else if (status == 1) { - cm.sendSimple("What do you want me to do today: \r\n \r\n #L0##bI want to be rebirthed#l \r\n #L1##bMaybe next time#k#l"); - } else if (status == 2) { - if (selection == 0) { - if (cm.getChar().getLevel() == 200) { - cm.sendYesNo("Are you sure you want to be rebirthed?"); - } else { - cm.sendOk("You are not level 200, please come back when you hit level 200."); - cm.dispose(); - } - } else if (selection == 1) { - cm.sendOk("Ok Bye") - cm.dispose(); - } - } else if (status == 3 && type == 1) { - cm.getChar().executeReborn(); - cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths"); - cm.dispose(); - } - - + cm.sendOk("... I came from distant planes to assist the fight against the #rBlack Magician#k. Right now I search my master, have you seen him?"); + cm.dispose(); } \ No newline at end of file diff --git a/scripts/npc/rebirth.js b/scripts/npc/rebirth.js new file mode 100644 index 0000000000..c32670e46a --- /dev/null +++ b/scripts/npc/rebirth.js @@ -0,0 +1,66 @@ +/* + This file is part of the OdinMS Maple Story Server + Copyright (C) 2008 Patrick Huy + Matthias Butz + Jan Christian Meyer + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation version 3 as published by + the Free Software Foundation. You may not use, modify or distribute + this program under any other version of the GNU Affero General Public + License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/* 9010021 - Wolf Spirit Ryko + @author Ronan + @author wejrox +*/ +var status; + +function start() { + status = -1; + if (!Packages.config.YamlConfig.config.server.USE_REBIRTH_SYSTEM) { + cm.sendOk("Rebirths aren't enabled on this server, how did you get here?"); + cm.dispose(); + return; + } + action(1, 0, 0); +} + +function action(mode, type, selection) { + if (mode == 1) { + status++; + } else { + cm.dispose(); + return; + } + if (status == 0) { + cm.sendNext("Come to me when you want to be reborn again. You currently have a total of #r" + cm.getChar().getReborns() + " #krebirths."); + } else if (status == 1) { + cm.sendSimple("What do you want me to do today: \r\n \r\n #L0##bI want to be reborn!#l \r\n #L1##bNothing for now...#k#l"); + } else if (status == 2) { + if (selection == 0) { + if (cm.getChar().getLevel() == 200) { + cm.sendYesNo("Are you sure you want to be reborn?"); + } else { + cm.sendOk("You are not level 200, please come back when you hit level 200."); + cm.dispose(); + } + } else if (selection == 1) { + cm.sendOk("See you soon!") + cm.dispose(); + } + } else if (status == 3 && type == 1) { + cm.getChar().executeReborn(); + cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths"); + cm.dispose(); + } +} \ No newline at end of file diff --git a/src/main/java/config/ServerConfig.java b/src/main/java/config/ServerConfig.java index dbdd9e0a76..5aee568e01 100644 --- a/src/main/java/config/ServerConfig.java +++ b/src/main/java/config/ServerConfig.java @@ -163,6 +163,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; //Dangling Items/Locks Configuration public int ITEM_EXPIRE_TIME ; diff --git a/src/main/java/net/server/channel/handlers/NPCTalkHandler.java b/src/main/java/net/server/channel/handlers/NPCTalkHandler.java index 71f71c345c..73fec20467 100644 --- a/src/main/java/net/server/channel/handlers/NPCTalkHandler.java +++ b/src/main/java/net/server/channel/handlers/NPCTalkHandler.java @@ -65,6 +65,8 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler { NPCScriptManager.getInstance().start(c, npc.getId(), "gachapon", null); } else if (npc.getName().endsWith("Maple TV")) { NPCScriptManager.getInstance().start(c, npc.getId(), "mapleTV", null); + } else if (YamlConfig.config.server.USE_REBIRTH_SYSTEM && npc.getId() == YamlConfig.config.server.REBIRTH_NPC_ID) { + NPCScriptManager.getInstance().start(c, npc.getId(), "rebirth", null); } else { boolean hasNpcScript = NPCScriptManager.getInstance().start(c, npc.getId(), oid, null); if (!hasNpcScript) {