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

eggs and balls

  • 32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    as i'm a bit nerdy, it somehow bothered me, that a pokemon hatches from an egg and already has a pokeball. so i changed the hatching script so that it only hatches when you have pokeballs with you, and one of them gets deleted then and it works fine.
    now i'd like to make it possible that other balls could be used as well, like if you don't have pokeballs but great balls instead, it would work too.

    here's what i've got so far, it's at the end of the hatching script section:

    Spoiler:


    now is there an elegant way to include other balls other than adding an || for every other ball type after the highlighted part?

    i think the new update would change the balltype afterwards to the mother's balltype anyways (maybe i'll take that out then), but it's illogical that you can only use one kind of balls on your newly hatched pokemon and always have to carry that one kind with you...

    EDIT: okay, i found a bug and if for some reason someone would like to implement this too, here's the fixed code:

    Code:
    Events.onStepTaken+=proc {|sender,e|
       next if !$Trainer
       for egg in $Trainer.party
         if egg.eggsteps>0
           egg.eggsteps-=1
           for i in $Trainer.party
             if !i.egg? && (isConst?(i.ability,PBAbilities,:FLAMEBODY) ||
                            isConst?(i.ability,PBAbilities,:MAGMAARMOR))
               egg.eggsteps-=1
               break
             end
           end
           ball=newGetBall
    [S-HIGHLIGHT]         if egg.eggsteps<=0
               if ball>0
             egg.eggsteps=0
             pbHatch(egg)
             $PokemonBag.pbDeleteItem(ball)
           else egg.eggsteps=1
             break
             end[/S-HIGHLIGHT]
           end
         end
       end
    }
    and in the day care script there was also something missing, i don't know why the change in the inheriting ball script wasn't enough:

    Code:
    def pbHatch(pokemon)
      speciesname=PBSpecies.getName(pokemon.species)
      pokemon.name=speciesname
      pokemon.trainerID=$Trainer.id
      pokemon.ot=$Trainer.name
      pokemon.happiness=120
      pokemon.timeEggHatched=pbGetTimeNow
      pokemon.obtainMode=1 # hatched from egg
      pokemon.hatchedMap=$game_map.map_id
    [S-HIGHLIGHT]  ball=newGetBall  
    pokemon.ballused=pbGetBallType(ball)[/S-HIGHLIGHT]
      $Trainer.seen[pokemon.species]=true
      $Trainer.owned[pokemon.species]=true
      pbSeenForm(pokemon)
      if !pbHatchAnimation(pokemon)
        Kernel.pbMessage(_INTL("Huh?\1"))
        Kernel.pbMessage(_INTL("...\1"))
        Kernel.pbMessage(_INTL("... .... .....\1"))
        Kernel.pbMessage(_INTL("{1} hatched from the Egg!",speciesname))
        if Kernel.pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?",speciesname))
          species=PBSpecies.getName(pokemon.species)
          nickname=pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),0,10,"",pokemon)
          pokemon.name=nickname if nickname!=""
        end
      end
    end
     
    Last edited:

    Nickalooose

    --------------------
  • 1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    You could always use the ball type variable which already holds every PokéBall.
    $BallTypes holds this.
    So if you create a new def and use:
    Code:
    def newGetBall
      for i in 0...$BallTypes.length
        if $PokemonBag.pbQuantity(getConst(PBItems,$BallTypes[i]))>0
          return getConst(PBItems,$BallTypes[i])
        end
      end
      return 0
    end
    Add this in PokemonBalls.

    Then you can use this:
    Code:
    Events.onStepTaken+=proc {|sender,e|
      next if !$Trainer
      for egg in $Trainer.party
        if egg.eggsteps>0
        egg.eggsteps-=1
        for i in $Trainer.party
          if !i.egg? && (isConst?(i.ability,PBAbilities,:FLAMEBODY) ||
            isConst?(i.ability,PBAbilities,:MAGMAARMOR))
            egg.eggsteps-=1
            break
          end
        end
        ball=newGetBall
        if egg.eggsteps<=0 && ball>0
          egg.eggsteps=0
          pbHatch(egg)
          $PokemonBag.pbDeleteItem(ball)
        else 
          egg.eggsteps=1
        end
      end
    end
    }
    On a side note, try using CODE tag instead of SPOILER.

    Let me know what happens.
     
  • 32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    Let me know what happens.

    yay, thanks a lot, it worked. i only had to also change the new "inheriting ball from mother script" in the day care section to:

    Code:
    ball=newGetBall  
    if mother.gender==1
        egg.ballused=pbGetBallType(ball)
      end

    so now the baby is in the deleted ball, whichever one it was.
    and thanks also for the hint with the code tag, i had not noticed the icons in the corner were for tagging too
     
  • 32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    Let me know what happens.

    sorry to bother you again, but there's still one little thing...
    i wanted to display a message in the hatching scene to inform the player about this process, like:

    Kernel.pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]",@pokemon.name))
    ball=newGetBall
    Kernel.pbMessage(_INTL("\\se[]{1} was stored in a {2}!\\wt[80]",@pokemon.name,ball))

    if Kernel.pbConfirmMessage(
    _INTL("Would you like to nickname the newly hatched {1}?",@pokemon.name))
    nickname=pbEnterText(_INTL("{1}'s nickname?",@pokemon.name),0,10)
    @pokemon.name=nickname if nickname!=""
    end
    end
    but if i put ball for {2} it displays the item id number instead of the item name (265 instead of ULTRABALL for example)

    do i have to use pbBallTypeToBall(balltype) or pbGetBallType(ball) or does it require another def defining ball.name or sth like this? all my tries didn't work so far...
     

    Nickalooose

    --------------------
  • 1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    You've almost got it... But can you think of one occasion where you see Item Names being used... What about when a player finds a Potion or something?
    What you need to do is turn the item id in to it's item name:
    Code:
    ball=PBItems.getName(newGetBall)
    This should do the trick.
     
  • 32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    You've almost got it... But can you think of one occasion where you see Item Names being used... What about when a player finds a Potion or something?
    What you need to do is turn the item id in to it's item name:
    Code:
    ball=PBItems.getName(newGetBall)
    This should do the trick.


    great, that's it. thank you very very much for your help and above all for your patience with me.
     
    Back
    Top