Merge pull request #99 from cpurules/feature/rebirth-paths

Update rebirth NPC to allow path selection
This commit is contained in:
Ponk
2022-08-16 12:40:55 +02:00
committed by GitHub
2 changed files with 29 additions and 7 deletions

View File

@@ -24,6 +24,7 @@
@author wejrox
*/
var status;
var jobId = 0;
function start() {
status = -1;
@@ -49,18 +50,29 @@ function action(mode, type, selection) {
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?");
if (cm.getChar().getLevel() === cm.getChar().getMaxClassLevel()) {
cm.sendSimple("I see... and which path would you like to take? \r\n\r\n #L0##bExplorer (Beginner)#l \r\n #L1##bCygnus Knight (Noblesse)#l \r\n #L2##bAran (Legend)#l");
} else {
cm.sendOk("You are not level 200, please come back when you hit level 200.");
cm.sendOk("It looks like your journey has not yet ended... come back when you're level " + cm.getChar().getMaxClassLevel());
cm.dispose();
}
} else if (selection === 1) {
cm.sendOk("See you soon!")
cm.dispose();
}
} else if (status === 3 && type === 1) {
cm.getChar().executeReborn();
} else if (status === 3) {
// 0 => beginner, 1000 => noblesse, 2000 => legend
// makes this very easy :-)
jobId = selection * 1000;
var job = "";
if (selection === 0) job = "Beginner";
else if (selection === 1) job = "Noblesse";
else if (selection === 2) job = "Legend";
cm.sendYesNo("Are you sure you want to be reborn as a " + job + "?");
}
else if (status === 4 && type === 1) {
cm.getChar().executeRebornAsId(jobId);
cm.sendOk("You have now been reborn. That's a total of #r" + cm.getChar().getReborns() + "#k rebirths");
cm.dispose();
}

View File

@@ -11137,15 +11137,25 @@ public class Character extends AbstractCharacterObject {
}
public void executeReborn() {
// default to beginner: job id = 0
// this prevents a breaking change
executeRebornAs(Job.BEGINNER);
}
public void executeRebornAsId(int jobId) {
executeRebornAs(Job.getById(jobId));
}
public void executeRebornAs(Job job) {
if (!YamlConfig.config.server.USE_REBIRTH_SYSTEM) {
yellowMessage("Rebirth system is not enabled!");
throw new NotEnabledException();
}
if (getLevel() != 200) {
if (getLevel() != getMaxClassLevel()) {
return;
}
addReborns();
changeJob(Job.BEGINNER);
changeJob(job);
setLevel(0);
levelUp(true);
}