Since I'm probably going to have a lot of different companion script-related queries come up, I thought I would bundle them all into this one thread.
I'm really sorry to have to ask people to comb through this, but this script is too important to my mod for it to not work, and I can't seem to figure it out, so I'd definitely appreciate any insights! Also, sorry, couldn't find the spoiler option on the editor...
The companion script (the big script at the very bottom) is NON_SabrinaCompanion (her name is Sabrina); the global NON_SabrinaFollowing, which shows up a lot, tracks whether or not she's following (= 1), not following (= 0) or dead/gone (-1). For other variables / scripts called, just ask and I shall explain, if they aren't clear.
My current problems:
1) Sabrina does not warp. (Fixed -- Abot is a genius, or at least, not an idiot like me!)
Specifically, Grumpy's warping code which should regularly and rapidly bring Sabrina near to the player (find it quickly via searching the messagebox phrase "normal warp") only works very rarely. I have seen the messageboxes come up (indicating warping) a handful of times; once during combat, and once while running around on hills. Otherwise, it never goes off and Sabrina gets left behind until eventually a bit of code courtesy of Stuporstar's companions forces an emergency warp (find it quickly via searching the messagebox phrase "EMERG"). This is the only type of warping which occurs (outside of the doorDelay warping), and I am not sure why normal warping is being blocked.
Other aspects of Sabrina's movement scripts (eg. her z-position matching in levitation or swimming) do work fine.
2) The underwater detection code does not work. (Fixed by stealing the function from Kateri's Julan script)
Find it quickly via searching for the test message "n_under reset" -- the point of this is to detect when Sabrina is underwater and set a local to activate certain greetings. The messageboxes never fire, and the greetings are never activated.
TBH, I wouldn't care much if someone just told me it was impossible -- seems like a lot of scripting for a very minor immersive dialogue function.
3) Sabrina's magicka is reported incorrectly. (Also fixed... by abot. Again!)
Specifically, in the main companion script the local 'currentmagicka' is used to track Sabrina's magicka. In dialogue, she reports her magicka as a % of her total magicka, via the following:
messagebox "[Sabrina's magicka is at %.0f percent]" currentmagicka
Initially this works fine. However, after a single round of Sabrina's levelling script alters her magicka from its CS-preset level of 100 to match the player's level, the formula starts reporting her current magicka as a percentage of this initial preset CS magicka level (100) rather than as a percentage of her newly set magicka.