Mod Categories, eTypes, and Turrets

Started by SkyeRangerDelta, February 16, 2015, 05:02:54 PM

Previous topic - Next topic

SkyeRangerDelta

Hello RimWorld players,
I'm in the midst of attempting to develop a mod (SkyeRanger Colony Defenses), and I can't seem to find any type of list that sepcifies what the categories for an object are. The wiki at (http://rimworldwiki.com/wiki/Modding_Tutorials/Getting_Started) just spits out info for a block that I can't even get to work.

As of right now, I understand XML, Mod File Structure, and Using Dev Mode in-game. All I have yet to do is learn the RimWorld way of coding in a mod. I have modded for both Minecraft and Squad's Kerbal Space Program, but I can't crack the code in RimWorld.

I was directed here in seek of knowledge. I want to learn, what the categories are, what eTypes are and how to use them, and how to create a turret including the top movement anim.

I use Notepad++, and I have Unity3D installed (for my other games). Any help would be greatly appreciated. Thanks!
-Skye
"Don't Take Life To Seriously, You'll Never Get Out of it Alive."

soulkata

Well, unity isnt necessary, you will need Visual Studio, or other C# edition tool. But in my experience, 95% of the modding is made under Defs folder... In this case, find a similiar mod, and check his Defs folder!

Almost forgot, use ILSpy to look at RimWorld and his Mods source code!

Haplo

Modding RimWorld can be done via Xml-Modding (New buildings, graphics, factions, recipes,...) or with additional C# code (.dll modding: New behaviors; everything that is not available in the base code)

The XML-Modding tutorial is a bit out of date as far as I know, so that is easier to learn by looking into other mods.
For the .dll modding there is a tutorial in here as a sticky. But it will also need a bit of XML-modding-knowledge.

With that, welcome and have fun ;)

SkyeRangerDelta

Well, I understand this much now and I even went as far as to open the RimWorld core xml files. I got so drastic that I even copied and pasted code and then altered it to what I wanted. Now I am having trouble referencing where the turretGunDef needs to be. I am getting errors because something is wrong with it (obviously). Something about no ThingDef could not reference to RimWorld.BuildingProperties.

It would help so much if there was a solid guide that is up-to-date concerning modding, the structure of an xml file and the anatmoy of a def. You know, all that. I'm trying to get this turret to work, but it says "nope" in the debug log.
"Don't Take Life To Seriously, You'll Never Get Out of it Alive."

SlimeCrusher

#4
(finnaly, a question i can answer!)
You have to create a gun definition.
Open ThingDefs, then copy "Weapons_Ranged.xml" (you can also check other weapons_blablabla) to your ThingDefs folder, open it and modify it acordingly.
Once you got your gun ready, copy its <defName>, and then go to your turret xml.
Once you're there, find the <turretGunDef> and put the defName of your gun there (ex. <turretGunDef>MyTurretGun</turretGunDef>)
If you don't want your gun to be used by raiders, change "<ThingDef ParentName="BaseHumanGun">" to "<ThingDef ParentName="BaseGun">"

Hope that helps  ;)

SkyeRangerDelta

Quote from: SlimeCrusher on February 17, 2015, 03:29:49 PM
(finnaly, a question i can answer!)
You have to create a gun definition.
Open ThingDefs, then copy "Weapons_Ranged.xml" (you can also check other weapons_blablabla) to your ThingDefs folder, open it and modify it acordingly.
Once you got your gun ready, copy its <defName>, and then go to your turret xml.
Once you're there, find the <turretGunDef> and put the defName of your gun there (ex. <turretGunDef>MyTurretGun</turretGunDef>)
If you don't want your gun to be used by raiders, change "<ThingDef ParentName="BaseHumanGun">" to "<ThingDef ParentName="BaseGun">"

Hope that helps  ;)

So I did what you said and I still get the same error. Except this time I changed the name of the def and the turretdef and the error simply changed its name too. I copied the xml code from Weapons_Guns.xml becuase there was no specific Weapons_Ranged except for Weapons_RangedNeolithic.xml   ???

