Enemy event spawning based on probability

RiseOfTheChimera

Bound together by difference.
Veteran
Joined
Jun 11, 2013
Messages
43
Reaction score
0
First Language
English
Primarily Uses
 Hello, I was wondering if there was a way to make overworld enemy events, or any event for that matter be set to spawn randomly based on chance or probability? For example: if you place a normal enemy event on a certain tile, make it so there is a 25% chance that it will spawn on the map when the player arrives? Is it possible to have this work without the use of script? If not can anyone direct me to a script that offers what I'm looking for? (if there even is one)

Thank you for reading, any advice or help would be greatly appreciated. :)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
it is possible with or without scripts - whether you'll need a script for this specific case depends on how you define "spawning".

As a general info, you can make a random generator by combining two event commands: control variable (set to random) and conditional branch (testing the variable's random value).

Now to the other part:

Your enemy events are either permanently placed on the map (without scripting) or to be copied to the map (with scripting).

In the first case you need an event with a minimum of three pages - one without conditions for checking probability, one for the active enemy spawned and one for either "not spawned" or "already killed". The primary page will then check the probability upon entering (autorun) and either activate the enemy page (with the logic to fight the player) or the empty/killed page.

In this case you'll never have more than the events placed on the map available, and you need to add a few more commands/logic pages if you want that enemy to respawn at a later time (basically give control back to the primary autorun page at the selected time/logic).

If you want the enemies being copied onto that map, you'll need some script commands at minimum and a controlling parallel event for placing the enemies. Depending on your wishes of that placements, you might get away with a few script calls or you might need a full script.

For better advice we need to know more details about what you're trying to achieve.
 

Daughter of Evil

Nightmare Princess
Veteran
Joined
Jun 21, 2013
Messages
147
Reaction score
19
First Language
English
Primarily Uses
You could use variables to help you. First create an event in your map.This event is your enemy. Open it up and on the right side there is something called variables. Now open it and pick any number form the right. For example I picked 001; at the bottom there is a name box call it chance or anything you like. Press okay and change the 0 variable number to one( you can find this under the variable section at the right). now create a command (this are like your text,enemy encounter.etc) enemy encounter. Select the enemy the player will fight. Now select the sprite for the event which could be change at the bottom left.  Now your finish with the enemy event. Next create a new event and set it to autorun. Now open the command variable, control variables not sure which one. You'll see something called random. Change first box to 1 and the second box to 2 then press ok. Open command condition branch and select variable. Press the ... and select the variable you chose earlier. I picked 001. Under that select equal to.Now inside the constant change it to 1. Press okay. Now you'll see something llike conditionalbrach: Variable [0001:chance]= 1 now select a command called command variable, control  not again which on; you'll see a add click it. Under variable slect the variable you chose earlier. At the constant box change the 0 to 1. press okay. Now create another command called temporary event removal. Make sure  this is at the bottom and not inside the conditionalbrach: Variable [0001:chance]= 1. Okay. now open your teleport event. This event is the one that transfers you to a different map and on top of evyrhting change create a command from the control variable,or command variable, select the variable you chose earlier and check the sub change the constant to 100. You have to do this fall all teleport events. Just simple copy and paste. Thats it your done. :)

Here is a short recap:

-Make enemy event

-open variable the the right side and choose a number

-under it change the value to 1

-make a new event set to autorun

-open the control variable or command variable; look for the random ; first box 1 second box 2

-open condition branch select the variable you chose earlier; select equal to, select constast which is 0 and change to 1

- press okay.

- inside the conditional branch open the control variable or command variable select variable you made earlier; select add change change constant to 1.

-beneath all your commands select temporary event removal.

-okay.

-Open teleport event.

-create a new command control variable or command variable select variable you made earlier; select sub change constant to 50

- do this for other teleport events and your done

:) If you need a demo I could pm you one but I'm not sure when.
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
 Hello, I was wondering if there was a way to make overworld enemy events, or any event for that matter be set to spawn randomly based on chance or probability? For example: if you place a normal enemy event on a certain tile, make it so there is a 25% chance that it will spawn on the map when the player arrives? Is it possible to have this work without the use of script? If not can anyone direct me to a script that offers what I'm looking for? (if there even is one)

Thank you for reading, any advice or help would be greatly appreciated. :)
You could just use random variables to do this if I understand what you are asking.

