Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:NRE when riposte kills attacker #3614

Closed
4 tasks done
masakitenchi opened this issue Dec 28, 2024 · 2 comments · Fixed by #3615
Closed
4 tasks done

[Bug]:NRE when riposte kills attacker #3614

masakitenchi opened this issue Dec 28, 2024 · 2 comments · Fixed by #3615
Labels
Bug Something isn't working

Comments

@masakitenchi
Copy link
Contributor

Complete the template below. Reports that do not follow the template will be deleted.
Title should be: [Bug]: (Short description of bug)

Specifications
Please provide the following.

Rimworld version: 1.5.4297
Combat Extended version: workshop latest
Combat Extended source (Steam, GitHub, etc.): steam
Your operating system: windows 10
Your mod list:

Initializing new game with mods:
  - brrainz.harmony
  - Ludeon.RimWorld
  - Ludeon.RimWorld.Royalty
  - Ludeon.RimWorld.Ideology
  - Ludeon.RimWorld.Biotech
  - Ludeon.RimWorld.Anomaly
  - CETeam.CombatExtended

Description
Provide a concise description of the issue or concern. What happened?
when riposte attack kills its opponent, game always throws a NRE in Verse.Verb.TryCastNextBurstShot
Expected behavior
What did you expect to happen?
No error, of course
To reproduce
Provide clear steps to reproduce the behavior. How do we make this happen?

  • Have enemies on map
  • Spawn or find a pawn with high melee
  • Give him/her a good weapon so that riposte has a good probability to kill its opponent
  • Wait

Screenshots & log dumps
I'll just post the whole log here. It's not that long. Also trimmed lines that has nothing to do with this error

RimWorld 1.5.4297 rev1079 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Unloading 5 Unused Serialized files (Serialized files now loaded: 4)
UnloadTime: 0.315000 ms

Unloading 969 unused Assets to reduce memory usage. Loaded Objects now: 26588.
Total: 278.024400 ms (FindLiveObjects: 0.992500 ms CreateObjectMapping: 0.603400 ms MarkObjects: 275.539000 ms  DeleteObjects: 0.889100 ms)

Initializing new game with mods:
  - brrainz.harmony
  - Ludeon.RimWorld
  - Ludeon.RimWorld.Royalty
  - Ludeon.RimWorld.Ideology
  - Ludeon.RimWorld.Biotech
  - Ludeon.RimWorld.Anomaly
  - CETeam.CombatExtended 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Exception in JobDriver tick for pawn Megascarab9587 driver=JobDriver_AttackMelee (toilIndex=2)
System.NullReferenceException: Object reference not set to an instance of an object
[Ref 4B2E07C]
 at Verse.Verb.TryCastNextBurstShot () [0x002d0] in <69945a8ed6c540cf90b578de735e0605>:0 
     - TRANSPILER CombatExtended.HarmonyCE: IEnumerable`1 CombatExtended.HarmonyCE.Harmony_Verb_TryCastNextBurstShot:Transpiler(IEnumerable`1 instructions, ILGenerator generator)
 at Verse.Verb.WarmupComplete () [0x00013] in <69945a8ed6c540cf90b578de735e0605>:0 
 at CombatExtended.Verb_MeleeAttackCE.WarmupComplete () [0x00008] in <d4f808b7eac94548b83685e1520170fc>:0 
 at Verse.Verb.TryStartCastOn (Verse.LocalTargetInfo castTarg, Verse.LocalTargetInfo destTarg, System.Boolean surpriseAttack, System.Boolean canHitNonTargetPawns, System.Boolean preventFriendlyFire, System.Boolean nonInterruptingSelfCast) [0x001c8] in <69945a8ed6c540cf90b578de735e0605>:0 
     - TRANSPILER CombatExtended.HarmonyCE: IEnumerable`1 CombatExtended.HarmonyCE.Harmony_Verb_TryStartCastOn:Transpiler(IEnumerable`1 instructions, ILGenerator generator)
 at Verse.Verb.TryStartCastOn (Verse.LocalTargetInfo castTarg, System.Boolean surpriseAttack, System.Boolean canHitNonTargetPawns, System.Boolean preventFriendlyFire, System.Boolean nonInterruptingSelfCast) [0x00007] in <69945a8ed6c540cf90b578de735e0605>:0 
 at RimWorld.Pawn_MeleeVerbs.TryMeleeAttack (Verse.Thing target, Verse.Verb verbToUse, System.Boolean surpriseAttack) [0x0009f] in <69945a8ed6c540cf90b578de735e0605>:0 
 at Verse.AI.JobDriver_AttackMelee.<MakeNewToils>b__4_2 () [0x0003d] in <69945a8ed6c540cf90b578de735e0605>:0 
 at Verse.AI.Toils_Combat+<>c__DisplayClass6_0.<FollowAndMeleeAttack>b__0 () [0x00118] in <69945a8ed6c540cf90b578de735e0605>:0 
 at Verse.AI.JobDriver.DriverTick () [0x00163] in <69945a8ed6c540cf90b578de735e0605>:0  
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Complete the following checklist
I hereby verify that I have done the following:

  • Confirmed that my game version and load order are correct.
  • Confirmed that I am running the appropriate and most updated version of Combat Extended and required compatibility patches.
  • Confirmed I am not running any mods with known incompatibilities with Combat Extended.
  • Disabled Combat Extended and attempted to reproduce the behavior without success. (vanilla doesn't have riposte mechanic at all, what else could I expect?)
@masakitenchi masakitenchi added the Bug Something isn't working label Dec 28, 2024
@masakitenchi
Copy link
Contributor Author

masakitenchi commented Dec 28, 2024

Dunno if post ludeon source is legal, but
The stacktrace suggests that the exception is thrown at here:

IL_02A7: ldarg.0
IL_02A8: callvirt   virtual Verse.Pawn Verse.Verb::get_CasterPawn()
IL_02AD: ldfld      Verse.Pawn_StanceTracker Verse.Pawn::stances
IL_02B2: ldarg.0
IL_02B3: ldfld      Verse.VerbProperties Verse.Verb::verbProps
IL_02B8: ldarg.0
IL_02B9: ldarg.0
IL_02BA: callvirt   virtual Verse.Pawn Verse.Verb::get_CasterPawn()
IL_02BF: callvirt   System.Int32 Verse.VerbProperties::AdjustedCooldownTicks(Verse.Verb ownerVerb, Verse.Pawn attacker)
IL_02C4: ldarg.0
IL_02C5: ldfld      Verse.LocalTargetInfo Verse.Verb::currentTarget
IL_02CA: ldarg.0
IL_02CB: newobj     System.Void Verse.Stance_Cooldown::.ctor(System.Int32 ticks, Verse.LocalTargetInfo focusTarg, Verse.Verb verb)
IL_02D0: callvirt   System.Void Verse.Pawn_StanceTracker::SetStance(Verse.Stance newStance)  <= Specifically here

so my conclusion is that Verse.Pawn_StanceTracker is null when game tries to call it, hence the NRE is thrown

@masakitenchi
Copy link
Contributor Author

further investigation found a transpiler that tries to solve this
https://github.com/CombatExtended-Continued/CombatExtended/blob/Development/Source/CombatExtended/Harmony/Harmony_Verb.cs#L61C1-L62C1
but it seems to do little

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant