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

Status
Not open for further replies.

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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.



Help?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Well, was your battle count a multiple of 3 when you entered that map?
 

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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?
 
Last edited by a moderator:

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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.



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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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?



Because it still isn't working. He still shows up even with no battles.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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).
 

Little Paw

Veteran
Veteran
Joined
May 5, 2013
Messages
707
Reaction score
294
First Language
English
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top