How to make captured units controlled by another power
-
So in this game, when moving a unit to a Friendly Neutral territory (in this case Albania), the units join your side, and the territory is controlled by whoever moved in.
However, I want the territory and the units to always be controlled by a specific power (Italy), no matter who moves in. If for example the French move in, I want Albania to be controlled by Italy and the units to become Italian, not French.
So like this:
Does anybody have an idea how to code do that?
And to be more precise, all neutrals in this game have a different power they are belligerent to. So when a power moves into e.g. Belgium, the territory is handed over to France, and the units become French. For Romania, this power is Russia, no matter which ally moves in.
-
Please remember that I am looking at the world_war_i_1914.xml, which may not show something that may have been changed.
There is this:
<attachment name="playerAttachment" attachTo="Neutral_Allied" javaClass="games.strategy.triplea.attachments.PlayerAttachment" type="player"> <option name="captureUnitOnEnteringBy" value="Russians:French:British:Italians:Americans"/> </attachment>
This is what is changing the units when the territory is captured. To ensure that Albania is given to the Italians, it would need to be check at the end of every players non-combat movement:
<!-- Check to see if there any allied units in Albania --> <attachment name="conditionAttachmentAlbaniaCaptured" attachTo="Neutral_Allied" javaClass="RulesAttachment" type="player"> <option name="alliedExclusionTerritories" value="Albania" count="1"/> <option name="unitPresence" value="Any" count="1"/> </attachment> <!-- You may also want to add a check to see if Albania was captured by a Central Power, but I'll leave that up to you. --> <!-- Change Albania to Italian control prior to endTurn --> <attachment name="triggerAttachmentAlbaniaCaptured" attachTo="Neutral_Allied" javaClass="TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentAlbaniaCaptured"/> <option name="changeOwnership" value="Albania:any:Italian:true"/> <option name="when" value="before:russiansEndTurn"/> <option name="when" value="before:frenchEndTurn"/> <option name="when" value="before:britishEndTurn"/> <option name="when" value="before:americansEndTurn"/> </attachment>
It may need some adjustment, but I hope you get the idea.
Cheers...
-
Thank you. So I used your code and it kinda works, although two things went wrong. First of all, Albania switched to Italian control even when no units moved in. I thought this was due to alliedExclusionTerritories which should be alliedPresenceTerritories, but that didn't work. Perhaps because it thinks Friendly Neutrals are also allied or something.
Second of all, this code does not make sure the units are controlled by Italy as well, they stay neutral. How should I do that? I know there is ChangeUnitOwners, but that would change all the units in that territory to Italians, including the allied infantry that moved in, which should stay the same.
-
So this happened at the end of the Russian turn
-
@wc_sumpton OK small improvement, I got Albania to become under the control of Italy after France moved in, by setting Albania to Neutral_True (Neutral_Allied apparently does count towards alliedPresenceTerritories, a bit annoying).
However, the units don't change ownership to Italy, not sure how to do that.
-
-
Yeah so with that one you can change units in a territory to another player I believe, but I only want specific units in a territory to be controlled by another player, not all. And I don't know how to do that.
-
@victoryfirst said in How to make captured units controlled by another power:
And I don't know how to do that.
I don't either
-
I'm back again. Your first problem is with Albania, you need to change the territory attachment to reflect that only the Italians can take control of their infantry:
<attachment name="territoryAttachment" attachTo="Albania" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory"> <option name="production" value="2"/> <option name="captureUnitOnEnteringBy" value="Italians"/> </attachment>
Now for the conditions, because the territory's ownership is changing as soon as France enters, ownership of the territory can be checked:
<!-- Check to see if Albania is still owned by the Neutral Allies --> <attachment name="conditionAttachmentAlbaniaCaptured" attachTo="Neutral_Allied" javaClass="RulesAttachment" type="player"> <option name="directOwnershipTerritories" value="Albania" count="1"/> <option name="invert" value="true"/> </attachment> <!-- You may also want to add a check to see if Albania was captured by a Central Power, but I'll leave that up to you. --> <!-- Change Albania to Italian control prior to endTurn --> <attachment name="triggerAttachmentAlbaniaCaptured" attachTo="Italians" javaClass="TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentAlbaniaCaptured"/> <option name="changeOwnership" value="Albania:any:Italians:true"/> <!-- Changes the units --> <option name="changeOwnership" value="Albania:any:Italians:false"/> <!-- Changes the territory --> <option name="uses" value="1"/> <!-- Should only be done the first time --> <option name="when" value="before:russiansEndTurn"/> <option name="when" value="before:frenchEndTurn"/> <option name="when" value="before:britishEndTurn"/> <option name="when" value="before:americansEndTurn"/> </attachment>
Cheers...
-
Man, I am speechless... you are a god who solved all my problems! Thank you so much for this!
Heh heh I am learning so much just looking at your code. So that's what 'uses' does I only still don't know what 'invert' exactly is.
This was an awesome start to my day
-
I guess 'invert' inverts the boolean... lol
-
Heh heh I also managed to get it to work after an enemy attacked
-
this post is deleted
-
this post is deleted
-
I need some help again.
<attachment name="conditionAttachmentAlbaniaCaptured" attachTo="Neutral_Allied" javaClass="RulesAttachment" type="player"> <option name="enemyExclusionTerritories" value="Albania" count="1"/> <option name="directOwnershipTerritories" value="Albania" count="1"/> </attachment>
I did this to make sure Albania didn't come under Italian control when an enemy captured Albania. However, what's happening now is that AlbaniaCaptured is triggered all the time. I can't figure out how to both trigger the event if an ally moves in, and not trigger if an enemy moves in.
-
I think I know where the issue lies. "directOwnershipTerritories" will be false when an ally takes over, but also when an enemy takes over. Due to the invert, the result will be true in both situations.
-
I got it to work I added an original owner to each neutral and then did this:
<attachment name="conditionAttachmentAlbaniaCaptured" attachTo="Italians" javaClass="RulesAttachment" type="player"> <option name="directOwnershipTerritories" value="Albania" count="1"/> </attachment>
So when an ally captures Albania, the territory comes under the control of the original owner (Italy). AlbaniaCaptured will only be triggered when the territory is under the control of Italy, and not when an enemy captures the territory
-
@victoryfirst said in How to make captured units controlled by another power:
I got it to work I added an original owner to each neutral and then did this:
Nice!
Cheers...