SetAV

Post » Sat Feb 19, 2011 1:55 am

ok so I was wondering if there was a way to safely use SetAV xxxx yyy without causing a bug if abilities get removed

what I need is a permanent boost to the player's magicka x amount of times
but I dont want it to cause the player to be bugged if he loses a fortify magicka ability

and I know I need to keep the boost stored somewhere that way if the player wants to
remove the mod it can restore his atributes to their original value

and I know I could do an ability to do this but i would look retarded

cause the boost might happen 20 times so the player say he gets 1 extra magicka each time
I know I could do 20 spells that add to the magicka so that each time it just swaps them out
but then what I decided to do it 50 extra magicka where the player could get an extra 50
magicka total I'd have to make 50 extra spells, ignoring the fact that it would be a painful
process it would take up alot of extra memory

so my question is... is it safe to boost the player's magicka stat using the SetAV function?
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Sat Feb 19, 2011 6:21 am

and I know I could do an ability to do this but i would look retarded

cause the boost might happen 20 times so the player say he gets 1 extra magicka each time I know I could do 20 spells that add to the magicka so that each time it just swaps them out but then what I decided to do it 50 extra magicka where the player could get an extra 50 magicka total I'd have to make 50 extra spells, ignoring the fact that it would be a painful process it would take up alot of extra memory

This is the only safe way to do it. OBSE has some commands which can make it less tedious, but they're also even more dangerous; I'd start by doing it the old fashioned way. Don't worry about memory usage, spells aren't that bad.
User avatar
joeK
 
Posts: 3370
Joined: Tue Jul 10, 2007 10:22 am

Post » Fri Feb 18, 2011 10:45 pm

...okay, now that I have a little more time to type, I should add that this is exactly the sort of task that http://www.gamesas.com/index.php?/topic/1091638-wipz-formulatoresm/ is intended for. It's currently alpha and mostly untested, so if you intend to release your mod soon, it's still worth doing it manually; but if you don't mind delaying a little while, I would greatly appreciate someone else testing Formulator's functions and this would help me get it released sooner, too.

Whichever method you use, there's one more thing you should be aware of: if a saved game contains an active effect from a mod, and the mod is removed, the effect is not cleared from the target. The best solution is to create a "clean-up" mode, activated by setting a variable on the console, which causes all effects to be removed. Note that if you put any effects on anyone but the player, clean-up has to last half an hour to guarantee that the script runs on actors not in loaded cells.
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Sat Feb 19, 2011 11:58 am

well considering that I have a system that would work

i could use

4x fortify magicka 2 pts
1x fortify magicka 10 pts
2x fortify magicka 20 pts
1x fortify magicka 50 pts
1x fortify magicka 100 pts

and everytime player has enough then change to the next spell up

but that would svck to script lol
User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am

Post » Sat Feb 19, 2011 3:48 am

A slightly more compact script would do it in binary - one each of 2, 4, 8, 16, 32, 64, 128, and pick the right set for whatever value you need. And yes, this is the classical safe way to do it. And yes, it svcks to code. ;)

For comparison, here's what I've done with Formulator, and why I'm trying to get other people to help me test it. You'd start with one Fortify Magicka ability that has zero magnitude. The code below assumes that you've assigned that ability to the currentAbility variable in an initialization block, and newMagnitude is set somewhere earlier in the script. No other bookkeeping or preparation is needed. (Note that Formulator requires OBSE, and this script does too.)

ref currentAbilitylong newMagnitudelong oldMagnitude  if (newMagnitude != oldMagnitude)    if (player.HasSpell currentAbility)      player.RemoveSpellNS currentAbility    endif    if (newMagnitude > 0)      call formSpellRegister currentAbility      call formSpellSetNthMagnitude newMagnitude 0      let currentAbility := call formSpellFinalize      player.AddSpellNS currentAbility    endif    let oldMagnitude := newMagnitude  endif

currentAbility now contains a reference to a new spell effect which is identical to the old one except for its magnitude. You don't ever need to edit it outside of this code block, just set a fresh newMagnitude and let it run. If you ever use the same magnitude again, Formulator will recognize that it's already created that effect, and re-use it to prevent save game bloat. Only one effect ever needs to be on a given actor, and as you can see, the script is much shorter!
User avatar
Jamie Moysey
 
Posts: 3452
Joined: Sun May 13, 2007 6:31 am

Post » Sat Feb 19, 2011 7:03 am

wow that would be great because I would like the player to be able to see the boost and also get many boosts so that the one player could have a boost of 18 where as another player could have a boost of like 84,

but one question does that create the actual spell for you?
User avatar
Leah
 
Posts: 3358
Joined: Wed Nov 01, 2006 3:11 pm

Post » Sat Feb 19, 2011 12:53 pm

but one question does that create the actual spell for you?

It can, but it's easiest to start with a base spell. Create the spell in the CS, change its type to Ability and add a Fortify Magicka effect, but don't set the magnitude. Then at the beginning of your control script you'd have something like,

short init  if init == 0  ; This should only happen once per game    let currentAbility := myAbilityEditorID    let init := 1  endif

After that, it's all set... the section from the first block I posted --
      call formSpellRegister currentAbility      call formSpellSetNthMagnitude newMagnitude 0      let currentAbility := call formSpellFinalize
-- actually creates a new spell with the magnitude you want.
User avatar
Katharine Newton
 
Posts: 3318
Joined: Tue Jun 13, 2006 12:33 pm

Post » Sat Feb 19, 2011 4:05 am

