Talk:GetStaminaPercentage

From the CreationKit Wiki
Jump to navigation Jump to search

UPDATE: I misidentified the problem. The code snippet I thought was responsible was actually properly written; I misread a != check as ==, because my disassembler doesn't decode float operations for me and I have to look up bits by hand.

The real problem is that GetStaminaPercentage messes with a smart pointer for some reason. It should just check the stamina on the actor it's given, which is a thing that it easily could have done, but instead, it calls an Actor subroutine that does this:

   struct SomeSmartPointer {
      TESObjectREFR* target = nullptr;
   }
   //
   float result;
   SomeSmartPointer ptr;
   if (this->Subroutine006E7C30(&ptr)) {
      result = ptr.target->GetActorValuePercentage(0x1A);
   }
   

The Actor::Subroutine006E7C30 subroutine sets the smart pointer. If the this actor has a certain flag set and has an ExtraAction in its extra-data, then the subroutine calls a different subroutine that can set the smart pointer to goodness-knows-what; otherwise, the smart pointer is set to the this actor. So the problem with this condition function, ultimately, is that it mucks about with smart pointers for no readily apparent reason, and the smart pointer in question gets set to the wrong reference. The condition function never actually pulls the stamina values from the actor you call it on.

DavidJCobb (talk) 2018-07-23T15:12:48 (EDT)