Help with Pawns

Started by skullywag, September 13, 2014, 06:55:12 PM

Previous topic - Next topic

skullywag

I think ive got most of the XML modding down and have moved into some light DLL work without issue but pawns....oh god...no matter which way i do things i end up with the same result:

NullReferenceException: Object reference not set to an instance of an object
  at Verse.Pawn.AddAndRemoveComponentsAsAppropriate () [0x00000] in <filename unknown>:0

  at Verse.PawnGenerator.GeneratePawn (Verse.PawnKindDef kindDef, RimWorld.Faction faction) [0x00000] in <filename unknown>:0

  at Verse.Dialog_DebugActionsMenu+<DoListingItems>c__AnonStorey1EE.<>m__2C6 () [0x00000] in <filename unknown>:0

  at Verse.DebugTool.DebugToolOnGUI () [0x00000] in <filename unknown>:0

  at Verse.DebugTools.DebugToolsOnGUI () [0x00000] in <filename unknown>:0

  at RimWorld.UIMapRoot.UIRootOnGUI () [0x00000] in <filename unknown>:0

  at VerseBase.Root.OnGUI () [0x00000] in <filename unknown>:0


Every time.

Ive tried using the pawn generator in a DLL, ive stripped it right back now and just have a the race def and the pawnkind and I still get the above....am i missing something obvious?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

RawCode

there is no mages on this forum.

you must provide both XML defs and you DLL source code in order to get any viable help.

skullywag

#2
I thought it might be a "gotcha" that someones had before. As an example I've copied the race and pawnkind defs into a mod removed all bar 1 in each changed the def name and labeks and stuff and I still get the above when spawning, no dll or anything. Ill put my xml up later when I'm home.

I'm wondering if my game dir is a bit screwey as well. I might remove and reinstall as I cant turn off some mods without the game erroring (the "T" mods for example).
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

ok, heres my defs, nothing more added just this.

<PawnKindDefs>

<PawnKindDef>
<defName>MyNewPawn</defName>
    <label>Some pawn i made</label>
    <race>New_Race</race>
    <pointsCost>290</pointsCost>
<defaultFactionType>Colony</defaultFactionType>
<aiAvoidCover>true</aiAvoidCover>
    <isFighter>true</isFighter>
    <standardBodyGraphicPath>Things/Pawn/Dude</standardBodyGraphicPath>
    <moneyForWeapons>
      <min>1200</min>
      <max>1200</max>
    </moneyForWeapons>
    <weaponTags>
      <li>MechanoidGunHeavy</li>
    </weaponTags>
  </PawnKindDef>

</PawnKindDefs>


<ThingDefs>

  <ThingDef Name="BasePawn" Abstract="True">
<eType>Pawn </eType>
<thingClass>Pawn</thingClass>
<category>Pawn</category>
<selectable>true</selectable>
<tickerType>Normal</tickerType>
<altitudeLayer>Pawn</altitudeLayer>
<useStandardHealth>false</useStandardHealth>
<flammability>1.0</flammability>
<hasTooltip>true</hasTooltip>
<soundBulletHit>BulletImpactFlesh</soundBulletHit>
<inspectorTabs>
      <li>ITab_Pawn_Thoughts</li>
  <li>ITab_Pawn_Prisoner</li>
  <li>ITab_Pawn_Gear</li>
  <li>ITab_Pawn_Character</li>
      <li>ITab_Pawn_Health</li>
</inspectorTabs>
<drawGUIOverlay>true</drawGUIOverlay>
  </ThingDef>





  <!-- ============================ Mechanoids ========================== -->
 
  <ThingDef ParentName="BasePawn" Name="BaseMechanoid" Abstract="True">
    <soundBulletHit>BulletImpactMetal</soundBulletHit>
    <flammability>0</flammability>
    <race>
      <mechanoid>true</mechanoid>
      <hasStory>false</hasStory>
      <needsRest>false</needsRest>
      <hasGenders>false</hasGenders>
      <isFlesh>false</isFlesh>
      <diet>NeverEats</diet>
    </race>
  </ThingDef>

 
 
  <!-- Centipede -->
  <ThingDef ParentName="BaseMechanoid">
