new production unit - barracks
-
Thx alot. It works fine, very well.
I am no native speaker, but my English is fine
The problems have been syntax issues.I started a new topic with that sea zone theme
-
Hi,
new idea for the barracks:
it would be an interesting idea to have an upgrade option
let's say for 10 IPC barracks can be upgraded to a regular factory.
In total 7+10 the later factory is more expensive, but for nations with limited financial funds this can be an interesting option.
can this be defined somehow? and would this mean that the barracks icon would disapear and a factory would appear on the map?
-
Sure its possible. Lots of maps have unit upgrades. Use a copy of the 'factory.png' and name it 'factory_upgrade.png', along with 'factory_upgrade_it.png', 'factory_upgrade_hit.png' and 'factory_upgrade_it_hit.png'
Make sure you add the unit to the 'unitList', and 'productionRule':<productionRule name="buyFactoryUpgrade"> <cost resource="PUs" quantity="10"/> <result resourceOrUnit="factory_upgrade" quantity="1"/> </productionRule>The 'unitAttachment' would look like this:
<!-- Factory Upgrade --> <attachment name="unitAttachment" attachTo="factory" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="isFactory" value="true"/> <option name="consumesUnits" value="1:barracks"/> </attachment>You will also need to add '<option name="requiresUnits" value="factory_upgrade"/>' for each unit the has the 'factory' requirement.
It will appear in the purchase window. And when purchased can only be place in a territory that has a barracks, and replaces that unit when placed.
Two points to remember. The AI does not purchase 'Upgrade' units. And the 'Upgrade' unit will appear for purchase even if the player has no barracks to upgrade.
Cheers...
-
here we go again.
the next project is to install a new production unit - the "port"
the port allows to build any naval unit, but no other unitsbut the barracks, for only infantry and the regular factory, for all units, are still in the game.
--
right now the infantry - the only unit that can be produced in both barracks and factory - has no extra coding
<!-- Infantry -->
<attachment name="unitAttachment" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType" attachTo="infantry">
<option name="movement" value="1"/>
<option name="transportCost" value="2"/>
<option name="isInfantry" value="true"/>
<option name="isAirTransportable" value="true"/>
<option name="attack" value="1"/>
<option name="defense" value="2"/>
<option name="artillerySupportable" value="true"/>
</attachment>but other units have the <option name="requiresUnits" value="factory"/> coding, e.g.
<!-- Carrier -->
<attachment name="unitAttachment" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType" attachTo="carrier">
<option name="carrierCapacity" value="2"/>
<option name="movement" value="2"/>
<option name="isSea" value="true"/>
<option name="attack" value="1"/>
<option name="defense" value="2"/>
<option name="requiresUnits" value="factory"/>
</attachment>so
- how to define all the naval units that they can build in either the "port" or the "factory"
- how to avoid that naval units can be build in the barracks
- how to secure that in a factory -as usual- any unit can be build
- how to secure a port to be build only in countries that have at least one Sea Zone adjacent.
thx in advance
-
Hi @Numetalfan
- Use the "requiresUnits" list both port and factory
- "requiresUnits" should work here as well. Can you post what you have for barracks ?
- I don't think you need anything other than "requiresUnits"
- use "unitPlacementOnlyAllowedIn" those TTys with adjacent SZs
There may be an easier way to do it but I think that should work. That's what I'd try anyway.
-
Hi,
so carrier would be:
<!-- Carrier -->
<attachment name="unitAttachment" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType" attachTo="carrier">
<option name="carrierCapacity" value="2"/>
<option name="movement" value="2"/>
<option name="isSea" value="true"/>
<option name="attack" value="1"/>
<option name="defense" value="2"/>
<option name="requiresUnits" value="factory"/>
<option name="requiresUnits" value="port"/>
</attachment>does the program understand that this is an "OR" option and you do not need both, factory and port?
<!-- Barracks -->
<unit name="barracks"/><productionRule name="buyBarracks">
<cost quantity="7" resource="PUs"/>
<result quantity="1" resourceOrUnit="barracks"/>
</productionRule><attachment name="unitAttachment" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType" attachTo="barracks">
<option name="isFactory" value="true"/>
</attachment><repairRule name="repairBarracks">
<cost quantity="1" resource="PUs"/>
<result quantity="1" resourceOrUnit="barracks"/>
</repairRule><productionFrontier name="production">
<frontierRules name="buyInfantry"/>
....
<frontierRules name="buyFactory"/>
<frontierRules name="buyBarracks"/>
</productionFrontier> -
@Numetalfan yea it only needs one.
requiresUnits values: is a list of units required to be present in the territory in order for you to build this unit there. Can have multiple instances. Only one instance needs to be true in order to build.
-
Hi,
I will try this.
Next question:
a factory can build always as many units as the IPC value of the country.
Is it possible to restrict barracks to build max 2 units, even if the country, e.g. India, has a higher IPC value ?
In an 1 IPC country, of course, the maximum will be 1 unit.how can this be programmed?
-
I have the idea to introduce a new production unit, the small factory, that works like a factory but only ground units can be bought - nothing special so far.
now I want to use your idea and create a factory update unit as described above - still nothing special so far.
But my next idea is:
a small Factory should be allowed to be upgraded to a factory
a barracks should not be allowed to be upgraded to a factory, so the factory update must be restricted to smallFactories onlyis this possible?
-
@Numetalfan said in new production unit - barracks:
Hi,
I will try this.
Next question:
a factory can build always as many units as the IPC value of the country.
Is it possible to restrict barracks to build max 2 units, even if the country, e.g. India, has a higher IPC value ?
In an 1 IPC country, of course, the maximum will be 1 unit.how can this be programmed?
yea I don't think you can. You can limit it to 2 units by using
<option name="canProduceXUnits" value="2"/>
but then you could build 2 in 1 value TTys as well which isn't what you want either. I guess a sloppy way of doing it would be to have two different barracks types. One that produces 1 and the other 2 and restrict the 1 build to 1 value TTys and then the opposite with the 2.
Maybe somebody knows a better way
-
@Numetalfan said in new production unit - barracks:
I have the idea to introduce a new production unit, the small factory, that works like a factory but only ground units can be bought - nothing special so far.
now I want to use your idea and create a factory update unit as described above - still nothing special so far.
But my next idea is:
a small Factory should be allowed to be upgraded to a factory
a barracks should not be allowed to be upgraded to a factory, so the factory update must be restricted to smallFactories onlyis this possible?
yea you can look at Global 40 it has a Factory Upgrade unit that turns a minor into a major. You need the "consumesUnits" and all the stuff you want the new unit to do.
<option name="consumesUnits" value="1:factory_minor"/>
-
@beelee said in new production unit - barracks:
@Numetalfan said in new production unit - barracks:
Hi,
I will try this.
Next question:
a factory can build always as many units as the IPC value of the country.
Is it possible to restrict barracks to build max 2 units, even if the country, e.g. India, has a higher IPC value ?
In an 1 IPC country, of course, the maximum will be 1 unit.how can this be programmed?
yea I don't think you can. You can limit it to 2 units by using
<option name="canProduceXUnits" value="2"/>
but then you could build 2 in 1 value TTys as well which isn't what you want either. I guess a sloppy way of doing it would be to have two different barracks types. One that produces 1 and the other 2 and restrict the 1 build to 1 value TTys and then the opposite with the 2.
Maybe somebody knows a better way
I would just try this. I had issues with mine not producing more than the IPC value, even though i had settings like that. So that setting might just set an either/or max with the value of the territory.
-
Hi,
I got an error message:
Sep 29, 2020 1:10:56 PM games.strategy.engine.data.GameParser parseMapProperties
SCHWERWIEGEND: SAXParseException: game: WW2v4-1941, line: 2825, column: 8, error: Element mit "buyFactoryUpdate" ist im Dokument erforderlich.but <i thought to have done all right with that new production unit:
....
<unit name="SmallFactory"/>
<unit name="Shipyard"/>
<unit name="FactoryUpgrade"/>
</unitList>...
<productionRule name="buyFactoryUpgrade">
<cost resource="PUs" quantity="8"/>
<result resourceOrUnit="FactoryUpgrade" quantity="1"/>
</productionRule>...
<productionRule name="buySmallFactory">
<cost quantity="8" resource="PUs"/>
<result quantity="1" resourceOrUnit="SmallFactory"/>
</productionRule>
<productionRule name="buyShipyard">
<cost quantity="8" resource="PUs"/>
<result quantity="1" resourceOrUnit="Shipyard"/>
</productionRule>..
<repairRules name="repairSmallFactory"/>
<repairRules name="repairShipyard"/>
<repairRules name="repairFactory"/>
</repairFrontier>...
<frontierRules name="buyShipyard"/>
<frontierRules name="buySmallFactory"/>
<frontierRules name="buyFactoryUpdate"/>
</productionFrontier>...
<!-- FactoryUpgrade --><attachment name="unitAttachment" attachTo="FactoryUpgrade" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isFactory" value="true"/>
</attachment>
<attachment name='unitAttachment' attachTo='FactoryUpgrade' javaClass='UnitAttachment' type='unitType'>
<option name='consumesUnits' value='1:SmallFactory'/>
</attachment>
<attachment name='unitAttachment' attachTo='FactoryUpgrade' javaClass='UnitAttachment' type='unitType'>
<option name='consumesUnits' value='1:Shipyard'/>
</attachment>
<!-- SmallFactory -->
<attachment name="unitAttachment" attachTo="Smallfactory" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isFactory" value="true"/>
</attachment>
<!-- Shipyard -->
<attachment name="unitAttachment" attachTo="Shipyard" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isFactory" value="true"/>
</attachment>
what is missing?
-
@Numetalfan said in new production unit - barracks:
<frontierRules name="buyFactoryUpdate"/>
Looks as if "Upgrade" and "Update" got mixed up.
-
True. How simple.
Thx -
@Numetalfan I've done it many a time myself

