Request for a script that allows random placements of events such as treasure chests and monsters that manages so they don't end up in walls. =3
Here's some help for whoever makes this script: You can use the code that I use for respawning in Blizz-ABS.
#----------------------------------------------------------------------------
# get_respawn_coordinates
# enemy - the killed enemy event
# Gets the respawning coordinates for the new enemy.
#----------------------------------------------------------------------------
def get_respawn_coordinates(enemy)
# if fixed Respawn Point exists
if enemy.respawn_point != nil
# coordinates of the Respawn Point
return [enemy.respawn_point.x, enemy.respawn_point.y]
end
# get virtual map passability
v_map = $game_map.virtual_passability
# passable
passables = []
# find all passable tiles
(0...v_map.xsize).each {|x| (0...v_map.ysize).each {|y|
# if passable and enemy may respawn and no event on position
if v_map[x, y] != 0x00 && !BlizzABS::Config::NO_ENEMY_TAGS.include?(
$game_map.terrain_tag(x, y)) && $game_map.event_passable?(x, y)
passables.push([x, y])
end}}
# random possibnle coordinates on the map
return passables[rand(passables.size)]
end
#----------------------------------------------------------------------------
# respawn_enemy
# enemy - the killed enemy event
# Processes the respawn of a dead enemy.
#----------------------------------------------------------------------------
def respawn_enemy(enemy)
# create new enemy on old enemy's template
new_enemy = Map_Enemy.new($game_map.map_id, enemy)
# gets the respawn coordinates
x, y = get_respawn_coordinates(enemy)
# no respawn position found
return nil if x == nil || y == nil
# move enemy to x, y coordinate
new_enemy.moveto(x, y)
# create sprite for respawned enemy
sprite = Sprite_Character.new($scene.spriteset.viewport1, new_enemy)
# set fade_in flag
sprite.fade_in = true
# add new sprite into spriteset
$scene.spriteset.character_sprites.push(sprite)
# enemy is invisible at first
new_enemy.opacity = 0
# return new enemy
return new_enemy
end
You'll have to delete the Blizz-ABS related stuff first. xD
I found a temporary solution to the random placement issue. I made a new enemy, named it Chest. Created an event that looks like a chest and named it Chest \m\e[3] . Now when it is destroyed it gets spawned somewhere else. Not a perfect sollution but it works for the moment.
Nice idea. xD Just don't forget to give him no actions, lol! You don't want a chest to eat you while you are trying to open it. xD
Unless of course it's a mimic! :ninja: