Instruções
1º Coloque esse script em qualquer area de script: [EXT] Traling Characters
AVISO: Não pode ser dois topicos, por se eu fazer só dois topico não ia dar porque a largura da mensagem ia ultrapassa o limite autorizado.
Topico 2: http://www.mundorpgmaker.com/forum/index.php?topic=83914.msg751812#msg751812
Creditos:
Eu - Por disponibilizar e resolver alguns erros ( Lembre-se que só foi alguns erros )
NetPlay Evolution
Script para usar:
['059-Aquatic01'] no lugar de 059-Aquatic01 você pode colocar outro grafico de pet.
AVISO: Isso não é global e contem alguns erros.
1º Coloque esse script em qualquer area de script: [EXT] Traling Characters
- Spoiler:
- #==============================================================================
# ** Trailing Characters
#==============================================================================
# SephirothSpawn
# Version 1
# 2006-05-24
#------------------------------------------------------------------------------
# * Instructions:
#
# ~ Adding Trailing Character:
# .add_trailing_character(, )
#
# ~ Deleting Trailing Character at a index
# .delete_trailing_character()
#
# ~ Delete Last Trailing Character
# .pop_trailing_character
#
# ~ Get Last Trailing Character
# .last_trailing_character
#
# ~ Get Number of Trailing Characters
# .number_of_trailing_characters
#
# * For Events, Replace with
# $game_map.events[]
#
# * For Player, Replace with
# $game_player
#
# ~ Enable or Disable Caterpillar
# $game_player.enable_caterpillar = True (On) or False (Off)
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Trailing Characters', 'SephirothSpawn', 1, '2006-05-24')
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Trailing Characters') == true
#==============================================================================
# ** Game_TrailingCharacter
#==============================================================================
class Game_TrailingCharacter < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :trail_number
attr_accessor :character_hue
attr_accessor :character_name
attr_accessor :x, :y, :direction
#--------------------------------------------------------------------------
# * Screen Z
#--------------------------------------------------------------------------
def screen_z(height = 0)
# Get Original Z Value
n = super(height)
# Decrease Z By 1 and return
return n - @trail_number
end
#--------------------------------------------------------------------------
# * Setup Initialization
#--------------------------------------------------------------------------
def setup(parent_character, character_name, character_hue)
# Set X & Y Coordinates
@x, @y = parent_character.x, parent_character.y
@real_x, @real_y = @x * 128, @y * 128
@direction = parent_character.direction
# Sets Character Sprite Information
@character_name = character_name
@character_hue = character_hue
# Turns Through On
@through = true
# If Parent Character is a Trailing Character
if parent_character.is_a?(Game_TrailingCharacter)
# Sets Trailing Number + 1
@trail_number = parent_character.trail_number + 1
else
# Sets 1 to Trailing Number
@trail_number = 1
end
end
#--------------------------------------------------------------------------
# * Delete
#--------------------------------------------------------------------------
def delete
# Return No Trailing Sprite
return if @trailing_character.nil?
# Switch Properties with trailing sprite
@character_name = @trailing_character.character_name
@character_hue = @trailing_character.character_hue
@trail_number = @trailing_character.trail_number
# Delete Trail Sprite
@trailing_character.delete
end
end
#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Trailing Character Movements
#--------------------------------------------------------------------------
Trailing_Character_Movements = [[], [], [], [], []]
Trailing_Character_Movements[0][2] = '@trailing_character.move_right'
Trailing_Character_Movements[1][1] =
'@direction == 2 ? @trailing_character.move_right : @trailing_character.move_down'
Trailing_Character_Movements[1][2] =
'@trailing_character.turn_right unless @trailing_character.direction == 6'
Trailing_Character_Movements[1][3] =
'@direction == 8 ? @trailing_character.move_right : @trailing_character.move_up'
Trailing_Character_Movements[2][0] = '@trailing_character.move_down'
Trailing_Character_Movements[2][1] =
'@trailing_character.turn_down unless @trailing_character.direction == 2'
Trailing_Character_Movements[2][3] =
'@trailing_character.turn_up unless @trailing_character.direction == 8'
Trailing_Character_Movements[2][4] = '@trailing_character.move_up'
Trailing_Character_Movements[3][1] =
'@direction == 2 ? @trailing_character.move_left : @trailing_character.move_down'
Trailing_Character_Movements[3][2] =
'@trailing_character.turn_left unless @trailing_character.direction == 4'
Trailing_Character_Movements[3][3] =
'@direction == 8 ? @trailing_character.move_left : @trailing_character.move_up'
Trailing_Character_Movements[4][2] = '@trailing_character.move_left'
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :trailing_character
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_trailingchara_gmchar_init initialize
alias seph_trailingchara_gmchar_update update
alias seph_trailingchara_gmchar_jump jump
alias seph_trailingchara_gmchar_mt moveto
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_trailingchara_gmchar_init
# Create Nil Trailing Character
@trailing_character = nil
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Original Frame Update
seph_trailingchara_gmchar_update
# If Trailing Sprite Exist
unless @trailing_character.nil?
# Update Trailing Character
@trailing_character.update
# Update Trailing Character Movements
update_trailing_character_movements
end
end
#--------------------------------------------------------------------------
# * Jump
#--------------------------------------------------------------------------
def jump(x_plus, y_plus)
# Original Jump Method
seph_trailingchara_gmchar_jump(x_plus, y_plus)
# Return if No Trailing Character
return if @trailing_character.nil?
# If Jumping
if self.jumping?
x_plus = @x - @trailing_character.x
y_plus = @y - @trailing_character.y
# Jump Trialing Character
@trailing_character.jump(x_plus, y_plus)
end
end
#--------------------------------------------------------------------------
# * Move to Designated Position
#--------------------------------------------------------------------------
def moveto(x, y)
# Original Moveto Method
seph_trailingchara_gmchar_mt(x, y)
# Move Trailing Sprite
unless @trailing_character.nil?
# Move Trailing Character
@trailing_character.moveto(x, y)
end
end
#--------------------------------------------------------------------------
# * Frame Update : Trailing Sprite Movements
#--------------------------------------------------------------------------
def update_trailing_character_movements
# Return if Trailing Character is Moving or Jumping
return if @trailing_character.moving? || @trailing_character.jumping?
# Calculate X & Y Difference
x_diff = @trailing_character.x - @x + 2
y_diff = @trailing_character.y - @y + 2
# Trailing Character Movements
unless Trailing_Character_Movements[x_diff][y_diff].nil?
eval Trailing_Character_Movements[x_diff][y_diff]
end
end
#--------------------------------------------------------------------------
# * Add Trailing Character
#--------------------------------------------------------------------------
def add_trailing_character(name = '', hue = 0)
# Add Trailing Character
if @trailing_character.nil?
@trailing_character = Game_TrailingCharacter.new
@trailing_character.setup(self, name, hue)
# Adds Sprite to Spriteset
if $scene.is_a?(Scene_Map)
$scene.spriteset.add_trailing_character(@trailing_character)
end
# Add Trailing Character to Trailing Sprite
else
@trailing_character.add_trailing_character(name, hue)
end
end
#--------------------------------------------------------------------------
# * Delete Trailing Character
#--------------------------------------------------------------------------
def delete_trailing_character(index = 0)
# Return if No Trailing Character
return if @trailing_character.nil?
# Start Indexing
n = 0
tc = @trailing_character
# Gets Trialing Character Index
while n < index
# Return if No Trailing Character
return if tc.trailing_character.nil?
# Add Index
n += 1
# Get Next Trailing Character
tc = tc.trailing_character
end
# Delete all Trailing Characters
tc.delete
# Pop Last Character
pop_trailing_character
end
#--------------------------------------------------------------------------
# * Pop Trailing Character
#--------------------------------------------------------------------------
def pop_trailing_character
# Return if No Trailing Character
return nil if @trailing_character.nil?
# If Trailing Sprite has a trailing Sprite
if @trailing_character.trailing_character != nil
@trailing_character.pop_trailing_character
# Delete Trailing Character
else
# Remove from Spriteset
# Delete Trailing Sprite
@trailing_character = nil
end
end
#--------------------------------------------------------------------------
# * Last Trailing Character
#--------------------------------------------------------------------------
def last_trailing_character
# Return nil if no trailing character
return nil if @trailing_character.nil?
# Fetches Last Character
tc = @trailing_character
until tc.trailing_character.nil?
tc = tc.trailing_character
end
return tc
end
#--------------------------------------------------------------------------
# * Number of Trailing Character
#--------------------------------------------------------------------------
def number_of_trailing_characters
# Returns 0 if no Trailing Character
return 0 if @trailing_character.nil?
# Starts Counter
n = 1
tc = @trailing_character
# Adds to Counter when more Trailing Characters
until tc.trailing_character.nil?
n += 1
tc = tc.trailing_character
end
# Return Counter
return n
end
end
#==============================================================================
# ** Game_Player
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :enable_caterpillar
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_catapillar_gmplyr_init initialize
alias seph_catapillar_gmplyr_refresh refresh
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_catapillar_gmplyr_init
# Enables Catapillar
@enable_caterpillar = true
end
#--------------------------------------------------------------------------
# * Enable Caterpiller
#--------------------------------------------------------------------------
def enable_caterpillar=(boolean)
# If Enabling
if boolean
@enable_caterpillar = true
else
# Deletes Party Members
($game_party.actors.size - 1).times do
delete_trailing_character
end
@enable_caterpillar = false
end
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Original Refresh
seph_catapillar_gmplyr_refresh
# Delete all Trailing Characters
until number_of_trailing_characters <
(@enable_caterpillar ? $game_party.actors.size : 1)
pop_trailing_character
end
# Return unless Caterpillar Disabled
return unless @enable_caterpillar
# Refreshes Actors
unless @trailing_character.nil?
tc, i = @trailing_character, 0
loop do
i += 1
actor = $game_party.actors[i]
tc.character_name = actor.character_name
tc.character_hue = actor.character_hue
tc.trailing_character.nil? ? break : tc = tc.trailing_character
end
end
# Add Party Characters
for i in (number_of_trailing_characters + 1)...$game_party.actors.size
# Gets Actor
actor = $game_party.actors[i]
# Adds Actor
add_trailing_character(actor.character_name, actor.character_hue)
end
end
#--------------------------------------------------------------------------
# * Pop Trailing Character
#--------------------------------------------------------------------------
def pop_trailing_character
# If Caterpillar Enabled
if @enable_caterpillar
# If No Extra Trailing Characters
return if number_of_trailing_characters < $game_party.actors.size
end
super
end
#--------------------------------------------------------------------------
# * Delete Trailing Character
#--------------------------------------------------------------------------
def delete_trailing_character(index = 0)
# If Caterpillar Enabled
if @enable_caterpillar
# Return if trying to delete a party member
return if (index + 1) < $game_party.actors.size
end
super(index)
end
end
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_trailingchara_ssetm_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original Initialization
seph_trailingchara_ssetm_init
# Adds Trailing Characters (Player)
unless $game_player.trailing_character.nil?
trailing_character = $game_player.trailing_character
add_trailing_character(trailing_character)
until trailing_character.trailing_character.nil?
trailing_character = trailing_character.trailing_character
add_trailing_character(trailing_character)
end
end
# Adds Trailing Characters (Events)
for event in $game_map.events.values
unless event.trailing_character.nil?
trailing_character = event.trailing_character
add_trailing_character(trailing_character)
until trailing_character.trailing_character.nil?
trailing_character = trailing_character.trailing_character
add_trailing_character(trailing_character)
end
end
end
end
#--------------------------------------------------------------------------
# * Add Trailing Character
#--------------------------------------------------------------------------
def add_trailing_character(character = nil)
# Return if nil Character
return if character.nil?
# Adds Character Sprite
@character_sprites.push(Sprite_Character.new(@viewport1, character))
end
#--------------------------------------------------------------------------
# * Pop Trailing Character
#--------------------------------------------------------------------------
def pop_trailing_character(character)
# Return if nil character
return if character.nil?
# Passes through all Character Sprites
for sprite in @character_sprites
# Pops Sprites Character
if sprite.character == character
# Disposes Sprite
sprite.dispose
# Deletes from Character Sprites
@character_sprites.delete(sprite)
return
end
end
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
attr_accessor :spriteset
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end
AVISO: Não pode ser dois topicos, por se eu fazer só dois topico não ia dar porque a largura da mensagem ia ultrapassa o limite autorizado.
Topico 2: http://www.mundorpgmaker.com/forum/index.php?topic=83914.msg751812#msg751812
Creditos:
Eu - Por disponibilizar e resolver alguns erros ( Lembre-se que só foi alguns erros )
NetPlay Evolution
Script para usar:
- Código:
c = ['059-Aquatic01']
c = c[rand(c.size)]
$game_player.add_trailing_character(c)
['059-Aquatic01'] no lugar de 059-Aquatic01 você pode colocar outro grafico de pet.
AVISO: Isso não é global e contem alguns erros.
Última edição por Alexandrexs em Sáb Set 10, 2011 8:02 am, editado 4 vez(es)