How to make an actor have an outside of battle ability

Hi so in my game there is a chicken that follows you around and I want him to be able pick up certain items after every 500 or so steps (it would be awesome if this number could easily be changed so that I could mess around with it to see what works). Could somebody please give me a script that would let me have a certain chance of picking up specific items. For 


example I would like it to have a 50% chance to get a certain amount of gold, 30% chance to get a small potion, 10% chance to get a medium potion, a 5% chance to get a rare artifact, and a 5% chance to get a large potion.
If this chicken follows you from map to map, use a parallel processing common event controlled by a switch - turn the switch on when the chicken is following you and you want it to be able to pick stuff up.


Set a variable to the number of steps.


In your common event, compare the number of steps taken with the 'saved' number of steps.  If the difference is equal to or greater than the variable you set above, reset the variable for 'saved' number of steps.  Then get a random number between 1 & 100, and do a series of conditional branches to see if it's less than 50, less than 80, less than 90, less than 95, with each one giving the appropriate reward.


Add a Wait 10 Frames either at the start or the very end of the common event (not within any conditioned blocks) so it takes a breath before repeating, so as not to cause any lag.
If this chicken follows you from map to map, use a parallel processing common event controlled by a switch - turn the switch on when the chicken is following you and you want it to be able to pick stuff up.


Set a variable to the number of steps.


In your common event, compare the number of steps taken with the 'saved' number of steps.  If the difference is equal to or greater than the variable you set above, reset the variable for 'saved' number of steps.  Then get a random number between 1 & 100, and do a series of conditional branches to see if it's less than 50, less than 80, less than 90, less than 95, with each one giving the appropriate reward.


Add a Wait 10 Frames either at the start or the very end of the common event (not within any conditioned blocks) so it takes a breath before repeating, so as not to cause any lag.

Hello Shaz this was very helpful. I set a variable for the steps needed for the ability to activate, the


current amount of steps, and a variable for the reward. I'm


confused about how you make the current steps variable increase by 1 every time you take a step. Also I want to show text that says "Chicken found x gold" where x is a variable called Gold from Pickup (u can see where the variable is set in the event). Here is the event:  image.jpg
Do you want to be able to adjust the number of steps in-game, so the chicken finds things more often in some areas than in others?


Do you actually have a chicken event that follows you on the map?  If so, could you please post a screenshot of that event?


Is this chicken only on one map, or does it follow you from map to map?


You don't have the variables set correctly - you're setting them to 0, and you should be setting them to the number of steps.  You don't make it increment each time the player takes a step - you just make it check how many steps the player has taken each time.


When you answer these questions I'll give you the exact event to use.


Please use Alt+PrintScreen to take a screenshot.  I don't do well with the 'turn your head sideways to read' thing.
Do you want to be able to adjust the number of steps in-game, so the chicken finds things more often in some areas than in others?


Do you actually have a chicken event that follows you on the map?  If so, could you please post a screenshot of that event?


Is this chicken only on one map, or does it follow you from map to map?


You don't have the variables set correctly - you're setting them to 0, and you should be setting them to the number of steps.  You don't make it increment each time the player takes a step - you just make it check how many steps the player has taken each time.


When you answer these questions I'll give you the exact event to use.


Please use Alt+PrintScreen to take a screenshot.  I don't do well with the 'turn your head sideways to read' thing.

It would be nice if I could adjust the number of steps for different areas. The chicken is a party member that follows you around every map. Here is the chicken event:

Screenshot.jpg
So, in all places where you turn on switch 4, add these commands:

Code:
Control Variables: Chicken Saved Steps = Game Data > Other > Steps
Control Variables: Chicken Current Steps = Gam Data > Other > Steps



When you want to change the number of steps required, either set a variable for it within an event, or have a parallel process event set up on the map just for this purpose, with the following:

Code:
Control Variables: Chicken Steps Required = 250
Erase Event

When you first get the chicken, if this variable hasn't already been set, you will need to set it, so it knows how many steps to start off with.


Now make your common event like this:

