Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Questions specific to OpenMW-CS can be asked, and content development related topics can be discussed here
Post Reply
User avatar
Greywander
Posts: 104
Joined: 04 Dec 2014, 07:01

Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by Greywander » 16 May 2017, 01:52

TL;DR at the end.

I just did a round of testing, and the deeper I went the more interesting things got. This may also speak to why GCD doesn't seem to allow your attributes to grow beyond 95, as Galsiah may have been exploiting bugs that have been fixed in OpenMW.

I started my investigation with Fortify and Drain spell effects and noticed that all the bugs seem to have been fixed. The most relevant one being that draining a fortified stat would be permanent, acting more like a Damage effect than a Drain. The only solution was to remove the Fortify effect, Restore the stat, then reapply the Fortify effect. It seems this has been fixed, meaning that modders can safely employ Fortify/Drain effects without worrying about screwing things up in this way.

But they might not even have to do that.

It seems that OpenMW doesn't follow exactly the same implementation of the Get/Mod/SetStat scripting commands that vanilla Morrowind does. This might cause some issues with existing mods (like GCD), but I think it will be an unintentional boon to those looking to make even better mods.

GetStat still works as in vanilla, giving your current stat (base + fortification/drain/damage).

ModStat nominally affects only the base stat, but is still bound to values between 0 and 100. Your current stat can never be less than 0, so if you are under a Drain or Damage effect and you ModStat below 0, it will erase the Drain/Damage effect. If you have a +30 Fortify effect, and you ModStat -200, you'll end up with 0 base and 30 current. Similarly, if you ModStat 200 while under a Damage or Drain of 30pts, you'll end up with 100 base and 70 current. In other words, Fortify effects are always preserved, Drain and Damage effects are preserved when modding up but can be lost when modding down.

We can use this to find a player's base stat. First, GetStat and save that to a variable so we can restore it later. Then ModStat 200 (or any number >100). The player's base stat should now be 100. GetStat and subtract 100. A positive value is the amount of Fortification, a negative value is the amount of Drain/Damage. Add/Subtract this from the player's original stat value to find the base stat, then restore the player's stat with SetStat to that base value.

Although my initial testing indicates that this should work, I'd like to see some more rigorous testing done. It's possible there are some unusual circumstances that might changes things that I haven't accounted for. For example, I've mostly only tested this with Agility (due to convenience on my current save), so it's possible it works differently for other attributes, or that it works differently for skills.

Now, this is all fine and dandy if you want to keep stats between 0 and 100. But what if you want to uncap attributes and skills so they can advance beyond 100? Enter SetStat.

SetStat nominally affects only the base stat, and is not limited. This means we can SetStat to values above 100 or below 0 and Fortify, Drain, and Damage effects will be preserved. Let me repeat that. Fortify, Drain, and Damage effects are always preserved. Your current stat can't be lower than 0, so if you SetStat to a negative value it will display as being at 0 in white (as if Fortified), but if you then SetStat to a positive value this faux Fortify effect is gone.

So now we have an even easier way to find base stats. Save current stat, SetStat 100, GetStat - 100, and you now have the amount of Fortification/Drain/Damage. (Might SetStat to something higher, like 500 or 1000, if you expect stats to go above 100. If they can go above 100, then they should also be able to be drained/damaged by more than 100.)

Putting this all together, we have a very easy way to find a player's base stat, and a way to set a stat to be higher than 100. The only thing missing is a way to allow the player to improve skills normally past 100. For skills, we would either need to cap off the base value below 100 so that players can still improve them normally, and boost them via Fortify effects, or implement skill improvement via scripts, which is probably a lot harder.

TL;DR
  • Fortify/Drain bugs are fixed.
  • GetStat gets your base stat + Fortify/Drain/Damage, as in vanilla.
  • ModStat won't go above 100 or below 0, but preserves Fortify effects, and preserves Drain/Damage effects unless going below 0.
  • SetStat only sets base stat, always preserving Fortify/Drain/Damage effects.
  • CurrentStat = GetStat, SetStat 100, FortifyStat = GetStat - 100, BaseStat = CurrentStat - FortifyStat, SetStat BaseStat.
With this discovery in hand, I'm looking into trying to make my own leveling mod again.


User avatar
halbe
Posts: 39
Joined: 14 Feb 2017, 03:55

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by halbe » 09 Jun 2017, 08:49

You have no idea how helpful this has been for me, I had previously spent quite awhile writing my own leveling/stat system script with vanilla setstat in mind (as in: completely avoiding it) and this will make my life so much easier, thank you.

User avatar
Greywander
Posts: 104
Joined: 04 Dec 2014, 07:01

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by Greywander » 09 Jun 2017, 20:57

Yeah, I was pretty happy when I made my discovery. I'm curious to see what you do with your mod. Have you taken a look at the mod I made? What do you think you might do differently?

