shaynec1981

Veteran
Veteran
Joined
Jun 10, 2014
Messages
89
Reaction score
22
First Language
English
Primarily Uses
Random Common Event Occurence v1.0
Drykul


Introduction
Basically this acts similar to random battle events only it calls a specified Common Event instead of a battle.

Features
- Process common events at random intervals depending on Region ID.
- Can adjust the % chance per event as well as minimum # of steps required before the event will proc.
- Disable/Enable any particular event by either setting to true/false, a $game_switch, or any other boolean.

Screenshots
No screenshots needed.

How to Use
Simply set up your events in the "Configuration Section", set up your common event in the database, and paint your terrain with the Region ID you specify.

Demo
No Demo Included (I will post one if requested but it's pretty easy to set up and use.)

Script

Code:
=begin  ---------------------------------------------  Random Common Event Occurance v1.0 by Drykul  ---------------------------------------------    Basically this acts similar to random battle events only it calls a specified  Common Event instead of a battle. Simply set up your events below in the  "Configuration Section", set up your common event in the database, and paint  your terrain with the Region ID you specify below.   *Special thanks to Adorna for writing the initial script and giving me the  inspiration for this!   --------------  Compatibility  --------------    The update method in Scene_Map is aliased. Other than that you shouldn't have  any issues with compatibility!   --------------------------------			    ToS  --------------------------------    Completely free to use for commercial and non-commercial with no restrictions.  Just a heads up to me that you're using it would be nice.    --------------  Contacting me  --------------    You can email me at drykul@cloud9studios.net, find me on the  /r/RPGMaker subreddit, I'm shaynec1981 at www.rpgmakerweb.com=end################################################################################class Random_Event_Occuranceattr_reader :reo_region_idattr_accessor :random_eventsattr_accessor :steps_counting  def reo_setup    @random_events =    {######################################################################################## DO NOT EDIT ABOVE THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ################################# Configuration Section ################################	    # :event_name => [ region id,  #				  % chance of occurance,  #				  enabled/disabled,  #				  common event to run,  #				  minimum number of steps taken to process ],    :test1 => [ 1,			    50,			    true,			    4,			    10 ],        :test2 => [ 2,			    20,			    true,			    5,			    40 ],						    ######################################################################################### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING #######################################################################################    }  end  def initialize    @regionid = nil    @steps_counting = nil    @numbers_to_proc = []    @steps = 0    reo_setup  end   def encounter_chance(region_id)    for i in @random_events	  if i[1][0] == region_id && i[1][2] == true	    @steps += 1	    chance = rand(101)	    while @numbers_to_proc.size < i[1][1]		  new_num = rand(101)		  if !@numbers_to_proc.include?(new_num)		    @numbers_to_proc[@numbers_to_proc.size] = new_num		  end		   	    end	    if @numbers_to_proc.include?(chance) && @steps >= i[1][4]		  $game_temp.reserve_common_event(i[1][3])		  @steps = 0	    end	  end    end  end   def update    reo_setup    if @regionid != $game_map.region_id($game_player.x, $game_player.y)	  @regionid = $game_map.region_id($game_player.x, $game_player.y)	  @steps = 0    end    encounter_chance(@regionid)    @numbers_to_proc.clear  end end################# UPDATED SCENE_MAP ############################################class Scene_Map < Scene_Base   alias random_event_occurance_map_update update  def update    random_event_occurance_map_update    for i in $reo.random_events	  if $game_map.region_id($game_player.x, $game_player.y) == i[1][0]	    if $reo.steps_counting != $game_party.steps		  $reo.steps_counting = $game_party.steps		  $reo.update	    end	  end    end  endend################# UPDATED DATAMANAGER###########################################module DataManager  class << self        unless self.method_defined?(:reo_GameObj_Alias)	  alias_method(:reo_GameObj_Alias, :create_game_objects)    end    unless self.method_defined?(:reo_MakeSaveAlias)	  alias_method(:reo_MakeSaveAlias, :make_save_contents)    end    unless self.method_defined?(:reo_ExtractSaveAlias)	  alias_method(:reo_ExtractSaveAlias, :extract_save_contents)    end    def create_game_objects	  reo_GameObj_Alias	  $reo = Random_Event_Occurance.new    end        def make_save_contents	  contents = reo_MakeSaveAlias	  contents[:reo] = $reo	  contents    end        def extract_save_contents(contents)	  reo_ExtractSaveAlias(contents)	  $reo = contents[:reo]    end  endend

FAQ


Credit and Thanks
- Drykul
- Adorna

Author's Notes
I'm fairly new to scripting and this is the first one that I thought would be easy enough to clean up and share and to get some feedback! Hopefully it comes in handy for someone. :)
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,647
Reaction score
15,738
First Language
English
Primarily Uses
RMMV
FAQ: the demo won't open, how to open it? Download winrar and try again.


There is no demo ;)
 

JosephSeraph

White Mage
Restaff
Joined
Mar 7, 2014
Messages
1,199
Reaction score
1,465
First Language
Portuguese
Wow! This looks like a fantastic scriot Thanks for making it!

Evented battle systems are coming!!! :D
 

shaynec1981

Veteran
Veteran
Joined
Jun 10, 2014
Messages
89
Reaction score
22
First Language
English
Primarily Uses
Wow! This looks like a fantastic scriot Thanks for making it!

Evented battle systems are coming!!! :D
Looking forward to seeing what you come up with! I'm just happy at least one other person finds this useful! Lol
 

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
Cool script - I'm tempted to add rare encounters to my game this way. Dedicated areas on the map with a chance to spawn a dragon? 

Edit: I've used it so that the main character says things every once in a while whilst walking about!
 
