Hi, I have a storyline involving the player character trying to steal things from a shop; if the shopkeeper looks in their direction, they're caught and there are consequences. If not, they acquire the item (ideally after a short pause). I'm having difficulty writing the script I need for the shopkeeper to spot the culprit though and although I took a lot of guidance from this, it's not working properly either as-written or after modifying for RMMZ per the script call reference.
This is the script I've come up with that, to my mind, should function for event ID 022:
$gameMap.event(022).direction() == 2 && $gameMap.event(022).y < $gamePlayer.y ||
$gameMap.event(022).direction() == 8 && $gameMap.event(022).y > $gamePlayer.y ||
$gameMap.event(022).direction() == 4 && $gameMap.event(022).x > $gamePlayer.x ||
$gameMap.event(022).direction() == 6 && $gameMap.event(022).x < $gamePlayer.x
Unfortunately, it doesn't work.
I've also tried:
I'd very much welcome any help!
This is the script I've come up with that, to my mind, should function for event ID 022:
$gameMap.event(022).direction() == 2 && $gameMap.event(022).y < $gamePlayer.y ||
$gameMap.event(022).direction() == 8 && $gameMap.event(022).y > $gamePlayer.y ||
$gameMap.event(022).direction() == 4 && $gameMap.event(022).x > $gamePlayer.x ||
$gameMap.event(022).direction() == 6 && $gameMap.event(022).x < $gamePlayer.x
Unfortunately, it doesn't work.
I've also tried:
- Using
thison the event itself instead of$gameMap.event(022)set up on a different tile - Using
$gameParty.leader()instead of$gamePlayeras my game shows player followers - Using parentheses to isolate sections of the code, e.g.
($gameMap.event(022).direction() == 2) && ($gameMap.event(022).y < $gamePlayer.y) - Changing the location of my player in relation to the event as well as changing the event direction
- Breaking up the pieces (like testing only
$gameMap.event(022).direction() == 2) to identify where I've gone wrong, but none of them function independently - Running the code within a loop
I'd very much welcome any help!
