Hi everyone,
I've tried really really hard to figure this one out on my own, but I am not proficient in code. I'm trying a rather ambitious task of getting an animation to play on a particular event
via a common event that gets executed when certain conditions are met.
The condition is a timed period that is determined by a random number chosen between 1 and 4.
1 = 60 frames
2 = 120 frames
3 = 180 frames
4 = 240 frames
Additionally, I also need to make sure that the player isn't standing on the same tile of the event that the script is executed in.
If they are, the event continues past this script and uses other scripts instead (which work).
Here's what I tried to come up with - this is only the latest iteration of it, so there's probably a lot of double-handling as I was trying to figure out why I couldn't get it to work.
Code:
var ani = Math.random() * (5 - 1) + 1; var wait = 0; var px = $gamePlayer.x; var py = $gamePlayer.y; var ex = $gameMap.event(this._eventId).x; var ey = $gameMap.event(this._eventId).y;
if (ani == 1){
while ((px!== ex) && (py !== ey) && (wait < 61)){
if (wait >= 60){
$gameTemp.reserveCommonEvent(40);
}
if (wait >= 61){
break;
}
wait + 1;
}
}
if (ani == 2){
while ((px !== ex) && (py !== ey) && (wait < 121)){
if (wait >= 120){
$gameTemp.reserveCommonEvent(40);
}
if (wait >= 121){
break;
}
wait + 1;
}
}
if (ani == 3){
while ((px!== ex) && (py !== ey) && (wait < 181)){
if (wait >= 180){
$gameTemp.reserveCommonEvent(40);
}
if (wait >= 181){
break;
}
wait + 1;
}
}
if (ani == 4){
while ((px!== ex) && (py !== ey) && (wait < 241)){
if (wait >= 240){
$gameTemp.reserveCommonEvent(40);
}
if (wait >= 241){
break;
}
wait + 1;
}
}
Any thoughts to help me with this mess appreciated. Thanks!
EDIT: I tested the above script on a stand-alone parallel event without anything else going on with it to make sure nothing else on the same event was interfering with it. It still didn't work.
The common event it calls, for the moment, it just a simple "Show Text" command with nothing else in it for testing purposes.