NPC :
var posArrayx = [-1638, -1496, -1386, -1366, -1286, -1252, -1178, -1040, -908, -884, -678, -578, -584, -438, -318, -200, 300, 560, 618, 784, 778, 894, 1142, 1048, 1234, 1348];
var eim, status = -1;
function start() {
eim = cm.getPlayer().getEventInstance();
if (eim != null) {
action(1, 0, 0);
} else {
cm.warp(261000021);
cm.dispose();
}
}
function action(m, t, s) {
if (m < 0) {
cm.dispose();
return;
}
if (m == 1)
status++;
else
status--;
if (status < 0) {
cm.dispose();
return;
}
var randClick = parseInt(eim.getProperty("randClick"));
var mesosArray = eim.getProperty("mesosArray").split(",");
var expArray = eim.getProperty("expArray").split(",");
var clickedSpots = eim.getProperty("clickedSpots").split(",");
for (var i = 0; i < posArrayx.length; i++) {
if (npc.getPosition().getX() == posArrayx[i]) {
if (i == randClick) {
cm.sendOk("Lol its the right one, but it isnt coded yet");
cm.dispose();
} else if (clickedSpots[i] > 0) {
cm.sendOk("Its looks someone already checked this place, i'd better look somewhere else.");
} else if (expArray.indexOf(posArrayx[i]) >= 0) {
cm.sendOk("You gained some mesos");
var meso = Math.floor(Math.random() * 3000) + 1000;
cm.gainMeso(meso);
} else if (mesosArray.indexOf(posArrayx[i]) >= 0) {
cm.sendOk("You gained some mesos");
var exp = Math.floor(Math.random() * 3000) + 1000;
cm.gainExp(exp);
} else {
cm.sendOk("Unable to find anything inside.");
}
clickedSpots[i] = 1;
}
}
eim.setProperty("clickedSpots", clickedSpots.toString());
cm.dispose();
}
Eim :
var pqtime = 45, eventMaps = [926110000], minPlayers = 3, exitMap = 261000021;
var posArrayx = [-1638, -1496, -1386, -1366, -1286, -1252, -1178, -1040, -908, -884, -678, -578, -584, -438, -318, -200, 300, 560, 618, 784, 778, 894, 1142, 1048, 1234, 1348];
function init() {
}
function setup() {
var eim = em.newInstance("Romeo and Juliet");
var randClickSpot = Math.floor((Math.random() * 26) + 0);
eim.setProperty("randClick", randClickSpot);
var mesosArray = new Array();
var expArray = new Array();
var clickedSpots = new Array();
for (var i = 0; i < posArrayx.length; i++) {
clickedSpots.push(0);
var rand = Math.floor(Math.random() * 5);
if (i != randClickSpot) {
if (rand == 4) {
mesosArray.push(posArrayx[i]);
} else if (rand == 3) {
expArray.push(posArrayx[i]);
}
}
}
eim.setProperty("mesosArray", mesosArray.toString());
eim.setProperty("expArray", expArray.toString());
eim.setProperty("clickedSpots", clickedSpots.toString());
eim.startEventTimer(1000 * 60 * pqtime);
return eim;
}
function playerEntry(eim, player) {
var map = eim.getMapInstance(eventMaps[0]);
player.changeMap(map);
}
function playerDead(eim, player) {
}
function playerRevive(eim, player) {
var party = eim.getPlayers();// player presses ok on the death pop up.
if (eim.isLeader(player) || party.size() <= minPlayers) { // Check for party leader
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose();
} else {
playerExit(eim, player);
}
}
function changedMap(eim, player, mapid) {
var onEvent = false;
for (var i = 0; i < eventMaps.length; i++) {
if (mapid == eventMaps[i]) {
onEvent = true;
}
}
if (!onEvent) {
removePlayer(eim, player);
}
}
function playerDisconnected(eim, player) {
var party = eim.getPlayers();
if (eim.isLeader(player) || party.size() < minPlayers) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
if (party.get(i).equals(player)) {
removePlayer(eim, player);
} else {
playerExit(eim, party.get(i));
}
eim.dispose();
}
} else {
removePlayer(eim, player);
}
}
function leftParty(eim, player) {
var party = eim.getPlayers();
if (party.size() < minPlayers) {
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose();
} else {
playerExit(eim, player);
}
}
function disbandParty(eim) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose();
}
function playerExit(eim, player) {
eim.unregisterPlayer(player);
player.changeMap(exitMap);
}
function removePlayer(eim, player) {
eim.unregisterPlayer(player);
player.getMap().removePlayer(player);
player.setMap(exitMap);
}
function clearPQ(eim) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose();
}
function allMonstersDead(eim) {
}
function monsterDead(eim) {
}
function monsterValue(eim) {
return -1;
}
function cancelSchedule() {
}
function scheduledTimeout(eim) {
if (eim != null) {
if (eim.getPlayerCount() > 0) {
var pIter = eim.getPlayers().iterator();
while (pIter.hasNext()) {
playerExit(eim, pIter.next());
}
}
eim.dispose();
}
}
function dispose(eim) {
}
Error :
Caused by: sun.org.mozilla.javascript.internal.EvaluatorException: Array index 1
5 is out of bounds [0..0]. (<Unknown source>#49)
at sun.org.mozilla.javascript.internal.DefaultErrorReporter.runtimeError
(Unknown Source)
at sun.org.mozilla.javascript.internal.Context.reportRuntimeError(Unknow
n Source)
at sun.org.mozilla.javascript.internal.Context.reportRuntimeError(Unknow
n Source)
at sun.org.mozilla.javascript.internal.Context.reportRuntimeError2(Unkno
wn Source)
at sun.org.mozilla.javascript.internal.NativeJavaArray.put(Unknown Sourc
e)
at sun.org.mozilla.javascript.internal.ScriptableObject.putProperty(Unkn
own Source)
at sun.org.mozilla.javascript.internal.ScriptRuntime.setObjectIndex(Unkn
own Source)
at sun.org.mozilla.javascript.internal.ScriptRuntime.setObjectIndex(Unkn
own Source)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Unknown
Source)
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Unknown Sou
rce)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(Unknown
Source)
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(Unknown
Source)
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(Unknown
Source)
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(Unknown Sourc
e)
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(Unknown S
ource)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(Unknown
Source)
... 27 more
无论我怎么做。对于某些原因,我无法改变clickedSpots数组..它确实识别了数组,但我无法更改数据。我无法推进它。而且我无法更改其中的数据。行:49是,clickedPos [i] = 1.任何人都有解决这个问题的方法吗?我非常绝望。我尝试了几件事,但没有一件工作。