ReduceRestore MAX StaminaMagicka at will

Post » Fri Nov 16, 2012 7:52 pm

Sorry to be a bother again. I'm interested in the easiest, simplest, most efficient way to reduce and restore the MAX amount of stamina/magicka at any given time.

The main goal is to reduce the MAX amount of stamina an actor has every time they get hit. In other words, the more you get hit, the less stamina you have to fight with.

However, I would like to be able to restore the MAX amount of stamina back to its original level after the battle (even if it takes a while).

I would also like to have a VERY slow drain on the MAX stamina over time (maybe 2% every hour) to account for natural fatigue, then restoring it to the true level when you rest. This particular drain would be ONLY for the player, though... and possibly a companion.

Are there any suggestions? Is there a magic effect/spell that can damage/drain the MAX level (even if applied through a script)? Or would I just need to do it mathematically through scripts manually? Personally, I think I would prefer to apply spells through scripts (OnHit events, etc.), but I don't know what spell/magic effect would do the job.

Any help would be appreciated. Thank you! :-D
User avatar
Amelia Pritchard
 
Posts: 3445
Joined: Mon Jul 24, 2006 2:40 am

Post » Fri Nov 16, 2012 2:11 pm

Triggering spells via scripts = good. Making changes to actor values via scripts = risky.

And any Value Modifier effect can do what you want, as long as you click both 'Detrimental' and 'Recover' - 'Recover' is what changes something from affecting your current HP/Stam/MP to affecting your maximum.
User avatar
John N
 
Posts: 3458
Joined: Sun Aug 26, 2007 5:11 pm

Post » Sat Nov 17, 2012 1:43 am

This requires some complex math to pull off, but I am doing something similar in one of my own mods. Let me know if you have any questions.

Spoiler
scriptname aaTKInjuriesSpellManager extends ActiveMagicEffect;Other Spell scripts that are attached to the actual Magic Effects are children of this one (they extend this script).;Contains functions that all Magic Effect scripts will want to use.Spell property ThisSpell AutoKeyword property WeapTypeGreatsword AutoKeyword property WeapTypeBattleAxe  AutoKeyword property WeapTypeWarhammer  AutoKeyword property WeapTypeBow		AutoFunction DispelMe()	getTargetActor().RemoveSpell(ThisSpell)EndFunctionFunction RemoveAVMod(Actor Target, Float Mod, String Value)	Target.ModAV(Value, -(Mod as Float))	EndFunctionInt function AdjustAVMod(Actor ActorTarget, Float Target, Int Mod, String Value)	int modTarget = (ActorTarget.GetBaseActorValue(Value) * Target) as int	if modTarget - Mod != 0		ActorTarget.ModActorValue(Value, (modTarget - Mod) as float)			return modTarget	else		return Mod	endIfEndFunction

Spoiler
scriptname INJInjuriesEffectScriptBloodLoss extends aaTKInjuriesSpellManagerMessage property INJBloodLossMSG AutoGlobalVariable property INJBloodPoints AutoGlobalVariable property INJBloodPointsFollower AutoReferenceAlias property Follower AutoActor MyTargetInt StaminaModFloat StaminaModPCTEvent OnEffectStart(Actor target, Actor caster)	If Target == game.getPlayer()			INJBloodLossMSG.Show()		MyTarget = game.getPlayer()	Else			MyTarget = Follower.GetActorReference()			EndIf		RegisterForSingleUpdate(1)		EndEventEvent OnUpdate()	If MyTarget == game.getPlayer()		SetMods(INJBloodPoints.GetValue())	Else		SetMods(INJBloodPointsFollower.GetValue())	EndIf		AdjustAV()	RegisterForSingleUpdate(1)	EndEventEvent OnEffectFinish(Actor Target, Actor Caster)		RemoveAVMod(MyTarget, StaminaMod, "Stamina")	UnregisterForUpdate()		EndEventFunction SetMods(Float Injury)	If Injury < 50			StaminaModPct = 0.75 * ((-Injury + 50) *-1) / 50.0		;Injury as Negative plus 70 inverts the numeric trend, so that as Injury goes down, StaminaModPCT goes up.		;Multiplied by -1 to invert and insure the calculation causes a loss (without that, it would be a gain).		;Maximum Health loss of 75% of player's base Stamina, achieved when Blood Points reach 0.	Else			StaminaModPct = 0.0		;Revert to 0, ready for next time the calculations are called to be made.	EndIf	EndFunctionFunction AdjustAV()	StaminaMod = AdjustAVMod(MyTarget, StaminaModPct, StaminaMod, "Stamina")EndFunction
User avatar
Janeth Valenzuela Castelo
 
