Missile-Armed Helicopter

CivOasis

Ahuizotl
Joined
Jun 22, 2011
Messages
3,005
Location
Sawaiki
I'm creating a small, one unit mod which *hopefully* adds a version of the helicopter gunship which can carry guided missiles (hopefully means it will probably carry nukes, too, though I'd rather it didn't). The logic behind this is as a sort of mobile missile launcher for terrestrial civs, especially those that aren't capable of launching a missile anywhere on the map (OCC's, for example).

This is the code for the Helicopter Gunship:
Spoiler :
<Row>
<Class>UNITCLASS_HELICOPTER_GUNSHIP</Class>
<Type>UNIT_HELICOPTER_GUNSHIP</Type>
<PrereqTech>TECH_ROCKETRY</PrereqTech>
<Combat>50</Combat>
<Cost>500</Cost>
<Moves>6</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_HELICOPTER_GUNSHIP</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_HELICOPTERGUNSHIP_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_HELICOPTER_GUNSHIP_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_HELICOPTER_GUNSHIP</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<AdvancedStartCost>60</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<UnitArtInfo>ART_DEF_UNIT_HELICOPTER_GUNSHIP</UnitArtInfo>
<UnitFlagIconOffset>75</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>28</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>

And this is the code for my MA Helicopter:
Spoiler :
<GameData>
<Row>
<Class>UNITCLASS_HELICOPTER_GUNSHIP</Class>
<Type>UNIT_MA_HELICOPTER</Type>
<PrereqTech>TECH_ROCKETRY</PrereqTech>
<Combat>30</Combat>
<Cost>400</Cost>
<Moves>6</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_HELICOPTERGUNSHIP_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_HELICOPTER_GUNSHIP_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_HELICOPTER_GUNSHIP</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<AdvancedStartCost>60</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<SpecialCargo>SPECIALUNIT_MISSILE</SpecialCargo>
<DomainCargo>DOMAIN_AIR</DomainCargo>
<UnitArtInfo>ART_DEF_UNIT_HELICOPTER_GUNSHIP</UnitArtInfo>
<UnitFlagIconOffset>75</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>28</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>
</GameData>

Any tips/suggestions? I currently can't get it to run ingame, if anyone can figure out whats wrong, I'd appreciate the information.
For those who don't want to sort through the code,
Helicopter gunship: 50 combat, 500 cost
MA Helicopter: 30 combat, 400 cost, can carry missiles.
The missile code was taken from the Missile Cruiser.
 
Hi CivOasis,

Good idea :goodjob: , but there are several other things that you need to do:

- if you simply modified the existing chopper, you would also need to scroll down the Units.xml to Promotions section and add a promotion so that chopper can carry cargo. Check the promotion which Aircraft Carrier receives, smth like CARGO_III. Give similar promotion to the chopper. Check UnitPromotions.xml to check what promotions exist.

- you add a new unit, so on top of what I described above, you also need to do these:

-- in your entry: set <Class>UNITCLASS_MA_HELICOPTER</Class> - I think, but not sure, that you must declare your unit under a new unit class

-- you are missing some tags in your XML. It should be:
<GameData>
<Units>
<Row>
<Class>UNITCLASS_MA_HELICOPTER</Class>
...etc...
</Row>
</Units>
...rest of XML...
</GameData>

-- similar to what is done in UnitClasses.xml, you need to add:
<UnitClasses>
<Row>
<Type>UNITCLASS_MA_HELICOPTER</Type>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<DefaultUnit>UNIT_MA_HELICOPTER</DefaultUnit>
</Row>
</UnitClasses>

-- now you're almost there but your unit uses text from standard chopper.

elements like TXT_KEY_UNIT_HELICOPTER_GUNSHIP_STRATEGY define text strings associated with your unit. Add to your XML things like:

<Language_en_US>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER_STRATEGY">
<Text>Strategy: nuke 'em and run!!!</Text>
</Row>
</Language_en_US>

original text lines are in XML/NewText/EN_US/Civ5GameTextInfos_Units.xml.

This should be it, I hope I didn't forget anything. Let me know if you still have problems!
 
No, It still isn't working, but I think I may have put parts in the wrong places. This is what it looks like now:
Spoiler :
<GameData>
<Units>
<Row>
<Class>UNITCLASS_MA_HELICOPTER</Class>
<Type>UNIT_MA_HELICOPTER</Type>
<PrereqTech>TECH_ROCKETRY</PrereqTech>
<Combat>30</Combat>
<Cost>400</Cost>
<Moves>6</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MA_HELICOPTER_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_MA_HELOCOPTER_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_MA_HELICOPTER</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<AdvancedStartCost>60</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<SpecialCargo>SPECIALUNIT_MISSILE</SpecialCargo>
<DomainCargo>DOMAIN_AIR</DomainCargo>
<UnitArtInfo>ART_DEF_UNIT_HELICOPTER_GUNSHIP</UnitArtInfo>
<UnitFlagIconOffset>75</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>28</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>
</Units>
<Unit_FreePromotion>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_CARGO_III</PromotionType>
</Unit_FreePromotion>
<UnitClasses>
<Row>
<Type>UNITCLASS_MA_HELICOPTER</Type>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<DefaultUnit>UNIT_MA_HELICOPTER</DefaultUnit>
</Row>
</UnitClasses>
<Language_en_US>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER_STARTEGY">
<Text>Strategy: A helicopter capable of carrying missiles, great for quick strikes or small, distant empires. Think of it as a terrestrial Missile Carrier.</Text>
</Row>
</Language_en_US>
</GameData>

Am I still missing something, or did I just mess up?
 
I have highlights in Red things which you need to add or correct. It seems, you don't have the correct tools for work though ;). I suggest you get Notepad++ and some file search engine, I use free Copernicus Desktop.

Text keys TXT_KEY_UNIT_MA_HELICOPTER_STRATEGY should be exactly the same everywhere, you have some typos in them. It's much beter if you copy-paste them from place to place, instead of retyping. In Notepad++ you can select the whole word by double-clicking, which makes it very easy.

<GameData>
<Units>
<Row>
<Class>UNITCLASS_MA_HELICOPTER</Class>
<Type>UNIT_MA_HELICOPTER</Type>
<PrereqTech>TECH_ROCKETRY</PrereqTech>
<Combat>30</Combat>
<Cost>400</Cost>
<Moves>6</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MA_HE LICOPTER_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_MA_HELOCOPTER_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_MA_HELICOPTER</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<AdvancedStartCost>60</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<SpecialCargo>SPECIALUNIT_MISSILE</SpecialCargo>
<DomainCargo>DOMAIN_AIR</DomainCargo>
<UnitArtInfo>ART_DEF_UNIT_HELICOPTER_GUNSHIP</UnitArtInfo>
<UnitFlagIconOffset>75</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>28</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>
</Units>

<Unit_FreePromotions>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_CARGO_III</PromotionType>
</Unit_FreePromotions>

<UnitClasses>
<Row>
<Type>UNITCLASS_MA_HELICOPTER</Type>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<DefaultUnit>UNIT_MA_HELICOPTER</DefaultUnit>
</Row>
</UnitClasses>

<Language_en_US>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER_STARTEGY">
<Text>Strategy: A helicopter capable of carrying missiles, great for quick strikes or small, distant empires. Think of it as a terrestrial Missile Carrier.</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER">
<Text>ADD TEXT</Text>
</Row>
<Row Tag="TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MA_HELICOPTER_TEXT">
<Text>ADD TEXT</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_HELP_MA_HELICOPTER">
<Text>ADD TEXT</Text>
</Row>

</Language_en_US>
</GameData>
 
Another mistake:

<Unit_FreePromotions>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_CARGO_III</PromotionType>
</Unit_FreePromotions>

has no <Row> declaration. It needs to be
Code:
<Unit_FreePromotions>
  <Row>
    <UnitType>UNIT_MA_HELICOPTER</UnitType>
    <PromotionType>PROMOTION_CARGO_III</PromotionType>
  </Row>
</Unit_FreePromotions>

Now, you don't HAVE to create a new unit class. If you don't, then it'll share the same class as the regular gunship, and you'll only be able to have one or the other (based on the Civilization_UnitClassOverrides table and the DefaultUnit declaration in the Unit Class).

You're also missing several other tables, most notably the unit AI table, the unit upgrade table, the unit Flavors table, and the resource requirements table. You need to add entries for each of these for your unit.
 
Ok, its still not running (In case it wasn't obvious, I'm new to modding)
Now, I have:
Spoiler :
<GameData>
<Units>
<Row>
<Class>UNITCLASS_MA_HELICOPTER</Class>
<Type>UNIT_MA_HELICOPTER</Type>
<PrereqTech>TECH_ROCKETRY</PrereqTech>
<Combat>30</Combat>
<Cost>400</Cost>
<Moves>6</Moves>
<CombatClass>UNITCOMBAT_HELICOPTER</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_FAST_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MA_HELICOPTER_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_MA_HELICOPTER_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_MA_HELICOPTER</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<AdvancedStartCost>60</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<SpecialCargo>SPECIALUNIT_MISSILE</SpecialCargo>
<DomainCargo>DOMAIN_AIR</DomainCargo>
<UnitArtInfo>ART_DEF_UNIT_HELICOPTER_GUNSHIP</UnitArtInfo>
<UnitFlagIconOffset>75</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>28</PortraitIndex>
<MoveRate>WHEELED</MoveRate>
</Row>
</Units>
<Unit_FreePromotions>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_CARGO_III</PromotionType>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_IGNORE_TERRAIN_COST</PromotionType>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_HOVERING_UNIT</PromotionType>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_ANTI_TANK</PromotionType>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_NO_DEFENSIVE_BONUSES</PromotionType>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<PromotionType>PROMOTION_NO_CAPTURE</PromotionType>
</Row>
</Unit_FreePromotions>
<UnitClasses>
<Row>
<Type>UNITCLASS_MA_HELICOPTER</Type>
<Description>TXT_KEY_UNIT_MA_HELICOPTER</Description>
<DefaultUnit>UNIT_MA_HELICOPTER</DefaultUnit>
</Row>
</UnitClasses>
<Unit_AITypes>
<Row>
<UnitType>UNIT_HELICOPTER_GUNSHIP</UnitType>
<UnitAIType>UNITAI_FAST_ATTACK</UnitAIType>
</Row>
</Unit_AITypes>
<Unit_Flavors>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<FlavorType>FLAVOR_OFFENSE</FlavorType>
<Flavor>10</Flavor>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<FlavorType>FLAVOR_DEFENSE</FlavorType>
<Flavor>8</Flavor>
</Row>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<FlavorType>FLAVOR_AIR</FlavorType>
<Flavor>12</Flavor>
</Row>
</Unit_Flavors>
<Unit_ResourceQuantityRequirements>
<Row>
<UnitType>UNIT_MA_HELICOPTER</UnitType>
<ResourceType>RESOURCE_ALUMINUM</ResourceType>
</Row>
</Unit_ResourceQuantityRequirements>
<Language_en_US>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER_STRATEGY">
<Text>Strategy: A helicopter capable of carrying missiles, great for quick strikes or small, distant empires. Think of it as a terrestrial Missile Carrier.</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_MA_HELICOPTER">
<Text>Missile Armed Helicopter</Text>
</Row>
<Row Tag="TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MA_HELICOPTER_TEXT">
<Text>Weaker version of the Helicopter Gunship, capable of carrying missiles for quick, mobile strikes.</Text>
</Row>
<Row Tag="TXT_KEY_UNIT_HELP_MA_HELICOPTER">
<Text>Helicopter Gunship that can carry missiles.</Text>
</Row>
</Language_en_US>
</GameData>

I don't have the upgrade path (not sure where that is), but, then again, its not supposed to upgrade, so does that matter?
It's not supposed to replace the Gunship, because its supposed to have a different role.
Lastly, I put the Gunship's AI in, but I don't think the AI will be able to use the unit properly, because there are no other terrestrial carriers (unless there's an AI for cities, I'm not sure where that would be, either).
I also added the other promotions for the gunship, they were missing before.
What else could be missing?
It does show the mod in my list of mods, but the unit doesn't actually appear.
 
By the way, both of you are going into my thanks section for this, I appreciate the help.
 
What else could be missing?

The obvious one is this:
OnModActivated/UpdateDatabase
If you have no idea what that meant, then that's the problem.

Also, what have the debugging files told you? That is, the log files will tell you when there's an error in XML during a game load, and FireTuner will sometimes tell you if something's wrong. If you're not enabling those sorts of debugging tools, then go do that first. If it's something trivial like a misspelled variable, that'll catch it.

If you have a question about something like this, it REALLY helps if you attach the files to your post so that we can look at this ourselves.

And one other thing: you posted this in the wrong forum. Questions go in the main C&C forum, these subfora are supposed to ONLY be for completed file packages. (If you'd attached the files to your original post then it might have been okay, and once you get it working you SHOULD attach the files to the original post and rewrite it to explain that you've made a new component mod.)
 
OK, It should be attached as a zip version of the folder.
And, yeah, I figured out this was in the wrong place after I posted this mod and another incomplete mod in the new civiliaztions section... probably annoyed the moderators, but I imagine it will be fine as soon as I finish them, so long as I don't do it again.
 

Attachments

Whoops, I think that was more than just the build folder, but there's only one file, so I think it should still be fine.
 
Okay, the problem is that you never turned on the XML. That's the OnModActivated/UpdateDatabase command I mentioned before. Without that, the game will just ignore any XML you made.

In ModBuddy, go to the mod's Properties. Go to the Actions Tab (the fourth one).

In the first column, put "OnModActivated"
In the second column, put "UpdateDatabase"
In the third column, put the file name of the XML file to be loaded (in this case, "MA_Helicopter.xml"). Note that this filename needs to include the path relative to the mod's root directory, so if you'd created subdirectories for the XMLs then you'd include those there. But since you didn't, don't worry about that.
 
Yep, it's running now.
Properly carries 3 missiles, and can attack on its own (though I think it is the weakest modern-era unit by 10 points, which is good for what its meant to do).
 
Glad to hear it's working now :). One last thing I noticed in your XML file is this:
Code:
	<Unit_AITypes>
		<Row>
			<UnitType>UNIT_HELICOPTER_GUNSHIP</UnitType>
			<UnitAIType>UNITAI_FAST_ATTACK</UnitAIType>
		</Row>
	</Unit_AITypes>

You should put your MA_HELICOPTER there. That would make AI know that it should use your MA helicopter the same way as it does helicopter gunship (behavior defined by UNITAI_FAST_ATTACK). The entry for HELICOPTER_GUNSHIP already exists in original Civ5Units.xml.

Go to Tools/Online Services in ModBuddy to post it on the mod hub if you want to.
 
Back
Top Bottom