User avatar
halbe
Posts: 39
Joined: 14 Feb 2017, 03:55

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by halbe » 11 Jun 2017, 05:47

The goals of each of our mods are almost completely opposite, I don't like games where your increases in power are incremental and not based on player decision so in mine you only increase skills at trainers and when you do they increase by 25 points at a time (but obviously it's very expensive). This comes from playing Fallout with the perks where even though each perk doesn't make you that much more powerful, they feel like they make you a lot more powerful because they make you significantly better at one specific thing. It also increases your level and get to spend 25 points on an attribute every (4?) skill increases. Since this is a gigantic departure from vanilla it's only an optional component of my mod and isn't even recommended by default.

Other things I'll use this information for are simplifying my script that control your max health/fatigue/magicka, simplifying my script that doubles your strength when jumping (for jump attacks), and simplifying my script on a birthsign that sets all of your armor skills equal to the highest of the four. This is all for a big-ass openmw mega overhaul which uses currently 170 different mods and the major gameplay changes aren't enabled by default since most people don't want a major departure from vanilla.

User avatar
Greywander
Posts: 104
Joined: 04 Dec 2014, 07:01

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by Greywander » 11 Jun 2017, 08:28

halbe wrote:
11 Jun 2017, 05:47
The goals of each of our mods are almost completely opposite, I don't like games where your increases in power are incremental and not based on player decision
I definitely understand this, and I could appreciate doing it this way myself. I was just heavily influenced by GCD, and so made my own mod in its image. I've thought about designing my own OpenMW game, and I'm leaning toward making attributes increase primarily by player choice rather than linking it to skill gains, but that's partially a product of how attributes, skills, and your combined resource pool ("health", if you will) interact.

For me, part of the appeal of linking attribute growth directly to skill gains (aside from immersion) is that it removes the burden of choice. It's a disheartening feeling when you're 20 or 30 hours into a game, only to realize you've built your character badly. With ncgdMW, if you don't like your current build it's just a matter of training up the skills you actually want to use. Contrast this with something like Dark Souls, where maybe you've poured many points into Strength, Endurance, and Agility, only to realize that you actually want to play a magic user.
so in mine you only increase skills at trainers and when you do they increase by 25 points at a time (but obviously it's very expensive).
What's the skill cap? Do you reach 100 after training just four times?
It also increases your level and get to spend 25 points on an attribute every (4?) skill increases.
I'm going to assume you mean that if you visit a trainer 4 times, you then get to spend 25 points on attributes. Would it make more sense to spend 7 or 8 points on attributes after each training, instead? Do attributes cap out at 100? If so, you might want to use the built in level up system, where you can distribute points to three different attributes. Just set if so that you require any skill to increase 25 times to level up, and so that you always have a x2 or x3 multiplier. This won't work if you want to increase past 100, but I just thought I'd throw that out there.
This comes from playing Fallout with the perks where even though each perk doesn't make you that much more powerful, they feel like they make you a lot more powerful because they make you significantly better at one specific thing.
I honestly haven't played much Fallout, although I have both 3 and NV. I do like the idea of perks, but I thought they were badly implemented in Skyrim. Particularly the perks that were basically, "do this, but better," e.g. the damage increase perks on the weapon trees. Perks, in my mind, should do something different and interesting. There was a Skyrim mod, for example, called SPERG that massively overhauled the perk trees. One of the Archery perks would allow you to conjure arrows if you tried to use your bow without any arrows. You'd expend a small amount of magicka to shoot these arrows, and they got more powerful as your Conjuration skill increased. It was a really neat idea, and good for any archer that found themselves without any arrows. Oblivion, IIRC, had an Acrobatics perk that allowed you to hop across the top of water. Stuff like that.
Other things I'll use this information for are simplifying my script that control your max health/fatigue/magicka,
Be aware that SetHealth, and (presumably) Set Magicka and SetFatigue work as in vanilla. You'll have to do the normal chicanery to figure out how much of a fortify effect a player's Health might be under, as well as to adjust the player's current Health to carry over any damage. I was disappointed when I learned this, but I found a way to work around it.

On the other hand, I discovered that GetMagickaGetRatio exists, and presumably GetFatigueGetRatio as well (although I haven't checked). I don't see these functions in any of the documentation of script commands, either on the wiki or in Scripting For Dummies. The OpenMW team must have added them for the sake of completeness.
simplifying my script on a birthsign that sets all of your armor skills equal to the highest of the four.
I didn't see the birthsign part when I read this the first time. I was going to say that a much easier way of doing this would be to adjust the GMSTs so that all armor is considered "Light" Armor (or Heavy Armor, maybe). You could then repurpose the other two armor skills as much as the scripting engine will allow. Looks like maybe you want this to just be a feature unique to that birthsign, though.

Anyway, good luck with your mod! It certainly sounds interesting. I really find it fascinating that you can be playing basically a completely different game with just a few mods, but it's actually still the same game!

User avatar
halbe
Posts: 39
Joined: 14 Feb 2017, 03:55

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by halbe » 12 Jun 2017, 03:20

>Do you reach 100 after training just four times?
Yep, I'd consider making it go past 100 though (I wonder if this is possible just by changing the trainer's stats).

>Would it make more sense to spend 7 or 8 points on attributes after each training, instead?
Not as someone who doesn't like small increments in power.

>Do attributes cap out at 100?
Probably, I guess it could work if they were higher though.

>use the built in level up system
Then the power is distributed among 3 different areas and thus would be less noticeable

>Perks, in my mind, should do something different and interesting
Well these aren't perks, they're just inspired by how perks give you a large amount of power in a very specific area.

>Be aware that SetHealth, and (presumably) Set Magicka and SetFatigue work as in vanilla
Ok thanks, I was about to go test those. My scripts did work fine before all of this so this isn't a big deal, the main thing this allows me to do is implement skill/attribute changes.

>adjust the GMSTs so that all armor is considered "Light" Armor (or Heavy Armor, maybe). You could then repurpose the other two armor skills as much as the scripting engine will allow
Looks like we've got a psychic over here, I actually did this before and turned the extra skills into different weapon types (weapon skill was used to determine stamina cost and there was no RNG) but I wasn't happy having two dummy skills (heavy armor and unarmored) which had to be set at certain numbers and never changed for balance.

>Looks like maybe you want this to just be a feature unique to that birthsign, though.
Yeah I originally removed the birthsign screen during chargen but I thought I might as well put my weird and controversial changes in under a birthsign and a ring so people can choose to play more vanilla style and keep the other changes. The positive side of this birthsign (The Lord) is letting you use all armor freely and the negative side is that the map has been disabled so you have to use in-game maps from Stuporstar's books to get around if you're new. I get that those two aren't really related to each other or The Lord but they are changes that have to happen from the start of the game and not when you get an item. The ring gives you 1000 attack but takes away 1000 luck, and I made it Fargoth's ring so you can get it early on. Considering finding some way to tie the ring to Jygglag since it's all about making the game less chaotic, I'll have to replay Sheogorath's quest and see if I can reference it somehow.

What I'm currently trying to figure out is how to redo the death system, I hate savescumming so I gave the player almsivi intervention on death (and some health so they don't die) but apparently there is no way to force you to drop all your items into a corpse where you died so I'm not sure how to balance it outside of stat penalties. Previously this was going to be more of a roguelike and each time you kill an NPC a clone of them gets sent to "the void" so when you die you can go there and mantle them which gives you their base stats as your starting stats as well as their starting location (and if you go there while alive you can eat their souls for attribute bonuses which would replace levelups, number of souls you can eat = level). However this requires me to have a function that gets their baseID and the cell they're in so I can't do this without MWSE.

