encountered, allowing you to create random troops while managing them using the troop editor.
of options, and more options can be added to it if necessary.
By creating a set of placeholder rules, along with the use of placeholders, you can effectively produce random encounters.
A placeholder enemy consists of a sprite, which is used as a visual reference in the troop editor, and a placeholder name.
Placeholder rules determine whether an enemy can be placed in a placeholder spot or not based on the placeholder name. You can use placeholder tags to restrict certain enemies from certain spots.
And you have a rule that says an enemy can only be placed in “Large” placeholders, then it cannot be placed in any other placeholder spot.
You should also include a graphic for your placeholder enemy.
In the troop editor, you can visually place the placeholders.
to always appear. Only placeholder enemies will be replaced.
Where id is the ID of the enemy this rule applies to. You can set the ID to 0 if you want a chance to replace the placeholder with no enemy.
And are separated by semi-colons.
This is the list of options available and what they mean.
Which placeholders this enemy can be placed in. The enemy can only be placed in placeholders whose name matches one of these tags. You can have multiple tags for a single rule.
So its intended to generate empty battles?
If none of the conditions are met then there won&apos;t be any enemies.
Got the hang of it after a few tries and it seems to work fine so far. Saved a lot of work and database entries, really like your script. Good work!
The problem is, your script can generate empty battles. In an clean project it instantly goes to victory, but which Yanfly Scripts (suppose its Battle Engine) i get the divison by zero error.
Maybe you could use a Bool to track if you have only empty battlers so far. And if you reach the last spawnbox the script has to choose an id which is not 0.
But i am not sure, because i did not look into your code yet.
You should get yanfly&apos;s engine fixed because no enemy means you win by default. The script shouldn&apos;t just pick a random enemy even though none of them can be added.
Theres a Bug if id 0 is to high you might get an "empty" battle which results in a division by 0 error and game crash.
This script doesn&apos;t do any division, so I don&apos;t think this script is the problem.
Thanks! You are good at what you do.
I had not actually tried to use the ID:0 as I had not seen an update stating it was added and had not thought about trying it before. Thanks for correcting me.
I have tested it and found that the script already supports ID 0 for no enemy.
There is actually a bug with the replacement though, and this is probably why you’re getting the results you’re getting: once the placeholders have been randomized once, it is permanently changed. So this pretty much explains why the randomization is not working correctly: it’s not even being randomized. I have updated the script to address this.
This means that if you have weights of A is 30 and B is 15, then there’s 66.6% chance of getting A and 33.3% chance of getting B. I tested it with some sample runs across a hundred million trials (in a single run) and the outcome was about that.
Just ran into an issue.
Script ‘Window_Selectable’ line 61: ZeroDivisionError occurred.
Using the semicolon separated (option1: value1; option2: value2) functions 100%.
It was a bug. I have addressed the issue and updated the script. Thanks for the report.
Thanks Hime! You are so much more responsive than most other prolific scripters in the community. And so much more polite to newbies like myself.
I hope I am not bothering you, but I have another apparent anomaly to report.
Can you possibly take a moment to explain to me the logic behind your weight math?
I don’t pretend to understand 100% of what I am seeing in the code, but the results in practice seem as though it will often get stuck on one replacement over another.
For example: A 4 member troop, with a single ‘medium’ slot (in position #1), and 3 ‘small’ slots (in position 2,3,4) with the following rules.
In game, if I get an ID 6 the first time the troop is called, I get it 100% of the time (at least for several minutes) in position 1, despite the fact that is is 2 times more likely that ID 2 should be there instead. And visa verse.
In troop ‘Battle Test’ mode, it randomizes normally. (Or so it appears) Of course, its also completely starting and stopping the game loop each time.
This leads me to think it has to do with the random seed.
Have you considered combining this with the functionality of your ‘Encounter Conditions’ script?
Also, is there a possibility to have a NULL troop member result?
I have to say the diversity of your work is astounding!
I believe encounter conditions can be used on placeholders as well since they are just regular troop members (that just happen to get replaced with a different enemy).
You can have a placeholder replaced with no enemy if none of the rules are satisfied. For example, if there are only “large” slots left, and none of your “large” enemies can be added, then no enemy will be selected.
Doh. Seems I asked the first question about the ‘Encounter Conditions’ script before adequate testing…. I had all the test flags set, so every troop member showed up regardless. You saying that prompted me to double check and found the issue.
Though I am not sure I asked the second question correctly.
I am wondering if I might have a weighted placeholder rule that simply replaces the holder-member with nothing. A simple way may be using an ID of 0, to denote an empty member.
Either way, I can jimmy together the ‘Encounter Conditions’ to get the same effect now!
ID of 0 sounds like a good idea as it gives gave devs full control over the chances that no enemy will show up.