For example: Make a parallel process event that guesses at a random variable every 999 frames or w/e time frame you want.  Something like [Random Variable1] = 1 ? 4 then Wait 999 frames.

Then on your event page conditions set the condition to Random Variable1 = 4 or above.  The event should then spawn on a 25% probability every 999 frames  - or at least something close to that effect.

If this has nothing to do with what you were asking just ignore it.  Sometimes I misinterpret posts.
 
Last edited by a moderator:

RiseOfTheChimera

Bound together by difference.
Veteran
Joined
Jun 11, 2013
Messages
43
Reaction score
0
First Language
English
Primarily Uses
You could use variables to help you. First create an event in your map.This event is your enemy. Open it up and on the right side there is something called variables. Now open it and pick any number form the right. For example I picked 001; at the bottom there is a name box call it chance or anything you like. Press okay and change the 0 variable number to one( you can find this under the variable section at the right). now create a command (this are like your text,enemy encounter.etc) enemy encounter. Select the enemy the player will fight. Now select the sprite for the event which could be change at the bottom left.  Now your finish with the enemy event. Next create a new event and set it to autorun. Now open the command variable, control variables not sure which one. You'll see something called random. Change first box to 1 and the second box to 2 then press ok. Open command condition branch and select variable. Press the ... and select the variable you chose earlier. I picked 001. Under that select equal to.Now inside the constant change it to 1. Press okay. Now you'll see something llike conditionalbrach: Variable [0001:chance]= 1 now select a command called command variable, control  not again which on; you'll see a add click it. Under variable slect the variable you chose earlier. At the constant box change the 0 to 1. press okay. Now create another command called temporary event removal. Make sure  this is at the bottom and not inside the conditionalbrach: Variable [0001:chance]= 1. Okay. now open your teleport event. This event is the one that transfers you to a different map and on top of evyrhting change create a command from the control variable,or command variable, select the variable you chose earlier and check the sub change the constant to 100. You have to do this fall all teleport events. Just simple copy and paste. Thats it your done. :)

Here is a short recap:

-Make enemy event

-open variable the the right side and choose a number

-under it change the value to 1

-make a new event set to autorun

-open the control variable or command variable; look for the random ; first box 1 second box 2

-open condition branch select the variable you chose earlier; select equal to, select constast which is 0 and change to 1

- press okay.

- inside the conditional branch open the control variable or command variable select variable you made earlier; select add change change constant to 1.

-beneath all your commands select temporary event removal.

-okay.

-Open teleport event.

-create a new command control variable or command variable select variable you made earlier; select sub change constant to 50

- do this for other teleport events and your done

:) If you need a demo I could pm you one but I'm not sure when.
I attempted to use your method but I got no result. I'm not too good with variables yet but a demo would be amazing!
 

RiseOfTheChimera

Bound together by difference.
Veteran
Joined
Jun 11, 2013
Messages
43
Reaction score
0
First Language
English
Primarily Uses
You could just use random variables to do this if I understand what you are asking.

For example: Make a parallel process event that guesses at a random variable every 999 frames or w/e time frame you want.  Something like [Random Variable1] = 1 ? 4 then Wait 999 frames.

Then on your event page conditions set the condition to Random Variable1 = 4 or above.  The event should then spawn on a 25% probability every 999 frames  - or at least something close to that effect.

If this has nothing to do with what you were asking just ignore it.  Sometimes I misinterpret posts.
I also tried your method but I couldn't get it to work either. Also the answer you provided is exactly what I need but I failed to recreate it. (Sorry in advance for double posting, I had no other way to reply to both suggestions)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
I attempted to use your method but I got no result. I'm not too good with variables yet but a demo would be amazing!
Try to follow my method - the way Daughter of Evil described allows you to set up a variable number of enemies (while my method requires you to make events for every monster), but her description stopped short of describing how to setup the enemy event - she tells you how to count and check the enemies, but not how the enemy events need to work. That description is more for an user with some experience in setting up RPGM-games.
 

RiseOfTheChimera

