• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
[v13+] Character Selection

Resource [v13+] Character Selection 1.2

Hello I start on pokémon essentials and I would like to know where to put the code I have and or please
 
Hello I start on pokémon essentials and I would like to know where to put the code I have and or please
Press F11 in RPG Maker XP to open script editor. Then, create a new script section above main (preferably, right above), then paste the script in the new empty section. You can also copy and past the script right in the Main section start, but I don't recommend this.
 
i tried to figure out how to use your puglin but i dont understand nothing, i tried to use as plugin but the console dont identify the puglin, then i tried put it above main but the call function all says erro, its confusing for me
 
i tried to figure out how to use your puglin but i dont understand nothing, i tried to use as plugin but the console dont identify the puglin, then i tried put it above main but the call function all says erro, its confusing for me
What was your error when putting above main?

See here how to convert it into a detectable plugin, if you prefer this way.

For calling it, just copy the example and put into the script call (without the '#') and try choosing Red of Leaf.
 
overworld = ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
battle = ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
"POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
result = startCharacterSelection(overworld,battle)
pbChangePlayer(result+1)

this is the example, its to many characters, the function to call the script dont allow me to put that many,

is to put these overworld and battle and replace in this function startCharacterSelection(overworld,battle) like:

startCharacterSelection(
["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
,
["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
"POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
)

i dont get it, sorry.
then i dont need to change anything in the script? add more ow and battle choices and where i can put?

the result and pbChangePlayer(result+1) are to call both on the same script? im asking all this because i trid a lot of thing and none of them worked
 
Code:
Expand Collapse Copy
overworld = ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
battle = ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
 "POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
result = startCharacterSelection(overworld,battle) 
pbChangePlayer(result+1)

this is the example, its to many characters, the function to call the script dont allow me to put that many,
You can run extendtext.exe ()look at your project folder) to raise this limit, create a def above main (a bit more complex) or use your other example with some changes

Code:
Expand Collapse Copy
startCharacterSelection(
["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
,
 ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
 "POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
)
The 'startCharacterSelection' just return you the index choosed (i.e. 0 for Red, 1 for Leaf). If you want to use it to change your character, you need to store the result and call pbChangePlayer. This way:

Code:
Expand Collapse Copy
r = startCharacterSelection(
["trainer_POKEMONTRAINER_Red",
"trainer_POKEMONTRAINER_Leaf"]
,
 ["POKEMONTRAINER_Red",
"POKEMONTRAINER_Leaf"]
)
pbChangePlayer(r+1)
(I also removed Brendan and May to make things simpler and shorter).

After this worked, you can change the sprites. Let me know if this doesn't work!
 
r = startCharacterSelection(
["trainer_POKEMONTRAINER_Red",
"trainer_POKEMONTRAINER_Leaf"]
,
["POKEMONTRAINER_Red",
"POKEMONTRAINER_Leaf"]
)
pbChangePlayer(r+1)

this worked but it change to a complete black screen with nothing
 
r = startCharacterSelection(
["trainer_POKEMONTRAINER_Red",
"trainer_POKEMONTRAINER_Leaf"]
,
["POKEMONTRAINER_Red",
"POKEMONTRAINER_Leaf"]
)
pbChangePlayer(r+1)

this worked but it change to a complete black screen with nothing
Where did you called the event script? I used a random NPC in Lappet to test it. What was your essentials version?
 
There is a mistake in my example. Change
Code:
Expand Collapse Copy
r = startCharacterSelection(
["trainer_POKEMONTRAINER_Red",
"trainer_POKEMONTRAINER_Leaf"]
,
 ["POKEMONTRAINER_Red",
"POKEMONTRAINER_Leaf"]
)
pbChangePlayer(r+1)
to
Code:
Expand Collapse Copy
r = startCharacterSelection(
["trainer_POKEMONTRAINER_Red",
"trainer_POKEMONTRAINER_Leaf"],
 ["POKEMONTRAINER_Red",
"POKEMONTRAINER_Leaf"]
)
pbChangePlayer(r+1)
I tested here in v21.1 and it was working, only arrows didn't appears but I gonna fix this soon. If the black screen continues, try using it in a vanilla v21.1.
 
I have a question: I put this above main:

First i have the code for character selection, that part works.

Below it I have this:

def somename
overworld = ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
battle = ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
"POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
result = startCharacterSelection(overworld,battle)
pbChangePlayer(result+1)
end

Then in the event I have this:

Script: somename
Script: pbChangePlayer(result+1)

I then get a crash after picking the trainer, removing the change player line results in the game continuing to run but with the default character regardless of choice. Any ideas? Also for the surfing and fishing animation, can i just add those to this list?
 
I have a question: I put this above main:

First i have the code for character selection, that part works.

Below it I have this:

def somename
overworld = ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf",
"trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"]
battle = ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
"POKEMONTRAINER_Brendan","POKEMONTRAINER_May"]
result = startCharacterSelection(overworld,battle)
pbChangePlayer(result+1)
end

