[Solved] Anyone having issues using the Toils_Combat.CastVerb toil?

Started by pidggit, June 04, 2014, 12:27:13 AM

Previous topic - Next topic

pidggit

Project K9 was using this toil in my custom "Kill" job which was working before the upgrade to Alpha 4.

I've updated everything else in the mod to work with Alpha 4, but when it tries to execute the CastVerb toil, it throws an NPE. Stacktrace:


Exception ticking Mutt_Mutt39921: System.NullReferenceException: Object reference not set to an instance of an object
  at Verb_MeleeAttack.TryShotSpecialEffect () [0x00000] in <filename unknown>:0
  at Verse.Verb.TryFireNextBurstShot () [0x00000] in <filename unknown>:0
  at Verse.Verb.InitCast () [0x00000] in <filename unknown>:0
  at Verse.Verb.TryStartCastOn (TargetPack castTarg) [0x00000] in <filename unknown>:0
  at Verse.AI.Toils_Combat+<CastVerb>c__AnonStorey131.<>m__13D () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.BeginNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.BeginNextToil () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.Notify_PatherArrived () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.PatherArrived () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.TryEnterNextPathSquare () [0x00000] in <filename unknown>:0
  at Verse.AI.Pawn_PathFollower.PatherTick () [0x00000] in <filename unknown>:0
  at Verse.Pawn.Tick () [0x00000] in <filename unknown>:0
  at Verse.TickList.SingleTick () [0x00000] in <filename unknown>:0


Here's my Kill job:


protected override IEnumerable<Toil> MakeNewToils()
{
    ToilFailConditions.EndOnDespawned<JobDriver_KillUnreserved>(this, TargetIndex.A, JobCondition.Succeeded);
    yield return Toils_Combat.SetJobToUseToBestAttackVerb();
   
    Toil gotoPosition = Toils_Combat.GotoCastPosition(TargetIndex.A);
    yield return gotoPosition;
   
    Toil jump = Toils_Jump.JumpIfCannotHitTarget(TargetIndex.A, gotoPosition);
    yield return jump;
   
    yield return Toils_Combat.CastVerb(TargetIndex.A);
   
    yield return Toils_Jump.Jump(jump);
}


A note on why I have a custom Kill job instead of using the provided one: The Provided Kill job reserves the target completely, and I'd like my dogs to attack together, so they need to not care about reserving the target.

Anyone have any ideas as to what I'm doing wrong?

Tynan

I think it's because your dog race needs to have melee sounds defined. Look at the other animal races, see their melee sounds and copy/paste the XML over. You're correct that this should be more stable.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

pidggit

You are exactly correct. This is my bad. I only looked at the individual RaceDef diffs. I didn't even look at the BasePawn ThingDef to see what changed there.

Everything's working now. Just need to test it a bit to make sure there's nothing else funky, and I can re-release Project K9 for Alpha 4. :D