$Trainer.outfit=1 don't work

Marina

Elite Trainer
Member
Joined
Mar 10, 2018
Posts
129
Hello, I've made many player with different hair colors and different hair cut and now I want $Trainer.outfit=1 to work, but how do I make it work?

I made an wardrobe event with show choices, inside the show choises are conditional branches with the script $Trainer.outfit=1
when I playtest it, the player don't change his appearance just the trainer sprite at the trainercard changes, but I want the overworld to change, as well!
I have Essentials v.17.2 and I remember that I had no problems with that in Essentials 16.2, now its not working in 17.2
 

TheMaper

Novice
Member
Joined
Sep 9, 2018
Posts
14
Extending off of what Jonas said. Do you have the new outfits named trchar000_1 or trchar001_1? When you make a new outfit for a character, you use their original name (trchar000 for default boy) and add an underscore 1,2,3,ect. for each new costume. Hopefully that works for you.
 

TheMaper

Novice
Member
Joined
Sep 9, 2018
Posts
14
Did you forget the $ sign in front of trainer ($Trainer.outfit=1)? like so: https://gyazo.com/88aa0e25c13f8f8687cda661df0c62af . It's also possible from your earlier mention of using a conditional branch that you have the conditional branch checking for the outfit, but not actually changing to it. For instance, if paste $Trainer.outfit=1 into the script section of a conditional branch, It will check if the player has outfit 1 selected, if so the interior will resolve, if not the else will resolve. So instead, have the conditional branch check for outfit 0, and use a loose script to actually change the outfit to 1. Here's an example of what I mean: https://gyazo.com/842f0ab101d3cde3286487b7dd60e5fc . You could also just use a loose script. Having the conditional branch check for outfit 0 would be redundant in this case, but could be useful if you had a special outfit you didn't want equiped without a previous one (aka team member outfits that require the previous rank to be worn before upgrading).
 
Last edited:

Marina

Elite Trainer
Member
Joined
Mar 10, 2018
Posts
129
Did you forget the $ sign in front of trainer ($Trainer.outfit=1)? like so: https://gyazo.com/88aa0e25c13f8f8687cda661df0c62af . It's also possible from your earlier mention of using a conditional branch that you have the conditional branch checking for the outfit, but not actually changing to it. For instance, if paste $Trainer.outfit=1 into the script section of a conditional branch, It will check if the player has outfit 1 selected, if so the interior will resolve, if not the else will resolve. So instead, have the conditional branch check for outfit 0, and use a loose script to actually change the outfit to 1. Here's an example of what I mean: https://gyazo.com/842f0ab101d3cde3286487b7dd60e5fc . You could also just use a loose script. Having the conditional branch check for outfit 0 would be redundant in this case, but could be useful if you had a special outfit you didn't want equiped without a previous one (aka team member outfits that require the previous rank to be worn before upgrading).
I did the same way you said but just the Trainer sprite in the trainer card changes. BUT the overworld sprite (OW) do not change :(
I don't know what to do. Maybe Maruno should help me too, maybe it's just a bug in essentials v.17.2?
 

Marina

Elite Trainer
Member
Joined
Mar 10, 2018
Posts
129
This are the trainer sprites of the boy character:


This are the back sprite of the trainer character:


the trchars:

NOTE: I just use boy_bike_ I don't use bicycle + bicycle2


below, near the doors there are: boy_surf_6 and boy_surf_7
As I said.. I don't use boy_bicycle nor boy_bicycle2 (they are just saved there for when I want to use them)
( I use boy_bike_ from 1 to 7)

Then the event:





 

chikorita

Novice
Member
Joined
Apr 2, 2017
Posts
43
Weird, there's nothing wrong with stock essentials regarding trainer outfits.
You can see here that my event have the same base as yours.


And it's working fine. No problem with essentials 17.2
 

Marina

Elite Trainer
Member
Joined
Mar 10, 2018
Posts
129
These are the scripts when I search outfit:

Ruby:
def pbGetPlayerCharset(meta,charset,trainer=nil)
  trainer=$Trainer if !trainer
  outfit=trainer ? trainer.outfit : 0
  ret=meta[charset]
  ret=meta[1] if !ret || ret==""
  if pbResolveBitmap("Graphics/Characters/")
    ret=outfit.+ret+"_"+to_s
  end
  return ret
end

Ruby:
def pbBattleAnimationOverride(viewport,battletype=0,foe=nil)
  ##### VS. animation, by Luka S.J. #####
  ##### Tweaked by Maruno           #####
  if (battletype==1 || battletype==3) && foe.length==1   # Against single trainer
    trainerid = (foe[0][0].trainertype rescue -1)
    if trainerid>=0
      tbargraphic = sprintf("Graphics/Transitions/vsBar%s",getConstantName(PBTrainers,trainerid)) rescue nil
      tbargraphic = sprintf("Graphics/Transitions/vsBar%d",trainerid) if !pbResolveBitmap(tbargraphic)
      tgraphic    = sprintf("Graphics/Transitions/vsTrainer%s",getConstantName(PBTrainers,trainerid)) rescue nil
      tgraphic    = sprintf("Graphics/Transitions/vsTrainer%d",trainerid) if !pbResolveBitmap(tgraphic)
      if pbResolveBitmap(tbargraphic) && pbResolveBitmap(tgraphic)
        outfit = ($Trainer) ? $Trainer.outfit : 0
        # Set up
        viewplayer = Viewport.new(0,Graphics.height/3,Graphics.width/2,128)
        viewplayer.z = viewport.z
        viewopp = Viewport.new(Graphics.width/2,Graphics.height/3,Graphics.width/2,128)
        viewopp.z = viewport.z
        viewvs = Viewport.new(0,0,Graphics.width,Graphics.height)
        viewvs.z = viewport.z
        fade = Sprite.new(viewport)
        fade.bitmap  = BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
        fade.tone    = Tone.new(-255,-255,-255)
        fade.opacity = 100
        overlay = Sprite.new(viewport)
        overlay.bitmap = Bitmap.new(Graphics.width,Graphics.height)
        pbSetSystemFont(overlay.bitmap)
        pbargraphic = sprintf("Graphics/Transitions/vsBar%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
        pbargraphic = sprintf("Graphics/Transitions/vsBar%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pbargraphic)
        if !pbResolveBitmap(pbargraphic)
          pbargraphic = sprintf("Graphics/Transitions/vsBar%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
        end
        pbargraphic = sprintf("Graphics/Transitions/vsBar%d",$Trainer.trainertype) if !pbResolveBitmap(pbargraphic)
        xoffset = (((Graphics.width/2)/10).round)*10
        bar1 = Sprite.new(viewplayer)
        bar1.bitmap = BitmapCache.load_bitmap(pbargraphic)
        bar1.x      = -xoffset
        bar2 = Sprite.new(viewopp)
        bar2.bitmap = BitmapCache.load_bitmap(tbargraphic)
        bar2.x      = xoffset
        vs = Sprite.new(viewvs)
        vs.bitmap  = BitmapCache.load_bitmap("Graphics/Transitions/vs")
        vs.ox      = vs.bitmap.width/2
        vs.oy      = vs.bitmap.height/2
        vs.x       = Graphics.width/2
        vs.y       = Graphics.height/1.5
        vs.visible = false
        flash = Sprite.new(viewvs)
        flash.bitmap  = BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
        flash.opacity = 0
        # Animation
        10.times do
          bar1.x += xoffset/10
          bar2.x -= xoffset/10
          pbWait(1)
        end
        pbSEPlay("Vs flash")
        pbSEPlay("Vs sword")
        flash.opacity = 255
        bar1.dispose
        bar2.dispose
        bar1 = AnimatedPlane.new(viewplayer)
        bar1.bitmap = BitmapCache.load_bitmap(pbargraphic)
        bar2 = AnimatedPlane.new(viewopp)
        bar2.bitmap = BitmapCache.load_bitmap(tbargraphic)
        pgraphic = sprintf("Graphics/Transitions/vsTrainer%s_%d",getConstantName(PBTrainers,$Trainer.trainertype),outfit) rescue nil
        pgraphic = sprintf("Graphics/Transitions/vsTrainer%d_%d",$Trainer.trainertype,outfit) if !pbResolveBitmap(pgraphic)
        if !pbResolveBitmap(pgraphic)
          pgraphic = sprintf("Graphics/Transitions/vsTrainer%s",getConstantName(PBTrainers,$Trainer.trainertype)) rescue nil
        end
        pgraphic = sprintf("Graphics/Transitions/vsTrainer%d",$Trainer.trainertype) if !pbResolveBitmap(pgraphic)
        player = Sprite.new(viewplayer)
        player.bitmap = BitmapCache.load_bitmap(pgraphic)
        player.x      = -xoffset
        trainer = Sprite.new(viewopp)
        trainer.bitmap = BitmapCache.load_bitmap(tgraphic)
        trainer.x      = xoffset
        trainer.tone   = Tone.new(-255,-255,-255)
        25.times do
          flash.opacity -= 51 if flash.opacity>0
          bar1.ox -= 16
          bar2.ox += 16
          pbWait(1)
        end
        11.times do
          bar1.ox -= 16
          bar2.ox += 16
          player.x += xoffset/10
          trainer.x -= xoffset/10
          pbWait(1)
        end
        2.times do
          bar1.ox -= 16
          bar2.ox += 16
          player.x -= xoffset/20
          trainer.x += xoffset/20
          pbWait(1)
        end
        10.times do
          bar1.ox -= 16
          bar2.ox += 16
          pbWait(1)
        end
        val = 2
        flash.opacity = 255
        vs.visible = true
        trainer.tone = Tone.new(0,0,0)
        trainername = foe[0][0].name
        textpos = [
           [$Trainer.name,Graphics.width/4,(Graphics.height/1.5)+10,2,
              Color.new(248,248,248),Color.new(12*6,12*6,12*6)],
           [trainername,(Graphics.width/4)+(Graphics.width/2),(Graphics.height/1.5)+10,2,
              Color.new(248,248,248),Color.new(12*6,12*6,12*6)]
        ]
        pbDrawTextPositions(overlay.bitmap,textpos)
        pbSEPlay("Vs sword")
        70.times do
          bar1.ox -= 16
          bar2.ox += 16
          flash.opacity -= 25.5 if flash.opacity>0
          vs.x += val
          vs.y -= val
          val = 2 if vs.x<=(Graphics.width/2)-2
          val = -2 if vs.x>=(Graphics.width/2)+2
          pbWait(1)
        end
        30.times do
          bar1.ox -= 16
          bar2.ox += 16
          vs.zoom_x += 0.2
          vs.zoom_y += 0.2
          pbWait(1)
        end
        flash.tone = Tone.new(-255,-255,-255)
        10.times do
          bar1.ox -= 16
          bar2.ox += 16
          flash.opacity += 25.5
          pbWait(1)
        end
        # End
        player.dispose
        trainer.dispose
        flash.dispose
        vs.dispose
        bar1.dispose
        bar2.dispose
        overlay.dispose
        fade.dispose
        viewvs.dispose
        viewopp.dispose
        viewplayer.dispose
        viewport.color = Color.new(0,0,0,255)
        return true
      end
    end
  end
  return false
end


Ruby:
  attr_accessor(:outfit)

Ruby:
  def outfit
    @outfit=0 if !@outfit
    return @outfit
  end

Ruby:
  def initialize(name,trainertype)
    @name=name
    @language=pbGetLanguage()
    @trainertype=trainertype
    @id=rand(256)
    @id|=rand(256)<<8
    @id|=rand(256)<<16
    @id|=rand(256)<<24
    @metaID=0
    @outfit=0
    @pokegear=false
    @pokedex=false
    clearPokedex
    @shadowcaught=[]
    for i in 1..PBSpecies.maxValue
      @shadowcaught[i]=false
    end
    @badges=[]
    for i in 0...8
      @badges[i]=false
    end
    @money=INITIALMONEY
    @party=[]
  end
end


Ruby:
def pbPlayerSpriteFile(type)
  return nil if !type
  outfit = ($Trainer) ? $Trainer.outfit : 0
  bitmapFileName = sprintf("Graphics/Characters/trainer%s_%d",
     getConstantName(PBTrainers,type),outfit) rescue nil
  if !pbResolveBitmap(bitmapFileName)
    bitmapFileName = sprintf("Graphics/Characters/trainer%03d_%d",type,outfit)
    if !pbResolveBitmap(bitmapFileName)
      bitmapFileName = pbTrainerSpriteFile(type)
    end
  end
  return bitmapFileName
end



Ruby:
def pbPlayerSpriteBackFile(type)
  return nil if !type
  outfit = ($Trainer) ? $Trainer.outfit : 0
  bitmapFileName = sprintf("Graphics/Characters/trback%s_%d",
     getConstantName(PBTrainers,type),outfit) rescue nil
  if !pbResolveBitmap(bitmapFileName)
    bitmapFileName = sprintf("Graphics/Characters/trback%03d_%d",type,outfit)
    if !pbResolveBitmap(bitmapFileName)
      bitmapFileName = pbTrainerSpriteBackFile(type)
    end
  end
  return bitmapFileName
end

Ruby:
def pbPlayerHeadFile(type)
  return nil if !type
  outfit = ($Trainer) ? $Trainer.outfit : 0
  bitmapFileName = sprintf("Graphics/Pictures/mapPlayer%s_%d",
     getConstantName(PBTrainers,type),outfit) rescue nil
  if !pbResolveBitmap(bitmapFileName)
    bitmapFileName = sprintf("Graphics/Pictures/mapPlayer%03d_%d",type,outfit)
    if !pbResolveBitmap(bitmapFileName)
      bitmapFileName = pbTrainerHeadFile(type)
    end
  end
  return bitmapFileName
end

Ruby:
def pbTrainerName(name=nil,outfit=0)
  pbChangePlayer(0) if $PokemonGlobal.playerID<0
  trainertype = pbGetPlayerTrainerType
  trname = name
  $Trainer = PokeBattle_Trainer.new(trname,trainertype)
  $Trainer.outfit = outfit
  if trname==nil
    trname = pbEnterPlayerName(_INTL("Your name?"),0,PLAYERNAMELIMIT)
    if trname==""
      gender = pbGetTrainerTypeGender(trainertype)
      trname = pbSuggestTrainerName(gender)
    end
  end
  $Trainer.name = trname
  $PokemonBag = PokemonBag.new
  $PokemonTemp.begunNewGame = true
end

Ruby:
    commands.add("playermenu","changeoutfit",_INTL("Set Player Outfit"),
       _INTL("Edit the player's outfit number."))

Ruby:
  when "changeoutfit"
    oldoutfit = $Trainer.outfit
    params = ChooseNumberParams.new
    params.setRange(0,99)
    params.setDefaultValue(oldoutfit)
    $Trainer.outfit = Kernel.pbMessageChooseNumber(_INTL("Set the player's outfit."),params)
    Kernel.pbMessage(_INTL("Player's outfit was changed.")) if $Trainer.outfit!=oldoutfit



Ruby:
  def getTrainer(type=$Trainer.trainertype)
    outfit = $Trainer ? $Trainer.outfit : 0
    bitmapFileName = sprintf("Graphics/Titles/Panorama/trainer%s_%d",
       getConstantName(PBTrainers,type),outfit) rescue nil
    if !pbResolveBitmap(bitmapFileName)
      bitmapFileName = sprintf("Graphics/Titles/Panorama/trainer%03d_%d",type,outfit)
      if !pbResolveBitmap(bitmapFileName)
        bitmapFileName = sprintf("Graphics/Titles/Panorama/trainer%03d",type)
      end
    end
    return bitmapFileName
  end
 
end
end
 
Top