Last edited by a moderator:

shaynec1981

Veteran
Veteran
Joined
Jun 10, 2014
Messages
89
Reaction score
22
First Language
English
Primarily Uses
Hah nice! I used it for when I had a player prancing about the woods you would randomly come across different areas or meet people. :)
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,859
First Language
English
Primarily Uses
RMVXA
Very cool script idea!  I could see this being used for a bunch of different things.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,535
Reaction score
854
First Language
English
Primarily Uses
RMVXA
Code fixed
Ruby:
=begin 
--------------------------------------------- 
Random Common Event Occurance v1.0 by Drykul 
---------------------------------------------   
Basically this acts similar to random battle events only it calls a specified 
Common Event instead of a battle. Simply set up your events below in the 
"Configuration Section", set up your common event in the database, and paint 
your terrain with the Region ID you specify below.   
*Special thanks to Adorna for writing the initial script and giving me the 
inspiration for this!   
--------------  Compatibility  --------------   
The update method in Scene_Map is aliased. Other than that you shouldn't have 
any issues with compatibility!   
--------------            ToS  ------------------   
Completely free to use for commercial and non-commercial with no restrictions. 
Just a heads up to me that you're using it would be nice.   
--------------  Contacting me  --------------   
You can email me at drykul@cloud9studios.net, find me on the 
/r/RPGMaker subreddit, I'm shaynec1981 at www.rpgmakerweb.com
=end
###############################################################################
class Random_Event_Occurance
    attr_reader     :reo_region_id
    attr_accessor :random_events
    attr_accessor :steps_counting 
    def reo_setup   
        @random_events =    {
###############################################################################
######### DO NOT EDIT ABOVE THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ######
########################### Configuration Section #############################       
# :event_name => [ region id, 
#                  % chance of occurance, 
#                  enabled/disabled, 
#                  common event to run, 
#                  minimum number of steps taken to process ],
    :test1 => [ 1,
                50,
                true,
                4,
                10 ],
    :test2 => [ 2,
                20,
                true,
                5,
                40 ],                           
################################################################################
######### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING #######
################################################################################   
        } 
    end 
    def initialize   
        @regionid = nil   
        @steps_counting = nil   
        @numbers_to_proc = []   
        @steps = 0   
        reo_setup 
    end   
    def encounter_chance(region_id)   
        for i in @random_events     
            if i[1][0] == region_id && i[1][2] == true       
                @steps += 1       
                chance = rand(101)       
                while @numbers_to_proc.size < i[1][1]         
                    new_num = rand(101)         
                    if !@numbers_to_proc.include?(new_num)           
                        @numbers_to_proc[@numbers_to_proc.size] = new_num         
                    end                   
                end       
                if @numbers_to_proc.include?(chance) && @steps >= i[1][4]         
                    $game_temp.reserve_common_event(i[1][3])         
                    @steps = 0       
                end     
            end   
        end 
    end   
    def update   
        reo_setup   
        if @regionid != $game_map.region_id($game_player.x, $game_player.y)     
            @regionid = $game_map.region_id($game_player.x, $game_player.y)     
            @steps = 0   
        end   
        encounter_chance(@regionid)   
        @numbers_to_proc.clear 
    end
end
################# UPDATED SCENE_MAP ############################################
class Scene_Map < Scene_Base   
    alias random_event_occurance_map_update update 
    def update   
        random_event_occurance_map_update   
        for i in $reo.random_events     
            if $game_map.region_id($game_player.x, $game_player.y) == i[1][0]       
                if $reo.steps_counting != $game_party.steps         
                    $reo.steps_counting = $game_party.steps         
                    $reo.update       
                end     
            end   
        end 
    end
end
################# UPDATED DATAMANAGER###########################################
module DataManager 
    class << self       
        unless self.method_defined?(:reo_GameObj_Alias)     
            alias_method(:reo_GameObj_Alias, :create_game_objects)   
        end   
        unless self.method_defined?(:reo_MakeSaveAlias)     
            alias_method(:reo_MakeSaveAlias, :make_save_contents)   
        end   
        unless self.method_defined?(:reo_ExtractSaveAlias)     
            alias_method(:reo_ExtractSaveAlias, :extract_save_contents)   
        end   
        def create_game_objects     
            reo_GameObj_Alias     
            $reo = Random_Event_Occurance.new   
        end       
        def make_save_contents     
            contents = reo_MakeSaveAlias     
            contents[:reo] = $reo     
            contents   
        end       
        def extract_save_contents(contents)     
            reo_ExtractSaveAlias(contents)     
            $reo = contents[:reo]   
        end 
    end
end
 

Latest Threads

Latest Posts

Latest Profile Posts

SF_People3_5 added!
index.php

Marketing seems to be about reducing dependence on luck to sell a product, as well as expanding the number of avenues in which luck can play a role in selling a product.
So, I've been wanting to do this randomized logic puzzle in my game for years now. I finally figured out how to do it by using arrays and a few small script calls. It's based on the Einstein Fish Puzzle! :D Though, I have no idea how to actually have the player put in answers.... might start a thread about it.

The projectiles shown in this video are as follows:
1, Basic Triple
2, 30-Degree Arc
3, Randomized Blast Wave
4, 8-way
5, 8-way Double
6, 8-way Slowness
7, 120-Degree Arc Repetitive
8, Projective Triple
9, Split 8-way
10, 2-way Split Randomized Arc
11, HP-MP Split Arc
12, Split Laser
13, Shock
14, Cosine
Drop shadows and water reflections tests in RPG Maker VX Ace


BgI3F80.png

Forum statistics

Threads
118,628
Messages
1,117,423
Members
155,718
Latest member
tepeeq
Top