• 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] Safari steps

76
Posts
8
Years
    • Seen Dec 9, 2022
    Hi guys,

    I am facing a dilemma right now. As you might now I am currently working on a Pokémon Fan Game (check my signature). Someone promised me to help me with a script but I am now waiting since 1 month and I think he will not reply me.

    How can I use the safari steps outside of the safari game, like permanently in the game? After the steps would go down to zero the player should be transferred to his home, without blacking out. Moreover I want to add items (like food and drinks) and after using those the steps would go up again.

    Anyone has an idea how to do it?
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    I think this might work for you?

    Place this above Main.
    Spoiler:

    Go to PBattle_Safari and delete everything under "pbSafariState" (everything in red)

    Code:
    def pbSafariState
      if !$PokemonGlobal.safariState
        $PokemonGlobal.safariState=SafariState.new
      end
      return $PokemonGlobal.safariState
    end
    [COLOR="Red"]Events.onStepTakenTransferPossible+=proc {|sender,e|
       handled=e[0]
       next if handled[0]
       if pbInSafari? && pbSafariState.decision==0 && SAFARISTEPS>0
         pbSafariState.steps-=1
         if pbSafariState.steps<=0
           Kernel.pbMessage(_INTL("PA:  Ding-dong!\1")) 
           Kernel.pbMessage(_INTL("PA:  Your safari game is over!"))
           pbSafariState.decision=1
           pbSafariState.pbGoToStart
           handled[0]=true
         end
       end
    }
    
    Events.onWildBattleOverride+= proc { |sender,e|
       species=e[0]
       level=e[1]
       handled=e[2]
       next if handled[0]!=nil
       next if !pbInSafari?
       handled[0]=pbSafariBattle(species,level)
    }
    
    def pbSafariBattle(species,level)
      genwildpoke=pbGenerateWildPokemon(species,level)
      scene=pbNewBattleScene
      battle=PokeBattle_SafariZone.new(scene,$Trainer,[genwildpoke])
      battle.ballcount=pbSafariState.ballcount
      battle.environment=pbGetEnvironment
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) { 
         pbSceneStandby {
            decision=battle.pbStartBattle
         }
      }
      pbSafariState.ballcount=battle.ballcount
      Input.update
      if pbSafariState.ballcount<=0
        if decision!=2 && decision!=5
          Kernel.pbMessage(_INTL("Announcer:  You're out of Safari Balls! Game over!")) 
        end
        pbSafariState.decision=1
        pbSafariState.pbGoToStart
      end
      Events.onWildBattleEnd.trigger(nil,species,level,decision)
      return decision
    end[/COLOR]

    Add a food and drink item to your items.txt.

    Code:
    528,BISCIUT,Bisciut,Bisciuts,1,100,"A tasty ration. Eat it to walk longer distances in the field.",2,0,0,
    529,COOLDRINK,Cool Drink,Cool Drinks,1,250,"A thirst-quenching drink. Drink it to walk far longer distances in the field.",2,0,0,

    Now go to PItem_ItemEffects to give the effects.

    Add these little effects under "pbRepel".

    Code:
    def pbFoodBoost
        pbSafariState.steps+=10
    end
    
    def pbDrinkBoost
        pbSafariState.steps+=20
    end



    Place these in the UseFromBag handlers subsection of PItem_ItemEffects. I placed these underneath HONEY.

    Code:
    ItemHandlers::UseFromBag.add(:BISCUIT,proc{|item| next 3 })
    
    ItemHandlers::UseFromBag.add(:COOLDRINK,proc{|item| next 3  })

    These go in the UseInField handlers subsection of PItem_ItemEffects. I placed these underneath HONEY also.

    Code:
    ItemHandlers::UseInField.add(:BISCUIT,proc{|item|  
       pbFoodBoost
       next 3
    })
    
    ItemHandlers::UseInField.add(:COOLDRINK,proc{|item|  
       pbDrinkBoost
       next 3
    })

    You can call everything using same script call you would use to call the normal safari.

    Code:
    pbSafariState.pbStart(30)

    The place you call the script is the same place that you will return to when you run out of steps, so I think the best place to put it is in your house. It seems to be never ending. I tested this and it seems to be working OK. But I am unsure if it's what you wanted? Just say so if this isn't what you wanted or if you find an error.
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    I think this might work for you?

    Place this above Main.
    Spoiler:

    Go to PBattle_Safari and delete everything under "pbSafariState" (everything in red)

    Code:
    def pbSafariState
      if !$PokemonGlobal.safariState
        $PokemonGlobal.safariState=SafariState.new
      end
      return $PokemonGlobal.safariState
    end
    [COLOR="Red"]Events.onStepTakenTransferPossible+=proc {|sender,e|
       handled=e[0]
       next if handled[0]
       if pbInSafari? && pbSafariState.decision==0 && SAFARISTEPS>0
         pbSafariState.steps-=1
         if pbSafariState.steps<=0
           Kernel.pbMessage(_INTL("PA:  Ding-dong!\1")) 
           Kernel.pbMessage(_INTL("PA:  Your safari game is over!"))
           pbSafariState.decision=1
           pbSafariState.pbGoToStart
           handled[0]=true
         end
       end
    }
    
    Events.onWildBattleOverride+= proc { |sender,e|
       species=e[0]
       level=e[1]
       handled=e[2]
       next if handled[0]!=nil
       next if !pbInSafari?
       handled[0]=pbSafariBattle(species,level)
    }
    
    def pbSafariBattle(species,level)
      genwildpoke=pbGenerateWildPokemon(species,level)
      scene=pbNewBattleScene
      battle=PokeBattle_SafariZone.new(scene,$Trainer,[genwildpoke])
      battle.ballcount=pbSafariState.ballcount
      battle.environment=pbGetEnvironment
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) { 
         pbSceneStandby {
            decision=battle.pbStartBattle
         }
      }
      pbSafariState.ballcount=battle.ballcount
      Input.update
      if pbSafariState.ballcount<=0
        if decision!=2 && decision!=5
          Kernel.pbMessage(_INTL("Announcer:  You're out of Safari Balls! Game over!")) 
        end
        pbSafariState.decision=1
        pbSafariState.pbGoToStart
      end
      Events.onWildBattleEnd.trigger(nil,species,level,decision)
      return decision
    end[/COLOR]

    Add a food and drink item to your items.txt.

    Code:
    528,BISCIUT,Bisciut,Bisciuts,1,100,"A tasty ration. Eat it to walk longer distances in the field.",2,0,0,
    529,COOLDRINK,Cool Drink,Cool Drinks,1,250,"A thirst-quenching drink. Drink it to walk far longer distances in the field.",2,0,0,

    Now go to PItem_ItemEffects to give the effects.

    Add these little effects under "pbRepel".

    Code:
    def pbFoodBoost
        pbSafariState.steps+=10
    end
    
    def pbDrinkBoost
        pbSafariState.steps+=20
    end



    Place these in the UseFromBag handlers subsection of PItem_ItemEffects. I placed these underneath HONEY.

    Code:
    ItemHandlers::UseFromBag.add(:BISCUIT,proc{|item| next 3 })
    
    ItemHandlers::UseFromBag.add(:COOLDRINK,proc{|item| next 3  })

    These go in the UseInField handlers subsection of PItem_ItemEffects. I placed these underneath HONEY also.

    Code:
    ItemHandlers::UseInField.add(:BISCUIT,proc{|item|  
       pbFoodBoost
       next 3
    })
    
    ItemHandlers::UseInField.add(:COOLDRINK,proc{|item|  
       pbDrinkBoost
       next 3
    })

    You can call everything using same script call you would use to call the normal safari.

    Code:
    pbSafariState.pbStart(30)

    The place you call the script is the same place that you will return to when you run out of steps, so I think the best place to put it is in your house. It seems to be never ending. I tested this and it seems to be working OK. But I am unsure if it's what you wanted? Just say so if this isn't what you wanted or if you find an error.
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    I think this might work for you?

    Place this above Main.
    Spoiler:

    Go to PBattle_Safari and delete everything under "pbSafariState" (everything in red)

    Code:
    def pbSafariState
      if !$PokemonGlobal.safariState
        $PokemonGlobal.safariState=SafariState.new
      end
      return $PokemonGlobal.safariState
    end
    [COLOR="Red"]Events.onStepTakenTransferPossible+=proc {|sender,e|
       handled=e[0]
       next if handled[0]
       if pbInSafari? && pbSafariState.decision==0 && SAFARISTEPS>0
         pbSafariState.steps-=1
         if pbSafariState.steps<=0
           Kernel.pbMessage(_INTL("PA:  Ding-dong!\1")) 
           Kernel.pbMessage(_INTL("PA:  Your safari game is over!"))
           pbSafariState.decision=1
           pbSafariState.pbGoToStart
           handled[0]=true
         end
       end
    }
    
    Events.onWildBattleOverride+= proc { |sender,e|
       species=e[0]
       level=e[1]
       handled=e[2]
       next if handled[0]!=nil
       next if !pbInSafari?
       handled[0]=pbSafariBattle(species,level)
    }
    
    def pbSafariBattle(species,level)
      genwildpoke=pbGenerateWildPokemon(species,level)
      scene=pbNewBattleScene
      battle=PokeBattle_SafariZone.new(scene,$Trainer,[genwildpoke])
      battle.ballcount=pbSafariState.ballcount
      battle.environment=pbGetEnvironment
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) { 
         pbSceneStandby {
            decision=battle.pbStartBattle
         }
      }
      pbSafariState.ballcount=battle.ballcount
      Input.update
      if pbSafariState.ballcount<=0
        if decision!=2 && decision!=5
          Kernel.pbMessage(_INTL("Announcer:  You're out of Safari Balls! Game over!")) 
        end
        pbSafariState.decision=1
        pbSafariState.pbGoToStart
      end
      Events.onWildBattleEnd.trigger(nil,species,level,decision)
      return decision
    end[/COLOR]

    Add a food and drink item to your items.txt.

    Code:
    528,BISCIUT,Bisciut,Bisciuts,1,100,"A tasty ration. Eat it to walk longer distances in the field.",2,0,0,
    529,COOLDRINK,Cool Drink,Cool Drinks,1,250,"A thirst-quenching drink. Drink it to walk far longer distances in the field.",2,0,0,

    Now go to PItem_ItemEffects to give the effects.

    Add these little effects under "pbRepel".

    Code:
    def pbFoodBoost
        pbSafariState.steps+=10
    end
    
    def pbDrinkBoost
        pbSafariState.steps+=20
    end



    Place these in the UseFromBag handlers subsection of PItem_ItemEffects. I placed these underneath HONEY.

    Code:
    ItemHandlers::UseFromBag.add(:BISCUIT,proc{|item| next 3 })
    
    ItemHandlers::UseFromBag.add(:COOLDRINK,proc{|item| next 3  })

    These go in the UseInField handlers subsection of PItem_ItemEffects. I placed these underneath HONEY also.

    Code:
    ItemHandlers::UseInField.add(:BISCUIT,proc{|item|  
       pbFoodBoost
       next 3
    })
    
    ItemHandlers::UseInField.add(:COOLDRINK,proc{|item|  
       pbDrinkBoost
       next 3
    })

    You can call everything using same script call you would use to call the normal safari.

    Code:
    pbSafariState.pbStart(30)

    The place you call the script is the same place that you will return to when you run out of steps, so I think the best place to put it is in your house. It seems to be never ending. I tested this and it seems to be working OK. But I am unsure if it's what you wanted? Just say so if this isn't what you wanted or if you find an error.
     
    76
    Posts
    8
    Years
    • Seen Dec 9, 2022
    Hi I think you totally got me, thanks for your effort first of all!
    But I don't want to abolish the Safari Game, so do I have to just change the name of def pbSafariState into def pbEatandrinkState ? Otherwise I will overwrite the Safari Game mechanics, no?
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    Oh, sorry.

    Just place this back into PBattle_Safari


    Code:
    Events.onWildBattleOverride+= proc { |sender,e|
       species=e[0]
       level=e[1]
       handled=e[2]
       next if handled[0]!=nil
       next if !pbInSafari?
       handled[0]=pbSafariBattle(species,level)
    }
    
    def pbSafariBattle(species,level)
      genwildpoke=pbGenerateWildPokemon(species,level)
      scene=pbNewBattleScene
      battle=PokeBattle_SafariZone.new(scene,$Trainer,[genwildpoke])
      battle.ballcount=pbSafariState.ballcount
      battle.environment=pbGetEnvironment
      decision=0
      pbBattleAnimation(pbGetWildBattleBGM(species),0,[genwildpoke]) { 
         pbSceneStandby {
            decision=battle.pbStartBattle
         }
      }
      pbSafariState.ballcount=battle.ballcount
      Input.update
      if pbSafariState.ballcount<=0
        if decision!=2 && decision!=5
          Kernel.pbMessage(_INTL("Announcer:  You're out of Safari Balls! Game over!")) 
        end
        pbSafariState.decision=1
        pbSafariState.pbGoToStart
      end
      Events.onWildBattleEnd.trigger(nil,species,level,decision)
      return decision
    end
     
    76
    Posts
    8
    Years
    • Seen Dec 9, 2022
    Hm it doesn't work unfortunately and also when trying to use the item it doesn't fill the steps.
    Also once the steps are finished they don't refill after your teleportation.
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    Oh, that's my mistake. I added something I shouldn't have.
    You should remove the Item Handler UseFromBag part I added from P_Item ItemEffects. You don't need it.

    Code:
    ItemHandlers::UseFromBag.add(:BISCUIT,proc{|item| next 3 })
    
    ItemHandlers::UseFromBag.add(:COOLDRINK,proc{|item| next 3  })

    That.^

    I'm not really sure why your steps are not refreshing? Is there a "Events.onStepTakenTransferPossible" section still in PBattle_Safari?
    If there is, you should get rid of it. I'll block refreshes if it's there.

    Also, I misspelled "BISCUIT" in items.txt. Sorry about that!
     
    76
    Posts
    8
    Years
    • Seen Dec 9, 2022
    Hi Arachnee. At the end I could implement the food steps. I kinda copied the Repel system and added a line that asks whether the player wants to eat or not (in case he has food) and if he doesnt he will be tired and want to go home to sleep. Thanks for your time ??????
     
    Back
    Top