My game starts lagging if the map is too large

Discussion in 'RPG Maker VX Ace' started by toto8080, Mar 8, 2018.

  1. toto8080

    toto8080 Villager Member

    Messages:
    15
    Likes Received:
    0
    First Language:
    German
    Primarily Uses:
    RMVXA
    Sorry if I'm posting my thread in a wrong topic, but since Im still new I still need some time to adapt the structure of the site.

    I have a huge project, where I make a pathfinder in RGSS3. So my problem is, if my dungeon is big ( for example 100x50 tiles), and the pathfinder event is far enough (ca. 50 tiles), it starts lagging, since the script is running as a paralell, repeat process, and the lagging occurs because it has to compute all the neighnour and parent tiles, so it has a lot to do, which needs time of course.

    I found basic AStar pseudos around the internet, and I implemented one in RGSS3, so my script should be full and functional, with all the necessarily functions in it.

    Is there a way to make the game smooth, without changing all my dungeons size?
     
    Last edited: Mar 10, 2018
    #1
  2. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,934
    Likes Received:
    9,942
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Alright, let me explain what the lag is.
    Lag is, simply put, when the CPU core doesn't have enough time to handle all stacked functions, because it's already handling a different function for too long due to its complexity or due to, if they're multiple, their complexity.
    So the only way to prevent that function from making your game lag is to reduce its complexity... Or pass it to another thread via multithreading, so it doesn't interfere with the main thread. Here it depends on one or two things:
    1. Ruby itself can do multithreading. But can VXAce's RGSS3 do multithreading? That is a question I don't know the answer to.
    2. If RGSS3 can do multithreading, are you capable of using it properly?
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,718
    Likes Received:
    11,428
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Pathfinding scripts lag when you have them on large maps. If you have yours as a parallel process, continually pathfinding, you're causing incredible lag. It's just a bad idea all round imo.
     
    #3
  4. toto8080

    toto8080 Villager Member

    Messages:
    15
    Likes Received:
    0
    First Language:
    German
    Primarily Uses:
    RMVXA
    The point of my game is, that the enemy continiusly calculates the optimal path toward the player's character. The script has to be paralell, since the player can move and therefore its position changes.

    Do you know any solution, where the game doesnt lag in that case?
     
    #4
  5. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,394
    Likes Received:
    4,968
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Assume you could script, why not 'stop' the script after like 10-50 nodes of search and let the game update it first, the continue the search?
    Real-time searching is different with simply A* implementation which works better in turn based game
     
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,718
    Likes Received:
    11,428
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    No, I don't know a solution, which is why I never implemented it in my Ace mouse script despite many requests from people who didn't realise the issues it would cause.
     
    #6
  7. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,115
    Likes Received:
    12,302
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    The problem is, pathfinding is just too complex for even today's systems. Ever play Dragon's Age (any of them)? The game will often hang 1 - 2 seconds when you select a new location as it is calculating the path for the party. So if it is trying to calculate this for each enemy every second, it will lag, even with today's computers.

    The better solution might be to have your parallel process invoke a 60 second wait. The player isn't going to move enough in 60 seconds to affect it too much. Then have it update. That should go a long ways to reducing the lag.
     
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    37,718
    Likes Received:
    11,428
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    60 seconds, or 60 frames?
     
    #8
  9. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,115
    Likes Received:
    12,302
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Good catch. I meant 60 frames. Though 60 seconds would probably also reduce the lag :p
     
    #9
  10. toto8080

    toto8080 Villager Member

    Messages:
    15
    Likes Received:
    0
    First Language:
    German
    Primarily Uses:
    RMVXA
    Sadly, none of the suggested methods are working.

    Because the player is - probably - always moving, the distance is between him and the chasing event is not changing, therefore the big 'calculations', where the script stores the current tiles and parents is always the same size, if not bigger. If I'm not mistaken, this wont help reduce the lag.

    The problem is same as the previous one. Its the same, if the event have to do the 'big work' now, or 60 sec later, the lag is still there.

    Guess the only option I left with that I have to reduce my dungeons from 100x50 to 50x50 and hope for the best. :(
     
    #10

Share This Page