Does having two turrets using the same turretGunDef effect it? I know that only the improvised turret uses the improvised turret def.
"Don't Take Life To Seriously, You'll Never Get Out of it Alive."

SlimeCrusher

Quote from: SkyeRangerDelta on February 17, 2015, 05:57:18 PM
So I did what you said and I still get the same error. Except this time I changed the name of the def and the turretdef and the error simply changed its name too. I copied the xml code from Weapons_Guns.xml becuase there was no specific Weapons_Ranged except for Weapons_RangedNeolithic.xml   ???

Does having two turrets using the same turretGunDef effect it? I know that only the improvised turret uses the improvised turret def.
uhh my bad, yes it was Weapons_Guns   :-[
Could you post, either the whole mod, or the defs (building_security and weapons_guns) so we can see what's going on?
And no, there shouldn't be any problem with 2 turrets using the same gun  ;)

yokai

RedTheHusky had created a tool, where you can see which Defs you have and is it possible to see if some Defs are dublicated. Probably this will help to find the wrong Defs. Heres the link: https://ludeon.com/forums/index.php?topic=10176.msg100504#msg100504

SkyeRangerDelta

Quote from: SlimeCrusher on February 17, 2015, 06:24:02 PM
uhh my bad, yes it was Weapons_Guns   :-[
Could you post, either the whole mod, or the defs (building_security and weapons_guns) so we can see what's going on?
And no, there shouldn't be any problem with 2 turrets using the same gun  ;)

Here are the modded files:
This is the BaseWeaponry.xml I am using the is the def for Gun_RangerTurret.
<?xml version="1.0" encoding="utf-8" ?>

<ThingDef Name="BaseBullet" Abstract="True">
    <category>Projectile</category>
    <tickerType>Normal</tickerType>
    <altitudeLayer>Projectile</altitudeLayer>
    <thingClass>Bullet</thingClass>
    <label>bullet</label>
    <useStandardHealth>False</useStandardHealth>
    <neverMultiSelect>True</neverMultiSelect>
    <shaderType>Transparent</shaderType>
  </ThingDef>



<ThingDef ParentName="BaseBullet">
    <defName>Bullet_TurretImprovised</defName>
    <label>improvised turret bullet</label>
    <graphicPath>Things/Projectile/Bullet_Small</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <projectile>
      <damageDef>Bullet</damageDef>
      <damageAmountBase>7</damageAmountBase>
      <speed>70</speed>
    </projectile>
  </ThingDef>

  <ThingDef ParentName="BaseGun">
    <defName>RangerTurret</defName>
    <label>improvised turret gun</label>
    <graphicPath>Things/Item/Equipment/WeaponRanged/R-4</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <menuHidden>true</menuHidden>
    <description>Jury-rigged gun attached to a turret.</description>
    <soundInteract>InteractRifle</soundInteract>
    <canBeSpawningInventory>false</canBeSpawningInventory>
    <weaponTags>
      <li>TurretGun</li>
    </weaponTags>
    <verbs>
      <li>
        <verbClass>Verb_Shoot</verbClass>
        <baseCooldownTicks>40</baseCooldownTicks>
        <hasStandardCommand>true</hasStandardCommand>
        <projectileDef>Bullet_TurretImprovised</projectileDef>
        <warmupTicks>90</warmupTicks>
        <range>25.9</range>
        <accuracyTouch>0.89</accuracyTouch>
        <accuracyShort>0.64</accuracyShort>
        <accuracyMedium>0.41</accuracyMedium>
        <accuracyLong>0.22</accuracyLong>
        <ticksBetweenBurstShots>8</ticksBetweenBurstShots>
        <burstShotCount>3</burstShotCount>
        <soundCast>GunShotA</soundCast>
      </li>
    </verbs>
  </ThingDef>


And This is the one for the turret constructions:
<?xml version="1.0" encoding="utf-8"?>
<Buildings>

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


<!--=============Ranger A1 Turret=====================-->


<ThingDef ParentName="MainBase">
    <defName>RangerA1</defName>
    <eType>Building_Turret</eType>
    <label>Ranger A1</label>
    <thingClass>Building_TurretGun</thingClass>
    <graphicPath>Things/Building/Security/RangerA1_Base</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <altitudeLayer>Waist</altitudeLayer>
    <statBases>
      <MaxHealth>140</MaxHealth>
      <Flammability>1.0</Flammability>
      <WorkToMake>2000</WorkToMake>
      <Beauty>-20</Beauty>
    </statBases>
    <tickerType>Normal</tickerType>
    <comps>
      <li>
        <compClass>CompExplosive</compClass>
        <explosiveRadius>2</explosiveRadius>
        <explosiveDamageType>Bomb</explosiveDamageType>
      </li>
      <li>
        <compClass>CompForbiddable</compClass>
      </li>
      <li>
        <compClass>CompPowerTrader</compClass>
        <basePowerConsumption>200</basePowerConsumption>
      </li>
    </comps>
    <description>The first in the line of Ranger Turrets. Good early game defense structure.</description>
    <size>(1,1)</size>
    <passability>Impassable</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <fillPercent>0.4</fillPercent>
    <graphicOverdraw>true</graphicOverdraw>
    <stuffCategories>
      <li>Metallic</li>
    </stuffCategories>
    <costStuffCount>80</costStuffCount>
    <costList>
      <Steel>80</Steel>
    </costList>
    <combatTargetBuilding>true</combatTargetBuilding>
    <filthLeavings>
      <SlagRubble>2</SlagRubble>
    </filthLeavings>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <designationCategory>Security</designationCategory>
    <specialDisplayRadius>25.9</specialDisplayRadius>
    <building>
      <turretGunDef>RangerTurret</turretGunDef>
      <turretBurstCooldownTicks>200</turretBurstCooldownTicks>
      <turretTopgraphicPath>Things/Building/Security/RangerA1_Top</turretTopgraphicPath>
    </building>
    <designationHotKey>U</designationHotKey>
  </ThingDef>
 
 
  <!--=================Ranger A2================-->
  <ThingDef ParentName="MainBase">
    <defName>RangerA2</defName>
    <eType>Building_Turret</eType>
    <label>Ranger A2</label>
    <thingClass>Building_TurretGun</thingClass>
    <graphicPath>Things/Building/Security/RangerA2_Base</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <altitudeLayer>Waist</altitudeLayer>
    <statBases>
      <MaxHealth>140</MaxHealth>
      <Flammability>1.0</Flammability>
      <WorkToMake>2500</WorkToMake>
      <Beauty>-40</Beauty>
    </statBases>
    <tickerType>Normal</tickerType>
    <comps>
      <li>
        <compClass>CompExplosive</compClass>
        <explosiveRadius>3</explosiveRadius>
        <explosiveDamageType>Bomb</explosiveDamageType>
      </li>
      <li>
        <compClass>CompForbiddable</compClass>
      </li>
      <li>
        <compClass>CompPowerTrader</compClass>
        <basePowerConsumption>200</basePowerConsumption>
      </li>
    </comps>
    <description>Second in the Ranger Turret series. Rapid fire turret.</description>
    <size>(1,1)</size>
    <passability>Impassable</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <fillPercent>0.4</fillPercent>
    <graphicOverdraw>true</graphicOverdraw>
    <stuffCategories>
      <li>Metallic</li>
    </stuffCategories>
    <costStuffCount>80</costStuffCount>
    <costList>
      <Steel>130</Steel>
    </costList>
    <combatTargetBuilding>true</combatTargetBuilding>
    <filthLeavings>
      <SlagRubble>3</SlagRubble>
    </filthLeavings>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <designationCategory>Security</designationCategory>
    <specialDisplayRadius>25.9</specialDisplayRadius>
    <building>
      <turretGunDef>RangerTurret</turretGunDef>
      <turretBurstCooldownTicks>50</turretBurstCooldownTicks>
      <turretTopgraphicPath>Things/Building/Security/RangerA2_Top</turretTopgraphicPath>
    </building>
    <designationHotKey>U</designationHotKey>
  </ThingDef>
 

</Buildings>


Hope that helps.
"Don't Take Life To Seriously, You'll Never Get Out of it Alive."