Reformat and clean up npc scripts

This commit is contained in:
P0nk
2021-09-09 23:35:02 +02:00
parent 0c1545f81d
commit d893309b4f
665 changed files with 19932 additions and 19046 deletions

View File

@@ -23,15 +23,15 @@ var status;
var stage;
function clearStage(stage, eim) {
eim.setProperty("stage" + stage + "clear", "true");
eim.showClearEffect(true);
eim.setProperty("stage" + stage + "clear", "true");
eim.showClearEffect(true);
eim.giveEventPlayersStageReward(stage);
eim.giveEventPlayersStageReward(stage);
}
function start() {
status = -1;
action (1, 0, 0);
action(1, 0, 0);
}
function action(mode, type, selection) {
@@ -42,31 +42,32 @@ function action(mode, type, selection) {
cm.dispose();
return;
}
if (mode == 1)
if (mode == 1) {
status++;
else
} else {
status--;
}
var eim = cm.getPlayer().getEventInstance();
if (eim == null) {
cm.warp(990001100);
} else {
if(eim.getProperty("stage1clear") == "true") {
if (eim.getProperty("stage1clear") == "true") {
cm.sendOk("Excellent work. You may proceed to the next stage.");
cm.dispose();
return;
}
if (cm.isEventLeader()) {
if (status == 0) {
if (eim.getProperty("stage1status") == null || eim.getProperty("stage1status").equals("waiting")) {
if (eim.getProperty("stage1phase") == null) {
stage = 1;
eim.setProperty("stage1phase",stage);
eim.setProperty("stage1phase", stage);
} else {
stage = parseInt(eim.getProperty("stage1phase"));
}
if (stage == 1) {
cm.sendOk("In this challenge, I shall show a pattern on the statues around me. When I give the word, repeat the pattern to me to proceed.");
} else {
@@ -74,7 +75,7 @@ function action(mode, type, selection) {
}
} else if (eim.getProperty("stage1status").equals("active")) {
stage = parseInt(eim.getProperty("stage1phase"));
if (eim.getProperty("stage1combo").equals(eim.getProperty("stage1guess"))) {
if (stage == 3) {
cm.getPlayer().getMap().getReactorByName("statuegate").forceHitReactor(1);
@@ -92,7 +93,7 @@ function action(mode, type, selection) {
eim.showWrongEffect();
cm.sendOk("You have failed this test.");
cm.mapMessage(5, "You have failed the Gatekeeper Test.");
eim.setProperty("stage1phase","1");
eim.setProperty("stage1phase", "1");
}
eim.setProperty("stage1status", "waiting");
cm.dispose();
@@ -100,17 +101,16 @@ function action(mode, type, selection) {
cm.sendOk("The statues are working on the pattern. Please wait.");
cm.dispose();
}
}
else if (status == 1) {
} else if (status == 1) {
var reactors = getReactors();
var combo = makeCombo(reactors);
cm.mapMessage(5, "Please wait while the combination is revealed.");
var delay = 5000;
for (var i = 0; i < combo.length; i++) {
cm.getPlayer().getMap().getReactorByOid(combo[i]).delayedHitReactor(cm.getClient(), delay + 3500*i);
cm.getPlayer().getMap().getReactorByOid(combo[i]).delayedHitReactor(cm.getClient(), delay + 3500 * i);
}
eim.setProperty("stage1status", "display");
eim.setProperty("stage1combo","");
eim.setProperty("stage1combo", "");
cm.dispose();
}
} else {
@@ -123,8 +123,8 @@ function action(mode, type, selection) {
//method for getting the statue reactors on the map by oid
function getReactors() {
var reactors = new Array();
var reactors = [];
var iter = cm.getPlayer().getMap().getReactors().iterator();
while (iter.hasNext()) {
var mo = iter.next();
@@ -132,12 +132,12 @@ function getReactors() {
reactors.push(mo.getObjectId());
}
}
return reactors;
}
function makeCombo(reactors) {
var combo = new Array();
var combo = [];
while (combo.length < (stage + 3)) {
var chosenReactor = reactors[Math.floor(Math.random() * reactors.length)];
var repeat = false;