Teleportação

Ver o tópico anterior Ver o tópico seguinte Ir em baixo

icone Teleportação

Mensagem  ▬Akio▬ em Sab Maio 22, 2010 9:13 am

Características


• Fácil controle de locais teleportable.
• automático de controle duplicado.
• Backup e restaurar a lista de locais.
• Cena feito que permite a seleção de jogador fácil.
• Temporariamente desabilitar e habilitar locais diferentes.

Spoiler:
Código:
#==============================================================================
# Teleporte
# Autor: ***
# Versao: 1.1
# Tipo: Game Addon
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Teleport Date 1.0b: 1/31/2009
# Teleport Date 1.01b: 1/31/2009
# Teleport Date 1.1: 2/5/2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# #  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
# #
# # Note that if you share this file, even after editing it, you must still
# # give proper credit to shdwlink1993.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                ~= Functions =~
#
# This script allows you to teleport to predefined locations, not unlike RPG
# Maker 2003's similar function.
#
# $game_player.add_location(name, map, x, y, face, description)
#  Adds a location to the list of teleportable locations. You cannot add a
# location if it's name is already in use (limit duplicates). Face refers to
# the direction the player will be facing. If you don't know, look at a number
# pad. 2 is down, 4 left, etc.
#
# $game_player.add_here(name, description)
#  Adds a location to the list where you are with the designated name and
# description.
#
# $game_player.remove_location(name)
#  Removes a location with the name from the list of teleportable locations.
#
# $game_player.disable_location(name)
#  Disallows you to teleport to the location with the name. This should be
#  used only in instances where the teleport is to be temporarily disabled. If
#  it should be permanently disabled, use the remove_location command to free
#  space.
#
# $game_player.enable_location(name)
#  Allows you to teleport to the disabled location with the name.
#
# $game_player.toggle_location(name)
#  Changes if the location with the name can be teleported to or not.
#
# $game_player.backup_locations
#  Makes a backup of all known locations and deletes them.
#
# $game_player.restore_locations
#  Restores the locations from the backup. All locations learned in the backup
#  are added to the list.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                              ~= Version History =~
#
# Version 1.0b ---------------------------------------------------- [1/31/2009]
# Version 1.01b --------------------------------------------------- [1/31/2009]
#  - Fixed a fatal error in $game_player.remove_location
#  - Added a variable to $game_system.
# Version 1.1 ------------------------------------------------------ [2/5/2009]
#  - Added in ability to disable individual teleports.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                              ~= Customization =~
#
# The only bit of customization occurs in the Sound module. The script asks for
# you to make a sound effect for the file. Replace name with the name of the
# file (Like 'teleport'), volume with the volume of the file (80 by default),
# and pitch with, you guessed it, the pitch of the file (default to 100).
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                              ~= Compatability =~
#
# - Should work perfectly with just about anything.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module Sound
 
  def self.play_tele
    RPG::SE.new('Item1', 80, 100).play
  end
 
end

class Game_System
 
  attr_accessor :teleport_disabled
 
  alias teleinit initialize
  def initialize
    teleinit
    @teleport_disabled = false
  end
 
end

class Game_Player
 
  attr_reader :known_locs
 
  alias teleinit initialize
  def initialize
    teleinit
    @known_locs = []
    @backup_locs = []
  end
 
  def add_here(name, desc = '')
    return add_location(name, $game_map.map_id, @x, @y, @direction, desc)
  end
 
  def add_location(name, map, x, y, face, desc = '')
    unless @known_locs == []
      @known_locs.each_index {|i| return if name == @known_locs[i][0] }
    end
    @known_locs.push([name, map, x, y, face, desc, true])
  end
 
  def remove_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs.delete(@known_locs[i])
        return
      end}
  end
 
  def disable_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = false
        return
      end}
  end
 
  def enable_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = true
        return
      end}
  end
 
  def toggle_location(name)
    @known_locs.each_index {|i|
      if name == @known_locs[i][0]
        @known_locs[i][6] = !@known_locs[i][6]
        return
      end}
  end
 
  def backup_locations
    @backup_locs = @known_locs
    @known_locs = []
  end
 
  def restore_locations
    @known_locs & @backup_locs
    @backup_locs = []
  end
 
end

class Window_Teleport < Window_Selectable
 
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @column_max = 2
    self.index = 0
    refresh
  end
 
  def item
    return @data[self.index]
  end
 
  def refresh
    @data = []
    $game_player.known_locs.each {|t| @data.push(t) }
    @item_max = @data.size
    create_contents
    @item_max.times {|i| draw_tele(i) }
  end
 
  def draw_tele(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      rect.width -= 4
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = item[6] ? 255 : 128
      self.contents.draw_text(rect.x + 2, rect.y, 172, WLH, item[0])
    end
  end
 
  def update_help
    @help_window.set_text(item == nil ? '' : item[5])
  end
 
end

class Scene_Teleport < Scene_Base
 
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @teleport_window = Window_Teleport.new(0, 56, 544, 360)
    @teleport_window.viewport = @viewport
    @teleport_window.help_window = @help_window
  end
 
  def terminate
    super
    dispose_menu_background
    @viewport.dispose
    @help_window.dispose
    @teleport_window.dispose
  end
 
  def return_scene
    $scene = Scene_Menu.new(4)
  end
 
  def update
    super
    update_menu_background
    @help_window.update
    @teleport_window.update
    update_item_selection
  end
 
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @teleport_window.item
      Sound.play_decision
      if @item[6]
        go_tele
      else
        Sound.play_buzzer
        return
      end
    end
  end
 
  def go_tele
    Sound.play_tele
    $game_player.reserve_transfer(@item[1], @item[2], @item[3], @item[4])
    $scene = Scene_Map.new
  end
 
end
avatar
▬Akio▬
moderador
moderador

Mensagens : 21
Pontos : 41
Reputação : 1
Data de inscrição : 07/03/2010
Idade : 22

Ver perfil do usuário

Voltar ao Topo Ir em baixo

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum