• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[PBS Question] pokemon altitude

153
Posts
4
Years
    • Seen Feb 4, 2020
    Hello everyone,

    This time I have a question which probably has a simple answer. I found that BattlerAltitude in the pokemon.pbs file was changing the Y position of the pokemon in battle and if==0 then it has no shadow.
    My problem is this one: I made another form for talonflame for an event and this one is not flying (on the picture). Then I went in pokemonforms.pbs and created a form 1 which worked perfectly but then I wanted to add BattlerAltitude=0 under it to make this property only for this form but the sprite is still in the air in battle.
    When I put BattlerAltitude=0 in pokemon.pbs it works but then all form 0 talonflame are going to fly on the ground.

    Thank you very much in advance for your tips.
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    I'm not 100% sure, but I was under the impression that altitude can't vary by form. Hopefully someone that knows more can drop in and confirm/deny this.

    If it is true, I doubt it would be too tricky to fix.
     

    _pheebee

    [I]Gosh! What's poppin'?[/i]
    528
    Posts
    5
    Years
  • I'm not 100% sure, but I was under the impression that altitude can't vary by form. Hopefully someone that knows more can drop in and confirm/deny this.

    If it is true, I doubt it would be too tricky to fix.

    don't quote me on this.
    But, I believe altitude varies by form, simply because Giratina's Origin form floats, where as the altered/normal form is firmly on the ground.
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    indeed Giratina has in pokemon.pbs:

    FormName=Altered Forme
    BattlerPlayerY=0
    BattlerEnemyY=9
    BattlerAltitude=0

    and in pokemonforms.pbs

    [GIRATINA-1]
    FormName=Origin Forme
    BaseStats=150,120,100,90,120,100
    Abilities=LEVITATE
    HiddenAbility=TELEPATHY
    Height=6.9
    Weight=650.0
    Shape=2
    BattlerEnemyY=4
    BattlerAltitude=10

    Then is it possible that I have to change something in the script pokemonforms? I thought this was necessary only to create a pokemon from the wild for example
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    I'm not 100% sure, but I was under the impression that altitude can't vary by form. Hopefully someone that knows more can drop in and confirm/deny this.

    If it is true, I doubt it would be too tricky to fix.
    Ok I tried with Giratina which didn't work (the event had an error loading the form from system utilities line 855) so I tried with landorus which was a similar case, form 1 shouldn't fly and it does fly so indeed, even though the pokemonforms.pbs contains changes in altitude it has no impact ingame.

    Any idea how to fix this?
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Any idea how to fix this?

    I think the fix would come in two parts:
    1. Make sure that the part of Compiler that loads form data actually handles the altitude data.
    2. Make sure that the graphic rendering part of Battle_Scene (I think that's its name?) uses the form altitude data instead of the non-form altitude when relevant.

    For both points I'd start by searching the code for altitude (I assume the code calls it that) with Ctrl+Shift+F, and trying to understand how that data is used throughout the system.
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    I found these lines in the compiler under pbCompilePokemonForms:

    Code:
      optionaltypes = {
        "BattlerPlayerY"   => [0,"i"],
        "BattlerEnemyY"    => [0,"i"],
        "BattlerAltitude"  => [0,"i"],
    line 1962

    Code:
          when "BattlerAltitude"
                    pbCheckSignedWord(value,key)
                    metrics[2][newspecies] = value
    line 2129
    and
    Code:
    metrics[0].fillNils(dexdatas.length,999) # player Y
      metrics[1].fillNils(dexdatas.length,999) # enemy Y
      metrics[2].fillNils(dexdatas.length,999) # altitude
    line 2336

    which are similar to the 3 lines where it appears in "compile pokemon" So I guess this checks your first tip

    I can't find any "altitude" in the PokeBattle_Scene script if it's the one you meant. In Pokemon_Sprites under Sprite position adjustement I found this:
    Code:
    def getBattleSpriteMetricOffset(species,index,metrics=nil)
      metrics = load_data("Data/metrics.dat") if !metrics
      ret = 0
      if index==1 || index==3   # Foe Pokémon
        ret += (metrics[1][species] || 0)*2 # enemy Y
        ret -= (metrics[2][species] || 0)*2 # altitude

    which is only taking the species into account. Is it the part I should modify? how?

    Thanks sorry I'm really trying to understand but it's still a bit hard for me.
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Looks like you're off to a great start! As you've noticed metrics[2][...] is the array for altitudes but it only uses the species, so we're going to have to change the structure a little to also take into account the form.

    Ultimately I think you want to be able to say this:
    Code:
    def getBattleSpriteMetricOffset(species,[color=green]form,[/color]index,metrics=nil)
      metrics = load_data("Data/metrics.dat") if !metrics
      ret = 0
      if index==1 || index==3   # Foe Pokémon
        ret += (metrics[1][species] || 0)*2 # enemy Y
        ret -= (metrics[2][species][color=green][form][/color] || 0)*2 # altitude

    I don't have the code in front of me, so I can only provide some handwavy thoughts about how to make that work.

    First we'll update the loading of BattlerAltitude to store a number per form instead a single number. I think that the number we load from pokemon.txt is for form 0, so we've replaced the number with a hash.

    Code:
          when "BattlerAltitude"
                    pbCheckSignedWord(value,key)
                    metrics[2][newspecies] = [color=green]{0 => [/color]value[color=green]}[/color]

    Next we'll need to make sure that the form parsing code handles BattlerAltitude and stores it in the metrics too. I'm not sure exactly where you'll put the code (have a look around for code that's similar to the above, but running over the forms data instead of over the species data). I'd expect you to end up with something a bit like this:

    Code:
    [color=green]      when "BattlerAltitude"
                    pbCheckSignedWord(value,key)
                    metrics[2][species][form] = value[/color]

    Then you'll need to make the changes (in green) to getBattleSpriteMetricOffset, and because I've introduced a new parameter you'll also need to find the places where getBattleSpriteMetricOffset is called and pass the form number through too.

    Finally you'll need to find everywhere else that "metrics[2]" is used so that you can change each occurrence to use the form number like we did in getBattleSpriteMetricOffset.


    You could take other approaches too, and those might be better. As I say, I haven't read the code so can't comment on which is best :)
     
    Last edited:
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    Wow awesome thank you very much. Your message helps me a lot more than you think because it's a lot of new informations on how things are working. I'll keep you up to date when I made it work... or not. :)

    edit: wow it's hard, when you talk about "update loading of BattlerAltitude, do you mean the first occurrence under compile pokemon? because then it's using [currentmap] instead of [newspecies]

    Sorry I try my best :D
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Hmm. Looks like currentmap is also a species since that code's inside pbCompilePokemonData. In fact, newspecies is part of pbCompilePokemonForms, so I think that one should be like the second code block in my post, and the currentmap one should be like the first.

    Now that I'm at home and I've actually read the code it looks like pbCompilePokemonForms actually converts the form into a new species number (this is what formtospecies is about), so that suggests that actually you should be able to make a much simpler fix—you just have to make sure that this special form species number gets passed to getBattleSpriteMetricOffset. It seems like the way to do that is find all the places where adjustBattleSpriteY is called and pass the form information, e.g. replacing:

    Code:
    [color=red]@endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)[/color]
    [color=green]@endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.form,pkmn.index)[/color]

    And updating the adjust function to convert the form and species into one of these pretend species values:

    Code:
    def adjustBattleSpriteY(sprite,species,[color=green]form,[/color]index,metrics=nil)
      [color=green]formstospecies = pbLoadFormsData
      species = formstospecies[species][form] rescue species[/color]
      ret = 0
      spriteheight = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.bitmap.height : 128
      ret -= spriteheight
      ret += getBattleSpriteMetricOffset(species,index,metrics)
      return ret
    end

    I'm not exactly sure that I'm using formstospecies or the rescue keyword correctly, and I haven't tested this change at all, so you'll probably need to make some changes.

    (BTW I don't think PC tells me when you've edited your post, so you might have better luck double-posting to make sure the thread ends up in the list of threads with new posts).

    Hopefully you're able to sort something out! I'm sure @NewAgeSteel would be happy to have a fix for altitude.
    So in my game I have some pokemon sprites that are bigger than usual (double the size of a normal sprite) and every time I battle against them, its floating way up in the air. the altitude isn't being changed because it doesn't have the shadow under it, but the Y position is. so ive gone into the editor in game, and tried editing the pbs outside of the game, but for some reason none of the changes make it move. ill edit the numbers and when I go back and check, the number have been saved and changed, but its not affecting the sprite position at all. does anyone know how to fix this? or is there possibly an issue with the size of the sprite that's making it not work? I didn't think size would be a problem since even the vanilla essentials has different size sprites going from gen 4 to 5. any help appreciated :)
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    Ok so I undo what I changed before?

    I'll get back to you tomorrow because today I won't have time to work on this but I'll definitely fix this.

    Thanks a lot!
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    Hey,

    I come back about this subject. I tried to change all what you said but it made no difference, and no crash neither so I don't know what I should do now :p
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    The part of the code I'm least confident in is this bit:
    Code:
      formstospecies = pbLoadFormsData
      species = formstospecies[species][form] rescue species
    Because that rescue will hide any errors that occur. So the first thing I'd do is try to double check exactly what's going on in there, maybe with some code like:
    Code:
      formstospecies = pbLoadFormsData[color=green]
      p("species=#{species}, form=#{form}, formspecies=#{formstospecies[species][form]}") if formstospecies[species]
      [/color]species = formstospecies[species][form] rescue species
    I'd expect that for the Pokémon with different altitudes for their forms a message gets displayed, and that it doesn't say "nil" (and for the Pokémon without a different form altitude it should say "nil").

    (Didn't test the code, so my syntax might be slightly wrong!)
     
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    I thought the above was doing no mistake but it was because I tried it only with the pokemon forms i wanted to display but after i met a regular random poke and had an error:
    underfined variable or method "form" in PokeBattle_scene. So this error poped up only when using the form=0 default

    I'll keep you updated^^
     
    Last edited:
    226
    Posts
    8
    Years
    • Seen Jul 19, 2023
    Sorry to bump this, but did you make any progress with this issue?

    I noticed the same thing as you did (forms do not have a separate altitude or Y positioning in v17.2), and tried using this as a workaround, without any visible effect.

    EDIT: Well, never mind, I fixed it, it turned out to be an issue with EBS not checking the pokemon's form before defining its metrics.
     
    Last edited:
    153
    Posts
    4
    Years
    • Seen Feb 4, 2020
    WOW I found a solution but it's not exactly what I wanted maybe you guys can help me.

    Actually Vendily posted this

    and following it I managed to modify the altitude and y position of a different form. However it is still not using the pbs and each different altitude has to be defined in the Pokemon_Forms script.

    example with landorus which was flying when it shouldn't

    Code:
    MultipleForms.register(:LANDORUS,{
    "getMetricOffset"=>proc{|pokemon|
       next if pokemon.form==0
       next [0,16,0]
    }
    })
     
    Last edited:
    Back
    Top