Dangers of ModAVSetAV in scripting? Or... how to edit AV's w

Post » Thu Jun 21, 2012 12:43 am

So I'm wanting to mod a few actor values. Traditionally what I've been doing so far is making a seperate magic effect for each actor value I want to change, and then simply having the effect to be the actor value and the magnitude as the multiplier/setting for it.

This works fine for doing stuff that works nice with having round numbers, but if I want to modify the value using math/formula, I'll need to use a script.

However, I've got no clue how to really approach this, seeing as I hear from basically any experienced scripter on these games, "NEVER MOD ACTOR VALUES IN YOUR SCRIPT!!!"

Is that really true? How can I do so *safely* so I don't mess up everyone's stats/save games? The magic effect system worked nice, because I could just remove an effect if I wanted the change gone. But I can't really do that it seems in the script, as I'm modding the value directly. So how I can mod it, while being safe and making sure I don't accidently stack a whole bunch of changes on each other, ruin another mod's work, or ruin a save game?

I ran some preliminary tests and I'm also having trouble actually getting my actor value changes to not stack up on itself.

Basically, what I'm doing is I'm modifying the base weapon speed multiplier depending on material type. I declare a variable that gets what the current value is. Then, I run some "if" conditions checking for material type. Once it gets to the correct type, it'll change the actor value of the weapon speed mult to ("MyDeclaredVariable" * 1.25), for example.

This "works", but the problem is, it stacks, even though I tell it to just set the AV to what I declared it as when the player unequips. So if I unequip and than requip a different weapon, or the same weapon, it'll get progressively faster and faster untill I can use weapons like I'm jackie chan on some serious drugs :tongue: How can I prevent this? It probably ties in with my first question too...
User avatar
sexy zara
 
Posts: 3268
Joined: Wed Nov 01, 2006 7:53 am

Post » Thu Jun 21, 2012 6:36 am

I haven't had any problems with it. For simple summoned actors, I actually scale their AVs with the player's level using SetAV and whatnot.

If you are going for temporary modifications to actor values, you can use DamageAV() and the corresponding function to restore the AV.

I think the reason things like ModAV and SetAV are frowned upon is because those specifically can mess up saves. But if you are modifying an AV on an actor that is specific to your mod, then I see no reason why you shouldn't. And if you are, for example, trying to do damage through a script that is modified by some parameter on the fly, the damageAV() function and its partner are great functions to use and I have had no trouble with them.



If you are just trying to modify weapon speed based on material, I suggest using perks though, because you can do the same thing much more effectively and safely. Take a look at the Limbsplitter perk. It does what you want. All you have to do is remove all the conditions that check to make sure it is a battleaxe, then change the entry points to modify weapon speed instead of apply combat hit spell.
User avatar
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Thu Jun 21, 2012 1:39 am

I am already doing the perk method, but the problem is I want to take those modifications and dynamically change them depending on certain factors, which can't simply be done through perks/magic system.

Does DamageAV work for positive values (i.e. I can temporarily add to the actor value), and does it work for ALL AV's, not just health/stam?
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am

Post » Wed Jun 20, 2012 9:30 pm

I don't know why anyone wouldn't use ModAV or SetAV, though I know why nobody should use ForceAV.
Both functions do what there are supposed to do, modify an AV modifier, if there are problems with that, the issue is most likely the script(er).

Does DamageAV work for positive values (i.e. I can temporarily add to the actor value), and does it work for ALL AV's, not just health/stam?
No, not to my knowledge, because of how http://www.creationkit.com/Actor_Values's work -- damage is its own modifier that is part of the complete formula, and its a negative modifier.

You need ModActorValue to modify the permanent modifier, which shouldn't be an issue since you have full control over what to pass and can undo your changes anytime.

Issues that can arise are external, OnEquipped might not trigger when you'd want it to and such.
User avatar
Charity Hughes
 
Posts: 3408
Joined: Sat Mar 17, 2007 3:22 pm

Post » Wed Jun 20, 2012 3:38 pm

I do not understand the difference between the first 3 here. I do know that you use negatives to lower AVs with these, and positives to increase AVs, but I do not get why there are 3 functions that seem to change AVs in the same way. I also do not know which, if any, or if all of them, modify current or maximum values. Take a target with 36/130 health, I have no idea how you would distinguish between modifying the 36 or the 130 when using these.
  • http://www.creationkit.com/ForceActorValue_-_Actor
  • http://www.creationkit.com/ModActorValue_-_Actor
  • http://www.creationkit.com/SetActorValue_-_Actor


GetAV() returns the current AV. So if you use it on a target and specify health as the av, and the target has 36 out of 130 health remaining, it will return 36. GetBaseAV() on the otherhand would return 130. Unsure of how this works for something like, say, conjuration skill. I am sure it could be tested easily.
  • http://www.creationkit.com/GetActorValue_-_Actor
  • http://www.creationkit.com/GetBaseActorValue_-_Actor

