Random Starting Set Ups
-
I am not looking for placing randomized sets of units at every territory assuming it would require endless amount of triggers.
Instead I would want having (for example) 6 different set ups for each nations and they will all have the same change to trigger before game start. I'am not even sure if it would be any easier to do that.
-
@schulz I am not exactly sure what you mean. If you want 6 different setups with the "same trigger" that just means 6 different scenarios within the mod.
If you want 6 different setups for each nation, chosen at random, it can be done but it will be a little trickier. You would need 6 different, 1 time triggers, with the first one having chance of 1/6, then 1/5 etc. You would have the trigger detect and not fire if units are already placed. Alternatively, you could use tech to achieve the same effect but you couldn't use tech for other purposes.
If you can standardize the triggers, you can use a foreach loop to place units randomly. Take a look at my mod Zombies-World War 2, which was just added to the repository.
What you can't do is take a fixed group of units and place them randomly throughout the controlled territories. You can place units into the production queue and let the computer place them.
You could also use a foreach loop to place units in each controlled territory.
-
@rogercooper Each nations will have its own 6 different versions of starting set ups which will trigger independently which means almost countless amount of different set ups actually.
6 is just an example which can be reduced to 3 or 4.
For example here is German Set Ups: G1,G2,G3,G4,G5,G6 and French Set Ups: F1,F2,F3,F4,F5,F6
If (for example) G4 triggers as German set up it doesn't mean that also F4 should be triggered.
I'am not good at handling triggers honestly and could do only if other maps have the same concept.
I'd be very grateful if someone could write the attachments as example. Could be great asset for other map makers too.
For example here is a simplified scenario:
Germany and France are the only nations. German territories are Berlin-Munich and French ones are Paris-Marseille. Infantry is the only unit.
G1 set up: 2 inf for Berlin and 1 inf for Munich
G2 set up: 3 inf for Berlin and 2 inf for MunichF1 set up: 4 inf for Paris
F2 set up: 2 inf for Paris and 2 inf for Marseille -
@schulz
Ive done something similar to my map so Ill copy what I have. The way Ive done this for my map is that I use lots of invisible units as switches for things, so you have a small empty region called Space and conditions that check whether the switch is present.Though I was writing it out, I realised that I hadnt looked at the code in awhile and im unsure if it works for 6 variants. It definitely works for 2 which is what I currently have but Ill put a modified version that should work below.
<!-- First Round Setup--> <attachment name="conditionAttachmentCountrySetupFirstRound" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <-Change to which country goes first-> <option name="rounds" value="1"/> </attachment> <!-- Switch Conditions Setup--> <attachment name="conditionAttachmentGermanySetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="Space" count="1"/> <option name="unitPresence" value="GermanySetupSwitch1" count="1"/> <option name="unitPresence" value="GermanyHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <attachment name="conditionAttachmentGermanySetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="Space" count="1"/> <option name="unitPresence" value="GermanySetupSwitch2" count="1"/> <option name="unitPresence" value="GermanyHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <attachment name="conditionAttachmentFranceSetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="Space" count="1"/> <option name="unitPresence" value="FranceSetupSwitch1" count="1"/> <option name="unitPresence" value="FranceHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <attachment name="conditionAttachmentFranceSetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="Space" count="1"/> <option name="unitPresence" value="FranceSetupSwitch2" count="1"/> <option name="unitPresence" value="FranceHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <!-- Country Randomisation Switches Setup--> <attachment name="triggerAttachmentGermanySetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/> <option name="placement" value="Space:GermanySetupSwitch1"/> <option name="players" value="Neutral"/> <option name="chance" value="2:2"/> </attachment> <attachment name="triggerAttachmentGermanySetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/> <option name="placement" value="Space:GermanySetupSwitch2"/> <option name="players" value="Neutral"/> <option name="chance" value="1:2"/> </attachment> <attachment name="triggerAttachmentFranceSetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/> <option name="placement" value="Space:FranceSetupSwitch1"/> <option name="players" value="Neutral"/> <option name="chance" value="2:2"/> </attachment> <attachment name="triggerAttachmentFranceSetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/> <option name="placement" value="Space:FranceSetupSwitch2"/> <option name="players" value="Neutral"/> <option name="chance" value="1:2"/> </attachment> <!-- Country Randomisation Triggers Setup--> <attachment name="triggerAttachmentGermanySetupHasSetup" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="removeUnits" value="Space:GermanyHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <attachment name="triggerAttachmentGermanySetupG1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="placement" value="Berlin:Infantry" count="2"/> <option name="placement" value="Munich:Infantry" count="1"/> </attachment> <attachment name="triggerAttachmentGermanySetupG2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="placement" value="Berlin:Infantry" count="3"/> <option name="placement" value="Munich:Infantry" count="2"/> </attachment> <attachment name="triggerAttachmentFranceSetupHasSetup" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="removeUnits" value="Space:GermanyHasNotSetupSwitch" count="1"/> <option name="players" value="Neutral"/> </attachment> <attachment name="triggerAttachmentFranceSetupF1" attachTo="France" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="placement" value="Paris:Infantry" count="4"/> </attachment> <attachment name="triggerAttachmentFranceSetupF2" attachTo="France" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="placement" value="Paris:Infantry" count="2"/> <option name="placement" value="Marseille:Infantry" count="2"/> </attachment> <attachment name="triggerAttachmentGermansSetupG1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentGermanySetupSwitch1:conditionAttachmentGermanySetupSwitch2"/> <option name="conditionType" value="1"/> <option name="when" value="before:germanyCombatMove"/> <-Change this to the very first phase of your map. -> <option name="activateTrigger" value="triggerAttachmentGermanySetupHasSetup:1:false:false:false:false"/> <option name="activateTrigger" value="triggerAttachmentGermanySetupG1:1:false:false:false:false"/> </attachment> <attachment name="triggerAttachmentTGermansSetupG2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentGermanySetupSwitch1:conditionAttachmentGermanySetupSwitch2"/> <option name="conditionType" value="2"/> <option name="when" value="before:germanyCombatMove"/> <-Change this to the very first phase of your map. -> <option name="activateTrigger" value="triggerAttachmentGermanySetupHasSetup:1:false:false:false:false"/> <option name="activateTrigger" value="triggerAttachmentGermanySetupG2:1:false:false:false:false"/> </attachment> <attachment name="triggerAttachmentFranceSetupF1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentFranceSetupSwitch1:conditionAttachmentFranceSetupSwitch2"/> <option name="conditionType" value="1"/> <option name="when" value="before:germanyCombatMove"/> <-Change this to the very first phase of your map. -> <option name="activateTrigger" value="triggerAttachmentFranceSetupHasSetup:1:false:false:false:false"/> <option name="activateTrigger" value="triggerAttachmentFranceSetupF1:1:false:false:false:false"/> </attachment> <attachment name="triggerAttachmentFranceSetupF2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentFranceSetupSwitch1:conditionAttachmentFranceSetupSwitch2"/> <option name="conditionType" value="2"/> <option name="when" value="before:germanyCombatMove"/> <-Change this to the very first phase of your map. -> <option name="activateTrigger" value="triggerAttachmentFranceSetupHasSetup:1:false:false:false:false"/> <option name="activateTrigger" value="triggerAttachmentFranceSetupF2:1:false:false:false:false"/> </attachment> --- <unitPlacement unitType="GermanyHasNotSetupSwitch" territory="Space" quantity="1" /> <unitPlacement unitType="FranceHasNotSetupSwitch" territory="Space" quantity="1" />
Hopefully this will work for you. Perhaps it could be done in a different way but Ive been using methods like this on my map with no issues.
Though I think the issue with this way is that if you expand it to more then 3 setup variants there will be an uneven chance on some of them happening, idk im bad at ratios.For a short explanation: 1-2 switches for both Germany and France are made, and then the triggers that spawn units for G1-2 and F1-2 occur depending on whether theres 1 switch or 2 switches that have spawned.
-
@zaroph I've just tried to adopt for only "Dervish" and error says "An element with the identifier "DervishHasNotSetupSwitch" must appear in the document.
<attachment name="conditionAttachmentCountrySetupFirstRound" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="rounds" value="1"/>
</attachment><attachment name="conditionAttachmentDervishSetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="directPresenceTerritories" value="Space" count="1"/>
<option name="unitPresence" value="DervishSetupSwitch1" count="1"/>
<option name="unitPresence" value="DervishHasNotSetupSwitch" count="1"/>
<option name="players" value="Neutral"/>
</attachment><attachment name="conditionAttachmentDervishSetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="directPresenceTerritories" value="Space" count="1"/>
<option name="unitPresence" value="DervishSetupSwitch2" count="1"/>
<option name="unitPresence" value="DervishHasNotSetupSwitch" count="1"/>
<option name="players" value="Neutral"/>
</attachment><attachment name="triggerAttachmentDervishSetupSwitch1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/>
<option name="placement" value="Space:DervishSetupSwitch1"/>
<option name="players" value="Neutral"/>
<option name="chance" value="2:2"/>
</attachment><attachment name="triggerAttachmentDervishSetupSwitch2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentCountrySetupFirstRound"/>
<option name="placement" value="Space:DervishSetupSwitch2"/>
<option name="players" value="Neutral"/>
<option name="chance" value="1:2"/>
</attachment><attachment name="triggerAttachmentDervishSetupHasSetup" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="removeUnits" value="Space:GermanyHasNotSetupSwitch" count="1"/>
<option name="players" value="Neutral"/>
</attachment><attachment name="triggerAttachmentDervishSetupA1" attachTo="Dervish" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="placement" value="Eritrea:conscript" count="1"/>
<option name="placement" value="Cibuti:conscript" count="1"/>
<option name="placement" value="Dessie:conscript" count="1"/>
<option name="placement" value="Adama:conscript" count="1"/>
<option name="placement" value="Aksum:infantry" count="1"/>
<option name="placement" value="Aksum:artillery" count="1"/>
<option name="placement" value="Gondar:artillery" count="1"/>
<option name="placement" value="SZ 160:destroyer" count="1"/>
</attachment><attachment name="triggerAttachmentDervishSetupA2" attachTo="Dervish" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="placement" value="Eritrea:conscript" count="1"/>
<option name="placement" value="Dessie:conscript" count="2"/>
<option name="placement" value="Adama:conscript" count="1"/>
<option name="placement" value="Cibuti:infantry" count="1"/>
<option name="placement" value="Gondar:gas" count="2"/>
<option name="placement" value="Aksum:artillery" count="1"/>
</attachment><attachment name="triggerAttachmentDervishSetupA1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentDervishSetupSwitch1:conditionAttachmentDervishSetupSwitch2"/>
<option name="conditionType" value="1"/>
<option name="when" value="before:germanyCombatMove"/>
<option name="activateTrigger" value="triggerAttachmentDervishSetupHasSetup:1:false:false:false:false"/>
<option name="activateTrigger" value="triggerAttachmentDervishSetupA1:1:false:false:false:false"/>
</attachment><attachment name="triggerAttachmentDervishSetupA2" attachTo="Germany" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentDervishSetupSwitch1:conditionAttachmentDervishSetupSwitch2"/>
<option name="conditionType" value="2"/>
<option name="when" value="before:germanyCombatMove"/>
<option name="activateTrigger" value="triggerAttachmentDervishSetupHasSetup:1:false:false:false:false"/>
<option name="activateTrigger" value="triggerAttachmentDervishSetupA2:1:false:false:false:false"/>
</attachment>
And this one below of <unitInitialize>
<unitPlacement unitType="DervishHasNotSetupSwitch" territory="Space" quantity="1" />
-
@schulz Do you have a unit fully defined called "DervishHasNotSetupSwitch"?
Do you even need a setup switch? For example, each setup places a unit in Eritrea, you could require that Eritrea be empty as a part of the trigger.
-
@rogercooper No. I just followed the example.
I need random set up feature to make each game unique since map is big enough to tolerate bad lucks and mistakes plus I couldn't create a balanced scenario with fixed set up with this map by myself.
But it won't have broken balance just it will be not as balanced as other games .
-
I've just tried to adopt for only "Dervish" and error says "An element with the identifier "DervishHasNotSetupSwitch" must appear in the document.
You need to define the switches like normal units, so you need for each switch:
<element name="SwitchName"/> ---- <attachment name="unitAttachment" attachTo="SwitchName" javaClass="UnitAttachment" type="unitType"> <option name="isInfrastructure" value="true"/> </attachment> ---- +A blank unit image put into the Neutral folder
Also make sure you add a small blank territory in the corner of a map and call it "Space".
Do you even need a setup switch? For example, each setup places a unit in Eritrea, you could require that Eritrea be empty as a part of the trigger.
Using switches is just the easiest way for me to do these sort of things, and in this case it acts as a way of only triggering one of the set up triggers instead of multiple.
-
I've just learned and decided to use another method which randomize unit distributions instead set ups;
Example;
<variable name="DervishConscript">
<element name="Eritrea"/>
<element name="Cibuti"/>
<element name="Aksum"/>
<element name="Dessie"/>
<element name="Adama"/>
<element name="Gondar"/>
</variable><attachment name="conditionAttachmentr1" attachTo="Germany" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="rounds" value="1"/>
</attachment><attachment foreach="$DervishConscript$" name="triggerAttachmentDervishConscript@DervishConscript@" attachTo="Dervish" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentr1"/>
<option name="placement" value="@DervishConscript@:conscript" count="1"/>
<option name="players" value="Dervish"/>
<option name="chance" value="1:2"/>
<option name="when" value="before:germanyCombatMove"/>
</attachment>