melee weapon def doesn't work

Started by kito1z, December 31, 2023, 06:44:23 AM

Previous topic - Next topic

kito1z

Error occurs when I try spawn axe by dev mode:
System.NullReferenceException: Object reference not set to an instance of an object

Def:

<?xml version="1.0" encoding="utf-8"?>
<Defs>
  <ThingDef ParentName="BaseMeleeWeapon_Sharp">
    <defName>Axe</defName>
    <label>axe</label>
    <graphicsData>
      <texPath>things/weapons/Axe.png</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicsData>
    <techLevel>Medieval</techLevel>
    <statBases>
      <MaxHitPoints>150</MaxHitPoints>
      <Mass>1.8</Mass>
      <Flammability>0</Flammability>
      <DeteriorationRate>0</DeteriorationRate>
      <MoveSpeed>0.1</MoveSpeed>
    </statBases>
    <equippedAngleOffset>-65</equippedAngleOffset>
    <tools>
      <li>
        <label>Head</label>
        <capacities>
          <li>Cut</li>
        </capacities>
        <power>19</power>
       <armorPenetrationSharp>0.95</armorPenetrationSharp>
      </li>
    </tools>
  </ThingDef>
</Defs>

Cluric

I'm not sure if it's still relevant, but I went on some issues recently with my own weapons and worked a while to resolve them, so here it is...

I'm pretty sure "<MoveSpeed>0.1</MoveSpeed>" is NOT an allowed <StatBases> for a weapon. Pretty sure this will cause some errors.
You should try something using <equippedStatOffsets> <MoveSpeed>0.1</MoveSpeed> </equippedStatOffsets> instead (or something similar, i'm writing from memory).


You'll need a "<description>This is an awesome axe</description>", probably after your label.

Less important, but concerning "Axe.png" --> is not an error I think but you dont need the ".png" which is considered default (you can store some .psn for example without any risk of confusion).