Character Holograms
Publicado em 29 de junho de 2012.Character Holograms (Version 1) é mais um script do SephirothSpawn para o RPG Maker XP. Este script foi projetado para permitir você a criar “hologramas” de todos os eventos e o jogador.
Os hologramas atravessam qualquer coisa e vão copiar os movimentos. Você pode fazer eles copiarem X simetricamente e/ou Y simetricamente. Também permite você a “empilhar” hologramas, assim seus hologramas podem ter hologramas, que também podem ter hologramas.
Este script, para funcionar, precisa do SDK. Você deve adicionar o código do Character Holograms, acima do Main e abaixo do SDK. O código do Character Hologramas está logo abaixo:
#==============================================================================
# ** Character Holograms
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-10-07
#------------------------------------------------------------------------------
# * Description :
#
# This script was designed to allow you to create "holograms" of all
# events and the player. The holograms pass through anything and will
# mirror your movements. You can make them mirror you x symmetrically and/or
# y symmetrically. This also allows you to "stack" holograms, so your
# holograms have holograms, as can those holograms have holograms.
#------------------------------------------------------------------------------
# * Instructions :
#
# Place The Script Below the SDK and Above Main.
# To Create, Delete, Push and Pop Holograms, Refer to Syntax
#------------------------------------------------------------------------------
# * Syntax :
#
# Creating Character Hologram
# - <game_character>.create_character_hologram(x, y, x_symmetric,
# y_symmetric, character_name, character_hue)
#
# Deleting Character Hologram
# - <game_character>.delete_character_hologram
#
# Push Character Hologram
# - <game_character>.push_character_hologram(x, y, x_symmetric,
# y_symmetric, character_name, character_hue)
#
# Pop Character Hologram (Remove Last Hologram)
# - <game_character>.pop_character_hologram
#
# Retrieving Character Hologram Data (Based Of Parent Character)
# - <game_character>.character_hologram
#
# Replace <game_character> with :
# player = $game_player
# event = $game_map.events[event_id]
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Character Holograms', 'SephirothSpawn', 1, '2006-09-07')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Character Holograms')
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :character_hologram
attr_reader :move_speed
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_chrholo_gmchr_init initialize
alias seph_chrholo_gmchr_md move_down
alias seph_chrholo_gmchr_ml move_left
alias seph_chrholo_gmchr_mr move_right
alias seph_chrholo_gmchr_mu move_up
alias seph_chrholo_gmchr_mll move_lower_left
alias seph_chrholo_gmchr_mlr move_lower_right
alias seph_chrholo_gmchr_mul move_upper_left
alias seph_chrholo_gmchr_mur move_upper_right
alias seph_chrholo_gmchr_j jump
alias seph_chrholo_gmchr_td turn_down
alias seph_chrholo_gmchr_tl turn_left
alias seph_chrholo_gmchr_tr turn_right
alias seph_chrholo_gmchr_tu turn_up
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
seph_chrholo_gmchr_init
@character_hologram = nil
end
#--------------------------------------------------------------------------
# * Create Character Hologram
#--------------------------------------------------------------------------
def create_character_hologram(x = @x, y = @y, x_sym = false, y_sym = true,
name = @character_name, hue = @character_hue)
unless @character_hologram.nil?
delete_character_hologram
end
@character_hologram = Game_HolographicCharacter.new(self, x, y,
x_sym, y_sym, name, hue)
$game_map.add_character(@character_hologram)
end
#--------------------------------------------------------------------------
# * Delete Character Hologram
#--------------------------------------------------------------------------
def delete_character_hologram
$game_map.delete_character(@character_hologram)
@character_hologram = nil
end
#--------------------------------------------------------------------------
# * Push Character Hologram
#--------------------------------------------------------------------------
def push_character_hologram(x = @x, y = @y, x_sym = false, y_sym = true,
name = @character_name, hue = @character_hue)
# If No Character Hologram
if @character_hologram.nil?
create_character_hologram(x, y, x_sym, y_sym, name, hue)
return
end
# Pass to Character Hologram
@character_hologram.push_character_hologram(x, y, x_sym, y_sym, name, hue)
end
#--------------------------------------------------------------------------
# * Pop Character Hologram
#--------------------------------------------------------------------------
def pop_character_hologram
# Return if No Character Hologram
return if @character_hologram.nil?
# Delete Character Hologram if Holograms Has No Child Hologram
if @character_hologram.character_hologram.nil?
delete_character_hologram
return
end
# Pass to Character Hologram
@character_hologram.pop_character_hologram
end
#--------------------------------------------------------------------------
# * Move Down
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# Move Hologram
move_hologram = passable?(@x, @y, 2)
# Original Move
seph_chrholo_gmchr_md(turn_enabled)
# If passable
return unless move_hologram
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric
@character_hologram.move_up(turn_enabled)
else
@character_hologram.move_down(turn_enabled)
end
end
end
#--------------------------------------------------------------------------
# * Move Left
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# Move Hologram
move_hologram = passable?(@x, @y, 4)
# Original Move
seph_chrholo_gmchr_ml(turn_enabled)
# If passable
return unless move_hologram
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.y_symmetric
@character_hologram.move_right(turn_enabled)
else
@character_hologram.move_left(turn_enabled)
end
end
end
#--------------------------------------------------------------------------
# * Move Right
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# Move Hologram
move_hologram = passable?(@x, @y, 6)
# Original Move
seph_chrholo_gmchr_mr(turn_enabled)
# If passable
return unless move_hologram
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.y_symmetric
@character_hologram.move_left(turn_enabled)
else
@character_hologram.move_right(turn_enabled)
end
end
end
#--------------------------------------------------------------------------
# * Move up
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# Move Hologram
move_hologram = passable?(@x, @y, 8)
# Original Move
seph_chrholo_gmchr_mu(turn_enabled)
# If passable
return unless move_hologram
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric
@character_hologram.move_down(turn_enabled)
else
@character_hologram.move_up(turn_enabled)
end
end
end
#--------------------------------------------------------------------------
# * Turn Down
#--------------------------------------------------------------------------
def turn_down
# Original Move
seph_chrholo_gmchr_td
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric
@character_hologram.turn_up
else
@character_hologram.turn_down
end
end
end
#--------------------------------------------------------------------------
# * Turn Left
#--------------------------------------------------------------------------
def turn_left
# Original Move
seph_chrholo_gmchr_tl
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.y_symmetric
@character_hologram.turn_right
else
@character_hologram.turn_left
end
end
end
#--------------------------------------------------------------------------
# * Turn Right
#--------------------------------------------------------------------------
def turn_right
# Original Move
seph_chrholo_gmchr_tr
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.y_symmetric
@character_hologram.turn_left
else
@character_hologram.turn_right
end
end
end
#--------------------------------------------------------------------------
# * Turn Up
#--------------------------------------------------------------------------
def turn_up
# Original Move
seph_chrholo_gmchr_tu
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric
@character_hologram.turn_down
else
@character_hologram.turn_up
end
end
end
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left
# Move Hologram
move_holo1 = (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4))
move_holo2 = (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
# Original Move
seph_chrholo_gmchr_mll(turn_enabled)
# When a down to left or a left to down course is passable
return unless move_holo1 or move_holo2
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric && @character_hologram.y_symmetric
@character_hologram.move_upper_right
elsif @character_hologram.x_symmetric
@character_hologram.move_upper_left
elsif @character_hologram.y_symmetric
@character_hologram.move_lower_right
else
@character_hologram.move_lower_left
end
end
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right
# Move Hologram
move_holo1 = (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6))
move_holo2 = (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
# Original Move
seph_chrholo_gmchr_mlr(turn_enabled)
# When a down to right or a right to down course is passable
return unless move_holo1 or move_holo2
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric && @character_hologram.y_symmetric
@character_hologram.move_upper_left
elsif @character_hologram.x_symmetric
@character_hologram.move_upper_right
elsif @character_hologram.y_symmetric
@character_hologram.move_lower_left
else
@character_hologram.move_lower_right
end
end
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left
# Move Hologram
move_holo1 = (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4))
move_holo2 = (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
# Original Move
seph_chrholo_gmchr_mul(turn_enabled)
# When an up to left or a left to up course is passable
return unless move_holo1 or move_holo2
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric && @character_hologram.y_symmetric
@character_hologram.move_lower_right
elsif @character_hologram.x_symmetric
@character_hologram.move_upper_left
elsif @character_hologram.y_symmetric
@character_hologram.move_upper_right
else
@character_hologram.move_upper_left
end
end
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right
# Move Hologram
move_holo1 = (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6))
move_holo2 = (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
# Original Move
seph_chrholo_gmchr_mur(turn_enabled)
# When an up to right or a right to up course is passable
return unless move_holo1 or move_holo2
# If hologram exist
unless @character_hologram.nil?
if @character_hologram.x_symmetric && @character_hologram.y_symmetric
@character_hologram.move_lower_left
elsif @character_hologram.x_symmetric
@character_hologram.move_lower_right
elsif @character_hologram.y_symmetric
@character_hologram.move_upper_left
else
@character_hologram.move_upper_right
end
end
end
#--------------------------------------------------------------------------
# * Jump
#--------------------------------------------------------------------------
def jump(x_plus, y_plus)
# Move Hologram
move_holo1 = (x_plus == 0 and y_plus == 0)
move_holo2 = passable?(new_x, new_y, 0)
# Original Move
seph_chrholo_gmchr_j(x_plus, y_plus)
# Calculate new coordinates
new_x = @x + x_plus
new_y = @y + y_plus
# If plus value is (0,0) or jump destination is passable
return unless move_holo1 or move_holo2
# If hologram exist
unless @character_hologram.nil?
x_plus *= -1 if @y_symmetric
y_plus *= -1 if @x_symmetric
@character_hologram.jump(x_plus, y_plus)
end
end
end
#==============================================================================
# ** Game_HolographicCharacter
#==============================================================================
class Game_HolographicCharacter < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :x_symmetric
attr_reader :y_symmetric
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(parent, x = parent.x, y = parent.y,
x_sym = false, y_sym = true,
name = parent.character_hue, hue = parent.character_hue)
super()
@parent = parent
@x, @y = x, y
@real_x, @real_y = x * 128, y * 128
@character_name, @character_hue = name, hue
@x_symmetric, @y_symmetric = x_sym, y_sym
@opacity = [parent.opacity - 50, 55].max
@direction, @move_speed = parent.direction, parent.move_speed
@through = true
end
#--------------------------------------------------------------------------
# * Determine if Passable
#--------------------------------------------------------------------------
def passable?(x, y, d)
# passable
return true
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super
@move_speed = @parent.move_speed
end
end
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_chrholo_gmmap_setup setup
alias seph_chrholo_gmmap_refresh refresh
alias seph_chrholo_gmmap_update update
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(map_id)
# Original Setup
seph_chrholo_gmmap_setup(map_id)
# Sets Up Hologram Sprites
@character_holograms = []
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Original Update
seph_chrholo_gmmap_update
# Updates Character Holograms
@character_holograms.each {|x| x.update}
end
#--------------------------------------------------------------------------
# * Add Character
#--------------------------------------------------------------------------
def add_character(character)
@character_holograms << character
$scene.spriteset.add_character(character)
end
#--------------------------------------------------------------------------
# * Delete Character
#--------------------------------------------------------------------------
def delete_character(character)
$scene.spriteset.delete_character(character)
@character_holograms.delete(character)
end
end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_chrholo_sprchr_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
return if self.disposed?
seph_chrholo_sprchr_update
end
end
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Add Character
#--------------------------------------------------------------------------
def add_character(character)
@character_sprites.push(Sprite_Character.new(@viewport1, character))
end
#--------------------------------------------------------------------------
# * Delete Character
#--------------------------------------------------------------------------
def delete_character(character)
for sprite_character in @character_sprites
if sprite_character.character === character
sprite_character.dispose
@character_sprites.delete(character)
return
end
end
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
attr_reader :spriteset
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
endInformações adicionais
- Categoria: Programação XP
- Tag: RPG Maker XP
- Adicionado por: LichKing
- Acessos: 60
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!
