Randomly Re-spawning Monsters

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
I have been bashing my head off this for hours now and will gladly kiss the posterior of anyone who can give me a "how to for dummies" to create randomly location events

  - "monsters" in "X" region ID. Being new i just keep running into walls off event coding and correctly applying scripts.

What I ideally would like it to do is have events i create spawn in a given region ID after a random amount of time in between two amounts "10-20 seconds" for example.

If anyone could tell me how to set it so you can run away from mapped encounters as well I would gladly marry you now. 
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
For your mapped encounters have you checked the box 'Escape ' on the Battle Processing command?
 

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
For your mapped encounters have you checked the box 'Escape ' on the Battle Processing command?
I had not thanks! That's one problem down :D
 

vincent274

Dwajhbsda
Member
Joined
May 27, 2014
Messages
7
Reaction score
0
First Language
Polish
Primarily Uses
Not sure if I'm getting what you mean with those regions, but if you set up a region, for example region 1, you can go to the map properties and in the "Encounters" section you can choose which mobs you want to appear in the region. You can also set average (which means it's still mostly random) steps you have to make in the region for the mobs to appear.
 

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
Not sure if I'm getting what you mean with those regions, but if you set up a region, for example region 1, you can go to the map properties and in the "Encounters" section you can choose which mobs you want to appear in the region. You can also set average (which means it's still mostly random) steps you have to make in the region for the mobs to appear.
Sorry i should have been clearer I am having mapped monsters not random encounters. The battler sprite appears on the map to be engaged rather than encounters just popping up.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
Maybe you could implement "player touched" events, that when stepped on activate a switch that will makes the on-map enemies appear?
 

vincent274

Dwajhbsda
Member
Joined
May 27, 2014
Messages
7
Reaction score
0
First Language
Polish
Primarily Uses
Ok, now I think I know what you mean. Since I'm using a different mob spawn system I can't tell you how to spawn mobs within a region, but I think I know how to spawn a mob after a random amount of time, maybe if you'll test the thing, you'll come to conclusion you don't need regions, just a normal event system. For the random time you can use variables, there's an example of random time variable in Celianna's Variables Guide here:

http://forums.rpgmakerweb.com/index.php?/topic/10099-variables-guide/

The random time variables are used by the pond, the event with catching a fish, the last event page. She uses labels etc.; they were pretty difficult for me to understand at the beginning but every way that doesn't require a script is better in my opinion.

Hope I helped you at least a bit.
 

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
Ok, now I think I know what you mean. Since I'm using a different mob spawn system I can't tell you how to spawn mobs within a region, but I think I know how to spawn a mob after a random amount of time, maybe if you'll test the thing, you'll come to conclusion you don't need regions, just a normal event system. For the random time you can use variables, there's an example of random time variable in Celianna's Variables Guide here:

http://forums.rpgmakerweb.com/index.php?/topic/10099-variables-guide/

The random time variables are used by the pond, the event with catching a fish, the last event page. She uses labels etc.; they were pretty difficult for me to understand at the beginning but every way that doesn't require a script is better in my opinion.

Hope I helped you at least a bit.
Thanks I will give this a go the only reason I want region IDs is to make it so the event can spawn and exist only in those regions for example an enemy that can only appear on grasslands can only spawn and stay there
 

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
Thanks I will give this a go the only reason I want region IDs is to make it so the event can spawn and exist only in those regions for example an enemy that can only appear on grasslands can only spawn and stay there
No joy sadly, i dont think I can get the variables to come back to allow the event to re-spawn after its been cleared.
 

Seraphoenix

RPG Maker Newb Extraordinaire
Veteran
Joined
Jun 9, 2014
Messages
32
Reaction score
0
First Language
English
Primarily Uses
Victory! Managed to do everything except keep the monster within region IDs any ideas would be appreciated!
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
Yanfly's Move restrict maybe?

Just make sure to adjust the "default regions" used, since I copied it from one of my games.

#==============================================================================

#
# ▼ Yanfly Engine Ace - Move Restrict Region v1.03
# -- Last Updated: 2012.01.03
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-MoveRestrictRegion"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.23.08 - Added Feature:
# 2012.01.03 - Added Feature:
# 2011.12.26 - Bug Fixed: Player Restricted Regions.
# 2011.12.15 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Not everybody wants NPC's to travel all over the place. With this script, you
# can set NPC's to be unable to move pass tiles marked by a specified Region.
# Simply draw out the area you want to enclose NPC's in on and they'll be
# unable to move past it unless they have Through on. Likewise, there are
# regions that you can prevent the player from moving onto, too!
#
#==============================================================================
# ▼ 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.
#
# -----------------------------------------------------------------------------
# Map Notetags - These notetags go in the map notebox in a map's properties.
# -----------------------------------------------------------------------------
#
#
# Players and NPC's on the map will be unable to move past region x even if
# they have the "through" flag set. The only thing that can go past is if the
# player is using the debug through flag. Draw out the area you want to close
# the player and NPC's in with the regions and both will be unable to move onto
# any of those tiles marked by region x. If you want to have more regions
# restrict NPC's, insert multiples of this tag.
#
#
#
# NPC's on that map will be unable to move past regions x unless they have a
# "Through" flag on. Draw out the area you want to close NPC's in with the
# regions and the NPC's will be unable to move onto any of those tiles marked
# by region x. If you want to have more regions restrict NPC's, insert
# multiples of this tag.
#
#
#
# Players will not be able to move on tiles marked by region x unless the
# player has a "Through" flag on. Draw out the area you want to close the
# player in with the regions and the player will be unable to move past any of
# those tiles marked by region x. If you want to have more regions restrict the
# player, insert multiples of this tag.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
module MOVE_RESTRICT

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Default Completely Restricted Regions -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# If you want there to always be a region ID that will forbid both the
# player and NPC's from passing through, insert that region ID into the
# array below. This effect will completely block out both players and NPC's
# even if they have the "through" flag. However, it does not block the
# debug_through flag for players.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
DEFAULT_ALL = [61]

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Default Player Restricted Regions -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# If you want there to always be a region ID that will forbid the player
# from passing through, insert that region ID into the array below.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
DEFAULT_PLAYER = [62]

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Default NPC Restricted Regions -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# If you want there to always be a region ID that will forbid NPC's from
# passing through, insert that region ID into the array below.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
DEFAULT_NPC = [63]

