How to create random spawning during the game?
-
Hej code wizards & Code Gurus mayeb @Cernel you might know..?
Still working here on a finishing touch of The Shogun Advanced and running in to this matter:
is there a way I could get Random Spawning (by "chance") of a specific type of unit without having to determine each single place
in a seperate trigger ( causing in this cause with over 160 terr's to be possible to place in far tooo much code )Example: ```
<attachment name="triggerAttachment_Activate_Farmer_Uprisings" attachTo="Ikko-Ikki" javaClass="TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentUprisingsTurn3"/> <option name="placement" value="Aki:Farmer" count="1"/> <option name="placement" value="Aki:Farmer" count="2"/> <option name="placement" value="Awa:Farmer" count="1"/> <option name="placement" value="Awa:Farmer" count="2"/> <option name="chance" value="1:20"/> <option name="when" value="after:minorNonCombatMove"/> </attachment>
so this will give a 1:20 chance for all 4 places get to Farmer uprising simultaneous where I look for a 1:20 chance for each separate one...
now the only solution I so far is as stated, getting EACH terr. its own TRIGGER... but that creates huge volume of coding..
is there another way? please let me know! or give me a refer to an example map...
( and I realize after my The Shogun compagnon @TheDog had looked at it there is a only tiny chance there will be another way )
Arrigato!
-
Just do a nested "foreach" loop.
https://forums.triplea-game.org/topic/560/categories-and-or-tags/51?_=1673720379348
-
-
@ebbe Take a look at my Zombies-World War 2 to see how to implement random uprisings.
-
Trying to crack the final issue here before starting a new ohter project!
So close to a Nesting solution here just miss one piece of the solution, after unsuccesfully trying to solve it a whole afternoon: here my help-call: anyone sees where it goes wrong?I want every player to have each Fort_damaged replaced in a Fort (kind of auto-repair) in their own controlled Territory in their before their own Place-delegate: It all works fine except for the
<option name="when" value="before:@AllPlayersMinorLC@CombatMove"/>
( =AllPlayersMinor Low Caps ) Both elements <variable name="AllPlayersMinor" & AllPlayersMinorLC" are well defined... so that is fine... but it simply doesn't work then, not even a error notification... it does work when I replace AllPlayersMinorLC with one of the players names; but that takes away the nesting advantage as I still need to repeat this trigger for 15 players each...
<attachment foreach="$AllTerr$^$AllPlayersMinor$" name="conditionAttachment_Fort_damaged_@AllPlayersMinor@_@AllTerr@" attachTo="@AllPlayersMinor@" javaClass="RulesAttachment" type="player"> <option name="directPresenceTerritories" value="@AllTerr@"/> <option name="unitPresence" value="Fort_damaged" count="1"/> </attachment> <attachment foreach="$AllTerr$^$AllPlayersMinor$" name="triggerAttachment_Place_Fort_@AllPlayersMinor@_@AllTerr@" attachTo="@AllPlayersMinor@" javaClass="TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachment_Fort_damaged_@AllPlayersMinor@_@AllTerr@"/> <option name="when" value="before:@AllPlayersMinorLC@CombatMove"/> <option name="placement" value="@AllTerr@:Fort"/> </attachment> <attachment foreach="$AllTerr$^$AllPlayersMinor$" name="triggerAttachment_Remove_Fort_damaged_@AllPlayersMinor@_@AllTerr@" attachTo="@AllPlayersMinor@" javaClass="TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachment_Fort_damaged_@AllPlayersMinor@_@AllTerr@"/> <option name="when" value="before:@AllPlayersMinorLC@CombatMove"/> <option name="removeUnits" value="@AllTerr@:Fort_damaged" count="1"/> </attachment>
hmmm
Anyone who sees a solution? I'll be very thankfull! -
@ebbe
You do not have 'AllPlayersMinorLC' in your "foreach" statement.
Try:
foreach="$AllTerr$^$AllPlayersMinor$:$AllPlayersMinorLC$"
and see if you get the results you are looking for.Cheers...
-
That was the one!!!! thanks for getting my Nesting -skills slightly improving !!!
-