Randomize Event Placement based on Region
Made for a request here.This script simply randomize the events position in the map with a name tag based on region.
Features:
Randomize Event Position(Placement)
How to Use:
Paste the script below Material and above Main
Set up the region number you wish to use in the setting area in the script
Put <randomize> in the event's name you wish to randomly positioned
Compatibility:
This script is using alias method, if you find it not working, simply place it below other custom script you have
Terms of Use:
Free for both Commercial and Non-Commercial
Script:
Spoiler Code:
#==============================================================================# ■ Meow Face Randomize Events Placement by Region ID#------------------------------------------------------------------------------# Randomize events in map and place them on region X#==============================================================================# How to Use:# Put this script below Material and above Main# Put <randomize> in event's name you wish to randomize# Set up Region number in the settings area#==============================================================================module MEOWREVENT #Do Not Remove!#==============================================================================# Settings Area#============================================================================== REGION = 2 #Region number you wish to use#==============================================================================# End of Settings Area# Edit anything past this line at your own risk!#==============================================================================endclass Game_Event < Game_Character alias meowreinitialize initialize def initialize(map_id, event) meowreinitialize(map_id, event) if @event.name.include?('<randomize>') position = [] x_pos = 0 y_pos = 0 $game_map.width.times do x_pos = 0 y_pos += 1 $game_map.height.times do x_pos += 1 position << if $game_map.region_id(x_pos, y_pos) == MEOWREVENT::REGION end end unless position.empty? loop do pos = position if $game_map.events_xy(pos, pos).empty? moveto(pos, pos) break end end end end endend
本贴来自国际rpgmaker官方论坛作者:MeowFace处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/randomize-event-placement-based-on-region.49983/
页:
[1]