Creating an event which "randomly" appears based on certain factors.

Sorry for making another topic so quickly, but this is a completely separate question and the other one was closed anyway.

I want to have an NPC which only sometimes appears.

Ideally, the way I want to do this is for him to only appear when your Battle Count is a multiple of a certain number (for example, a multiple of 3), but I would also be satisfied with him appearing by pulling the event chance from a random number generation.

The thing is... I have no idea how to get either way to work...

Help?
Since the default conditions on an event page don't allow for either of those conditions, you'll need two events - one to check the conditions and set a switch accordingly, and the other your NPC controlled by that switch.


Create a parallel process event that will turn a switch on or off based on your conditions, and then erase itself. So turn the switch off initially, set a variable to the battle count, then do a mod 3, and if it's 0 turn on a switch; or set a variable to a random number between 0 and whatever you want, and if it's 1, turn on the switch. Remember to erase the event afterwards (assuming those conditions change on a different map)


The other will be your NPC event, and will be conditioned by that switch.
Since the default conditions on an event page don't allow for either of those conditions, you'll need two events - one to check the conditions and set a switch accordingly, and the other your NPC controlled by that switch.

Create a parallel process event that will turn a switch on or off based on your conditions, and then erase itself. So turn the switch off initially, set a variable to the battle count, then do a mod 3, and if it's 0 turn on a switch; or set a variable to a random number between 0 and whatever you want, and if it's 1, turn on the switch. Remember to erase the event afterwards (assuming those conditions change on a different map)

The other will be your NPC event, and will be conditioned by that switch.
Um... I think that perhaps I am not understanding your instructions correctly, because this doesn't work for the trigger event.

IF1ofoa.png


Help?
Well, was your battle count a multiple of 3 when you entered that map?
Well, was your battle count a multiple of 3 when you entered that map?
Nope. Tested both at 0 battles and 1 battle as well, and the guy was there when he should not be.
And his NPC event is conditioned by switch 97? Every page of that event?


And the event above is on the same map as the NPC event?
And his NPC event is conditioned by switch 97? Every page of that event?

And the event above is on the same map as the NPC event?
Yessir.

BoSmh3Z.png


The rest of the pages are just where he sells you more maps. They're more or less copies of page 2 but with increased price and giving you the next map. They're controlled by the same switch and the relevant variable being a certain number. At present, page 2 is the one that loads.
ahahaha - you've got to PUT the battle count into variable 68 before you do the mod 3.


Because you haven't done that, the variable uses its default (0) and 0 % 3 is 0. So the switch will always be getting turned on.


Battle Count comes from Game Data.
ahahaha - you've got to PUT the battle count into variable 68 before you do the mod 3.

Because you haven't done that, the variable uses its default (0) and 0 % 3 is 0. So the switch will always be getting turned on.

Battle Count comes from Game Data.
Um... Like this?

BenTgO3.png


Because it still isn't working. He still shows up even with no battles.
With no battles, he SHOULD show up. Because no battles is 0, and 0 % 3 is 0, so your condition is true.

If you want at least one battle, try this instead:

Code:
Control Switches: [0097: Map Merchant Appear] = OFFControl Variables: [0068: Battle Count] = Battle CountConditional Branch: Variable [0068: Battle Count] > 1  Control Variables: [0068: Battle Count] %= 3  Conditional Branch: Variable [0068: Battle Count] == 0    Control Switches: [0097: Map Merchant Appear] = ON  Branch EndBranch EndErase Event
You also don't need the Else there, so you can get rid of that (there's a checkbox at the bottom of the Conditional Branch window).
With no battles, he SHOULD show up. Because no battles is 0, and 0 % 3 is 0, so your condition is true.

If you want at least one battle, try this instead:

Control Switches: [0097: Map Merchant Appear] = OFFControl Variables: [0068: Battle Count] = Battle CountConditional Branch: Variable [0068: Battle Count] > 1 Control Variables: [0068: Battle Count] %= 3 Conditional Branch: Variable [0068: Battle Count] == 0 Control Switches: [0097: Map Merchant Appear] = ON Branch EndBranch EndErase EventYou also don't need the Else there, so you can get rid of that (there's a checkbox at the bottom of the Conditional Branch window).
Ah, I see now!

Actually it doesn't matter if he appears at 0 battles or not, because there's a required battle before you can enter the area where this guy is.

It works now, thanks!

One quick question... is there any reason to get rid of the Else branch? I mean, if there's nothing to run in the branch, it just ignores it, right? Cause I have a whole bunch of events that I just left with the Else there like that.
Yeah, it doesn't do anything if there's nothing in there. I just think it takes up unnecessary space and looks messy, so if it's not needed, I get rid of it.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/creating-an-event-which-randomly-appears-based-on-certain-factors.17615/