These are great, and are what I use for custom damage spells. When I use these on AVs like health, stamina, magicka, they do damage just as if the target was attacked. The AV's maximum does not change. Thus, using these, you can easily exert a lot of control over the damage an attack does and have it scale or change with any number of factors, such as players skill, level, or percentage of remaining health. Since the CK is [censored], and you cant go below 0.01 when messing with entry points in perks, this is the next best option for people that want to do things like have attacks do more damage the lower your health is.
  • http://www.creationkit.com/RestoreActorValue_-_Actor
  • http://www.creationkit.com/DamageActorValue_-_Actor
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Thu Jun 21, 2012 6:30 am

AV are split into four modifiers that are computed with some formula to give the actual AV value. The different functions modify different modifiers.

ForceActorValue:
Use ONLY with an NPC that either you want to die at some point or to live forever.

Or a much better idea -- never use this function.
It does the same thing as SetActorValue although with a twist, it will essentially break that AV its called on, permanently and irreparably.

ModActorValue: Modifies the permanent modifier.
SetActorValue: Modifies the base modifier.

DamageActorValue: Modifies the damage modifier by increasing it.
RestoreActorValue: Modifies the damage modifier by decreasing it.

GetActorValue: Returns the actual or total value which is computed.
GetBaseActorValue: Returns only the base-part of an AV.
User avatar
Ray
 
Posts: 3472
Joined: Tue Aug 07, 2007 10:17 am

Post » Wed Jun 20, 2012 4:01 pm

Thanks for the input guys. How can I make sure then that my script won't mess things up for users though?

And how can I prevent my SetAV changes from stacking on each other? Currently I have to so when you equip an item, it'll check (for example) if it is an iron greatsword. If so, it'll change the attack speed multiplier by 1.3.

If I keep equipping and unequipping items, the changes don't get reverted and the multipliers stack. Even though I'm telling in my unequip script to set the actor value of the speed mult to be what the stored variable was (which is established when the player first equips an item, before anything else is done on the equip script)?
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Wed Jun 20, 2012 7:42 pm

perhaps make it so when you unequip, it does SetAV again, but reduces by the same amount you increase it by when you equip the item.
User avatar
Jon O
 
Posts: 3270
Joined: Wed Nov 28, 2007 9:48 pm

Post » Thu Jun 21, 2012 12:46 am

That wont work because the actor value is a multiplier, not an additon/subtraction

Is there a way to store the value of a variable once you get it? That's what I need to do. I need to store the value of GetAV when it's called and then get that stored value when I need to restore it.

Then again I guess this isn't ideal if the player has some kind of boon they are using while the object is equipped that affects the same values.

Ugh. I wish there was a way to set actor values as temporary things instead of having it only be able to do absolute value/permanent changes. The only thing that works with the temporary damage actor value command are the 3 basic health/magic/stam AV's...

Of course I could just make 30 different magic effects that all do the same thing except at different values. That would do exactly what I want, but it seems a bit extreme, sloppy, and inefficent. Maybe I'll have to do it though if I want this working right as only a temporary change vs a permanent one.
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Thu Jun 21, 2012 3:06 am

That wont work because the actor value is a multiplier, not an additon/subtraction

Just reverse the function with 1 / [multiplier] ?

Eg. You do a GetAV, then SetAV (GetAV * multiplier). On uneqip, do a SetAV(GetAV * (1 / multiplier)).
User avatar
Invasion's
 
Posts: 3546
Joined: Fri Aug 18, 2006 6:09 pm

Post » Thu Jun 21, 2012 3:13 am

Hmmm well apparently certain actor values don't stack. Or at least, if they do, I can't find a way to get them to.

I.E. I've got my base skill magic effect affecting the multiplier. I then want to take this base skill multiplier and then change it depending on what weapon type you are using, so I do just that with a 2nd effect that modifies the same AV.

However, the only AV that goes into effect is the 2nd one, because it effectively "replaces" the base AV setting. Not sure how to fix... I've tried changing the effect from a value modifier to a peak value modifier, but no luck.

I'll try doing that but I wanted to ween off the script applying direct changes to the actor value in case of things going on in between equipps that would mess the AV up. I.E. another mod or another effect, completely involuntary of what I'm doing, changing the AV. At least with magic/perk effects, I'm effectively only adding/subtracting to the magnitude of the multiplier, instead of setting it directly to a certain value via a script.
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am

Post » Wed Jun 20, 2012 7:01 pm

Anyone got any ideas on how to make it so different spells actually stack instead of replacing each other when they modify the same actor value? I'd rather just figure that out, then do an hours worth of work porting my script over to magic effects only to find it doesn't work then have to spend time re-doing what I've already done except trying division by 1 in order to reverse setav settings :\
User avatar
carrie roche
 
Posts: 3527
Joined: Mon Jul 17, 2006 7:18 pm

Post » Wed Jun 20, 2012 5:13 pm

Note that SetActorValue changes the base value of an AV. So it actually sounds like it's doing what you're telling it to do. If you want to adjust the modifier and not the base value, use ModActorValue instead. Anyway, Plutoman's suggestion is sound. I'd definitely go that way, it is the right way.
User avatar
Shelby McDonald
 
Posts: 3497
Joined: Sat Jan 13, 2007 2:29 pm


Return to V - Skyrim