Greslin Posted April 4, 2017 Share Posted April 4, 2017 So I just released an initial version of my limb damage mod. In the process of coding it, I ran into a few mysteries that are bugging me. 1. I have a script attached to a potion MGEF, and at first I had the script located in a namespace. I've namespaced scripts in other mods before with no problem, but this was my first MGEF, and man, it did NOT like the namespace. Wouldn't execute at all. When I moved it out of the namespace, everything worked fine. Is there some deeper complexity to script namespaces that I'm missing? 2. At least when limb health floats go into negative numbers, SetValue() would go weird for me. If I did something similar to: PlayerRef.SetValue(leftmobilitycondition, 10.0) as long as I had all the properties set up right, I would think that would set left leg health to 10HP. And generally it does, if the initial value was positive. If the initial number is negative, the above seems to be ignored. So I boot into the game, drop into console. player.getav leftmobilitycondition Comes back with -2.38. The left leg is crippled. Then: player.setav leftmobilitycondition 10.0 player.getav leftmobilitycondition That should give me a solid 10.0, right? Instead, I get something like -7.21. Not a mod conflict, not cached save data, and I don't *think* it's bad typecasting (but I suppose it still could be). Any ideas? 3. The purpose of DamageValue() and RestoreValue() just elude me. I've read the CK docs multiple times, sorted through the base game scripts, and for the life of me I can't currently see the point of using these instead of setvalue and modvalue. Can someone enlighten me? I suspect that the answer is somewhat related to mystery #2. Thanks in advance, guys. This feels like really basic stuff to me, so I'm feeling kind of stupid here that I can't quite seem to get it. Link to comment Share on other sites More sharing options...
vkz89q Posted April 4, 2017 Share Posted April 4, 2017 (edited) Damagevalue damages value, like hitting it with weapon. For example, legendary weapon mod that cripples legs, does something like(in magic effect script) : DamageValue(leftmobilitycondition, 99999) so it will insta-cripple anything it hits. About the other questions, I'm not sure right now. I'll post more if I figure something :tongue: edit. What difference it has vs ModValue? Not much I guess, you dont have to use -, heh. edit.2 Could there be something "Mod":ing the value? Like, some effect that does ModValue, so when you do SetAv, it still mods it. For example something has effect that does ModAv(xxx, -100), and you do SetAv(xxx, 10), it will propably still be -90 because the "mod". Just a though. Edited April 4, 2017 by vkz89q Link to comment Share on other sites More sharing options...
Greslin Posted April 6, 2017 Author Share Posted April 6, 2017 Okay, so I think I'm getting closer to solving these mysteries. After quite a bit of experimentation, I'm reaching the conclusion that something is seriously not right about SetValue() when it's being used against the player's limb or general health numbers. I've done plenty of GetValue-ing, and always have gotten accurate results, but doing something similar to: PlayerRef.SetValue(leftmobilitycondition, 10.0) Is flat out not doing the job. Every time I attempt to SetValue/SetAV limb health, I get unpredictable results. ModValue/ModAV, however, works. If the left leg health is currently 25, and I do: PlayerRef.ModValue(leftmobilitycondition, 10.0) and then GetAV it, I get 35. Right on target. It does a relative shift on the existing value, nice and reliably. What I think is happening is that in the above situations, SetValue() is attempting to fetch a base value rather than an actual one, and coming back with garbage data when attempted against player limb health. I'm guessing that DamageValue and RestoreValue are basically just wrappers on ModValue. So now I'm avoiding use of SetValue(), unless there's just no other way of doing it. You can use ModValue to set an absolute value by doing this: PlayerRef.ModValue(LeftMobilityCondition, (PlayerRef.GetValue(LeftMobilityCondition) * -1) + AbsValue) Take the negative of the value, null the value to 0, then add. I don't know what's up with SetValue(), whether it's bugged or what. But this at least seems to be a working way around it. Link to comment Share on other sites More sharing options...
vkz89q Posted April 6, 2017 Share Posted April 6, 2017 (edited) Yes, I believe Set will set base value. I have speed spell that gives npc extra speed. If she is wearing item that gives move speed, then the final speed is what I SET + modded amount. So, when I do Set speed to 150, she wears 10% hat, then I do Get, I get 160, not 150. When the effect stops, speed goes to 110 if she is wearing hat, even if I do SET 100. I can see it's not gonna be good vs player health that scales from items, levels, food, chems, etc etc. Then, also the limb health is % of player health, I believe. Edited April 6, 2017 by vkz89q Link to comment Share on other sites More sharing options...
Greslin Posted April 6, 2017 Author Share Posted April 6, 2017 I can see it's not gonna be good vs player health that scales from items, levels, food, chems, etc etc. Then, also the limb health is % of player health, I believe. No, not that I've seen. Limb health is still stored as independent values, though it seems that torso health (endurancecondition) has now been rolled into general health. The other limbs are still basic 0-100 floats. Link to comment Share on other sites More sharing options...
Recommended Posts