Script to increase HealthMagickaStamina on Skill Leveling

Post » Thu Jun 21, 2012 5:44 am

Spoiler


I've been working on a script that adds 1 to a stat max when the linked skill levels up.

Spoiler


The idea was that this would work in tandem with a script which would set the skill at 100 when it reached 101, with normal stat increases from leveling (and indeed leveling itself) turned off.

I initially assumed that I could use some maths with ModActorValue to make this work like so (because '+' doesn't work with modactorvalue):

ScriptName WZTestOneHanded extends QuestEvent OnStoryIncreaseSkill(string OneHanded)if (Game.GetPlayer().GetActorValue("OneHanded") == 101)			  Game.GetPlayer().ModActorValue("Health", -100)						Game.GetPlayer().ModActorValue("Health", 101)endIfendEvent

This would include a hundred more entries that each substract and add to effectively increase max Health by 1 every time the skill leveled. But this script only increases Health by 1 no matter how many times the skill levels. Apparently ModActorValue sets the Permanent Modifier rather than altering it? So I would have to use a script like this:

ScriptName WZTestOneHanded extends QuestEvent OnStoryIncreaseSkill(string OneHanded)if (Game.GetPlayer().GetActorValue("OneHanded") == 101)			   Game.GetPlayer().ModActorValue("Health", 101)endIf

So every time a skill levels up, the max health modifier is altered to a number equal to the level. This however means repeatedly leveling up a skill to 101 would not increase the stat, nor would leveling up a different skill. Interesting to note that this script has no effect on the first time a skill levels after loading (possibly after entering an area as well).


As far as I can tell not SetActorValue, DamageActorValue, ForceActorValue or RestoreActorValue won't help me pull this off.

Any ideas? Could I do this with SKSE? Or am I doing something wrong/missing something obvious?

Alternatively, would it be possible to create a spell effect or something that does this? Like if Health starts at 100, and every time an applicable skill levels a 1% increase spell effect is cast on the player?


EDIT: Update

Ok, I created a spell to Fortify player health 1 point on skill level.

ScriptName WZTestOneHanded extends QuestSpell Property WZTestFortifyHealthAbility AutoEvent OnStoryIncreaseSkill(string OneHanded)(Game.GetPlayer().AddSpell(WZTestFortifyHealthAbility))if (Game.GetPlayer().GetActorValue("OneHanded") == 101)Game.GetPlayer().SetActorValue("OneHanded", 100)endIfendEvent

Still not working though...

Log says:


error: Cannot add a None spell to the actor
stack:
[ (00000014)].Actor.AddSpell() - "" Line ?



TLDR: Got it working, now trying to write a script to repeatedly increase the magnitude of the spell
User avatar
Ricky Meehan
 
Posts: 3364
Joined: Wed Jun 27, 2007 5:42 pm

Post » Thu Jun 21, 2012 5:06 am

Bump
User avatar
Marilú
 
Posts: 3449
Joined: Sat Oct 07, 2006 7:17 am

Post » Wed Jun 20, 2012 10:02 pm

Add two following:
Actor Property Player Auto
Spell Property NewSpell Auto

Set the values to the player and your spell.

Then your addspell code would be

Player.Addspell(NewSpellProperty)


FYI - Using the SMEN Skill Increase will kill any other mod that uses it if the mod is loaded lower than yours. If yours is loaded lower, your mod won't work.
http://www.creationkit.com/SM_Event_Node scroll down to Known Issues.
You'll need to be aware of that when people start complaining...
Or find a way to use some other method such as an OnUpdate event.
User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Thu Jun 21, 2012 8:02 am

I got it working thanks.

Yeah I noticed that about SMEN Skill Increase, it was initially clashing with my perpetual skill leveling mod, so I put them into one.
User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm

Post » Thu Jun 21, 2012 7:10 am

I got it working thanks.

Yeah I noticed that about SMEN Skill Increase, it was initially clashing with my perpetual skill leveling mod, so I put them into one.
How are you writing this..?

I worry about what you're doing since you said this...
TLDR: Got it working, now trying to write a script to repeatedly increase the magnitude of the spell
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Thu Jun 21, 2012 1:43 am

How are you writing this..?

Perpetual leveling?

ScriptName WZTestOneHanded extends QuestEvent OnStoryIncreaseSkill(string OneHanded)if (Game.GetPlayer().GetActorValue("OneHanded") == 101)			   Game.GetPlayer().SetActorValue("OneHanded", 100)endIfendEvent

(Using skill uncapper)

It allows to keep leveling up using a skill that is maxed out without breaking the skill. Although I am trying to sidestep leveling altogether by linking stat increases to skill increases.

I worry about what you're doing since you said this...

Yeah, I don't think its possible. Is there a way to make the fortify health spell stack/increase in magnitude? If not, I have run into the same problem as a purely script based approach.

Hmm, what if I had a value that increased every time the relevant skill increased, and depending on the value it would select a spell of different magnitude. I would have to make like 200 duplicate spells though?
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Wed Jun 20, 2012 10:51 pm

Perpetual leveling?

ScriptName WZTestOneHanded extends QuestEvent OnStoryIncreaseSkill(string OneHanded)if (Game.GetPlayer().GetActorValue("OneHanded") == 101)			   Game.GetPlayer().SetActorValue("OneHanded", 100)endIfendEvent

(Using skill uncapper)

It allows to keep leveling up using a skill that is maxed out with breaking the skill. Although I am try to sidestep leveling altogether by linking stat increases to skill increases.



Yeah, I don't think its possible. Is there a way to make the fortify health spell stack/increase in magnitude? If not, I have run into the same problem as a purely script based approach.
I think this would be possible... I modify the players maximum health in my mod during a certain event, and change it back after I'm done with it. You could do the same, but simply have it only "remove" the fortification once the mod is uninstalled. I kinda forgot the code though so I'll have to post it here after I get back home.

But yeah, you could use the same logic to work for skill increases.
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Thu Jun 21, 2012 7:34 am

That would be fantastic thanks! The problem is getting the stat to incrementally increase for every skill level up, the hard part being doing so repeatedly when 101 is reached.

Hmm, what does the 'Skill Usage Mult' for Magic Effects do? I assume it has something to do the with Magic Skill...
User avatar
Lisa
 
Posts: 3473
Joined: Thu Jul 13, 2006 3:57 am

Post » Thu Jun 21, 2012 6:34 am

To answer your question regarding skill usage mult, I don't really remember, but I'm almost positive it's not what you need. Now, I've never messed with story events, so I can't help you with any of the logic there, but as far as adjusting health or skill values goes, I believe this should do what you need it to do.

You're going to need a basic quest with a script, a magic effect with a script, a spell that uses that magic effect, and then your story event related stuff placed wherever.


First create a basic quest. It should have start game enabled, with no objectives, no stages--just one single script.

(For this example, I'll just call this quest HealthManagementQuest and the script it uses will be called HealthManagementQuestScript)

The script will contain only one variable, a float property called "HealthIncrementValue", that initializes at 0.0.

Then you will create a magic effect, which I'll call "SkillHealthFortificationEffect". You should tick the following checkboxes. No magnitude, No Area, No duration, Hide in UI, Recover, and Persists on death. Make it a constant effect, self based magic effect that is of the archetype "Script". You can then go ahead and click OK, and create the spell for it. Name it SkillHealthFortification, constant effect, self target with the effect you created.

Go back to the magic effect, and create a script for it. Call the script something like SkillHealthFortificationEffectScript.
Scriptname SkillHealthFortificationEffectScript extends ActiveMagicEffect  {This script will fortify the players Health by a certain amount, based on the decided amount of increased health}Actor Property Player Auto			; It is preferred to use a direct reference to the player at all times for optimization purposes.HealthManagementQuestScript Property HealthManagementQuest AutoFloat HealthAdjustValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0		; Value that the players Health will be modified by. Used to revert changes after buff expiration.Event OnEffectStart(Actor akTarget, Actor akCaster)	; Only run code if the target is the player	If akTarget == Player		; Set the health adjust value		HealthAdjustValue = (Player.GetBaseAV("Health") + HealthManagementQuest.HealthIncrementValue)		; Fortify their Health by the amount		akTarget.ModAV("Health", HealthAdjustValue)	Else		Dispel()	EndIfEndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)	; Only run finishing code if target was the player	If akTarget == Player && HealthAdjustValue != 0.0		; Restore their Health to its original value		akTarget.ModAV("Health", -HealthAdjustValue)	EndIfEndEvent

So that will increase their health by the total amount specified, and then reduce it once the effect finishes. (This is very important for fixing things after your mod is uninstalled, and it's also just easier to work with.)

So now, all that needs to be done, is change that "HealthIncrementValue" whenever a skill is increased.

Now, I'm pretty sure you can merge the quest I described with whichever one is controlling your story event stuff, but it's not a big performance hit or anything if you can't.

So taking the script you posted earlier,
ScriptName WZTestOneHanded extends QuestEvent OnStoryIncreaseSkill(string OneHanded)if (Game.GetPlayer().GetActorValue("OneHanded") == 101)                           Game.GetPlayer().SetActorValue("OneHanded", 100)endIfendEvent

If you can merge it with the quest I described, I would change it to this.
ScriptName HealthManagementQuestScript extends QuestActor Property Player Auto			; It is preferred to use a direct reference to the player at all times for optimization purposes.float Property HealthIncrementValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0 AutoSpell Property SkillHealthFortification AutoEvent OnStoryIncreaseSkill(string Skill)	If (Player.GetBaseAV("Skill") == 101)		; It's important to get their BASE AV, not their current AV. GetAV will account for buffs and equipment. BaseAV will not.		Player.RemoveSpell(SkillHealthFortification)		HealthIncrementValue+= 1.0		Player.SetAV("Skill", 100)		; SetAV, oddly enough, DOES set their base AV, from what I've seen.		Player.AddSpell(SkillHealthFortification, abVerbose=False)	EndIfendEvent

So what that would do, is every time a skill is increased to 101, it would Remove the health buff (putting them at their original value), and then increase the health fortification number by 1. It would revert the skill to 100, and then add the new fortification effect.

This all rides on the SetAV actually working. And honestly I have not tested any of the above scripts. You may need to tweak some things and possibly even alter some formulas, but this logic should point you in the right direction.
(I can only hope this is what you were looking for, but even if not, hopefully someone will be able to benefit from this.)

EDIT: Fixed some code issues.
User avatar
Jeremy Kenney
 
Posts: 3293
Joined: Sun Aug 05, 2007 5:36 pm

Post » Thu Jun 21, 2012 9:35 am

Wow, thanks for all that Delfofthebla, it definitely pushed me in the right direction. I was at it for a long time using a variety of different interpretations and approaches, using both a spell effect and pure scripting, but in both cases the end result was the same; a one off increase of 1 and no subsequent increases. I suspect that the script is starting over each time, meaning the variable never actually increases.

Thus I have been trying to create a global variable, but I can't get the mod global variable script to compile at all.

This is roughly what I have at the moment, WZHealthIncrementValue being the global variable, and HealthIncrementValue being the script variable derived from it:

Scriptname WZHealthFortificationEffectScript extends Questfloat Property HealthIncrementValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0 Autofloat Property WZHealthIncrementValue = 0.0 AutoEvent OnStoryIncreaseSkill(string OneHanded)HealthIncrementValue += (float newValue = WZHealthIncrementValue.Mod(1))Game.GetPlayer().ModActorValue("health", HealthIncrementValue)endEvent

float newValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/WZHealthIncrementValue.Mod(1) wont seem to compile no matter what I do, and I'm not sure how to get it added to HealthIncrementValue even if it did.
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm

Post » Thu Jun 21, 2012 12:36 pm

Wow, thanks for all that Delfofthebla, it definitely pushed me in the right direction. I was at it for a long time using a variety of different interpretations and approaches, using both a spell effect and pure scripting, but in both cases the end result was the same; a one off increase of 1 and no subsequent increases. I suspect that the script is starting over each time, meaning the variable never actually increases.

Thus I have been trying to create a global variable, but I can't get the mod global variable script to compile at all.

This is roughly what I have at the moment, WZHealthIncrementValue being the global variable, and HealthIncrementValue being the script variable derived from it:

Scriptname WZHealthFortificationEffectScript extends Questfloat Property HealthIncrementValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0 Autofloat Property WZHealthIncrementValue = 0.0 AutoEvent OnStoryIncreaseSkill(string OneHanded)HealthIncrementValue += (float newValue = WZHealthIncrementValue.Mod(1))Game.GetPlayer().ModActorValue("health", HealthIncrementValue)endEvent

float newValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/WZHealthIncrementValue.Mod(1) wont seem to compile no matter what I do, and I'm not sure how to get it added to HealthIncrementValue even if it did.
To be honest, I don't really know why you're doing things the way you are in that script, but here is how you would fix it.

Scriptname WZHealthFortificationEffectScript extends QuestGlobalVariable Property WZHealthIncrementValue AutoEvent OnStoryIncreaseSkill(string OneHanded)WZHealthIncrementValue.Mod(1)Game.GetPlayer().ModActorValue("health", WZHealthIncrementValue.GetValue())endEvent
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Thu Jun 21, 2012 12:36 am

To be honest, I don't really know why you're doing things the way you are in that script,

haha, because I only started scripting a couple of days ago and don't know what I'm doing. Thanks for that. Hmm its still not working in game though ... I'm guessing I'm doing something wrong linking the script/quest/globalvariable.
User avatar
City Swagga
 
Posts: 3498
Joined: Sat May 12, 2007 1:04 am

Post » Thu Jun 21, 2012 10:50 am



haha, because I only started scripting a couple of days ago and don't know what I'm doing. Thanks for that. Hmm its still not working in game though ... I'm guessing I'm doing something wrong linking the script/quest/globalvariable.
Ahh, I see. After you save the script, you have to right click it, edit properties, and then connect them up. (If your globalvariable is the same name in both the editor and your script, clicking "Auto Fill All" should connect them up for you.)
User avatar
Alexis Acevedo
 
Posts: 3330
Joined: Sat Oct 27, 2007 8:58 pm

Post » Thu Jun 21, 2012 5:50 am

I should have known that, thanks. Gah, still having the core problem; it increases by 1 once and only once. Out of ideas now.
User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am

Post » Thu Jun 21, 2012 5:18 am

I should have known that, thanks. Gah, still having the core problem; it increases by 1 once and only once. Out of ideas now.
What increases by 1 and only 1? Give more details :P
User avatar
Melissa De Thomasis
 
Posts: 3412
Joined: Tue Feb 27, 2007 6:52 pm

Post » Wed Jun 20, 2012 10:18 pm

Max Health, and presumably the global variable?
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Thu Jun 21, 2012 8:40 am

Max Health, and presumably the global variable?
So you're basically saying the script is only running once then. I think that has to do with the story event stuff. As far as I'm aware, story events are ran to "start" the quest, and after they are ran, they do not run again. I'm almost positive that's your issue, so I would try and figure out how to fix that.
User avatar
Emily Rose
 
Posts: 3482
Joined: Sat Feb 17, 2007 5:56 pm

Post » Thu Jun 21, 2012 10:37 am

In order to get the Story manager to launch a quest repeatedly, you have to put a
Stop()
at the end of your code.
User avatar
Monika Krzyzak
 
Posts: 3471
Joined: Fri Oct 13, 2006 11:29 pm

Post » Thu Jun 21, 2012 6:59 am

Another terrible script, trying to use an onupdate event.

Spoiler


Scriptname WZHealthFortificationEffectScript extends QuestGlobalVariable Property WZHealthIncrementValue Autofloat Property OldValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0 AutoEvent OnUpdate()Game.GetPlayer().GetActorValue("Onehanded")If Onehanded > Oldvalue		Game.GetPlayer().ModActorValue("health", WZHealthIncrementValue.Mod(1))			  Set.OldValue =http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/= OnehandedendifFunction WZHealthIncrementValue				  registerForUpdate(1)EndFunctionendEvent


EDIT: Thanks Ingenue I'll er try to figure out how to do that.
User avatar
Suzy Santana
 
Posts: 3572
Joined: Fri Aug 10, 2007 12:02 am

Post » Thu Jun 21, 2012 9:19 am

Another terrible script, trying to use an onupdate event.

Scriptname WZHealthFortificationEffectScript extends QuestGlobalVariable Property WZHealthIncrementValue Autofloat Property OldValue = http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/0.0 AutoEvent OnUpdate()Game.GetPlayer().GetActorValue("Onehanded")If Onehanded > Oldvalue        Game.GetPlayer().ModActorValue("health", WZHealthIncrementValue.Mod(1))              Set.OldValue =http://forums.bethsoft.com/topic/1371249-script-to-increase-healthmagickastamina-on-skill-leveling/= OnehandedendifFunction WZHealthIncrementValue                  registerForUpdate(1)EndFunctionendEvent
That's a terrible terrible script and you should delete it immediately.

OnUpdate is something you should only use as a last resort, and definitely not with that low of numbers. I recommend trying what Ingenue stated.
User avatar
Eoh
 
Posts: 3378
Joined: Sun Mar 18, 2007 6:03 pm

Post » Thu Jun 21, 2012 12:13 am

Something like this?

Scriptname WZHealthFortificationEffectScript extends QuestGlobalVariable Property WZHealthIncrementValue AutoQuest Property WZTestPerpetiual AutoEvent OnStoryIncreaseSkill(string OneHanded)WZHealthIncrementValue.Mod(1)Game.GetPlayer().ModActorValue("health", WZHealthIncrementValue.GetValue())endEventWZTestPerpetual.Stop()
User avatar
kennedy
 
Posts: 3299
Joined: Mon Oct 16, 2006 1:53 am

Post » Thu Jun 21, 2012 10:39 am

Something like this?

Scriptname WZHealthFortificationEffectScript extends QuestGlobalVariable Property WZHealthIncrementValue AutoQuest Property WZTestPerpetiual AutoEvent OnStoryIncreaseSkill(string OneHanded)WZHealthIncrementValue.Mod(1)Game.GetPlayer().ModActorValue("health", WZHealthIncrementValue.GetValue())endEventWZTestPerpetual.Stop()
You want to put the stop inside the event, not outside of it.
User avatar
joannARRGH
 
Posts: 3431
Joined: Mon Mar 05, 2007 6:09 am

Post » Thu Jun 21, 2012 8:48 am

It would have to go in the event. (And it will stop your quest, in case you didn't realize.)
User avatar
Ells
 
Posts: 3430
Joined: Thu Aug 10, 2006 9:03 pm

Post » Thu Jun 21, 2012 7:37 am

So, do I need to start the quest again? It seemed to be working in my first test but now nothing is happening and I didn't change anything.

EDIT:

Ah, ok its working. Thank you so much both of you for all your help. The rate at which it updates is oddly inconsistent, sometimes the health level is 1 or 2 behind but then it catches it up ... could it be I'm entering the menu to check before the script finishes? I'll check that now.

EDIT: Er, ok I don't know why it is doing that but it balances out in the long run.
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Wed Jun 20, 2012 11:31 pm

You need to use the story manager to run your quest on a skill increase event.

Sorry, I've come in late (attracted by the mention of the story manager) and don't have time right now to read the thread carefully. But I wrote some basic instructions the other day for using a story manager event, which might help you - they're nearly at the bottom of http://www.gamesas.com/topic/1370343-trouble-casting-a-spell-from-an-wearable-item-to-player/page__pid__20713393#entry20713393.
User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Next

Return to V - Skyrim

cron