Difference between revisions of "Modding Tutorials/Furniture"

From RimWorld Wiki
Jump to navigation Jump to search
(return link (very helpful))
(Hey, there's a "Defs" category too!)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''[[Modding Tutorials|Back to tutorial index]]'''
+
{{BackToTutorials}}
  
 
Buildings and Furniture are distinct mainly by how tall they are defined. Otherwise, both types of objects are usually usable by colonists. For example, both the Comms Console and the Kitchen Stove are used to perform tasks. But the Comms Console is considered a building because it is taller than a colonist while the Kitchen Stove has a counter that is not as tall as the colonist.
 
Buildings and Furniture are distinct mainly by how tall they are defined. Otherwise, both types of objects are usually usable by colonists. For example, both the Comms Console and the Kitchen Stove are used to perform tasks. But the Comms Console is considered a building because it is taller than a colonist while the Kitchen Stove has a counter that is not as tall as the colonist.
Line 5: Line 5:
 
==Making Furniture Interactive==
 
==Making Furniture Interactive==
  
The first thing most modders want to do when they create new furniture or buildings is to make the object interactive. Interactive objects have a yellow circle indicator that shows where the colonist stands when using the object. If you have completed the Simple Block tutorial open this file again and do the following:
+
The first thing most modders want to do when they create new furniture or buildings is to make the object interactive. Interactive objects have a yellow circle indicator that shows where the colonist stands when using the object.
  
First change the .xml "size" tag to: "(3,2)". This will make your Simple Block the same size as the Comms Console. Don't worry, the texture files don't need to be updated. The image stretch to the new proportion.
+
The [[Modding_Tutorials/Smelter|Smelter]] tutorial is intended to get you started with making interactive buildings that function like work benches.
  
Next add a new .xml tag named "hasInteractionSquare" and give it the value "true". This tells the game that the object has a position where colonists can stand to interact with it. Pretty self-explanatory.
 
  
Finally add a new .xml tag named "interactionSquareOffset". Give it the value "(0,0,2)". Note that there are three coordinates. This is necessary for the Unity game engine used by Rimworld. The object's center is defined as 0, 0, 0 in the x, y, z coordinate system. Although this may be a bit confusing, for now just remember to ignore the middle value and think of the third value as "y". So the value "(0,0,2)" tells the game that the interaction square is offset from the object's center by two squares on the y-axis.
+
==Building XML Codes==
 +
'''Common Stuff (needed for all Buildings):'''
  
This is what the three new lines should look like in .xml:
+
  <nowiki><ThingDef Name="BuildingBase" Abstract="True">
 +
    <category>Building</category>
 +
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
 +
    <selectable>true</selectable>
 +
    <drawerType>MapMeshAndRealTime</drawerType>
 +
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
 +
    <repairEffect>Repair</repairEffect>
 +
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
 +
    <filthLeaving>BuildingRubble</filthLeaving>
 +
  </ThingDef>
 +
</nowiki>
  
  <ThingDef ParentName="BuildingBase">
+
 
  ...
+
 
  <size>(3,2)</size>
+
'''Example Building: Barbed Wire (out of elStrange's DefendThatColony!, modified by Cefwyn):'''
  <hasInteractionSquare>true</hasInteractionSquare>
+
  <nowiki>
  <interactionSquareOffset>(0,0,2)</interactionSquareOffset>
+
<ThingDef ParentName="BuildingBase">
  ...
+
<defName>WallWire</defName>
  </ThingDef>
+
<label>Barbed Wire</label>
 +
<thingClass>Building</thingClass>
 +
<category>Building</category>
 +
<description>[DTC!] A cheap and easy defence system that is impassable</description>
 +
</nowiki>
 +
The above defines a new object 'WallWire' that inherited all previously defined qualities of the object 'BuildingBase' (see above).
 +
In game it will be labeled as 'Barbed Wire', and have the indicated description on mouse-over.
 +
 
 +
<nowiki>
 +
        <rotatable>false</rotatable>
 +
<selectable>true</selectable>
 +
<neverMultiSelect>true</neverMultiSelect>
 +
<placingDraggableDimensions>1</placingDraggableDimensions>
 +
<terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
 +
<designationCategory>Security</designationCategory>
 +
</nowiki>
 +
DesignationCategory defines the in-game tab the new building can be found under
 +
 
 +
<nowiki>
 +
<staticSunShadowHeight>0.5</staticSunShadowHeight>
 +
<constructEffect>ConstructDirt</constructEffect>
 +
<repairEffect>ConstructDirt</repairEffect>
 +
</nowiki>
 +
staticSunShadowHeight defines how much of a shadow the strucure casts ('''Range: 0.0 - 1.0''')
 +
 
 +
<nowiki>
 +
<graphicData>
 +
<texPath>Things/Buildings/BarbedWire_Atlas</texPath>
 +
    <graphicClass>Graphic_Single</graphicClass>
 +
<linkType>CornerFiller</linkType>
 +
    <linkFlags>
 +
    <li>Sandbags</li>
 +
    </linkFlags>
 +
</graphicData>
 +
</nowiki>
 +
New in A11: <br>
 +
<graphicData> opens a new strucure that contains the above parts <br>
 +
<texPath> includes the Path to the texture graphic - either graphic already included in the base game, or alternatively included with the mod <br>
 +
 
 +
<nowiki>
 +
<linkFlags>
 +
  <li>STRUCTURE</li>
 +
</linkFlags>
 +
</nowiki>  
 +
This part defines structures which our Barbed Wire directly connects to. <br>
 +
Options include '''Walls, Sandbags, Rocks''', and more. Just replace STRUCTURE with the desired option. <br> Add another row with <nowiki><li>STRUCTURE</li></nowiki> for each option. <br>
 +
 
 +
 
 +
  <nowiki>
 +
    <blueprintGraphicData>
 +
<texPath>Things/Building/Linked/Sandbags_Blueprint_Atlas</texPath>
 +
</blueprintGraphicData>
 +
</nowiki>
 +
This part is also new in A11, and replaces the previous single-line <nowiki><blueprintgraphicsPath>.</nowiki> <br>
 +
It defines which texture is used to display the planed structure before pawns start building it.
 +
<nowiki>
 +
<uiIconPath>Things/Buildings/BarbedWire_Icon</uiIconPath>
 +
<statBases>
 +
    <MaxHitPoints>250</MaxHitPoints>
 +
    <Beauty>-10</Beauty>
 +
    <WorkToMake>200</WorkToMake>
 +
    <Flammability>0</Flammability>
 +
</statBases>
 +
    <pathCost>500</pathCost>
 +
<passability>Impassable</passability>
 +
<altitudeLayer>FloorEmplacement</altitudeLayer>
 +
<castEdgeShadows>false</castEdgeShadows>
 +
<fillPercent>0.3</fillPercent>
 +
    <costList>
 +
    <WoodLog>1</WoodLog>
 +
    <Steel>1</Steel>
 +
</costList>
 +
</ThingDef>
 +
</nowiki>
 +
 
 +
[[Category:Modding tutorials]][[Category:Modding]][[Category:Defs]]

Latest revision as of 14:45, 29 November 2018

Modding Tutorials

Buildings and Furniture are distinct mainly by how tall they are defined. Otherwise, both types of objects are usually usable by colonists. For example, both the Comms Console and the Kitchen Stove are used to perform tasks. But the Comms Console is considered a building because it is taller than a colonist while the Kitchen Stove has a counter that is not as tall as the colonist.

Making Furniture Interactive[edit]

The first thing most modders want to do when they create new furniture or buildings is to make the object interactive. Interactive objects have a yellow circle indicator that shows where the colonist stands when using the object.

The Smelter tutorial is intended to get you started with making interactive buildings that function like work benches.


Building XML Codes[edit]

Common Stuff (needed for all Buildings):

 <ThingDef Name="BuildingBase" Abstract="True">
    <category>Building</category>
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
    <selectable>true</selectable>
    <drawerType>MapMeshAndRealTime</drawerType>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <repairEffect>Repair</repairEffect>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <filthLeaving>BuildingRubble</filthLeaving>
  </ThingDef>


Example Building: Barbed Wire (out of elStrange's DefendThatColony!, modified by Cefwyn):

<ThingDef ParentName="BuildingBase">
	<defName>WallWire</defName>
	<label>Barbed Wire</label>
	<thingClass>Building</thingClass>
	<category>Building</category>
	<description>[DTC!] A cheap and easy defence system that is impassable</description>
 

The above defines a new object 'WallWire' that inherited all previously defined qualities of the object 'BuildingBase' (see above). In game it will be labeled as 'Barbed Wire', and have the indicated description on mouse-over.

        <rotatable>false</rotatable>
	<selectable>true</selectable>
	<neverMultiSelect>true</neverMultiSelect>
	<placingDraggableDimensions>1</placingDraggableDimensions>
	<terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
	<designationCategory>Security</designationCategory>
 

DesignationCategory defines the in-game tab the new building can be found under

	<staticSunShadowHeight>0.5</staticSunShadowHeight>
	<constructEffect>ConstructDirt</constructEffect>
	<repairEffect>ConstructDirt</repairEffect>
 

staticSunShadowHeight defines how much of a shadow the strucure casts (Range: 0.0 - 1.0)

	<graphicData>
		<texPath>Things/Buildings/BarbedWire_Atlas</texPath>
    		<graphicClass>Graphic_Single</graphicClass>
		<linkType>CornerFiller</linkType>
    		<linkFlags>
     			<li>Sandbags</li>
    		</linkFlags>
	</graphicData> 
 

New in A11:
<graphicData> opens a new strucure that contains the above parts
<texPath> includes the Path to the texture graphic - either graphic already included in the base game, or alternatively included with the mod

 
 <linkFlags>
   <li>STRUCTURE</li>
 </linkFlags>
 

This part defines structures which our Barbed Wire directly connects to.
Options include Walls, Sandbags, Rocks, and more. Just replace STRUCTURE with the desired option.
Add another row with <li>STRUCTURE</li> for each option.


    	<blueprintGraphicData>
		<texPath>Things/Building/Linked/Sandbags_Blueprint_Atlas</texPath>
	</blueprintGraphicData>
 

This part is also new in A11, and replaces the previous single-line <blueprintgraphicsPath>.
It defines which texture is used to display the planed structure before pawns start building it.

	<uiIconPath>Things/Buildings/BarbedWire_Icon</uiIconPath>
	<statBases>
     		<MaxHitPoints>250</MaxHitPoints>
     		<Beauty>-10</Beauty>
     		<WorkToMake>200</WorkToMake>
     		<Flammability>0</Flammability>
	</statBases>
    	<pathCost>500</pathCost>
	<passability>Impassable</passability>
	<altitudeLayer>FloorEmplacement</altitudeLayer>
	<castEdgeShadows>false</castEdgeShadows>
	<fillPercent>0.3</fillPercent>
    	<costList>
     		<WoodLog>1</WoodLog>
     		<Steel>1</Steel>
	</costList>
</ThingDef>