XS Random Event Position

heroscratch

Veteran
Veteran
Joined
Oct 10, 2012
Messages
111
Reaction score
12
First Language
English
Primarily Uses
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:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,146
Reaction score
12,418
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#=*==========================================================================*=#
 

heroscratch

Veteran
Veteran
Joined
Oct 10, 2012
Messages
111
Reaction score
12
First Language
English
Primarily Uses
@Shaz

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

100% solved.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,247
Reaction score
459
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:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,146
Reaction score
12,418
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Me : "Wearing glasses is annoying."
*put out glasses*
Also me : "Keep mistaking 0, 6 and 8."
oh god, a new version of RPG Maker is coming soon already....
So a new RPG Maker has been teased on RPG Maker Web's Twitter. Hmm...
So in my stream for the No Travel Game Jam, I mentioned we were going to do a teaching make a game from beginning to end series of streams, but it had to wait on an announcement I couldn't make yet before I could start... Keep your eyes on our twitter tonight.
Surprise extra Text Adventure session! Feel free to drop by!

Forum statistics

Threads
98,122
Messages
949,445
Members
129,401
Latest member
YagyuChan
Top