Talk:GetSpellUsageNum

There are no discussions on this page.

In Skyrim Classic, this function calls float MagicTarget::GetTotalMagnitudeOf(void* Arg1) on the subject-actor's magic target data (Actor::magicTarget).

GetTotalMagnitudeOf starts by calling MagicItem::Subroutine00406B40 on Arg1 and storing the return value in EffectItem* ebp. If ebp is nullptr, then we return 0.0 immediately and that's the end of that. Otherwise, GetTotalMagnitudeOf continues: it creates an IsSpellTargetFunctor, sets Arg1 as the functor's parameter, and passes the parameter to MagicTarget::ExecuteFunctor (0x00663410); the "functor" mechanism abstracts away the need to manually loop over the list of active effects in a MagicTarget.

If the magic-target is indeed targeted by Arg1, then GetTotalMagnitudeOf initializes float esp0C to zero and loops over all of the active effects on the magic-target. For each active effect, if ActiveEffect::effect is the same pointer as ebp, then the active effect's magnitude is computed and added to esp0C. At the end of the loop, esp0C is returned.

The return value of GetTotalMagnitudeOf is the return value of the GetSpellUsageNum condition function -- and pardon the editorializing, but what a bad name for that function, if that's what it does. "Usage num?!"

DavidJCobb (talk) 2018-07-23T14:51:12 (EDT)

Return to "GetSpellUsageNum" page.