Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Event Respawner
- Autor: Raizen
- Comunity: www.centrorpg.com
- Compatible with: RMVXAce
- The script allows an event to be spawned in a map,
- respecting or not tile passabilities and respecting
- if the player will be trapped by the spawned event.
- To use the command to event spawn, you only need to Call Script
- in the third tab of events commands, and write the command like this.
- event_spawn(check, move, distance, switch)
- where move can bem 1 or 0.
- 1 = event will appear in only passable tiles.
- 0 = event will appear anywhere on the map.
- the value check, is used to check if after the event spawns on a map,
- it will not trap the player, mainly used for non-movable events like
- chests and switches. Its value is true(doesn´t allow traps) or
- false(doesn´t matter where it will appear).
- distance represents the distance in tiles the event will spawn on a map.
- switch é the local switch it will turn off after the event spawn.
- An exemple on how to use correctly the script.
- Call Script: event_spawn(true, 1, 4, "A")
- If no switch is needed to be turned off you can write this way
- the command.
- Call Script: event_spawn(true, 1, 4)
- You can also event spawn other events not being themselfs writing instead
- of a local switch, the ID number of the event this way.
- Exemple: Call Script: event_spawn(false, 1, 4, 5, "A")
- In this example I spawn the event with ID 5, and then turn off
- Local Switch A of that event.
- You can also not turn off the Local Switch like this.
- Exemple: Call Script: event_spawn(true, 1, 4, 5)
- Here starts the script
- =======================================================
- =end
- class Game_Interpreter
- def event_spawn(check, move, distance, switch = "", switch2 = "")
- switch.is_a?(Integer) ? event_id = switch : event_id = @event_id
- switch = switch2 unless switch2 == ""
- x = $game_map.width
- y = $game_map.height
- cx = $game_player.x
- cy = $game_player.y
- count = - 1
- while count <= distance
- if move == 1
- x = rand($game_map.width)
- y = rand($game_map.height)
- x - cx >= 0 ? count = x - cx : count = - x + cx
- y - cy >= 0 ? count2 = y - cy : count2 = - y + cy
- count = count2 if count2 >= count
- count = - 1 unless $game_map.check_passage(x, y, 0x0f)
- else
- x = rand($game_map.width)
- y = rand($game_map.height)
- x - cx >= 0 ? count = x - cx : count = - x + cx
- y - cy >= 0 ? count2 = y - cy : count2 = - y + cy
- count = count2 if count2 >= count
- end
- if check
- count = - 1 if $game_map.spawner_passable(x, y)
- end
- end
- $game_map.events[event_id].moveto(x,y)
- $game_self_switches[[@map_id, event_id, switch]] = false unless switch == ""
- return
- end
- end
- class Game_Map
- def spawner_passable(x, y)
- return false if check_passage(x - 1,y , 0x0f) and check_passage(x ,y -1, 0x0f) and check_passage(x - 1,y -1, 0x0f)
- return false if check_passage(x + 1,y , 0x0f) and check_passage(x ,y -1, 0x0f) and check_passage(x + 1,y -1, 0x0f)
- return false if check_passage(x - 1,y , 0x0f) and check_passage(x ,y +1, 0x0f) and check_passage(x - 1,y +1, 0x0f)
- return false if check_passage(x + 1,y , 0x0f) and check_passage(x ,y +1, 0x0f) and check_passage(x + 1,y +1, 0x0f)
- return true
- end
- end
RAW Paste Data