Bound together by difference.
Veteran
Joined
Jun 11, 2013
Messages
43
Reaction score
0
First Language
English
Primarily Uses
Try to follow my method - the way Daughter of Evil described allows you to set up a variable number of enemies (while my method requires you to make events for every monster), but her description stopped short of describing how to setup the enemy event - she tells you how to count and check the enemies, but not how the enemy events need to work. That description is more for an user with some experience in setting up RPGM-games.
I tried your way as well but still I couldn't get the event to even show up at all. More specific instructions would be really helpful! :)
 

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
I think it's best if you'd go through our tutorial forum a bit more and brush up your skills if you are having problems getting an event to show up (this shows lack of knowledge how event page conditions work). Did you try the Variables Guide?
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
I also tried your method but I couldn't get it to work either. Also the answer you provided is exactly what I need but I failed to recreate it. (Sorry in advance for double posting, I had no other way to reply to both suggestions)
I had same problem when I first came on these forums.  What I ended up doing was using the Multi Quote thing on the bottom right.  This helps you respond to numerous people at once.

I would think the method I gave you should work though Chimera.  I use basically the same process on my game.  If you want, you could give me examples of how you wrote your two events and I'll try to figure out why it's not working.
 
Last edited by a moderator:

Daughter of Evil

Nightmare Princess
Veteran
Joined
Jun 21, 2013
Messages
147
Reaction score
19
First Language
English
Primarily Uses
I suggest your read more about variables. This are really important factors that could help your game. Once you get a basic understanding you'll probably be able to answer this question are more to come. :)

  Sorry If I wasn't able to explain it in full detail. :(
 

zeroline

Warper
Member
Joined
Feb 3, 2014
Messages
1
Reaction score
0
First Language
Bahasa
Primarily Uses
 Hello, I was wondering if there was a way to make overworld enemy events, or any event for that matter be set to spawn randomly based on chance or probability? For example: if you place a normal enemy event on a certain tile, make it so there is a 25% chance that it will spawn on the map when the player arrives? Is it possible to have this work without the use of script? If not can anyone direct me to a script that offers what I'm looking for? (if there even is one)

Thank you for reading, any advice or help would be greatly appreciated. :)
I don't know if you are still there but I have a method to do it.

1. on the next map to the map where your enemy is, create an event placed right next to transfer player event that transfers you to the map where your enemy is(you will probably need 1 or more of this event. just copy and paste it next to transfer player event).

    1.1 click the command field in this event

    1.2 select 'Control Variable' command

    1.3 in the variable box, choose single and click the '...'

    1.4 create a variable named 'Enemy' or whatever you want.

    1.5 in operation box, choose set

    1.6 in operand box, choose random; fill the first box with 1 and second box with 2

    1.7 click ok.

    1.8 click apply and click ok to close this event

Note: this event is used to trigger your enemy event which is in the step 3.

2. Now, go to the map where your enemy is

3. in this map, create an event with 2 pages.

    2.1 in the first page of this event, check the variable box in condition box.

          2.1.1 select the variable to one you created in step one and set its number to 1

note:this page will give you a chance to make the enemy doesn't appear.

    2.2 go to the second page.

note:the second page is your enemy page. so, choose your enemy graphic and set your own battle processing.

          2.2.1 in the conditional box, do the same thing as step 2.1 and 2.1.1 but set the number to 2, not 1 again.

As the result, 

the enemy may spawn or not spawn whenever you go to their map through the map with trigger event(s).

How it works:

the trigger event is used to trigger the enemy event whether the enemy will spawn or not on the next map. that's why the trigger event(s) should be placed next to the transfer player event to activate enemy event whenever you want go to their map.

The random (1...2) Control Variable command in trigger event is used to randomly activate one of enemy event pages according to its condition. That's why you set the first page's condition with 'Variable is 1 or above' checked and set the second page's condition with 'Variable is 2 or above' checked. Also, it can be used for multiple enemy event objects, I guess.

hope this helps.  :D  and sorry for my bad english cause it's not my mother language.

PS: to be honest, I'm using it for a different purpose and it works perfectly. and I think, it's using the same logic and can be used to solve your problem.
 
Last edited by a moderator:

Hali

Warper
Member
Joined
Jun 9, 2017
Messages
1
Reaction score
0
First Language
English
Primarily Uses
RMMV
This was extremely helpful! thank you! I learned that it works with multiple variables at the same time. For instance, if I want the possibility of anywhere from 0-3 enemies to spawn on a certain map, I just create 3 separate events (0001, 0002, and 0003) and repeat the steps given by Daughter of Evil for each enemy. That way theres a chance for each possibility.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
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

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top