Sujet n°10801
Posté par Conan Edogawa le 6 Jan - 21:58 (2012)
Titre : Probleme Follow Me
Bonjour - bonsoir,
Etant donné que les charchas 5G on étés postés j'ai modifié le follow me pour intégrer la 5G et les formes des cerfs
Mais un bug survient au lancement du jeu:
?????"Follow Me" ? 79 ???SyntaxError ?????????

Voici les modifications:
Code:
#==============================================================================
# ■ Follow Me Pokémon
# par Brendan75
#-----------------------------------------------------------------------------
# Rend le premier pokémon de l'équipe visible sur la map.
#==============================================================================

PKM_TRANSPARENT_SWITCHES = 50 # Index de l'interrupteur pour rendre invisible

class Follower_Pkm < Game_Character
  include POKEMON_S
 
  def initialize
    super()
    @through = false
    @step_anime = true
    @pkm_id = 0
  end
 
  def update
    if $pokemon_party.size != 0
      @pkm_id = $pokemon_party.actors[0].id
      if pkm_id >= 494
      string = "#{sprintf('%03d', @pkm_id)}.png"
    else
       string = "#{sprintf('%03d', @pkm_id)}_0.png"
     if @pkm_id == 586 or @pkm_id == 585
       if $game_variables[50] == "Hiver"
         string = "#{sprintf('%03d', @pkm_id)}-wt.png"
       elsif $game_variables[50] == "Printemps"
         string = "#{sprintf('%03d', @pkm_id)}-sp.png"
       elsif $game_variables[50] == "Eté"
         string = "#{sprintf('%03d', @pkm_id)}-sm.png"
       elsif $game_variables[50] == "Automne"
         string = "#{sprintf('%03d', @pkm_id)}-at.png"
       end
    else
      @character_name = ""
    end
    super
  end
 
  def check_event_trigger_touch(x, y) end
   
  def passable?(x, y, d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    unless $game_map.valid?(new_x, new_y)
      return false
    end
    if @through
      return true
    end
    unless $game_map.passable?(x, y, d, self)
      return false
    end
    unless $game_map.passable?(new_x, new_y, 10 - d)
      return false
    end
    for event in $game_map.events.values
      if event.x == new_x and event.y == new_y
        unless event.through
          if self != $game_player
            return false
          end
          if event.character_name != ""
            return false
          end
        end
      end
    end
    return true
  end
end

#-----------------------------------------------------------------------------
# ● Spriteset Map
#-----------------------------------------------------------------------------
class Spriteset_Map
  alias follow_me_initialize initialize
  def initialize
    follow_me_initialize
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_party.follower_pkm))
    update
  end
end

#-----------------------------------------------------------------------------
# ● Scene Map
#-----------------------------------------------------------------------------
class Scene_Map
  alias follow_me_transfer_player transfer_player
  def transfer_player
    $game_party.erase_moves
    follow_me_transfer_player
  end
 
  alias follow_me_update update
  def update
    follow_me_update
    $game_party.follower_pkm.update
  end
end

#-----------------------------------------------------------------------------
# ● Game Player
#-----------------------------------------------------------------------------
class Game_Player
  alias follow_me_moveto moveto
  def moveto(x, y)
    follow_me_moveto(x, y)
    $game_party.follower_pkm.moveto(x, y)
  end
 
  def move_down(turn_enabled = true)
    if passable?(@x, @y, 2)
      $game_party.move_party_actors
      $game_party.add_move_list(Input::DOWN, turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_left(turn_enabled = true)
    if passable?(@x, @y, 4)
      $game_party.move_party_actors
      $game_party.add_move_list(Input::LEFT, turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_right(turn_enabled = true)
    if passable?(@x, @y, 6)
      $game_party.move_party_actors
      $game_party.add_move_list(Input::RIGHT, turn_enabled)
    end
    super(turn_enabled)
  end
 
  def move_up(turn_enabled = true)
    if passable?(@x, @y, 8)
      $game_party.move_party_actors
      $game_party.add_move_list(Input::UP, turn_enabled)
    end
    super(turn_enabled)
  end
end

#-----------------------------------------------------------------------------
# ● Game Party
#-----------------------------------------------------------------------------
class Game_Party
  include POKEMON_S
  attr_accessor :follower_pkm
 
  alias follow_me_initialize initialize
  def initialize
    follow_me_initialize
    @follower_pkm = Follower_Pkm.new
    @next_move = nil
  end
 
  def move_party_actors
    case @next_move.type
    when Input::DOWN
      @follower_pkm.move_down(@next_move.turn_enabled)
    when Input::LEFT
      @follower_pkm.move_left(@next_move.turn_enabled)
    when Input::RIGHT
      @follower_pkm.move_right(@next_move.turn_enabled)
    when Input::UP
      @follower_pkm.move_up(@next_move.turn_enabled)
    else
      return
    end
    erase_moves
  end
   
  def add_move_list(type, turn_enabled)
    @next_move = Move_List_Element.new(type, turn_enabled)
  end
 
  def erase_moves
    @next_move = nil
  end
end

#-----------------------------------------------------------------------------
# ● Move List Element
#-----------------------------------------------------------------------------
class Move_List_Element
  attr_reader :type
  attr_reader :turn_enabled
 
  def initialize(type, turn_enabled)
    @type = type
    @turn_enabled = turn_enabled
  end
end

Voila merci d'avance
Ps:Le "if @pkm_id >= 494" sert a modifier le nom de fichier car il etait pas nommés pareil et j'avais la flemme

Posté par Nuri Yuri le 6 Jan - 22:21 (2012)
Il manque un End, une de tes conditions n'a pas son bloc écris avec l'espace nécessaire du coup le programme t'a fait croire que les conditions étaient toute fermées.
Remplace
Code:
string = "#{sprintf('%03d', @pkm_id)}-at.png" 
       end 

par
Code:
string = "#{sprintf('%03d', @pkm_id)}-at.png" 
       end 
     end

Posté par Conan Edogawa le 6 Jan - 22:23 (2012)
Je teste....Bug!
????"Follow me"????? Syntax error ?????? L.38 ?????
(c'est un else)

Posté par Nuri Yuri le 6 Jan - 22:27 (2012)
Essaie de remplacer toute la méthode Update par :
Code:
  def update 
    if $pokemon_party.size != 0 
      @pkm_id = $pokemon_party.actors[0].id 
      if pkm_id >= 494 
        string = "#{sprintf('%03d', @pkm_id)}.png" 
      else 
       string = "#{sprintf('%03d', @pkm_id)}_0.png" 
       if @pkm_id == 586 or @pkm_id == 585 
         if $game_variables[50] == "Hiver" 
           string = "#{sprintf('%03d', @pkm_id)}-wt.png" 
         elsif $game_variables[50] == "Printemps" 
           string = "#{sprintf('%03d', @pkm_id)}-sp.png" 
         elsif $game_variables[50] == "Eté" 
           string = "#{sprintf('%03d', @pkm_id)}-sm.png" 
         elsif $game_variables[50] == "Automne" 
           string = "#{sprintf('%03d', @pkm_id)}-at.png" 
         end 
       end
     end       
    else 
      @character_name = "" 
    end 
    super 
  end 

Edit : cite le message pour copier le code.

Posté par Conan Edogawa le 6 Jan - 23:15 (2012)
bug ligne 28 ("if $game-variables[50] == "Hiver"")
syntax error