niston Posted February 6, 2020 Share Posted February 6, 2020 You might have come across this already, but if not: Object reference scale in FO4 is determined by two settings - The REF scale and the BASE scale. The actual Scale of the reference then computes as PRODUCT = REF * BASE. - REF scale is what you change when you use SetScale in console. It's also what you can change from Papyrus when you're using ObjectReference.SetScale() function. - BASE is defined on the base object of the reference. In effect, this is a setting inside a plugin. - BASE, REF and PRODUCT are all shown on the console output when you use the GetScale command. - But Interestingly enough, if you use ObjectReference.GetScale() from Papyrus, it does NOT return the REF scale. Instead, PRODUCT is returned. This means that, if you use something like: ; save scale Float previousScale = myRef.GetScale() ; perform very important calculations or whatever ; .... ; restore scale myRef.SetScale(previousScale) It will not work properly for any ObjectReference whose BASE scale is not 1.0. Even worse: If you do this repeatedly on such an objectreference, an ever increasing error will be introduced! And that's because GetScale() gets you the PRODUCT, meanwhile SetScale() works on the REF. To do this properly, you must save and restore the REF value, not the PRODUCT. Unfortunately, Papyrus doesn't have any means of accessing the REF value directly. There is, however, a way to infer the REF value: ; we cant directly access REF scale, so we must infer it - LIFE IS A HASSLE ; thanks to shad0wshayd3 and Scrivener07 for help with brainstorming Float fCurScaleProduct = myRef.GetScale() ; gets REF*BASE myRef.SetScale(1.0) ; set REF to 1 Float fCurScaleBase = myRef.GetScale() ; gets 1*BASE Float fCurScaleRef = fCurScaleProduct / fCurScaleBase ; infer REF from PRODUCT and 1*BASE myRef.SetScale(fCurScaleRef) ; restore original REF ; current REF scale Debug.Trace(Self + ": Current ref scale is " + fCurScaleRef) Have fun! Link to comment Share on other sites More sharing options...
Zorkaz Posted February 10, 2020 Share Posted February 10, 2020 Thanks Link to comment Share on other sites More sharing options...
lee3310 Posted November 5, 2022 Share Posted November 5, 2022 Very important stuff (good catch). Link to comment Share on other sites More sharing options...
Recommended Posts