Let me know if you have any ideas for the death system, I'm also not entirely satisfied with how you gain attributes. I'm considering making attribute levelups something you buy at shrines of the nerevar but I'm not satisfied with that either. Worst case scenario I just do it vanilla style until I think of something better.

User avatar
Greywander
Posts: 104
Joined: 04 Dec 2014, 07:01

Re: Get/Mod/SetStat, Fortify/Drain Stat, and Leveling Mods

Post by Greywander » 12 Jun 2017, 08:49

halbe wrote:
12 Jun 2017, 03:20
What I'm currently trying to figure out is how to redo the death system, I hate savescumming so I gave the player almsivi intervention on death (and some health so they don't die) but apparently there is no way to force you to drop all your items into a corpse where you died so I'm not sure how to balance it outside of stat penalties.
At one point, I tried to do something similar via a birthsign. Once per day, you'd be saved from death via Almsivi Intervention. Of course, once you're dead there's no way to bring you back (maybe after 1.0?), so I got around that limitation by giving the player a Fortify Health 100 pts while they had their extra life, and if they dropped below 100 health then they would be "dead" and the ability would kick in. If something did more than 100 damage instantaneously, then it would be able to bypass the extra life, but what can you do?

As for penalties... hmm... Maybe you could cut the player's Health, Magicka, and Fatigue in half every time they die (or reduce it by 10%, if you want something less severe). There might be a number of ways to restore themselves back to full, but you could also make it time-based, where your maximums gradually increase each day until they're back to their full amount. Or maybe you'd need to obtain a rare ingredient from monster, or make a pilgrimage to secluded shrine, or chase down a shadowy doppelganger carrying your stolen power.

Also despise save scumming, and in fact wrote a rather lengthy post on the topic a while back. You can find it here. The part on save scumming starts after the second quote block (the one talking about random Luck gains). I also wrote a second post about character creation and respeccing, which may be relevant to your mod. I've refined some of my opinions on these subjects since, but they're definitely still worth a read if you're interested.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest