sarana Protecteur de la Lumière
Nombre de messages : 160 Localisation : Thailande Date d'inscription : 09/06/2006
| Sujet: Côté entière d'une map téléporte Sam 26 Aoû - 2:14 | |
| Pour téléporter le héros sur une autre carte, ce dernier doit marcher sur une case téleport spéciale. Pas très réaliste, hein ? Grâce à ce script, TOUTES les cases sur les côtés seront des téleports. 1. Le scriptÀ installer au-dessus de Main (mettre le SDK au-dessous si vous l'avez) - Code:
-
=begin ============ Maplinks - version 0.95 (2005-11-10) ============ par Wachunga
=end
#-------------------------------------------------------------------------------
class Game_Event < Game_Character alias ml_ge_init initialize def initialize(map_id, event) ml_ge_init(map_id, event) if @event.name.upcase.include?('<MAPLINK>') dir = nil if @event.y == $game_map.height-1 dir = 2 unless @event.x == 0 or @event.x == $game_map.width-1 elsif @event.x == 0 dir = 4 unless @event.y == 0 or @event.y == $game_map.height-1 elsif @event.x == $game_map.width-1 dir = 6 unless @event.y == 0 or @event.y == $game_map.height-1 elsif @event.y == 0 dir = 8 unless @event.x == 0 or @event.x == $game_map.width-1 end if dir != nil @list.each { |command| if command.code == 201 # make sure new location isn't be specified by variables if command.parameters[0] == 0 $game_map.maplinks[dir] = Maplink.new(command.parameters) break end end } end end end end
#-------------------------------------------------------------------------------
class Game_Map attr_accessor :maplinks
alias ml_gm_setup setup def setup(map_id) @maplinks = {} ml_gm_setup(map_id) end
def width(map_id = @map_id) if map_id == @map_id return @map.width else return load_data(sprintf("Data/Map%03d.rxdata", map_id)).width end end
def height(map_id = @map_id) if map_id == @map_id return @map.height else return load_data(sprintf("Data/Map%03d.rxdata", map_id)).height end end
end
#-------------------------------------------------------------------------------
class Maplink
def initialize(parameters) @param = parameters end
def activate width = $game_map.width(@param[1]) height = $game_map.height(@param[1]) # modify x (p[2]) or y (p[3]) coordinates appropriately if @param[2] == 0 or @param[2] == width-1 @param[3] = $game_player.y elsif @param[3] == 0 or @param[3] == height-1 @param[2] = $game_player.x end # set up a dummy interpreter just for teleport interpreter = Interpreter.new interpreter.parameters = @param interpreter.index = 0 interpreter.command_201 end
end
#-------------------------------------------------------------------------------
class Game_Player
alias ml_cett check_event_trigger_touch def check_event_trigger_touch(x, y) check_maplinks(x,y) ml_cett(x,y) end
def check_maplinks(x,y) if $game_map.valid?(x, y) then return end dir = nil if y == $game_map.height then dir = 2 elsif x == -1 then dir = 4 elsif x == $game_map.width then dir = 6 elsif y == -1 then dir = 8 end if dir != nil if $game_map.maplinks[dir] != nil $game_map.maplinks[dir].activate end end end
end
#-------------------------------------------------------------------------------
class Interpreter attr_accessor :parameters attr_accessor :index end
2. InstructionsSur un bord de la carte, créez un événement portant <maplink> dans son nom, puis mettez un événement téleport normal. Le script se chargera de prendre la position x/y du héros et de le tranporter sur les autres cases. Ne mettez pas d'événements dans les coins. Si la première carte est plus grande que la deuxième, le joueur sera transporté sur les coins de cette dernière. Le joueur doit appuyer sur Espace pour se téléporter. 3. CréditsFait par Wachunga Reposté par TruthfulTiger alias Me | |
|