<defName>New_Race</defName>
<label>New Race</label>
    <description>Some desc text.</description>
    <maxHealth>100</maxHealth>
<overdraw>true</overdraw>
    <targetHitChanceFactor>1.0</targetHitChanceFactor>
  <meleeAttacks>
  <li>
  <damageDef>Bludgeon</damageDef>
  <damageAmount>50</damageAmount>
  </li>
  </meleeAttacks>
    <race>
<thinkTree>Mechanoid</thinkTree>
      <walkSpeed>0.29</walkSpeed>
    <body>MechanicalCentipede</body>
      <bodySize>2.0</bodySize>
    <healthScale>2.0</healthScale>
      <meatAmountMultiplier>0.3</meatAmountMultiplier>
      <soundWounded>Pawn_Mech_Centipede_Wounded</soundWounded>
      <soundDeath>Pawn_Mech_Centipede_Death</soundDeath>
      <soundCall>Pawn_Mech_Centipede_Call</soundCall>
      <soundCallIntervalRange>
        <min>1000</min>
        <max>2000</max>
      </soundCallIntervalRange>
      <soundAngry>Pawn_Mech_Centipede_Angry</soundAngry>
      <soundMeleeHitPawn>Pawn_Melee_MechanoidBash_HitPawn</soundMeleeHitPawn>
      <soundMeleeHitBuilding>Pawn_Melee_MechanoidBash_HitBuilding</soundMeleeHitBuilding>
      <soundMeleeMiss>Pawn_Melee_MechanoidBash_Miss</soundMeleeMiss>
    </race>
    <killedLeavings>
      <li>
        <thingDef>Metal</thingDef>
        <count>50</count>
      </li>
    </killedLeavings>
    <sunShadowInfo>
      <baseWidth>0.6</baseWidth>
      <baseHeight>0.6</baseHeight>
      <tallness>0.8</tallness>
    </sunShadowInfo>
</ThingDef>

</ThingDefs>


As you can see ive done nothing more than copy the mechanoid ones and change some details, trying to spawn them ingame results in the error i posted. I would expect this to result in a pawn acting like a mechanoid but looking like my "dude" textures. What am i doing wrong?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

#4
ok im getting somewhere, this is due to me setting the default faction to Colony, anything else works fine. Im guessing I have to extend the colonist pawnkind def but im sure ive tried that before. Giving it another go.

Ok can spawn colonists of my pawndef, now I think ive hit on the real problem, using
<standardBodyGraphicPath>Things/Pawns/Dude</standardBodyGraphicPath>

does nothing so am i able in pure XML to change the look of a colonist, or do I need to define a new type of Pawn in a C# which uses this?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Shinzy

Quote from: skullywag on September 14, 2014, 02:18:27 PM
ok im getting somewhere, this is due to me setting the default faction to Colony, anything else works fine. Im guessing I have to extend the colonist pawnkind def but im sure ive tried that before. Giving it another go.

Ok can spawn colonists of my pawndef, now I think ive hit on the real problem, using
<standardBodyGraphicPath>Things/Pawns/Dude</standardBodyGraphicPath>

does nothing so am i able in pure XML to change the look of a colonist, or do I need to define a new type of Pawn in a C# which uses this?

See if you can get a hold on Haplo, or have a look see on his MAI mod
or Justin C and his Zombie mod
those two mite have the best idea on how these things work
I'm sure they won't kill you too much if you spam their pm with such trivial qu- *gets struck by lightning*

skullywag

Nah ill just do a cheeky bump and see if someone comes along. Funnily enough its the one issue holding me back from releasing my version of mechatronics. Im thinking something changed between A5 and 6 in this regard as I get the same error, I also get a very large naked colonist instead of a centipede but hey thats the least of my issues!
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Haplo

I think the main problem is that the normal pawn genner is a bit set in its ways. He assumes that when it is part of the colony it must be like a normal colonist pawn e.g. a human with a bunch of control parts. If you set your pawn now to be non human a bunch of the needed control parts aren't initialized. And later on it crashes with a NullRefException.
That is the reason why my Mai still is internally a human and why I've made my own aipawn genner for her. The vanilla part just assumes wrongly if I use that.

Demo

As Haplo said before me, I believe it's just a problem with the race, switch the race to Humanoid then test it and post the results.