playMaker

Author Topic: Random event with condition  (Read 1922 times)

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
Random event with condition
« on: March 13, 2019, 09:29:38 AM »
Hello,
Please tell me if you can use Playmaker to implement a similar situation:

https://imgur.com/6y1Yuvq

How can you make an event chosen randomly, but it should be played back, let's say a couple of times and then not be available for choosing a random?
Suppose I want event 1 to be selected 2 times, and event 2 4 times, event 3 10 times.
And how to reset this account after all events are randomly played by random to start the process again?

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Random event with condition
« Reply #1 on: March 13, 2019, 10:50:08 PM »
Hey there

You'll need a few different things going to get what you want.  First I'd make an array that containers all of the events you want to fire off.

I believe there is an action for Pick Random Event (Not sure of exact name) to randomly pick an event.  The tricky part will be converting that Array from earlier into that action (I'm thinking using the Array get next action to grab each available event and plug it into the random event action).

After that is set, a simple Int Add and Int compare  can be use to have it limited to X amount of times used.  Once its been used up, a simple array remove action to stop it from happening again.  Once all actions are used up, reset all the Int values to 0 and repeat.

At work currently so can't fully dive into it but that's my first thought on it and hopefully points you in the right direction.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Random event with condition
« Reply #2 on: March 14, 2019, 04:20:46 AM »
Hi.

You have also 'Random array get random' 'random event' and 'send random event'  will send a random event and would not need an array.

and advantage on the 'send random event ' is that you can set weights.

you could also use a 'random int' and set no repeat. if you do not want the same 2x in a row.

then you can use a int switch or use the int value as index for the array and use array get with that number.

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
Re: Random event with condition
« Reply #3 on: March 16, 2019, 04:20:48 AM »
Thanks  :)

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Random event with condition
« Reply #4 on: March 17, 2019, 03:18:58 PM »
go ecosystem and get "int compare range" or "Float Compare Range"

it will do the trick!

Good Luck!

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Random event with condition
« Reply #5 on: March 17, 2019, 06:29:15 PM »
Another approach, somewhat outside the box, depending on how complex and versatile this has to be, I’d built it with a number of game objects.

1) Make a parent game object, Event Manager that has two children, Pool A and Pool B. Pool A has three children, called Events.

Event Manager
— Pool A
—— Event 1
—— Event 2
—— Event 3
— Pool B

The parent gets a FSM that draws a random child from Pool A, and parents the child to Pool B. If no child is in Pool A, then rename Pool A to Pool B, and vice versa and continue. So what it does, it draws events and puts it into the other pool. If you put types of events into it, it should process them nicely in a random order and until all are depleted, then shuffle them back, and repeat.

2) Next, put an identical FSM on each Event object. It listens to a global event, say “DOEVENT” and then sends out a desired event of a specific type to a target FSM. This specific event type is the only thing you need to adjust. Say, Event 1 sends event1, Event 2 sends event2 etc. and to wherever you want it.

3) Now, you only need to go to the FSM in Event Manager and after it grabs one random child, also send the DOEVENT of that child. All put together, it will grab a random child, start the FSM routine inside which sends out a special event. Then puts the child into the discarded pool B. By simply duplicating the events of each type, you can control exactly how many there are of each type.

You probably don’t want to do this like that, since there are more direct methods with weights on the events, but it all depends on what you try to do overall.