# ============================================================================= # TheoAllen - Random Event Location # Version : 1.0 # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com # (This script documentation is written in informal indonesian language) # ============================================================================= ($imported ||= {})[:Theo_RandEventLocation] = true # ============================================================================= # CHANGE LOGS: # ----------------------------------------------------------------------------- # 2013.06.15 - Finished script # ============================================================================= =begin Perkenalan : Script ini berfungsi untuk menempatkan event secara acak berdasar region id yang telah diset. Cara penggunaan : Pasang dibawah material namun diatas main Tulis comment pada event dengan format seperti ini Dimana n adalah region id. Kamu bisa menulis region id sebanyak-banyaknya. Terms of use : Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau dipake buat komersil, jangan lupa, gw dibagi gratisannya. =end # ============================================================================= # Tidak ada konfigurasi : # ============================================================================= module THEO module MAP module REGEXP RAND_REGION = /<(?:RAND_POS|rand pos): [ ]*[ ]*(\d+(?:\s*,\s*\d+)*)>/i end end end class Game_Map include THEO::MAP Point = Struct.new(:x,:y) alias pre_rand_location_setup setup def setup(map_id) pre_rand_location_setup(map_id) setup_rand_events_location end def setup_rand_events_location @events.values.each do |event| event.list.each do |cmd| code = cmd.code next unless code == 108 || code == 408 case cmd.parameters[0] when REGEXP::RAND_REGION points = [] $1.scan(/\d+/).each do |region| points += get_region_points(region.to_i) end next if points.empty? selected = rand(points.size) x_pos = points[selected].x y_pos = points[selected].y event.moveto(x_pos,y_pos) end end end end def get_region_points(reg_id) result = [] for x_pos in 0..width for y_pos in 0..height result.push(Point.new(x_pos,y_pos)) if region_id(x_pos,y_pos) == reg_id end end return result end end