Configurei diversas vezes o sistema de pet global do RD12 no NP MASTER 4.07 e também no NP MASTER 4 e em ambos funciona normalmente quando há apenas um jogador logado, porém quando um segundo jogador entra aparece o seguinte erro.
POR FAVOR ME AJUDEM!
POR FAVOR ME AJUDEM!
- Código:
=begin
:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
|Autor: RD12| Pet Global
--------------------------------------------------------------------------------
Com esse sistema os jogadores poderão ter Pets, globais.
O pet será o Anel[acessório].
--------------------------------------------------------------------------------
Para criar um Pet, insira no Módulo PET o seguinte:
ID[id] = ["Gráfico", HP, MP, Tempo]
---------------------------Explicação-------------------------------------------
id = ID do Anel, que será o Pet
HP/MP = HP/MP que o pet recupera com o Tempo
Tempo = Segundos que o pet recupera o HP/MP
:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
AldeiaRpgBr.com
=end
module PET
ID = []
#ID[Luva_ID] = ["Gráfico", HP, MP, Tempo(segundos)]
ID[01] = ["pet", 0, 0, 0]#Botei pra não recuperar HP/MP
#ID[37] = ["mecha", 10, 10, 5]
end
class Scene_Map
attr_reader :spriteset
end
class Spriteset_Map
attr_reader :character_sprites, :viewport1
alias rd12_dispose dispose
def player_sprite
@character_sprites.each do |spr_char|
if spr_char.character == $game_player
return spr_char
end
end
end
def dispose
$Pet = nil
rd12_dispose
end
end
class Scene_Map
attr_reader :character
attr_reader :animation_id
alias alias_update update
def update
alias_update
return if !$scene.is_a?(Scene_Map)
return if $scene.spriteset.nil?
@actor = $game_party.actors[0]
return unless $scene.is_a?(Scene_Map)
if PET::ID[@actor.armor4_id].nil? or @actor.armor4_id.nil?
return if $Pet.nil?
$Pet.bitmap = RPG::Cache.character("", 4)
$Pet = nil
return
end
@direção = $game_player.direction
#Criar sprite do pet
unless $Pet
$Pet = Sprite.new(@spriteset.viewport1)
$Pet.x = $game_player.screen_x
$Pet.y = $game_player.screen_y
end
$Pet.bitmap = RPG::Cache.character(PET::ID[@actor.armor4_id][0], 4)
#Pet Recuperar o HP/MP com o tempo
tempo = PET::ID[@actor.armor4_id][3]
if tempo > 0
if Graphics.frame_count % (20 * tempo) == 0
$game_party.actors[0].hp += PET::ID[@actor.armor4_id][1]
$game_party.actors[0].sp += PET::ID[@actor.armor4_id][2]
end
end
#Cria o gráfico do Pet, e com animação de andar
cw = $Pet.bitmap.width / 4
ch = $Pet.bitmap.height / 4
aw = $frame*cw
ah = (@direção - 2) / 2 * ch
$Pet.src_rect = Rect.new(aw, ah, cw ,ch )
player_spr = $scene.spriteset.player_sprite
#Pet Seguir o Player
#Direção =:2:=
if $game_player.direction == 2
$Pet.z = player_spr.z - 1
return unless $game_map.passable?($game_player.x, $game_player.y-1, 2)
if $Pet.x < ($game_player.screen_x - $Pet.bitmap.width/8)
$Pet.x += 4
end
if $Pet.x > ($game_player.screen_x - $Pet.bitmap.width/8)
$Pet.x -= 4
end
if $Pet.y < ($game_player.screen_y-32-$Pet.bitmap.height/4)
$Pet.y += 4
end
if $Pet.y > ($game_player.screen_y-32-$Pet.bitmap.height/4)
$Pet.y -= 4
end
#Direção =:4:=
elsif $game_player.direction == 4
return unless $game_map.passable?($game_player.x+1, $game_player.y, 4)
$Pet.z = player_spr.z + 1
if $Pet.x < ($game_player.screen_x+16)
$Pet.x += 4
end
if $Pet.x > ($game_player.screen_x+16)
$Pet.x -= 4
end
if $Pet.y < ($game_player.screen_y-$Pet.bitmap.height/4)
$Pet.y += 4
end
if $Pet.y > ($game_player.screen_y-$Pet.bitmap.height/4)
$Pet.y -= 4
end
#Direção =:6:=
elsif $game_player.direction == 6
return unless $game_map.passable?($game_player.x-1, $game_player.y,
$Pet.z = player_spr.z + 1
if $Pet.x < ($game_player.screen_x-16-$Pet.bitmap.width/4)
$Pet.x += 4
end
if $Pet.x > ($game_player.screen_x-16-$Pet.bitmap.width/4)
$Pet.x -= 4
end
if $Pet.y < ($game_player.screen_y-$Pet.bitmap.height/4)
$Pet.y += 4
end
if $Pet.y > ($game_player.screen_y-$Pet.bitmap.height/4)
$Pet.y -= 4
end
#Direção =:8:=
elsif $game_player.direction == 8
return unless $game_map.passable?($game_player.x, $game_player.y+1, 8)
$Pet.z = player_spr.z + 1
if $Pet.x < ($game_player.screen_x - ($Pet.bitmap.width/8))
$Pet.x += 4
end
if $Pet.x > ($game_player.screen_x - ($Pet.bitmap.width/8))
$Pet.x -= 4
end
if $Pet.y < ($game_player.screen_y+12-($Pet.bitmap.height/8))
$Pet.y += 4
end
if $Pet.y > ($game_player.screen_y+12-($Pet.bitmap.height/8))
$Pet.y -= 4
end
end#if player.direction
end#update
end#class
class Sprite_Character < RPG::Sprite
alias alias_update update
def update
alias_update
$frame = @character.pattern
end
end
class Sprite_NetCharacter < RPG::Sprite
alias rd12_animate_player animate_player
def dispose
@_text_display.dispose
@chat_text_display.dispose
@pet_spr.dispose
super
end
#--------------------------------------------------------------------------
# * Atualizar movimento do Jogador e Pet
#--------------------------------------------------------------------------
def animate_player
@chat_text_display.x = self.x
@chat_text_display.y = self.y - 129
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
cw = @pet_spr.bitmap.width / 4
ch = @pet_spr.bitmap.height / 4
aw = @character.pattern*cw
ah = (@character.direction - 2) / 2 * ch
@pet_spr.src_rect = Rect.new(aw, ah, cw ,ch )
if @character.direction == 2
@pet_spr.z = self.z-1
@pet_spr.x = (self.x - @pet_spr.bitmap.width/8)
@pet_spr.y = (self.y-32-@pet_spr.bitmap.height/4)
elsif @character.direction == 4
@pet_spr.x = (self.x+16)
@pet_spr.y = (self.y-@pet_spr.bitmap.height/4)
elsif @character.direction == 6
@pet_spr.x = (self.x-16-@pet_spr.bitmap.width/4)
@pet_spr.y = (self.y-@pet_spr.bitmap.height/4)
elsif @character.direction == 8
@pet_spr.z = self.z+1
@pet_spr.x = (self.x-(@pet_spr.bitmap.width/8))
@pet_spr.y = (self.y+12-(@pet_spr.bitmap.height/8))
end
rd12_animate_player
end
end