Then in the event I have this:

Script: somename
Script: pbChangePlayer(result+1)

I then get a crash after picking the trainer, removing the change player line results in the game continuing to run but with the default character regardless of choice. Any ideas? Also for the surfing and fishing animation, can i just add those to this list?
The line 'pbChangePlayer(result+1)' after 'somename' will crash the game, since game doesn't know what is 'result', so remove this line at this place. After this change, did you can at least change between first and second player? This should be working.
 
The line 'pbChangePlayer(result+1)' after 'somename' will crash the game, since game doesn't know what is 'result', so remove this line at this place. After this change, did you can at least change between first and second player? This should be working.
I did that and after picking any of the characters, it just gives me the default male character.
 
I did that and after picking any of the characters, it just gives me the default male character.
I tested right now at a clear v21.1 in a NPC at Lappet Town and when I select (and confirm) Leaf (the female character), I changed into Leaf. This should be working, looks like something that you changed. I suggest testing in a vanilla v21.1.
 
I was able to figure out what I was missing (not updating the metadata). Everything is good now, I just wish Essentials included the full sprite sheets for Brenden and May :/
 
Julie made a version compatible with Animated Trainer Intros, from Lucidious89.

Ruby:
Expand Collapse Copy
#===============================================================================
# * Character Selection - by FL (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It's a character selection screen
# suggested for player selection or partner selection.
#
#== INSTALLATION ===============================================================
#
# To this script works, put it above main OR convert into a plugin. Put a 32x32
# background at "Graphics/UI/character_selection_tile" (may works with other 
# sizes).
#
#== HOW TO USE =================================================================
#
# Call 'startCharacterSelection(overworld,battle)' passing two arrays with the
# same size as arguments: 
#
# - The first include overworld graphics names (from "Graphics/Characters").
# - The second include battler/front graphics names (from "Graphics/Trainers" 
# or "Graphics/Characters").
#
# The return is the player selected index, starting at 0. 
#
#== EXAMPLES ===================================================================
#
# A basic example that initialize the player:
#
#  overworld = [
#   "trainer_POKEMONTRAINER_Red",
#   "trainer_POKEMONTRAINER_Leaf"]
#  battle = ["POKEMONTRAINER_Red",
#   "POKEMONTRAINER_Leaf"]
#  r=startCharacterSelection(
#   overworld,battle) 
#  pbChangePlayer(r+1)
#
# Example with 4 characters. This example won't change your character, just 
# store the index result at game variable 70.  
#
#  overworld = [
#    "trainer_POKEMONTRAINER_Red", "trainer_POKEMONTRAINER_Leaf",
#    "trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAINER_May"
#  ]
#  battle = [
#    "POKEMONTRAINER_Red","POKEMONTRAINER_Leaf",
#    "POKEMONTRAINER_Brendan","POKEMONTRAINER_May"
#  ]
#  $game_variables[70] = startCharacterSelection(overworld,battle) 
#
#===============================================================================

if defined?(PluginManager) && !PluginManager.installed?("Character Selection")
  PluginManager.register({                                                 
    :name    => "Character Selection",                                        
    :version => "1.2",                                                     
    :link    => "https://www.pokecommunity.com/showthread.php?t=338481",             
    :credits => "FL"
  })
