• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Making Pikcup Trigger on Step

  • 217
    Posts
    15
    Years
    • Seen Nov 29, 2021
    So I had a look at it, but onstep events are coded completely differently. This is what I got before it got too confusing:

    Code:
    ## Pickup from walking about
    
    Events.onStepTakenTransferPossible+=proc {|sender,e|
      handled=e[0]
      next if handled[0]
      if $PokemonGlobal.stepcount % 4 == 0
        for i in $Trainer.party
          if isConst?(pokemon.ability,PBAbilities,:PICKUP) && 
          !pokemon.isEgg? && pokemon.item=0 && rand(10)=0
      pickupList=pbDynamicItemList(
         :POTION,
         :ANTIDOTE,
         :SUPERPOTION,
         :GREATBALL,
         :REPEL,
         :ESCAPEROPE,
         :FULLHEAL,
         :HYPERPOTION,
         :ULTRABALL,
         :REVIVE,
         :RARECANDY,
         :SUNSTONE,
         :MOONSTONE,
         :HEARTSCALE,
         :FULLRESTORE,
         :MAXREVIVE,
         :PPUP,
         :MAXELIXIR
      )
      pickupListRare=pbDynamicItemList(
         :HYPERPOTION,
         :NUGGET,
         :KINGSROCK,
         :FULLRESTORE,
         :ETHER,
         :IRONBALL,
         :DESTINYKNOT,
         :ELIXIR,
         :DESTINYKNOT,
         :LEFTOVERS,
         :DESTINYKNOT
      )
      return if pickupList.length!=18
      return if pickupListRare.length!=11
      randlist=[30,10,10,10,10,10,10,4,4,1,1]
      items=[]
      plevel=[100,pokemon.level].min
      itemstart=(plevel-1)/10
      itemstart=0 if itemstart<0
      for i in 0...9
        items.push(pickupList[itemstart+i])
      end
      items.push(pickupListRare[itemstart])
      items.push(pickupListRare[itemstart+1])
      rnd=rand(100)
      cumnumber=0
      for i in 0...11
        cumnumber+=randlist[i]
        if rnd<cumnumber
          pokemon.setItem(items[i])
          break
        end
      end
    end
    }
     
    I already see an error, on the eighth line of what you posted. You want it to read
    Code:
          !pokemon.isEgg? && pokemon.item==0 && rand(10)==0

    Using one equals sign sets the variable on the left to be the value on the right. Using two equals signs turns it into a question "does the left equal the right?"
     
    I'm not seeing the problem?
    It checks to make sure it's not already holding anything, and then it does a 1 in N chance check.

    Edit: That'd be because I'm looking at your corrected code, doh.

    That said, that was taken straight from pickup, so... odd.
     
    Back
    Top