redeyesandlonghair Posted April 5, 2011 Share Posted April 5, 2011 Hi. For the purposes of SetActorValue , how do I make that effect the player's character? is it Player.SetActorValue ? Also, can I add calculations for the value I want something set to? For example Player.SetActorValue Speed ( Strength * Encumbrance ) Soul that set my speed to be my Strength times my current encumbrance? (Don't worry that's not the actual script I plan on making lol) Thank you in advance for any replys (even if they're just to tell me I just wrote a bunch of gibberish) Link to comment Share on other sites More sharing options...
Skevitj Posted April 5, 2011 Share Posted April 5, 2011 (edited) You can't nest functions, so you will need at least two variables, and then might as well just do the calculation on a different line. When calling the functions, "player.setav ..." will work, but it depends how the script is being run, ie, if it's a spell effect then "setav" should be used instead. See here for more info on how to correctly call them. The script for what you described would look something like:scn ... short SrtVar short EncVar begin ... ... set StrVar to player.GetAV Strength set EncVar to player.GetAV Encumbrance set StrVar to StrVar * EncVar ;NOTE: I'm reusing StrVar to hold the product of the two player.SetAV Speed StrVar ... end Edited April 5, 2011 by Skevitj Link to comment Share on other sites More sharing options...
redeyesandlonghair Posted April 5, 2011 Author Share Posted April 5, 2011 You can't nest functions, so you will need at least two variables, and then might as well just do the calculation on a different line. When calling the functions, "player.setav ..." will work, but it depends how the script is being run, ie, if it's a spell effect then "setav" should be used instead. See here for more info on how to correctly call them. The script for what you described would look something like:scn ... short SrtVar short EncVar begin ... ... set StrVar to player.GetAV Strength set EncVar to player.GetAV Encumbrance set StrVar to StrVar * EncVar ;NOTE: I'm reusing StrVar to hold the product of the two player.SetAV Speed StrVar ... end Thank you for your reply! :laugh: So from reading your reply and a little bit of eswiki browsing I have come up with the following script. I would be overjoyed if someone might point out if this is going to do what I think it is going to... or just mess ma game up :sweat: If you're wondering, what I want this to do is adjust my Speed based on my current fatigue and encumbrance levels. If my encumbrance is less than half of my maximum encumbrance, I want it to lower my speed by up to 50% (completely encumbered would equal -50% speed, though obviously the game would stop me in my tracks anyways, [unless there's some way to turn that function off, which I would also like to implement if possible, but one thing at a time lol]) My current Fatigue would also lower my speed by up to 50%. -0% at full fatigue, -50% at completely empty fatigue (at which point another mod makes me pass out anyways). So at full encumbrance and zero fatigue my speed would be 0. Looking forward to your responses :woot: ScriptName AAAMyEncumbranceFatigueSpeedRules ;short StrengthVar;short EncumbVar;short FatigueVar;short MaxEncumbVar;short HalfEncumbVar;short SpeedVar;short BaseSpeedVar ;BaseSpeedVar is meant to keep my normal unadjusted Speed value so that this script doesn't cause a devestating speed-killing loop effect. ;short StrengthSpeedModVar;short FatigueSpeedModVar;short TotalSpeedModVar ;Begin GameMode ;set StrengthVar to player.GetAV Strength ;set EncumbVar to player.GetAV Encumbrance ;set FatigueVar to player.GetFatiguePercentage ;set SpeedVar to player.GetAV Speed ;If [ BaseSpeedVar > 0 ) ;set SpeedVar to BaseSpeedVar ;Else ;set SpeedVar to player.GetAV Speed ;EndIf ;Here I set the currently recognized Speed value to the old one, if it has been defined before. If it hasn't, then it gets current Speed. ;set MaxEncumbVar to StrengthVar * 5 ;set HalfEncumbVar to StrengthVar * 2.5 ;If ( EncumbVar > HalfEncumbVar ) ;set StrengthSpeedModVar to EncumbVar / MaxEncumbVar ;EndIf ;Setting up the % modifier that encumberance will apply. ;set FatigueSpeedModVar to FatigueVar / 2 ;set StrengthSpeedModVar to StrengthSpeedModVar / 2 ;set StrengthSpeedModVar to .5 - StrengthSpeedModVar ;Dividing them in half so they don't add up to more than 100% ;set TotalSpeedModVar to FatigueSpeedModVar + StrengthSpeedModVar ;set BaseSpeedVar to SpeedVar ;player.setAV Speed SpeedVar * TotalSpeedModVar ;Applying the final modifier to speed, and keeping the unmodified speed value as BaseSpeedVar ;End PS - I'm starting to see why there are so many extensive mods. This script is tiny and it's already very addicting. Link to comment Share on other sites More sharing options...
fg109 Posted April 5, 2011 Share Posted April 5, 2011 (edited) Your script looks like it would work, but I'm not sure that it's such a good idea. You're using SetAV at the end, which is supposed to change the base value of the attribute. It would be better to use ModAV2 instead (assuming you have OBSE) because that would not alter the base value, and it doesn't have bugs like the regular ModAV. Also, your script doesn't account for leveling up or magic effects altering your speed. I suggest getting rid of the BaseSpeedVar and anything related to that, and changing your script to this: ScriptName AAAMyEncumbranceFatigueSpeedRules ;Your variables short initialize short ModdedSpeed short tempshort Begin GameMode if (StrengthVar != player.GetAVStrength) set initialize to 1 elseif (EncumbVar != player.GetAV Encumbrance) set initialize to 1 elseif (FatigueVar != Player.GetFatiguePercent) set initialize to 1 elseif (ModdedSpeed != Player.GetAV Speed) set initialize to 1 endif ; Stop the rest of the script from running if not initialized if (initialize == 0) Return endif ; Find out how much (if any) change in speed and sets SpeedVar if (ModdedSpeed > 0) set tempshort to (Player.GetAV Speed - ModdedSpeed) else set SpeedVar to Player.GetAV Speed endif set SpeedVar to (tempshort + SpeedVar) ; Do your calculations here... set ModdedSpeed to (SpeedVar * TotalSpeedModVar) set tempshort to (ModdedSpeed - Player.GetAV Speed) Player.ModAV2 Speed tempshort End You could refine this further with GetTotalAEMagnitude if you don't want your script to react to bonuses or debuffs from spells affecting speed. Or if you don't want it reducing the total bonus or debuff from the spell. Edited April 5, 2011 by fg109 Link to comment Share on other sites More sharing options...
redeyesandlonghair Posted April 6, 2011 Author Share Posted April 6, 2011 wow...okay... you basically just upped the ante... by about ten times the number of chips I've got....... or rather, what I should say is, I'm looking at what you typed like it's written in chinese :blink: In the "do my calculations here" part, which variables and commands do I use to do that...am I basically using the same ones that I did it in the script I typed up? If that's the case then... well, yay! The other script, not surprisingly, didn't work at all. It did absoluotly nothing when I flipped it on (And yes I got rid of all the ; things and fixed the couple of errors I had :yucky: ) I'm going to guess that it did nothing because I have mods that adjust my fatigue by a very wide margin. The mod in question is Vim&Vigor, and it adds about 4500 fatigue to my total, with a permanent Fortify Fatigue effect, so I'm guessing the variable for fatigue that I was using was about...say, 4500 lower than my actual maximum fatigue. Will Player.GetFatiguePercent take into account the fact that I have 4500 extra fatigue? Or does that only account for my unmodded fatigue? Also, I'm guessing that != means does not equal. There's a lot of new things in that script! Thank you very much for your response and the better script :blush: Link to comment Share on other sites More sharing options...
fg109 Posted April 6, 2011 Share Posted April 6, 2011 By "do your calculations here..." I meant what you already had in your script, except for anything dealing with BaseSpeedVar and SpeedVar. According to the [urel=http://cs.elderscrolls.com/constwiki/index.php/GetFatiguePercentage]CS Wiki[/url], GetFatiguePercent returns your current fatigue as a fraction of your base. So since you have 4500 extra fatigue, that would probably be higher than 10... I don't know why it didn't work though. That mod would have caused your speed to increase instead of decrease, but there should have been some noticeable change. I guess it could be that it raised your TotalSpeedModVar so much that you were trying to set your Speed attribute over the limit (I don't remember if that's 255 or 256). Link to comment Share on other sites More sharing options...
redeyesandlonghair Posted April 6, 2011 Author Share Posted April 6, 2011 According to the [urel=http://cs.elderscrolls.com/constwiki/index.php/GetFatiguePercentage]CS Wiki[/url], GetFatiguePercent returns your current fatigue as a fraction of your base. So since you have 4500 extra fatigue, that would probably be higher than 10... Yarg! Well I'm sure I can figure out some sort of formula to account for this. I think I remember seeing the formula for how the game calculates normal base fatigue, so I can just do that and add 4500. As long as the getplayer Fatigue gets my current fatigue rather than my max, then it should be doable. :pirate: As far as the other one raising speed; I had actually noticed that and changed the formulas so it would lower speed, but I'm wondering if the overly high fatigue was causing issues, something along the lines of the game returning a value of me having 1000% of my base fatigue, and then trying to raise my speed beyond the maximum like you said. I think, but I'm not sure, that my character may have seemed a bit fast...not sure, she's allready pretty speedy. Link to comment Share on other sites More sharing options...
THEMAS Posted September 10, 2014 Share Posted September 10, 2014 This is interesting. I think I'll try something similar for script practice. Link to comment Share on other sites More sharing options...
Recommended Posts