ok... I was trying to not use obse as much as possible(not because i dont like it, i love it in fact but just for capatibly reasons) but I went in and looked at what I could do and I can simply make a base spell then remove it from the player and change it then add it back, and it wont any down sides...

I'm not saying your mod(or plugin really) isnt awesome I just dont understand why i couldnt just edit a base spell reference since the player is the only one that will be using the spell... unless
when I edit it the spell wont stay at that magnitude when I save/load

so what makes your plugin better then that again, I'm not being mean at all just trying to figure it out, like I can see the awesome effects it could do it you had one spell for multiple npcs and the player it would be extremely awesome and help alot, but for just a player only spell wouldnt it be better to use setNthIEMagnitude?
User avatar
Cameron Wood
 
Posts: 3384
Joined: Wed Oct 31, 2007 3:01 pm

Post » Sat Feb 19, 2011 5:09 am

I was trying to not use obse as much as possible(not because i dont like it, i love it in fact but just for capatibly reasons)

Hehe, I made that mistake for a while too. ;)

unless when I edit it the spell wont stay at that magnitude when I save/load

This is a problem, but it can be overcome by "CloneForm"-ing the spell (once, in an init block) and only using the clone, because that does get saved. Or set the magnitude before removing the spell, as well as before adding it -- the active effect on the player is actually independent of the base form, you just need to make sure it's removed correctly.

And you're right: for something as straightforward as this, you can get away with that. The only advantages of Formulator here are slightly cleaner code, and an easy conversion if you decide to affect NPCs later. I guess mostly I'm just hoping to get more people looking at it right now. ;) More eyes find bugs faster, and it's a tool that can be great for many applications. But yeah, maybe too much tool for this one.
User avatar
Connor Wing
 
Posts: 3465
Joined: Wed Jun 20, 2007 1:22 am

Post » Fri Feb 18, 2011 10:54 pm

no no I mean your Formulator sounds really great Im just not sure that I need to dive into something deep like cloneforms if I can help it cause I just really only need to change the magnitude for the player but if I was going to use the spell for many npcs and the player as well i would love the formulator cause that would be very helpful a less of a time consuming process, so keep up the good work cause I did look at your mods and you have many great looking ones (Im downloading the Life detection cause it looks awesome lol...)

but I do have a question does the SetNthIEMagnitude save or would I need to set it every load? (Im pretty sure theres like a OnLoad or something like that so it shouldnt be hard but I just need to know so i can if i need to lol)
User avatar
jason worrell
 
Posts: 3345
Joined: Sat May 19, 2007 12:26 am

Post » Sat Feb 19, 2011 9:49 am

but I do have a question does the SetNthIEMagnitude save or would I need to set it every load? (Im pretty sure theres like a OnLoad or something like that so it shouldnt be hard but I just need to know so i can if i need to lol)

The fact is, I don't remember for sure. :P I'm 90% sure it doesn't. But your variable holding the magnitude it should have is saved, and the command you're looking for is GetGameLoaded. Or as I mentioned above, just set it every time you remove it as well as every time you add it. Oblivion scripts are very processor-efficient, there's no reason to cut corners.

In case it's not entirely clear, here's how the process works internally: when you add the ability to the player, Oblivion checks the ability's magnitude, internally calls ModAV on the appropriate attribute (Magicka in this case), and adds an Active Effect (AE) record to the player which points back to the ability. The AE stores a magnitude value for display, but that's all it's used for. If you later remove the ability, instead of using the AE magnitude, Oblivion checks the base form's magnitude again and calls ModAV for the inverse value. Except for when it's added and when it's removed, the ability's magnitude is not checked; so if you save the game then quit and reload, the base spell has a magnitude of 0 again but the effect on the player is still at whatever magnitude it had when you saved. You need to change it back before removing the effect or the inverse-ModAV will be incorrect; but you don't need to set it as soon as the game loads, because from the player's perspective everything is as it should be. (Again, better safe than sorry -- I'd set it on game load AND right before removing it.)

I actually took advantage of this in Willful Resistance to use the same two base abilities (resist and weakness) on every actor in the game: I set them to different magnitudes for each actor, because once applied, changes to the base form don't matter. Immediately before removing an ability, I set it back to what it was when I applied it, so it came away clean. The downside is that other mods checking those actors' abilities might not get the right info, and for that reason Willful Resistance is one of the mods I'll be switching over to Formulator once it's ready; but in your case, with only the player being affected, it should be safe enough.
User avatar
Laura-Lee Gerwing
 
Posts: 3363
Joined: Fri Jan 12, 2007 12:46 am

Post » Sat Feb 19, 2011 4:01 am

thanks so much for all the help hopefully I'll get some progress I've been working on a mod recently and want it be great, what would your opinion of a Lich Mod be?
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am

Post » Sat Feb 19, 2011 6:00 am

thanks so much for all the help hopefully I'll get some progress I've been working on a mod recently and want it be great, what would your opinion of a Lich Mod be?

Ooh, I'm not sure I've ever seen one of those done before... funny, since it seems like an obvious idea! It's the kind of thing I'll probably never have the time to try out myself, but I think it's a great concept and should be popular. Feel free to PM me if you need any help!
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Fri Feb 18, 2011 10:34 pm

ok thanks, i've seen some out there but none are really inventive or have any kind of system it's just a get the items then your a full blown demi-god so Im left a little depraved lol but ya thanks for the help i think I gotta good system for it now, thanks to your advice and steering
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am


Return to IV - Oblivion