Help Copy-edit Safari steps method to emulate a food and drink system

Obermarschall

Novice
Member
Posts
18
#1
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?
 

kmb

dabbling in game design
Member
Posts
61
#3
You might want to try implementing a switch for those events. Open up the script you're using, press CTRL + F (for the "find and replace" menu), search for the Safari Zone steps script. Now, modify it by adding a conditional and a switch. Set the switch to check the number of steps, like the Safari Zone, but, instead of the Safari Zone ending, enter what you want it to do--show text: player is hungry, for example. If player doesn't eat, make player black out, for example. Then, make the switch automatically reset itself and start the process over again. All of these things can then be handled by creating switches to activate / deactivate the events you created. If you aren't sure how to handle switches, look back at the "making ghosts" tutorial (if it's still available).

If that only made a little bit of sense, someone else might have a more detailed explanation.
 
Last edited:

Obermarschall

Novice
Member
Posts
18
#4
Ok thanks I will try to do that. Do you know how I can add steps through an item? Like let's say I want to add 10 steps with item x? I know how to add items and all of that, just I don't see any example where an item 'adds steps'. I tried doing it by including it with this 'pbSafariState.steps+=20' but nothing happens.
 
Last edited:

kmb

dabbling in game design
Member
Posts
61
#5
Ok thanks I will try to do that. Do you know how I can add steps through an item? Like let's say I want to add 10 steps with item x? I know how to add items and all of that, just I don't see any example where an item 'adds steps'. I tried doing it by including it with this 'pbSafariState.steps+=20' but nothing happens.
The way I would do it may not be the easiest way, but maybe just create a switch that activates every time item (x) is used?
 

Obermarschall

Novice
Member
Posts
18
#6
Hm and if there is a way of using 'repel' but like after this 'alternate repel' goes to zero you are asked whether you want to eat/drink, you click on the item and it would repeat over and over again. When you choose not to eat, you'd be teleported in your bed home? Do you have an idea for that?
 

kmb

dabbling in game design
Member
Posts
61
#7
Hm and if there is a way of using 'repel' but like after this 'alternate repel' goes to zero you are asked whether you want to eat/drink, you click on the item and it would repeat over and over again. When you choose not to eat, you'd be teleported in your bed home? Do you have an idea for that?
Let's break down what you want to do.
You want to program it so that after taking a number of steps each time, let's say 255 steps, the player is asked whether or not s/he wants to eat or drink.
If the player chooses to "eat,' the player will be given the item "food,' and "food" will reset the step counter and perhaps display the text, "you have eaten / you are no longer hungry,"
If the player chooses not to "eat," the player will black out and be teleported back home / to a clinic / Pokemon center, and Nurse Joy / the NPC "mom" will lecture the player about neglecting his / her health?

I think you can do this with a switch. (if you aren't sure how to use switches inside of scripts, Google the "making ghosts" script for PKMNE) Search for the proper script using CTRL + F. Copy and paste the text. Create a conditional branch, and connect it to a switch with an unoccupied number. (name the switch in the project database for easy reference)
Let's just call it switch "hungry" for now.
Set it so that when switch "hungry" is activated, the player will only be able to take a certain number of steps before s/he is asked whether or or not s/he wants to eat.
If the player decides not to eat, you can either set it to reset and then ask the player again, or set it to have the player "black out." Have an animation that turns the screen black for a few seconds and then transfers the player to a Pokemon center / back home.
If the player decides to eat, you can use another switch to check whether or not the player has the item "food"
If not, display text: you have nothing to eat! (reset the counter for an additional number of steps (use the same script for Repel, if you want) so that the player can purchase food, or have the player black out and end up in a hospital, missing half his / her money. (reset the step counter to its original position)
If the player has the item "food," display text: you ate some sandwiches! (reset the counter to the original position)
If the player tries to use the item "food" when the switch "hungry" is not activated, display text: "you are not hungry, better save this food for later."
End

I'm not sure if this is the easiest way, as it does require you to code a check for a switch into the script itself. If you didn't want to do this, you could probably use variables, but I think that would be a little more tedious and / or complicated.

Let me know if you have any more questions or if something isn't working right. Codes can be tricky.

I can't cut and paste exact codes because I can't access my copy of Essentials right now. I might be able to provide further assistance, though, if you cut and paste your exact codes if you get any error messages.
 
Last edited:
Posts
29
#10
Not totally I want that also an item can add steps, not just refresh the counter back to 600
You don't need to refresh entirely. Just make it so the item you used make the variable for steps go minus 200, as an example.
So, if you are at 400/600, using the drink will make you go 200/600.
Variable for traking steps, current food meter and one for max food meter.
It seems like an easy system to make with Common Events.

(Unless you mean actually increasing steps, but the basic is the same only focusing the 600 part)
 
Posts
18
#13
UPDATE: I found a better way how to do it, I will use the repel system!
However I still can't figure out the following: Whenever the player has the choice to eat or drink something more, he will still be transferred to his home? The player should just be transferred if he has no food or dirnk left whatsoever. How can I change that?

The script:
Events.onStepTaken+=proc {
if !PBTerrain.isIce?($game_player.terrain_tag) # Shouldn't count down if on ice
if $PokemonGlobal.food>0
$PokemonGlobal.food-=1
if $PokemonGlobal.food<=0
Kernel.pbMessage(_INTL("The player feels tired..."))
ret=pbChooseItemFromList(_INTL("Should he eat or drink something?"),1,
:BISCUIT,:COOLDRINK)
pbUseItem($PokemonBag,ret) if ret>0
Kernel.pbStartOver
end
end
end
}
 

MGriffin

Trainer
Member
Posts
74
#14
So I guess pbUseItem returns a value to tell you if the item was successfully used? You can check for that value on the Kernel.pbStartOver line. If it doesn't return a value then I guess you can check if $PokemonGlobal.food<=0 again, because I suppose your items increase that number?
 
Top