-
Notifications
You must be signed in to change notification settings - Fork 5
1.3 An Example
This section of the document will quickly go through the creation of the XML for the Machine Gun Emplacement in TE Turret Expansion, a mod which utilises the framework extensions offered by Turret Extensions.
First off, we must create the actual turret building ThingDef. For now, we'll do a standard non-TE def which looks like this:
<ThingDef ParentName="BuildingBase">
<defName>Turret_MGEmplacement</defName>
<label>machine gun emplacement</label>
<description>A fixed gun emplacement with a heavy machine gun mounted on top. Has good power and good range, but poor accuracy and a slower rate of fire.</description>
<thingClass>Building_TurretGun</thingClass>
<statBases>
<MaxHitPoints>300</MaxHitPoints>
<Flammability>0.7</Flammability>
<WorkToBuild>6000</WorkToBuild>
<Beauty>-20</Beauty>
</statBases>
<uiIconPath>Things/Building/Security/MachineGunEmplacement_MenuIcon</uiIconPath>
<uiIconScale>0.90</uiIconScale>
<constructionSkillPrerequisite>6</constructionSkillPrerequisite>
<researchPrerequisites>
<li>GasOperation</li>
</researchPrerequisites>
<terrainAffordanceNeeded>Heavy</terrainAffordanceNeeded>
<designationCategory>Security</designationCategory>
<costList>
<Steel>100</Steel>
<ComponentIndustrial>6</ComponentIndustrial>
</costList>
<costStuffCount>110</costStuffCount>
<stuffCategories>
<li>Metallic</li>
</stuffCategories>
<placeWorkers>
<li>PlaceWorker_TurretTop</li>
<li>PlaceWorker_ShowTurretRadius</li>
</placeWorkers>
<graphicData>
<texPath>Things/Building/Security/MachineGunEmplacement/MachineGunEmplacement</texPath>
<graphicClass>Graphic_Multi</graphicClass>
<drawSize>(3.5,1.5)</drawSize>
<damageData>
<cornerTL>Damage/Corner</cornerTL>
<cornerTR>Damage/Corner</cornerTR>
<cornerBL>Damage/Corner</cornerBL>
<cornerBR>Damage/Corner</cornerBR>
</damageData>
</graphicData>
<altitudeLayer>Building</altitudeLayer>
<tickerType>Normal</tickerType>
<comps>
<li Class="CompProperties_Mannable">
<manWorkType>Violent</manWorkType>
</li>
<li Class="CompProperties_Forbiddable"/>
<li Class="CompProperties_Refuelable">
<fuelLabel>Shots until barrel change</fuelLabel>
<fuelGizmoLabel>Barrel durability</fuelGizmoLabel>
<fuelFilter>
<thingDefs>
<li>Steel</li>
</thingDefs>
</fuelFilter>
<fuelCapacity>300</fuelCapacity>
<initialFuelPercent>1</initialFuelPercent>
<autoRefuelPercent>0.25</autoRefuelPercent>
<showFuelGizmo>true</showFuelGizmo>
<fuelMultiplier>6</fuelMultiplier>
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
<outOfFuelMessage>Cannot shoot: Needs new barrel</outOfFuelMessage>
<fuelIconPath>UI/Overlays/Barrel</fuelIconPath>
</li>
</comps>
<passability>PassThroughOnly</passability>
<pathCost>50</pathCost>
<size>(3,1)</size>
<hasInteractionCell>True</hasInteractionCell>
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
<fillPercent>0.57</fillPercent>
<castEdgeShadows>true</castEdgeShadows>
<hasTooltip>true</hasTooltip>
<building>
<turretGunDef>Gun_TurretMGEmplacement</turretGunDef>
<turretBurstCooldownTime>3.6</turretBurstCooldownTime>
<turretBurstWarmupTime>1.8</turretBurstWarmupTime>
</building>
</ThingDef>
Now that the standard building def has been created for the machine gun emplacement, it's possible to have it actually utilise the framework extensions offered by Turret Extensions.
In this particular building's case, it was given the firingArc
and affectedByEMP
tags, since I didn't want this manned turret to have full 360-degree coverage and it doesn't use electricity so it doesn't make sense for EMP to affect it.
The following XML was added to the end of the ThingDef as a result:
<modExtensions>
<li Class="TurretExtensions.TurretFrameworkExtension">
<firingArc>180</firingArc>
<affectedByEMP>false</affectedByEMP>
</li>
</modExtensions>
Now that the manned turret modifications have been made, this is what the entire XML for the turret looks like when everything gets tied together:
<ThingDef ParentName="BuildingBase">
<defName>Turret_MGEmplacement</defName>
<label>machine gun emplacement</label>
<description>A fixed gun emplacement with a heavy machine gun mounted on top. Has good power and good range, but poor accuracy and a slower rate of fire.</description>
<thingClass>Building_TurretGun</thingClass>
<statBases>
<MaxHitPoints>300</MaxHitPoints>
<Flammability>0.7</Flammability>
<WorkToBuild>6000</WorkToBuild>
<Beauty>-20</Beauty>
</statBases>
<uiIconPath>Things/Building/Security/MachineGunEmplacement_MenuIcon</uiIconPath>
<uiIconScale>0.90</uiIconScale>
<constructionSkillPrerequisite>6</constructionSkillPrerequisite>
<researchPrerequisites>
<li>GasOperation</li>
</researchPrerequisites>
<terrainAffordanceNeeded>Heavy</terrainAffordanceNeeded>
<designationCategory>Security</designationCategory>
<costList>
<Steel>100</Steel>
<ComponentIndustrial>6</ComponentIndustrial>
</costList>
<costStuffCount>110</costStuffCount>
<stuffCategories>
<li>Metallic</li>
</stuffCategories>
<placeWorkers>
<li>PlaceWorker_TurretTop</li>
<li>PlaceWorker_ShowTurretRadius</li>
</placeWorkers>
<graphicData>
<texPath>Things/Building/Security/MachineGunEmplacement/MachineGunEmplacement</texPath>
<graphicClass>Graphic_Multi</graphicClass>
<drawSize>(3.5,1.5)</drawSize>
<damageData>
<cornerTL>Damage/Corner</cornerTL>
<cornerTR>Damage/Corner</cornerTR>
<cornerBL>Damage/Corner</cornerBL>
<cornerBR>Damage/Corner</cornerBR>
</damageData>
</graphicData>
<altitudeLayer>Building</altitudeLayer>
<tickerType>Normal</tickerType>
<comps>
<li Class="CompProperties_Mannable">
<manWorkType>Violent</manWorkType>
</li>
<li Class="CompProperties_Forbiddable"/>
<li Class="CompProperties_Refuelable">
<fuelLabel>Shots until barrel change</fuelLabel>
<fuelGizmoLabel>Barrel durability</fuelGizmoLabel>
<fuelFilter>
<thingDefs>
<li>Steel</li>
</thingDefs>
</fuelFilter>
<fuelCapacity>300</fuelCapacity>
<initialFuelPercent>1</initialFuelPercent>
<autoRefuelPercent>0.25</autoRefuelPercent>
<showFuelGizmo>true</showFuelGizmo>
<fuelMultiplier>6</fuelMultiplier>
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
<outOfFuelMessage>Cannot shoot: Needs new barrel</outOfFuelMessage>
<fuelIconPath>UI/Overlays/Barrel</fuelIconPath>
</li>
<li Class="TurretExtensions.CompProperties_SmartForcedTarget"/>
</comps>
<passability>PassThroughOnly</passability>
<pathCost>50</pathCost>
<size>(3,1)</size>
<hasInteractionCell>True</hasInteractionCell>
<interactionCellOffset>(0,0,-1)</interactionCellOffset>
<fillPercent>0.57</fillPercent>
<castEdgeShadows>true</castEdgeShadows>
<hasTooltip>true</hasTooltip>
<building>
<turretGunDef>Gun_TurretMGEmplacement</turretGunDef>
<turretBurstCooldownTime>3.6</turretBurstCooldownTime>
<turretBurstWarmupTime>1.8</turretBurstWarmupTime>
</building>
<modExtensions>
<li Class="TurretExtensions.TurretFrameworkExtension">
<firingArc>180</firingArc>
<affectedByEMP>false</affectedByEMP>
</li>
</modExtensions>
</ThingDef>
And that concludes how to make a turret use TurretFrameworkExtension
!
To learn how to make a turret upgradable, see here.
1 - Basic Framework Extension
1.1 - Introduction
1.2 - Properties
1.3 - An Example
2 - Upgradability
2.1 - Introduction
2.2 - Properties
2.3 - An Example
3 - Miscellaneous
3.1 - Smarter Forced Targeting