-
Next topic,
everything works now, but not perfect:
<!-- SmallFactory -->
<attachment name="unitAttachment" attachTo="Smallfactory" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isFactory" value="true"/>
</attachment>
<!-- Shipyard -->
<attachment name="unitAttachment" attachTo="Shipyard" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isFactory" value="true"/>
</attachment>
all ground units are coded that way:
<attachment name="unitAttachment" attachTo="cruiser" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="2"/> <option name="isSea" value="true"/> <option name="attack" value="3"/> <option name="defense" value="3"/> <option name="canBombard" value="true"/> <option name="hitPoints" value="1"/><option name="requiresUnits" value="factory"/>
<option name="requiresUnits" value="Shipyard"/>
</attachment>I expected that now cruiser can only be build in countries that contain either a factory or a shipyard.
But it is not - I could build it in a small factroy too.vice-versa the same problem:
I could build an armour in a country with only a shipyard, but no other factory, even the armour is coded:
<attachment name="unitAttachment" attachTo="armour" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="2"/> <option name="transportCost" value="3"/> <option name="canBlitz" value="true"/> <option name="isLandTransport" value="true"/> <option name="attack" value="3"/> <option name="defense" value="3"/><option name="requiresUnits" value="factory"/>
<option name="requiresUnits" value="Smallfactory"/>
</attachment>what is wrong?
-
@Numetalfan so the "isFactory" is what is allowing that. I'm not 100% sure how to do what you want but it may be possible. I have something similar but probably not quite what you want.
So make your Shipyard without "isFactory" and require the Naval units to have it and you will only be able to build where a Factory and Shipyard are. Then make something that the Armor requires as well, I'll just call it "ArmorProduction" for now. So then you can only build the Armor with a factory and a ArmorProduction.
I don't remember what you had for smallFactory. But if you don't want something being built there just make sure you don't have the required unit there.
-
Thx. I will try that. I coded them with "is factory" to allow enemy bombers to do SBR.
Means to remove that that strategic bombing is no longer possible to that units? -
@Numetalfan yea so you need to have "isInfrastructure" so they can be bombed. Here's an example:
<!-- Harbour12 -->
<attachment name="unitAttachment" attachTo="harbour12" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isInfrastructure" value="true"/>
<option name="canBeDamaged" value="true"/>
<option name="maxDamage" value="6"/>
<option name="maxOperationalDamage" value="2"/>
<option name="repairsUnits" value="battleship:carrier:battleship-damaged"/>
<option name="isConstruction" value="true"/>
<option name="constructionType" value="harbour12_structure"/>
<option name="constructionsPerTerrPerTypePerTurn" value="1"/>
<option name="maxConstructionsPerTypePerTerr" value="1"/>
<option name="movement" value="0"/>
<option name="givesMovement" value="1:transport"/>
<option name="givesMovement" value="1:transportC8"/>
<option name="givesMovement" value="1:submarine"/>
<option name="givesMovement" value="1:destroyer"/>
<option name="givesMovement" value="1:destroyerC5"/>
<option name="givesMovement" value="1:cruiser"/>
<option name="givesMovement" value="1:carrier"/>
<option name="givesMovement" value="1:EscortCarrier"/>
<option name="givesMovement" value="1:EscortCarrierASW"/>
<option name="givesMovement" value="1:battleship"/>
<option name="isAAforBombingThisUnitOnly" value="true"/>
<!--<option name="canBeGivenByTerritoryTo" value="British"/>-->
</attachment>So isConstruction allows it to be placed without a Factory. You can have it do it's move support and be bombed etc...but if you don't have a Factory there as well you can't build units there. And if the unit has the requiresUnits thingy you would need both present.
You need all the images too. The "_hit image" etc..
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login