new production unit - barracks
-
Hi all,
I want to extent the WW2v3-1941.xml with a new production unit, the barracks
barracks should cost 7 IPC to contruct than thy work like factories except the can only produce infantry.
What has to be done to make this work.
so far I created a barracks.pgn and added it to all nations in the unit folder
the WW2v3-1941.xml was edited so far with the following commandos:<unit name="barracks"/>
</unitList>
</productionRule>
<productionRule name="buyBarracks">
<cost resource="PUs" quantity="7"/>
<result resourceOrUnit="barracks" quantity="1"/>
</productionRule>
</attachment>
<!-- Barracks -->
<attachment name="unitAttachment" attachTo="barracks" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
<option name="isBarracks" value="true"/>
</attachment>
</property>
<property name="maxBarracksPerTerritory" value="1"/>
<property name="Placement Restricted By Barracks" value="true" editable="false">
<boolean/>but that is not all. I miss the part where I restrict the barracks to only build infantry.
where ist that?And which files have to be changed too, until it will work?
-
@Numetalfan Look at 270BC, with the barracks working like the legonaire, the factory working like the city, the infantry working like the fort and so on.
Also, as far as I know,
Placement Restricted By Factory
andmaxFactoriesPerTerritory
are hardcoded property, meaning that I believe yourPlacement Restricted By Barracks
andmaxBarracksPerTerritory
are directly irrelevant to the program, assuming you got there by changing "Factories" and "Factory" with "Barracks", in the aforementioned properties (properties are not validated, so the program will never let you know you are coding any property wrong). -
@Numetalfan I assume the
isBarracks
option is giving you an error. Whatever you are assuming that option to do, it won't do it. I suppose you changed the name of the "isFactory" option, starting from an attachment named "factory" having this option true, but that option is not there because assigned to a unit called "factory" due to the name itself. It is, instead, an option (indirectly) setting some behaviours for the unit, regardless of the unit's name. -
Moved to Map Making.
-
@Numetalfan welcome to xml programming for TripleA!!
I'm going to assume that you have very little, if any, prior code writing knowledge. If that is true, then congrats Sir! This is an excellent first attempt!
Your first steps are right, by defining what you want, a 'barracks' unit that can only produce infantry units. You added the unit to the unit list, and defined its productionRule. The next is repair, like a factory, this unit should be damageable by SBR:
<repairRule name="repairBarracks"> <cost resource="PUs" quantity="1"/> <result resourceOrUnit="barracks" quantity="1"/> </repairRule>
Then add the repairRule to the repairFrontier:
<repairRules name="repairBarracks"/> </repairFrontier>
And so that countries can buy this unit, it will need to be added to the productionFrontier:
<frontierRules name="buyBarracks"/> </productionFrontier>
So far so good, now to the barracks attachment:
<!--- Barracks ---> <attachment name="unitAttachment" attachTo="barracks" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="isFactory" value="true"/> </attachment>
Ok so far. At this point there are two production units, factory and barracks. And both unit can produce all units. So how do we restrict the production of the barracks? We limit where each unit can be produced. In each unitAttachment, artillery, armour, fighter, bomber, transport, battleship, cruiser, destroyer, carrier, submarine and don't forget the aaGun add:
<option name="requiresUnits" value="factory"/> </attachment>
Because infantry can be produced by both, there doesn't need to be anything added to its unitAttachment.
One last step is to add the option to use requiresUnits:
<property name="Unit Placement Restrictions" value="true" editable="false"> <boolean/> </property>
And there you have it. The barracks should now work as designed. To test add a barracks to France:
<unitPlacement unitType="barracks" territory="France" quantity="1" owner="Germans"/> </unitInitialize>
Load the game, and now Germany can produce only infantry units in France, but they can also still produce infantry in Germany.
Like I said you had the right ideas, and you went a long way to getting what you wanted. There were just a few things that need to be added or changed. Don't give up now!! Mod! Mod! and Mod some more!!
Cheers...
-
And yet another nugget of wisdom I have to redo BlackElk's "Military base " now
-
Cheers...
-
I would also like to mention that this method works for sea units as well, if you want different shipyards to make different naval units.
I initially thought it wouldnt because they are adjacent to factories in land territories, and the XOB option browser says this for them: "All units in the list are required to be present in the territory in order to place the attachTo unit there." but it does seem to work exactly the same as land units which is nice.
-
Thanks alot !
Yes I am a beginner in map designing, but I will try my best. THX for all the input.
I will test that barracks input the next days. -
the next beginners question, sorry.
the downloaded world_war_ii_v3-master is located on my computer C:\Users....\triplea\downloadedMaps
now I made a local copy that folder is now named
world_war_ii_v4
the maps with all the barracks changes is called WW2v4-1941
it is located C:\Users....\triplea\downloadedMaps\world_war_ii_v4\world_war_ii_v4 -master\map\gamesthe question is:
what has to be done to make this game run? Do I need a master zip file and a properties file in the \downloadedMaps folder? How to create them?
-
@Numetalfan
What you are doing is making a mod for an existing map. So this is how I do this:
Download the map 'World War II v3' and in the downloadedMaps directory I get world_war_ii_v3-master.zip and world_war_ii_v3-master.zip.properties.
Open world_war_ii_v3-master.zip and drag the file world_war_ii_v3-master to the downloadedMaps directory. This will add that directory with the files unzipped, which makes it easier to work with. Then remove both world_war_ii_v3-master.zip and world_war_ii_v3-master.zip.properties. I also delete the '-master' for the unzipped directory, so all I have is an unzipped directory 'world_war_ii_v3'.After that setup I open the xml game file 'WW2v3-1941' with Notepad++ drop down to the info line and change the name:
<game> <!--<info name="World War II v3 1941" version="1.7"/>--> <info name="World War II v3 1941 with Barracks" version="1.7"/>
Then do 'file - Save As...' and add a notation to the file name ie: 'WW2v3-1941.xml' now becomes 'WW2v3-1941_barracks.xml'. So both files exist in the map directory, and I can open and refer to the original if necessary.
You don't need the '.properties'. It just added with the download, and all of them can be removed.
Otherwise your modified game xml can reside in the same folder. Just select the name from the 'Select Map' list.
Hope this helps...
And don't be sorry for asking. Mod, make mistakes, ask and get help, and mod some more. We all started by not knowing, so answering is fun and helpful. I also learned some things by doing this for you! So it was fun and helpful for me!
Cheers...
-
thx, that's what I did, but now there is an error....could not parse...
the error message names the xml file.instead of World War II v3 1941 with Barracks I named it
WW2v4-1941.xmlI have right now
a folder named world_war_ii_v4 -master
in the C:\Users...\triplea\downloadedMapsand in the
C:\Users...\triplea\downloadedMaps\world_war_ii_v4 -master\map\games
a WW2v4-1941.xml filein that xml file
...
<game>
<info name="WW2v4-1941" version="1.7 edited BM"/>
<loader javaClass="games.strategy.triplea.TripleA"/>
<triplea minimumVersion="1.7"/>
...what might be the mistake?
-
Hi @Numetalfan
So at the bottom of the xml where it says"mapName" that has to match exactly the name of the folder in the DL'd maps folder.
-
@Numetalfan said in new production unit - barracks:
instead of World War II v3 1941 with Barracks I named it
WW2v4-1941.xmlThis sounds like a name of a mod of "World War II v4" set somewhere in 1941, instead of in the spring of 1942.
-
@Numetalfan
I think I understand.
This is the game name and can be very descriptive:<game> <info name="WW2v4-1941" version="1.7 edited BM"/>
You created a new directory for you map
"C:\Users...\triplea\downloadedMaps\world_war_ii_v4 -master"
Since it looks like its not a zip file, I would remove the " -master". (Don't for get the space before the "-") So the xml directory looks like "C:\Users...\triplea\downloadedMaps\world_war_ii_v4\map\games".
Now as to what @beelee is saying. Because you created a new directory you have to change the "mapName" property. Most of the time it is located at the bottom of the xml, just before the "notes" property and it need to equal the file name for you new map:<!-- Map Name: must equal file name --> <property name="mapName" value="world_war_ii_v4" editable="false"/> <!-- notes appear in the notes menu in the main screen, format as html --> <property name="notes">
Hope this is helpful.
Cheers...
-
thanks to the freuquent support,
I feel I am close to what I want but still it there is the following error:
Jun 28, 2020 11:31:50 AM games.strategy.engine.framework.ui.GameChooserModel createGameChooserEntry
SCHWERWIEGEND: Could not parse: file:/C:/Users/.../triplea/downloadedMaps/world_war_ii_v4/map/games/WW2v4-1941.xml
games.strategy.engine.data.GameParseException: map name: 'file:/C:/Users/.../triplea/downloadedMaps/world_war_ii_v4/map/games/WW2v4-1941.xml', game name: '<unknown>', failed to parse XML document
at games.strategy.engine.data.GameParser.newGameParseException(GameParser.java:108)
at games.strategy.engine.data.GameParser.parseDom(GameParser.java:136)
at games.strategy.engine.data.GameParser.parseShallow(GameParser.java:127)
at games.strategy.engine.data.GameParser.parseShallow(GameParser.java:123)
at games.strategy.engine.framework.ui.GameChooserEntry.<init>(GameChooserEntry.java:36)
at games.strategy.engine.framework.ui.GameChooserModel.createEntry(GameChooserModel.java:168)
at games.strategy.engine.framework.ui.GameChooserModel.createGameChooserEntry(GameChooserModel.java:147)
at games.strategy.engine.framework.ui.GameChooserModel.populateFromDirectory(GameChooserModel.java:181)
at games.strategy.engine.framework.ui.GameChooserModel.lambda$parseMapFiles$0(GameChooserModel.java:62)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source)
at java.util.concurrent.CountedCompleter.exec(Unknown Source)
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.util.concurrent.ForkJoinPool$WorkQueue.execLocalTasks(Unknown Source)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: org.xml.sax.SAXParseException; systemId: jar:file:/C:/Program%20Files/TripleA/bin/triplea-game-headed-1.9.0.0.13066-all.jar!/games/strategy/engine/xml/; lineNumber: 870; columnNumber: 3; Elementtyp "production" muss mit dem entsprechenden Endtag "</production>" beendet werden.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at games.strategy.engine.data.GameParser.getDocument(GameParser.java:323)
at games.strategy.engine.data.GameParser.parseDom(GameParser.java:134)
... 17 more -
@Numetalfan so what I think this is saying is that there is no </production> tag. This could be miss leading because you do have the </production> tag. It also gives a line number which is way before the end of the xml. If you were missing the tag the line number would be something like 2200. So what you need to do is check you xml at line 870 to see if there is an extra closing tag, maybe 2 </productionRule> tags together or something similar.
Hopefully we get there soon.
Cheers...
P.S. You could post your xml so that it may be checked by others. (But I know the thrill of getting it right on my own!! )
-
Hi,
I found some mistakes by myself, yet there still is not everything fine -
Hello @Numetalfan, well I guess things got a little bit confusing. I am very sorry, I should have been clearer in my instructions. I assumed that since you had created 2 new properties, that you understood that properties appear at the end of the xml. That was my bad. So with that out of the way lets get to your xml:
<!-- Infantry --> <attachment name="unitAttachment" attachTo="infantry" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <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"/> <!-- <property name="Unit Placement Restrictions" value="true" editable="false"> Remove --> <!-- <boolean/> Remove --> <!-- </property> Remove --> <!-- </attachment> Remove --> </attachment> <!-- Artillery --> <attachment name="unitAttachment" attachTo="artillery" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="1"/> <option name="transportCost" value="3"/> <option name="attack" value="2"/> <option name="defense" value="2"/> <option name="artillery" value="true"/> <option name="requiresUnits" value="factory"/> <!-- <property name="Unit Placement Restrictions" value="true" editable="false"> Remove --> <!-- <boolean/> Remove --> <!-- </property> Remove --> <!-- </attachment> Remove --> </attachment>
Please note that I am also removing one of the </attachment> tags. Again my bad.
You need to do this for all the units. Next to the Barracks. There are 3 - in the Barracks comment ie: <--- Barracks ---> and it should be only 2:
<!-- Barracks --> <attachment name="unitAttachment" attachTo="barracks" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="isFactory" value="true"/> <!-- </attachment> Remove --> </attachment>
There is also an extra </attachment> tag to remove here also.
Now to properly add that property. Since the two properties you added are not doing anything, we will add the property there:
<!-- <property name="maxBarracksPerTerritory" value="1"/> Remove --> <!-- <property name="Placement Restricted By Barracks" value="true" editable="false"> Remove --> <!-- <boolean/> Remove --> <!-- </property> Remove --> <property name="Unit Placement Restrictions" value="true" editable="false"> <boolean/> </property>
So now lets load and test.
Cheers...
-
@Numetalfan looks like there are more problems. This happens sometimes. The error talks about a missing end properties tag at line 2250. Line 2250 is the bottom of the xml, which means its missing above this line. When you cut and copied the mapName line you replaced a </property> tag. It happens. Its a mistake, and we learn by finding and correcting those errors.
<property name="Neutrals Are Blitzable" value="false" editable="false"> <boolean/> </property> <!-- Add --> <!-- Map Name: must equal file name --> <property name="mapName" value="world_war_ii_v4" editable="false"/>
Now save and run again.
Cheers...