• 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.

[Scripting Question] Revisiting an Old Problem [v20.1]

sonicfan7895

Just a dude, I guess
122
Posts
13
Years
  • In reference to this old post: https://www.pokecommunity.com/showthread.php?t=380091

    TL;DR: I need to select more than one Pokemon to fuse into another, a la Kyurem.​

    I did in fact go back to the drawing board. Almost seven whole years later...

    I decided to try and give the "fusing legendary" problem another go, and finally came up with another solution. Making "Legendary 3" from the previous post require both legendaries to be fused into it in order to reach its full power.

    The only roadblock I'm hitting is I'm unable to select "Legendary 1" and "Legendary 2" after selecting "Legendary 3" to pull the former two in.

    I have a vague idea how I can restructure the selection to allow more than one, but what I tried initially didn't work as intended.

    Code:
    ItemHandlers::UseOnPokemon.add(:EBONYSTONE, proc { |item, qty, pkmn, scene|
      if !pkmn.isSpecies?(:SERKINDRAC) || !pkmn.fused.nil?
        scene.pbDisplay(_INTL("It had no effect."))
        next false
      elsif pkmn.fainted?
        scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
        next false
      end
      # Fusing
      chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
      [COLOR="Red"][U]next false if chosen < 1[/U][/COLOR]
      other_pkmn = $player.party[chosen]
      if pkmn == other_pkmn
        scene.pbDisplay(_INTL("It cannot be fused with itself."))
        next false
      elsif other_pkmn.egg?
        scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
        next false
      elsif other_pkmn.fainted?
        scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
        next false
      elsif !other_pkmn.isSpecies?(:SERKIRA) &&
            !other_pkmn.isSpecies?(:EBONDRAC)
        scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
        next false
      end
      newForm = 0
      [COLOR="Red"][U]newForm = 1 if other_pkmn.isSpecies?(:SERKIRA) && other_pkmn.isSpecies?(:EBONDRAC)[/U][/COLOR]
      pkmn.setForm(newForm) {
        pkmn.fused = other_pkmn
        $player.remove_pokemon_at_index(chosen)
        scene.pbHardRefresh
        scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
      }
      $bag.replace_item(:EBONYSTONE, :EBONYSTONEUSED)
      next true
    })
    
    ItemHandlers::UseOnPokemon.add(:EBONYSTONEUSED, proc { |item, qty, pkmn, scene|
      if !pkmn.isSpecies?(:SERKINDRAC) || pkmn.fused.nil?
        scene.pbDisplay(_INTL("It had no effect."))
        next false
      elsif pkmn.fainted?
        scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
        next false
      elsif $player.party_full?
        scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
        next false
      end
      # Unfusing
      pkmn.setForm(0) {
        $player.party[$player.party.length] = pkmn.fused
        pkmn.fused = nil
        scene.pbHardRefresh
        scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
      }
      $bag.replace_item(:EBONYSTONEUSED, :EBONYSTONE)
      next true
    })

    The outcome was that it was able to fuse, initially, but since the condition was still only met halfway the forme change happened. I need to select both consecutively in order for this to occur, not the forme change to occur and then have to choose another. I don't want to have to add a "half-powered" form, cause that sounds way too convoluted.

    Those that are underlined in the first section were what I changed to try and force the engine to allow me to pick two Pokemon before the forme change. Though I don't know if there are any tips or tricks to pick more than one Pokemon for a process like this.

    Any help would be appreciated!
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • Quick reply to this; one idea I had is a check to see if both Legendaries 1 and 2 are present in the party when the item is used, and THEN the two get pulled into Legendary 3, thus completing the fusing and allowing Legendary 3 to reach its next form.

    Quick thought.
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • I apologize for the spam replies to this, cause as I'm working I'm starting to get closer and closer.

    It now works "75%". For one, I got the three to merge together into one! When done in a certain order the two legendaries disappear and the other one changes forms. However, a new bug has arisen... when I try to unfuse, only one legendary returns. I would also appreciate help on this (until I inevitably find the fix while struggling)
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • I'm so, SO incredibly close, but I'm still failing at this...

    This is the code I have so far, that got me so close. And the reason I'm so close is that when fused a certain way, both legendaries disappear. But now when I go to unfuse them, two of the same Pokemon reappear. I know this has to do with $player.party[$player.party.length] having two instances in the unfusing method, but I'm having trouble trying to define each legendary without messing with the game variables. Unless that's my only other option...

    Anyway, here's what I have to show for three hours of struggling into the night last night...

    Code:
    ItemHandlers::UseOnPokemon.add(:EBONYSTONE, proc { |item, qty, pkmn, scene|
      if !pkmn.isSpecies?(:SERKINDRAC) || !pkmn.fused.nil?
        scene.pbDisplay(_INTL("It had no effect."))
        next false
      elsif pkmn.fainted?
        scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
        next false
      end
      # Fusing
      chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
      chosen2 = scene.pbChoosePokemon(_INTL("Fuse with another which Pokemon?"))
      next false if chosen < 1
      other_pkmn = $player.party[chosen]
      other_pkmn2 = $player.party[chosen2]
      if pkmn == other_pkmn
        scene.pbDisplay(_INTL("It cannot be fused with itself."))
        next false
      elsif other_pkmn.egg?
        scene.pbDisplay(_INTL("It cannot be fused with an Egg."))
        next false
      elsif other_pkmn.fainted?
        scene.pbDisplay(_INTL("It cannot be fused with that fainted Pokémon."))
        next false
      elsif !other_pkmn.isSpecies?(:SERKIRA) && !other_pkmn.isSpecies?(:EBONDRAC)
        scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
        next false
      end
      newForm = 0
      newForm = 1 if other_pkmn.isSpecies?(:SERKIRA) && other_pkmn.isSpecies?(:EBONDRAC)
      pkmn.setForm(newForm) {
        pkmn.fused = other_pkmn
        pkmn.fused = other_pkmn2
        $player.remove_pokemon_at_index(chosen)
        $player.remove_pokemon_at_index(chosen2)
        scene.pbHardRefresh
        scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
      }
      $bag.replace_item(:EBONYSTONE, :EBONYSTONEUSED)
      next true
    })
    
    ItemHandlers::UseOnPokemon.add(:EBONYSTONEUSED, proc { |item, qty, pkmn, scene|
      if !pkmn.isSpecies?(:SERKINDRAC) || pkmn.fused.nil?
        scene.pbDisplay(_INTL("It had no effect."))
        next false
      elsif pkmn.fainted?
        scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
        next false
      elsif $player.party_full?
        scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
        next false
      end
      # Unfusing
      pkmn.setForm(0) {
        $player.party[$player.party.length] = pkmn.fused
        $player.party[$player.party.length] = pkmn.fused
        pkmn.fused = nil
        scene.pbHardRefresh
        scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
      }
      $bag.replace_item(:EBONYSTONEUSED, :EBONYSTONE)
      next true
    })

    I'm putting this on the backburner until I can get some help. I'm literally ripping my hair out of my head over this, when I could be focusing on other things.
     
    1,682
    Posts
    8
    Years
    • Seen yesterday
    Code:
    pkmn.fused = other_pkmn
        pkmn.fused = other_pkmn2
    you only saved other_pkmn2 in the fused, then in the unfusing process, you restore 2 copies of the mon you fused.
    the fused variable by default only expects to hold a pokemon object or nil. the easiest way I can see to get around this is fusing other_pkmn with other_pkmn2 before fusing the remaining mon with pkmn.
    then when unfusing you unfuse the second fused mon from the first fused mon.
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • Code:
    pkmn.fused = other_pkmn
        pkmn.fused = other_pkmn2
    you only saved other_pkmn2 in the fused, then in the unfusing process, you restore 2 copies of the mon you fused.
    the fused variable by default only expects to hold a pokemon object or nil. the easiest way I can see to get around this is fusing other_pkmn with other_pkmn2 before fusing the remaining mon with pkmn.
    then when unfusing you unfuse the second fused mon from the first fused mon.

    So if I'm understanding it correctly, basically the only way around it is to have a step-based fusion system? And each time you want to fully unfuse you have to basically work backwards?

    It doesn't seem like the most ideal solution... but if that's the way it has to be done, then so be it. I could see what my team leader wants to do going forward. Even if I'm not fully understanding, thanks for your answer and help. I really appreciate it. :)
     
    1,682
    Posts
    8
    Years
    • Seen yesterday
    So if I'm understanding it correctly, basically the only way around it is to have a step-based fusion system? And each time you want to fully unfuse you have to basically work backwards?

    It doesn't seem like the most ideal solution... but if that's the way it has to be done, then so be it. I could see what my team leader wants to do going forward. Even if I'm not fully understanding, thanks for your answer and help. I really appreciate it. :)

    Sorry, I suppose my explanation wasn't super clear. I mean in the saving process we do
    Code:
    other_pkmn.fused = other_pkmn2
        pkmn.fused = other_pkmn
    So that one mon is auto saved inside the other before saving both into the main mon. It doesn't need to be two separate steps.
     

    sonicfan7895

    Just a dude, I guess
    122
    Posts
    13
    Years
  • Sorry, I suppose my explanation wasn't super clear. I mean in the saving process we do
    Code:
    other_pkmn.fused = other_pkmn2
        pkmn.fused = other_pkmn
    So that one mon is auto saved inside the other before saving both into the main mon. It doesn't need to be two separate steps.

    Oh, I see... so like Reshiram and/or Zekrom, everything for them would get stored during the fusion, and then when unfused they would be restored to how they were before then?
     
    Back
    Top