Help. Trying to create a stealth tag event system

● ARCHIVED · READ-ONLY
Started by JustKrancy 3 posts View original ↗
  1. Hi,

    I'm trying to create a stealth tag event system as the title says, where the event will wonder the map until it sees you, then it'll chase you and catch you.

    I found this thread which I've based my code on, translating the code for RMMV: https://forums.rpgmakerweb.com/index.php?threads/direction-based-line-of-sight-events.3452/

    My current problem I'm having is a SyntaxError: Unexpected end of input and I'm not sure what to do.

    I've included a screenshot of the console when the error occures.

    This is my first time posting, so apologies if this is in the wrong section.

    What I've got...
    Code:
    function getEventId() {($gameMap.event(this._eventId).x - $gamePlayer.x).abs <= 1 && ($gameMap.event(this._eventId).y - $gamePlayer.y).abs <= 3 || ($gameMap.event(this._eventId).y - $gamePlayer.y).abs <= 1 && ($gameMap.event(this._eventId).x - $gamePlayer.x).abs <= 3
    Code:
    function getEventDir() {$game_map.event(this._eventid).direction == 2 && $gameMap.event(this._eventId).y < $gamePlayer.y || $gameMap.event(this._eventId).direction == 8 && $gameMap.event(this._eventId).y > $gamePlayer.y || $gameMap.event(this._eventId).direction == 4 && $gameMap.event(this_eventId).x > $gamePlayer.x || $gameMap.event(this._eventId).direction == 6 && $gameMap.event(this._eventId).x < $gamePlayer.x}
    Code:
    function oneBlockCheck() {(($gameMap.event(this._eventId).x - $gamePlayer.x).abs + ($gameMap.event(this._eventId).y - $gamePlayer.y).abs) == 1}
  2. @JustKrancy If you want to add additional information, please just edit your earlier post and include it there. I have merged your two posts into one.
  3. Defining a function in a Script Event Command doesn't create the function for use later. Create a plugin file for your functions and add it to the plugin to the project.

    The getEventId() function is missing it's closing brace/curly bracket which is the source of the error message. Game_Event objects do not have an abs property and trying to access a property an object does not have results in a value of undefined. I assume the code means to get the absolute value of the x coordinate of an event. There's no return statement in the getEventId()which means its return value will be undefined. I'm guessing the language being translated from has some form of implicit return feature but JavaScript functions have to be told to return a value.

    Code:
    function example() {
        1 + 1;
    }
    
    example(); // Return value: undefined
    
    function example1() {
        return 1 + 1;
    }
    
    example1(): // Return value: 2

    There's more but that's all I've got time I've got for now.