Posts: 3411
Joined: Wed Jun 21, 2006 3:03 am

Post » Fri Nov 16, 2012 11:25 pm

Thank you both! :-)
I managed to reduce the maximum stamina through a spell applied through an OnHit script :-)

I have another question now, though. Is there a way to make the reduction dissipate over time? I'm trying to use the magic effect's taper settings, but I can't seem to get it to work.

My goal is to do something such as the following...

Max Stamina is 100
Spell reduces Max Stamina by 10 instantly
Max Stamina is now 90
Spell has a taper duration of 10 seconds
The Max Stamina should be 91 after 1 second, 92 after 2 seconds, etc.

Sadly, it seems I can't get the taper to work. Max Stamina stays at 90 until the taper duration is over.

Would anyone know what taper settings would need to be to achieve the goal of the above example? Can something such as Max Stamina even be tapered? Thank you again! :-D
User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Fri Nov 16, 2012 8:41 pm

look at this on the wiki

http://www.creationkit.com/Magic_Effects

Has some info on tapering
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Fri Nov 16, 2012 8:35 pm

Thank you! :-)

Hmm, oddly, it still does the same thing for some reason. I have the following settings...

Taper Duration: 10 seconds
Taper Weight: 1
Taper Curve: 1

Max Stamina goes from 100 to 90 instantly, but stays at 90 for the duration of the taper. Then it jumps right back up to 100.
Haha, have I broken the CK? :-P
User avatar
Add Me
 
Posts: 3486
Joined: Thu Jul 05, 2007 8:21 am

Post » Fri Nov 16, 2012 8:41 pm

taper just extends the length of the spell by 10 seconds in this case. You could damage stamina by 10 at the end of the effect (I assume your goal is to not have Stamina snap back to 100 as soon as the spell expires?)

If you had the "Recover" flag unchecked, the spell would continue doing damage (that slowly tapers off) over 10 seconds after the duration of the main spell runs out.
User avatar
Emma
 
Posts: 3287
Joined: Mon Aug 28, 2006 12:51 am

Post » Fri Nov 16, 2012 6:25 pm

Yes, that is my goal... to slowly bring the Max Stamina level back to 100 slowly and gradually.

That does sound like something that could suffice, thank you. But I was thinking of having some such magic effects last for days. And within my ideal alteration, it would be much more difficult to restore Max Stamina than the actual Stamina itself.

I'm want Stamina (as a whole) to simulate physical awareness/capability. At normal Stamina capacity, you are in optimal fighting condition. The more strikes you can make, the longer you can sprint... basically, the longer you can stay effective in a fight. But with every hit you take, your Max Stamina decreases, leaving you less energy to fight with.

Basically, think of a boxer getting knocked silly with one punch in the first round. He may very well have lots of energy to keep fighting, but his capability to use that energy just got crippled... and it will take time to recover the actual fighting capability. I would like to eventually implement knockdowns and knockouts with a script, but I think I would prefer to use the Max Stamina value instead of current stamina levels to do that.

I would also like to put a very, very slow drain on Max Stamina to account for natural fatigue. Something that will only be recoverable by resting.
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Sat Nov 17, 2012 1:37 am

Just checking my luck tonight. Any ideas?
Happy Independence Day! :-D
User avatar
Katie Louise Ingram
 
Posts: 3437
Joined: Sat Nov 18, 2006 2:10 am

Post » Fri Nov 16, 2012 10:14 am

Just checking my luck tonight. Any ideas?
Happy Independence Day! :-D

I'm planning on doing something similar. I was thinking I could use two spell effects. One of them keeps track of the state of the damage and wether it needs to stay steady, increase or decrease. The other one implements the stat changes.

You could give the governing effect an long period update loop and every hour it could check the implementer effect to see what the damage levels were, and then cast a new instance of the implementer on the player, with values adjusted for the recovery rate you wanted.

Complicated, I know, but gives you as much control as you like.

Good wishes from the Evil British, by the way!
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Fri Nov 16, 2012 1:10 pm

Ah, good to hear! I hope someone gets it all working! :-D

Good wishes from the Evil British, by the way!

Haha, thanks! And no worries, we all have our bad "kings." November 6th will take care of yet another ;-)
User avatar
Farrah Barry
 
Posts: 3523
Joined: Mon Dec 04, 2006 4:00 pm


Return to V - Skyrim