Code:
Wait 10 Frames
Control Variables: Chicken Current Steps = Game Data > Other > Player Steps
Control Variables: Chicken Current Steps -= Chicken Saved Steps
If: Chicken Current Steps >= Chicken Steps Required
  Control Variables: Chicken Saved Steps = Game Data > Other > Player Steps
  Control Variables: Pickup Reward = Random 1..100
  If: Pickup Reward <= 50
    Control Variables: Gold from Pickup = Random 5..50
    Text: You found \v[x] gold! (x is the variable id for Gold from Pickup)
    Change Gold = Gold from Pickup
  Else
    If: Pickup Reward <= 80
      Text: You found a small potion!
      Change Items + Small Potion
    Else
      If: Pickup Reward <= 90
        Text: You found a medium potion!
        Change Items + Medium Potion
      Else
        If: Pickup Reward <= 95
          Text: You found a rare artifact!
          Change Items + Rare Artifact
        Else
          Text: You found a large potion!
          Change Items + Large Potion
        End
      End
    End
  End
End



I note that your common event is conditioned by switch 4, which means you've fed the chicken.  This means if you're indoors and the chicken is fed, it will find stuff inside houses as well as outside.  If that's what you want to happen, it's all good.  If it's not though, you'll want to condition your common event by a different switch, and put that code above that initializes the step counters wherever THAT switch is turned on, rather than where switch 4 is turned on.
So, in all places where you turn on switch 4, add these commands:

Code:
Control Variables: Chicken Saved Steps = Game Data > Other > Steps
Control Variables: Chicken Current Steps = Gam Data > Other > Steps



When you want to change the number of steps required, either set a variable for it within an event, or have a parallel process event set up on the map just for this purpose, with the following:

Code:
Control Variables: Chicken Steps Required = 250
Erase Event

When you first get the chicken, if this variable hasn't already been set, you will need to set it, so it knows how many steps to start off with.


Now make your common event like this:

Code:
Wait 10 Frames
Control Variables: Chicken Current Steps = Game Data > Other > Player Steps
Control Variables: Chicken Current Steps -= Chicken Saved Steps
If: Chicken Current Steps >= Chicken Steps Required
  Control Variables: Chicken Saved Steps = Game Data > Other > Player Steps
  Control Variables: Pickup Reward = Random 1..100
  If: Pickup Reward <= 50
    Control Variables: Gold from Pickup = Random 5..50
    Text: You found \v[x] gold! (x is the variable id for Gold from Pickup)
    Change Gold = Gold from Pickup
  Else
    If: Pickup Reward <= 80
      Text: You found a small potion!
      Change Items + Small Potion
    Else
      If: Pickup Reward <= 90
        Text: You found a medium potion!
        Change Items + Medium Potion
      Else
        If: Pickup Reward <= 95
          Text: You found a rare artifact!
          Change Items + Rare Artifact
        Else
          Text: You found a large potion!
          Change Items + Large Potion
        End
      End
    End
  End
End



I note that your common event is conditioned by switch 4, which means you've fed the chicken.  This means if you're indoors and the chicken is fed, it will find stuff inside houses as well as outside.  If that's what you want to happen, it's all good.  If it's not though, you'll want to condition your common event by a different switch, and put that code above that initializes the step counters wherever THAT switch is turned on, rather than where switch 4 is turned on.

I will try this in the morning, it's a bit much to process at close to midnight. Thank you so much. I really appreciate all the help.
you can just reply without quoting 😉
@Shaz I don't know why it's happening but as soon as I get the chicken he gives me an item right away (I don't want this to happen). When I hit enter, after 10 frames (I'm assuming), the chicken gives me another item. Can you tell me how to fix this?
Remember to post a picture of your event, so we can troubleshoot with a bit more info.
Did you initialize all the variables like I said?

So, in all places where you turn on switch 4, add these commands:

Code:
Control Variables: Chicken Saved Steps = Game Data > Other > Steps
Control Variables: Chicken Current Steps = Gam Data > Other > Steps



When you want to change the number of steps required, either set a variable for it within an event, or have a parallel process event set up on the map just for this purpose, with the following:

Code:
Control Variables: Chicken Steps Required = 250
Erase Event

When you first get the chicken, if this variable hasn't already been set, you will need to set it, so it knows how many steps to start off with.
@Shaz


Sorry for the delayed response. I've been busy with school. I forgot to make an event that set the chicken steps required variable. It turns out my problem besides that was my event said


Control Variables: Chicken Current Steps = Game Data > Other > Player Steps
Control Variables: Chicken Current Steps = Chicken Saved Steps


instead of

Code:
Control Variables: Chicken Current Steps = Game Data > Other > Player Steps
Control Variables: Chicken Current Steps -= Chicken Saved Steps

it works perfectly now. Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-an-actor-have-an-outside-of-battle-ability.59788/