end

class CharacterSelectionScene
  BACKGROUND_SPEED = 3
  ANIMATION_FRAME_INTERVAL = 4 # Increase for slower animation.
  FRAMES_TO_TURN = 128
  
  def pbStartScene(overworld,battle)
    @overworld = overworld
    @battle = battle
    @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @sprites["bg"]=CharacterSelectionPlane.new(
      BACKGROUND_SPEED,FRAMES_TO_TURN,@viewport)
    @sprites["bg"].setBitmap("Graphics/UI/character_selection_tile")
    @sprites["arrow"]=IconSprite.new(@viewport)
    @sprites["arrow"].setBitmap(arrowBitmapPath)
    @sprites["battlerbox"]=Window_AdvancedTextPokemon.new("")
    @sprites["battlerbox"].viewport=@viewport
    pbBottomLeftLines(@sprites["battlerbox"],5)
    @sprites["battlerbox"].width=256
    @sprites["battlerbox"].x=Graphics.width-@sprites["battlerbox"].width
    @sprites["battlerbox"].z=0
    @sprites["battler"]=IconSprite.new(384,284,@viewport)
    # Numbers for coordinates calculation
    lines = 2
    totalWidth = 512
    totalHeight = 232
    marginX = totalWidth/((@overworld.size/2.0).ceil+1)
    marginY = 72
    for i in 0...@overworld.size
      @sprites["icon#{i}"]=AnimatedChar.new(
          "Graphics/Characters/"+@overworld[i],4,
          [ANIMATION_FRAME_INTERVAL-1,0].max, FRAMES_TO_TURN, @viewport)
      @sprites["icon#{i}"].x = marginX*((i/2).floor+1)
      @sprites["icon#{i}"].y = marginY+(totalHeight - marginY*2)*(i%lines)
      @sprites["icon#{i}"].start
    end
    updateCursor
    @sprites["messagebox"]=Window_AdvancedTextPokemon.new(
        _INTL("Choose your character."))
    @sprites["messagebox"].viewport=@viewport
    pbBottomLeftLines(@sprites["messagebox"],5)
    @sprites["messagebox"].width=256
    pbFadeInAndShow(@sprites) { update }
  end
  
  def updateCursor(index=nil)
    @index=0
    if index
      pbPlayCursorSE
      @index=index
    end
    @sprites["arrow"].x=@sprites["icon#{@index}"].x-32
    @sprites["arrow"].y=@sprites["icon#{@index}"].y-32
    bmpPath = trainerBitmapPath(@battle[@index])[1]
    if bmpPath
      echoln("Path found: #{bmpPath}")
      #@sprites["battler"].setBitmap(bmpPath)
      @sprites["battler"].setTrainerBitmap(bmpPath)
      if @sprites["battler"].bitmap
        echoln("Bitmap loaded: #{@sprites["battler"].bitmap.width}x#{@sprites["battler"].bitmap.height}")
        @sprites["battler"].ox=@sprites["battler"].bitmap.width/2
        @sprites["battler"].oy=@sprites["battler"].bitmap.height/2
      else
        echoln("Bitmap Path Exists, but it doesnt load!")
      end
    else
      echoln("Sprite not found: #{@battle[@index]}")
    end
  end

  def arrowBitmapPath
    ret = pbResolveBitmap("Graphics/UI/sel_arrow")
    return ret if ret
    ret = pbResolveBitmap("Graphics/Pictures/selarrow")
    return ret
  end

  def trainerBitmapPath(spriteName)
    ret = [pbResolveBitmap("Graphics/Trainers/"+spriteName.to_s), spriteName]
    return ret if ret
    ret = pbResolveBitmap("Graphics/Characters/"+spriteName)
    return ret
  end
  
  def pbMidScene
   loop do
    Graphics.update
    Input.update
    self.update
    if Input.trigger?(Input::C)
      pbPlayDecisionSE
      if pbDisplayConfirm(_INTL("Are you sure?"))
        pbPlayDecisionSE
        return @index
      else 
        pbPlayCancelSE
      end
    end
    lines=2
    if Input.repeat?(Input::LEFT)
      updateCursor((@index-lines)>=0 ? 
          @index-lines : @overworld.size-lines+(@index%lines))
    end
    if Input.repeat?(Input::RIGHT)
      updateCursor((@index+lines)<=(@overworld.size-1) ? 
          @index+lines : @index%lines)
    end
    if Input.repeat?(Input::UP)
      updateCursor(@index!=0 ? @index-1 : @overworld.size-1)
    end
    if Input.repeat?(Input::DOWN)
      updateCursor(@index!=@overworld.size-1 ? @index+1 : 0)  
    end
   end 
  end
  
  def update
    pbUpdateSpriteHash(@sprites)
    @sprites["battler"].play
  end
  
  def pbDisplayConfirm(text)
   ret=-1
   oldtext=@sprites["messagebox"].text
   @sprites["messagebox"].text=text
   using(cmdwindow=Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])){
     cmdwindow.z=@viewport.z+1
     cmdwindow.visible=false
     pbBottomRight(cmdwindow)
     cmdwindow.y-=@sprites["messagebox"].height
     loop do
       Graphics.update
       Input.update
       cmdwindow.visible=true if !@sprites["messagebox"].busy?
       cmdwindow.update
       self.update
       if Input.trigger?(Input::B) && !@sprites["messagebox"].busy?
         ret=false
       end
       if (Input.trigger?(Input::C) && 
           @sprites["messagebox"].resume && !@sprites["messagebox"].busy?)
         ret=(cmdwindow.index==0)
         break
       end
     end
   }
   @sprites["messagebox"].text=oldtext
   return ret
  end
  
  def pbEndScene
    pbFadeOutAndHide(@sprites) { update }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end

  class CharacterSelectionPlane < AnimatedPlane
    LIMIT=16
    
    def initialize(speed, turnTime, viewport)
      super(viewport)
      @speed = speed
      @turnTime = turnTime
    end  
    
    def update
      super
      @frame=0 if !@frame
      @frame+=1
      @direction=0 if !@direction
      if @frame==@turnTime
        @frame=0
        @direction+=1
        @direction=0 if @direction==4
      end
      case @direction
      when 0 #down
        self.oy+=@speed
      when 1 #left
        self.ox-=@speed
      when 2 #up
        self.oy-=@speed
      when 3 #right
        self.ox+=@speed
      end
      self.ox=0 if self.ox==-LIMIT || self.ox==LIMIT 
      self.oy=0 if self.oy==-LIMIT || self.oy==LIMIT 
    end
  end

  class AnimatedChar < AnimatedSprite
    def initialize(*args)
      @realframeschar=0
      @direction=0
      @turnTime=args[3]
      super([args[0],args[1],args[2],args[4]])
      @frameheight=@animbitmap.height/4
      if @animbitmap.width%framecount!=0
        raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]",@animbitmap.width,@framewidth,@animname)
      end
      @playing=false
      self.src_rect.height=@frameheight
      self.ox=@framewidth/2
      self.oy=@frameheight
    end
  
    def frame=(value)
      @frame=value
      @realframes=0
      self.src_rect.x=@frame%@framesperrow*@framewidth
    end
  
    def update
      super
      if @playing
        @realframeschar+=1
        if @realframeschar==@turnTime
          @realframeschar=0 
          @direction+=1
          @direction= 0 if @direction==4
          #Spin
          if @direction==2
            dir=3
          elsif @direction==3
            dir=2
          else
            dir=@direction
          end  
          self.src_rect.y=@frameheight*dir
        end
      end
    end
  end  
end

class CharacterSelectionScreen
  def initialize(scene)
    @scene=scene
  end
  
  def pbStartScreen(overworld,battle)
    @scene.pbStartScene(overworld,battle)
    ret = @scene.pbMidScene
    @scene.pbEndScene
    return ret
  end
end

def startCharacterSelection(overworld,battle)
  ret = nil
  pbFadeOutIn(99999) {
    scene=CharacterSelectionScene.new
    screen=CharacterSelectionScreen.new(scene)
    ret=screen.pbStartScreen(overworld,battle)
  }
  return ret
end
 
Back
Top