Reformat and clean up portal scripts

This commit is contained in:
P0nk
2021-09-09 23:35:59 +02:00
parent d893309b4f
commit a78ca88a02
435 changed files with 2712 additions and 2287 deletions

View File

@@ -2,17 +2,19 @@ var leverSequenceExit = false;
function enterLeverSequence(pi) {
var map = pi.getMap();
var jailn = (pi.getMap().getId() / 10) % 10;
var maxToggles = (jailn == 1) ? 7 : 6;
var mapProp = pi.getEventInstance().getProperty("jail" + jailn);
if(mapProp == null) {
if (mapProp == null) {
var seq = 0;
for(var i = 1; i <= maxToggles; i++) {
if(Math.random() < 0.5) seq += (1 << i);
for (var i = 1; i <= maxToggles; i++) {
if (Math.random() < 0.5) {
seq += (1 << i);
}
}
pi.getEventInstance().setProperty("jail" + jailn, seq);
@@ -20,16 +22,16 @@ function enterLeverSequence(pi) {
}
mapProp = Number(mapProp);
if(mapProp != 0) {
if (mapProp != 0) {
var countMiss = 0;
for(var i = 1; i <= maxToggles; i++) {
if(!(pi.getMap().getReactorByName("lever" + i).getState() == (mapProp >> i) % 2)) {
for (var i = 1; i <= maxToggles; i++) {
if (!(pi.getMap().getReactorByName("lever" + i).getState() == (mapProp >> i) % 2)) {
countMiss++;
}
}
const PacketCreator = Java.type('tools.PacketCreator');
if(countMiss > 0) {
if (countMiss > 0) {
map.broadcastMessage(PacketCreator.showEffect("quest/party/wrong_kor"));
map.broadcastMessage(PacketCreator.playSound("Party1/Failed"));
@@ -42,7 +44,8 @@ function enterLeverSequence(pi) {
pi.getEventInstance().setProperty("jail" + jailn, "0");
}
pi.playPortalSound(); pi.warp(pi.getMapId() + 2,0);
pi.playPortalSound();
pi.warp(pi.getMapId() + 2, 0);
return true;
}
@@ -54,7 +57,8 @@ function enterNoMobs(pi) {
pi.playerMessage(5, "Please use the levers to defeat all the threats before you proceed.");
return false;
} else {
pi.playPortalSound(); pi.warp(pi.getMapId() + 2,0);
pi.playPortalSound();
pi.warp(pi.getMapId() + 2, 0);
return true;
}
}