end # MOVE_RESTRICT
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
module REGEXP
module MAP

ALL_RESTRICT =
/<(?:ALL_RESTRICT|all restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
NPC_RESTRICT =
/<(?:NPC_RESTRICT|npc restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
PLAYER_RESTRICT =
/<(?:pLAYER_RESTRICT|player restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i

end # MAP
end # REGEXP
end # YEA

#==============================================================================
# ■ RPG::Map
#==============================================================================

class RPG::Map

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :all_restrict_regions
attr_accessor :npc_restrict_regions
attr_accessor :player_restrict_regions

#--------------------------------------------------------------------------
# common cache: load_notetags_mrr
#--------------------------------------------------------------------------
def load_notetags_mrr
@all_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_ALL.clone
@npc_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_NPC.clone
@player_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_PLAYER.clone
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEA::REGEXP::MAP::ALL_RESTRICT
$1.scan(/\d+/).each { |num|
@all_restrict_regions.push(num.to_i) if num.to_i > 0 }
when YEA::REGEXP::MAP::NPC_RESTRICT
$1.scan(/\d+/).each { |num|
@npc_restrict_regions.push(num.to_i) if num.to_i > 0 }
when YEA::REGEXP::MAP::pLAYER_RESTRICT
$1.scan(/\d+/).each { |num|
@player_restrict_regions.push(num.to_i) if num.to_i > 0 }
#---
end
} # self.note.split
#---
end

end # RPG::Map

#==============================================================================
# ■ Game_Map
#==============================================================================

class Game_Map

#--------------------------------------------------------------------------
# alias method: setup
#--------------------------------------------------------------------------
alias game_map_setup_mrr setup
def setup(map_id)
game_map_setup_mrr(map_id)
@map.load_notetags_mrr
end

#--------------------------------------------------------------------------
# new method: all_restrict_regions
#--------------------------------------------------------------------------
def all_restrict_regions
return @map.all_restrict_regions
end

#--------------------------------------------------------------------------
# new method: npc_restrict_regions
#--------------------------------------------------------------------------
def npc_restrict_regions
return @map.npc_restrict_regions
end

#--------------------------------------------------------------------------
# new method: player_restrict_regions
#--------------------------------------------------------------------------
def player_restrict_regions
return @map.player_restrict_regions
end

end # Game_Map

#==============================================================================
# ■ Game_CharacterBase
#==============================================================================

class Game_CharacterBase

#--------------------------------------------------------------------------
# alias method: passable?
#--------------------------------------------------------------------------
alias game_characterbase_passable_mrr passable?
def passable?(x, y, d)
return false if npc_region_forbid?(x, y, d)
return false if player_region_forbid?(x, y, d)
return game_characterbase_passable_mrr(x, y, d)
end

#--------------------------------------------------------------------------
# new method: npc_forbid?
#--------------------------------------------------------------------------
def npc_region_forbid?(x, y, d)
return false unless self.is_a?(Game_Event)
region = 0
case d
when 1; region = $game_map.region_id(x-1, y+1)
when 2; region = $game_map.region_id(x+0, y+1)
when 3; region = $game_map.region_id(x+1, y+1)
when 4; region = $game_map.region_id(x-1, y+0)
when 5; region = $game_map.region_id(x+0, y+0)
when 6; region = $game_map.region_id(x+1, y+0)
when 7; region = $game_map.region_id(x-1, y-1)
when 8; region = $game_map.region_id(x+0, y-1)
when 9; region = $game_map.region_id(x+1, y-1)
end
return true if $game_map.all_restrict_regions.include?(region)
return false if @through
return $game_map.npc_restrict_regions.include?(region)
end

#--------------------------------------------------------------------------
# new method: player_region_forbid?
#--------------------------------------------------------------------------
def player_region_forbid?(x, y, d)
return false unless self.is_a?(Game_Player)
return false if debug_through?
region = 0
case d
when 1; region = $game_map.region_id(x-1, y+1)
when 2; region = $game_map.region_id(x+0, y+1)
when 3; region = $game_map.region_id(x+1, y+1)
when 4; region = $game_map.region_id(x-1, y+0)
when 5; region = $game_map.region_id(x+0, y+0)
when 6; region = $game_map.region_id(x+1, y+0)
when 7; region = $game_map.region_id(x-1, y-1)
when 8; region = $game_map.region_id(x+0, y-1)
when 9; region = $game_map.region_id(x+1, y-1)
end
return true if $game_map.all_restrict_regions.include?(region)
return false if @through
return $game_map.player_restrict_regions.include?(region)
end

end # Game_CharacterBase

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top