Trying to make simple mod to C-NAW but not working

Commander - Napoleon at War is a turn based strategy game that brings gaming back to its roots - it's fun!

Moderators: Slitherine Core, The Lordz

Post Reply
blindsey
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 49
Joined: Fri May 28, 2010 3:50 pm
Location: Washington, DC

Trying to make simple mod to C-NAW but not working

Post by blindsey »

Hi, I am a lurker who has been playing war games for decades and Slitherine/Matrix/Lordz games for years and I rarely post to forums. My favorite all time game is Panzer General 2, so of course I had to buy and play Panzer Corps with all of the DLC (I am impatiently waiting for '42).

However, I love Commander - Napoleon at War! It is a true gem. I have talked friends into buying it. I highly recommend this one, it is perfect for fast play with just the right balance of economy/research, mixed arms, upgrading units with traits and leaders, sea and land battles, convoy raiding, historical, etc. (While I like C-EaW, I find it takes too long, is more complex/complicated and difficult to recover after an early strategic blunder. And while I will buy and try the WWI version when it comes out, I am not a huge fan of that era. I would really, really love to see an American Civil War version using the Napoleon engine and if one isn't forthcoming I would mod one if I had the ability and time. Johan, if you need help on Commander - American Civil War, please let me know.)

I am a history major. I am a very basic self-taught modder with no real programming education, just trial and error. I have successfully modded other similar games, like Panzer General 2 into Napoleon General, but editor tools exist (and I understand one may not be forthcoming for C-NaW).

I am trying to mod C-NaW without any luck. I first tried adding guard units, but that didn't work and I started thinking that was a bad idea as the AI could buy a ton of them so I changed focus and now I am trying to add a few new "land leader" attachments, for the French Old, Middle and Young Imperial Guards. Instead of Leadership they would boost Ground Attack and Defense stats (0-3-3, 0-2-2, 0-1-1). If they worked I wanted to add some special unit attachments and leaders to other countries.

This seemed simple enough. Using a text editor (I typically use TextPad, but I have EditPad Pro 7) I added the guard units to the land_leader.txt file and I added their descriptions to the messages_eng.txt file. I used some of the artwork from the images folder to create the sets of 3 PNG files (37, 64 and 126) for each unit in the Data\Commander subfolder. I used a clean install and I deleted the data folder created during game initialization from my My Documents folder. I thought that would be all it took, however when I run the game it freezes on the first start up splash screen (I tried disabling these in the settings.txt file without luck). I am not familiar with Java and I don't understand the error messages, so I don't know if I made a mistake in the text files or images, or if there is some other file I need to hack, or if I have to do additional hacking of class files, etc, (I have done that a little in the past). I used Ultimate Paint to make the images but can't tell from the error messages if it is them causing the problem(s).

Having played the scenarios several times against the AI (I prefer to play against AI versus people), I would love to modify this game. I know this isn't Johan Persson main thrust (I assume he is polishing WWI) so I didn't want to bother him by emailing him directly, so I was hoping someone here could help me. I use Windows Vista Business on a built-by-me gaming PC. Any and all comments and suggestions are highly appreciated. My added code and the error messages are below:

land_leader.txt:
france oldgrdinf Old_Guard_Infantry 0 3 3 90 1291
france midgrdinf Middle_Guard_Infantry 0 2 2 60 1292
france ynggrdinf Young_Guard_Infantry 0 1 1 30 1203
france artguard Guard_Artillery 0 3 0 45 1294
france oldgrdcav Old_Guard_Cavalry 0 3 2 75 1295
france midgrdcav Middle_Guard_Cavalry 0 2 1 50 1296
france ynggrdcav Young_Guard_Cavalry 0 1 1 25 1297


messages_eng.txt:
INDEX-1291| "Grenadiers a Pied de la Garde Imperiale (Heavy Infantry)

The Old Guard:
The men of the Old Guard were hand-picked men, who wore ellegant uniforms with tall bearskin hats and were armed with the best weapons. All other regiments were ordered to halt and present arms when they were passing.
- 1st Regiment of the Foot Grenadiers of the Imperial Guard: 1er Regiment Grenadiers a Pied de la Garde Imperiale. Nickname: The Grumblers. It was the senior regiment in Napoleon's Guard infantry.
- 1st Regiment of the Foot Chasseurs of the Imperial Guard: 1er Regiment Chasseurs a Pied de la Garde Imperiale. It was the second regiment in seniority in the Guard infantry."

INDEX-1292| "Grenadiers a Pied de la Garde Imperiale (Heavy Infantry)

The Middle Guard:
- 2nd, 3rd and 4th Regiment of Foot Grenadiers of the Imperial Guard.
- The 2nd, 3rd and 4th Regiment of Foot Chasseurs of the Imperial Guard.
- Regiment of Fusilier-Grenadiers.
- Regiment of Fusiliers-Chasseurs.
Officially they were the Old Guard although everyone called them the Middle Guard."


INDEX-1293| "Grenadiers a Pied de la Garde Imperiale (Light Infantry)

The Young Guard:
- 1st-18th Regiments of Tirauliers of the Imperial Guard.
- 1st-18th Regiments of Voltigeurs of the Imperial Guard.
The taller recruits went into the Tirauliers and the shorter went into the Voltigeurs. Their officers were from the Old Guard and their NCOs from the Middle Guard. There were also a Regiment of Flanquers-Grenadiers and a Regiment of Flanques-Chasseurs; both troops enjoyed the status of the Young Guard."

INDEX-1294| "Artillerie de la Garde Impériale (Artillery)

The main attack against a selected point of the enemy's line began with the guard artillery riding out in front of the infantry, unlimbering at less than 500 meters away from the enemy and opening a furious fire. It was customary for the gunners of the guard to boldly handle their weapons. This intensive bombardment battered a breach into which the cavalry or infantry could plunge into."

INDEX-1295| "Cavalerie de la Garde Imperiale (Heavy Cavalry)

Old Guard:
- Regiment of Horse Grenadiers of the Imperial Guard (Grenadier à Cheval de la Garde Impériale). Nicknames: The High Heels, The Gods. The senior regiment in Napoleon's guard cavalry. In 1815 they were the last regiment of the entire guard that was disbanded.
- Regiment of Horse Chasseurs of the Imperial Guard (Chasseur à Cheval de la Garde Impériale). They were Napoleon's escort and for this reason were probably the most popular regiment in the army. Nickname: The Pet Children.
- 1st Regiment of Lighthorse-Lancers of the Imperial Guard (Polish) (1ere Chevau-Légers Lanciers Polonais de la Garde Impériale).
- Regiment of Empress Dragoons.
- Mamelukes.
- officers and NCOs of the Middle Guard.
- officers of the Young Guard."

INDEX-1296| "Cavalerie de la Garde Imperiale (Medium Cavalry-Lancers)

Middle Guard:
- 2nd Regiment of Lighthorse-Lancers of the Imperial Guard (Dutch), 2eme Chevau-Légers Lanciers de la Garde Impériale.
Nick Name: The Red Lancers. These young soldiers suffered badly in Russia where the Cossacks hunted them mercilessly. After 1812 they were rebuild using the cavalry of the Guard of Paris, volunteers, and King Joseph's (Napoleon's brother) guard. In 1815 it was no longer a Dutch unit but almost entirely French. They performed well during the Campaign of 1815.
- officers of the Young Guard"

INDEX-1297| "Cavalerie de la Garde Imperiale (Light Cavalry)

Young Guard:
Squadrons of Velites in every guard regiment. In the following years the number of regiments in the Young Guard were increased by the regiments of Gardes de Honneur and regiments of Eclaireurs.
- The 1st Regiment was formed of the Garde d'Honneur.
- The 2nd Regiment was formed of Postilions.
- The 3rd Regiment was formed of the Poles collected in Sedan and from the 4th, 6th and 7th squadrons of the 1st Reg. of Lighthorse-Lancers of the Guard.
- Elite Gendarmes of the Guard (Gendarmerie d'Élite de la Garde Impériale)
- Eclaireurs of the Guard (Eclaileurs de la Garde Impériale)"

From command prompt error message window:

java.lang.ArrayIndexOutOfBoundsException: 156
at game.LandLeadersData.getName(LandLeadersData.java:115)
at game.Country._$17304(Country.java:904)
at game.Country.<init>(Country.java:86)
at game.Game.<init>(Game.java:125)
at gui.MainMenu._$7937(MainMenu.java:105)
at gui.MainMenu.<init>(MainMenu.java:96)
at gui.TheScreen._$7937(TheScreen.java:78)
at gui.TheScreen.<init>(TheScreen.java:36)
at CNAW.main(CNAW.java:194)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at gui.MainMenu.paintComponent(MainMenu.java:314)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "Thread-3" java.lang.NullPointerException
at game.MediaTrackerThread.run(MediaTrackerThread.java:783)
blindsey
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 49
Joined: Fri May 28, 2010 3:50 pm
Location: Washington, DC

Post by blindsey »

I figured out the problem. You have to modify both the land_leader.txt and land_leader_eng.txt files in the \data folder, and include the new graphics in the images\commanders folder. I was trying to set Leadership, Attack, Defense AND Cost all in the land_leader.txt file, but (I suspect, I haven't tested changing build time or costs yet) the number of turns to build (1) and the cost factor (10) (and I believe the actual cost is computed using a formula in the unit.class file) are set in the land_leader_eng.txt file and the leadership, Attack and Defense are set in the land_leader.txt file. So I now have my Guards attachments. I need better graphics with the actual uniforms for the Old, Middle and New Gds Inf, Cav and Art units, but the concept works. So adding new leaders or unit attachments is not difficult. If anyone is interested, I could zip and upload the edited text files and the image files I am currently using to test it yourself. Remember, after you replace and add the new files you have to delete the data folder from your documents\C-NaW folder and start a new game for the new attachments to show up in the purchase window. Remember to always backup your files before you start modding.

Example:

land_leader.txt:
Country Data Translation Leadership GrdAtt GrdDef Cost Bio
france napoleon Napoleon 10 2 3 0 501
france oldgrdinf Old_Guard_Infantry 0 3 3 0 1291

land_leader_eng.txt
Country Data Translation Leadership Attack Defence Cost Biography
france napoleon Napoleon 1 0 0 10 501
france oldgrdinf Old_Guard_Infantry 1 0 0 10 1291

Adding new units on the other hand (after a layman's examination of the various .class files) looks to be a bit more difficult as I think you have to build a new class file for your new type of unit (there are currently 24 unit class files) and add it into a bunch of other files.
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil »

Glad you got it working - we dont have any developer support for this game any more as they no longer exist so we do what we can but are limited!
Post Reply

Return to “Commander - Napoleon at War”