XS Random Event Position

Discussion in 'RGSSx Script Support' started by heroscratch, Mar 25, 2015.

  1. heroscratch

    heroscratch Veteran Veteran

    Messages:
    111
    Likes Received:
    12
    Location:
    Colorado, USA
    First Language:
    English
    Sorry for posting so quickly in this thread, however I found the XS Random Even Position to be much easier for me to use;


    (script link: http://niclas-thornqvist.se/rpg/scripts/ace/xs-random-event-positions.txt)


    I have all my events I want randomized using the comment "<RANDOM_POS:1>". I have 20 random events, and 20 region tiles marked "1". Everything works great when I first enter; all is random as it should be. The problem I'm facing is that when I leave the dungeon, it doesn't randomize again upon re-entry, only the first time.


    Again; upon initial entry to my dungeon all is randomized. But if I leave and come back it doesn't randomize again.


    ***I understand the script says perma random. But there has to be some tweak in there I can change to simply randomize every time instead of only once****


    Thanks in advance for any help.
     
    Last edited by a moderator: Mar 25, 2015
    #1
  2. Shaz

    Shaz Veteran Veteran

    Messages:
    37,296
    Likes Received:
    11,118
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Yeah, I've only had a quick look through it, but it seems it chooses a random position the first time around, then saves it away and just looks it up again next time.

    I'm about to shut down, and don't have time to test, but try replacing the script with this shortened version, which doesn't save the details - it should re-randomize the position every time you load the map:

    Code:
    #==============================================================================#   XaiL System - Random Event Positions#   Author: Nicke#   Created: 04/11/2012#   Edited: 06/11/2012#   Version: 1.0#==============================================================================# Instructions# -----------------------------------------------------------------------------# To install this script, open up your script editor and copy/paste this script# to an open slot below ? Materials but above ? Main. Remember to save.#==============================================================================# Requires: XS - Core Script.#==============================================================================# The snippet enables you to specify a permanent random location in a# region tile, for a specific event using a comment:# <RANDOM_POS: n>## Examples:# <RANDOM_POS: 1> Enables the event to spawn at random location inside region id 1.# <RANDOM_POS: 9> Enables the event to spawn at random location inside region id 9.## This can be neat if you want to include a bit more randomness inside your# game.## *** Only for RPG Maker VX Ace. ***#==============================================================================($imported ||= {})["XAIL-RAND-EVT-POS"] = true# *** Don't edit below unless you know what you are doing. ***#==============================================================================## ** Error Handler#==============================================================================#  unless $imported["XAIL-XS-CORE"]    # // Error handler when XS - Core is not installed.    msg = "The script %s requires the latest version of XS - Core in order to function properly."    name = "XS - Random Event Positions"    msgbox(sprintf(msg, name))    exit  end#==============================================================================## ** Game_Map#==============================================================================#class Game_Map    def random_region_tile(id)    # // Method to get random tile in specified region id.    reg_tiles = []    for x in 0...width      for y in 0...height        next unless region_id(x, y) == id        next if x == $game_player.x and y == $game_player.y        next if $game_player.collide_with_characters?(x, y)        reg_tiles << ([x, y])      end    end    return reg_tiles.sample  end  end#==============================================================================## ** Game_Event#==============================================================================#class Game_Event < Game_Character    alias xail_rand_evt_pos_setup_page_settings setup_page_settings  def setup_page_settings(*args, &block)    # // Method to setup page settings for the event.    xail_rand_evt_pos_setup_page_settings(*args, &block)    random_pos(comment_int?("RANDOM_POS"))  end    def random_pos(id)    # // Method to determine random spawn location.    pos = $game_map.random_region_tile(id)    return if pos.nil? or id == 0    moveto(pos[0],pos[1])  end  end # END OF FILE#=*==========================================================================*=## ** END OF FILE#=*==========================================================================*=#
     
    #2
    heroscratch likes this.
  3. heroscratch

    heroscratch Veteran Veteran

    Messages:
    111
    Likes Received:
    12
    Location:
    Colorado, USA
    First Language:
    English
    @Shaz

    That worked perfectly. Thanks so much; if I could give you a kiss, I would. I'll like your reply instead.

    100% solved.
     
    #3
    Shaz likes this.
  4. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,578
    Likes Received:
    344
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    fixed script format
    Edited version of the original script.
    Code:
    #==============================================================================
    #   XaiL System - Random Event Positions
    #   Author: Nicke
    #   Created: 04/11/2012
    #   Edited: 06/11/2012 #by Shaz - will not save positions when changing maps
    #   Version: 1.0
    #==============================================================================
    # Instructions
    # -----------------------------------------------------------------------------
    # To install this script, open up your script editor and copy/paste this script
    # to an open slot below ? Materials but above ? Main. Remember to save.
    #==============================================================================
    # Requires: XS - Core Script.
    #==============================================================================
    # The snippet enables you to specify a permanent random location in a
    # region tile, for a specific event using a comment:
    # <RANDOM_POS: n>
    #
    # Examples:
    # <RANDOM_POS: 1> Enables the event to spawn at random location inside region id 1.
    # <RANDOM_POS: 9> Enables the event to spawn at random location inside region id 9.
    #
    # This can be neat if you want to include a bit more randomness inside your
    # game.
    #
    # *** Only for RPG Maker VX Ace. ***
    #==============================================================================
    ($imported ||= {})["XAIL-RAND-EVT-POS"] = true
    # *** Don't edit below unless you know what you are doing. ***
    #==============================================================================
    #
    # ** Error Handler
    #==============================================================================
    #
    unless $imported["XAIL-XS-CORE"] 
    # // Error handler when XS - Core is not installed. 
        msg = "The script %s requires the latest version of XS - Core in order to function properly." 
        name = "XS - Random Event Positions" 
        msgbox(sprintf(msg, name)) 
        exit
    end
    #==============================================================================
    #
    # ** Game_Map
    #==============================================================================
    #
    class Game_Map 
        def random_region_tile(id) 
        # // Method to get random tile in specified region id. 
            reg_tiles = [] 
            for x in 0...width   
                for y in 0...height     
                    next unless region_id(x, y) == id     
                    next if x == $game_player.x and y == $game_player.y     
                    next if $game_player.collide_with_characters?(x, y)     
                    reg_tiles << ([x, y])   
                end 
            end 
            return reg_tiles.sample
        end
    end
    #==============================================================================
    #
    # ** Game_Event
    #==============================================================================
    #
    class Game_Event < Game_Character 
        alias xail_rand_evt_pos_setup_page_settings setup_page_settings
        def setup_page_settings(*args, &block) 
        # // Method to setup page settings for the event. 
            xail_rand_evt_pos_setup_page_settings(*args, &block) 
            random_pos(comment_int?("RANDOM_POS"))
        end 
        def random_pos(id) 
        # // Method to determine random spawn location. 
            pos = $game_map.random_region_tile(id) 
            return if pos.nil? or id == 0 
            moveto(pos[0],pos[1])
        end
    end
    # END OF FILE
    #=*==========================================================================*=#
    # ** END OF FILE
    #=*==========================================================================*=#
     
    Last edited: May 25, 2019
    #4
    Shaz likes this.
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,296
    Likes Received:
    11,118
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Nice - thanks for that. Would you mind adding an extra line to the header to say it was edited by me on that date to not save the positions? I'd hate for people to grab that one thinking they have the original, when they don't.
     
    #5

Share This Page