Lose % of a stat

Post » Tue Jun 19, 2012 4:08 pm

So here is the full script for anyone else who wants to use this function - personally I think it's pretty cool. Having items to juggle stats. I want to make a bunch of them.

Scriptname blahblahblahSCR extends ObjectReference Float healthModEvent OnEquipped(Actor akActor)	    If akActor == Game.GetPlayer()			    healthMod = akActor.GetBaseActorValue("health") * 0.5			   			    akActor.ModAv("health", -healthMod)			    akActor.ModAv("magicka", healthMod)	    EndIfEndEventEvent OnUnequipped(Actor akActor)	    If akActor == Game.GetPlayer()			    akActor.ModAv("health", healthMod)			    akActor.ModAv("magicka", -healthMod)	    EndIfEndEvent
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Tue Jun 19, 2012 9:45 pm

Ya, if you dont save how much was removed, and the base health changes between equipping and unequipping, then you'll end up messing stuff up. Also just so you know, if your health changes while your wearing your ring, with that script, it wont change how much health is turned into magicka.

Ex.
You have 100 health and 100 magicka
You put on ring, your stats change to 50hp and 150 magicka

You level up and choose health
You now would have 110hp and 100 magicka if the ring wasnt on which would be 55/155 if you put the ring on then
But with that code, until you remove the ring and re-equip it you'll have 60 health and 150 magicka
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Tue Jun 19, 2012 8:10 pm

I think I can live with that. If the player raises health or magicka while wearing the item they can quickly toggle it off and back on to re adjust the new values.
User avatar
Natalie Harvey
 
Posts: 3433
Joined: Fri Aug 18, 2006 12:15 pm

Post » Wed Jun 20, 2012 6:59 am

Thanks for taking the time to write that out. Unfortunately it wont compile and I'm not skilled enough in papyrus to understand why.

Yeah, I don't have the CK installed on this machine, so I was coding from memory.

Glad you got it sorted out.
User avatar
Rob Davidson
 
Posts: 3422
Joined: Thu Aug 02, 2007 2:52 am

Post » Wed Jun 20, 2012 6:27 am

Still though - thanks for chiming in.
User avatar
Alyna
 
Posts: 3412
Joined: Wed Aug 30, 2006 4:54 am

Post » Wed Jun 20, 2012 1:34 am

Resusable code

Float Function CalculatePercentageOf(Float fPercentage, Float fValue)	Float c = (fPercentage / 100.0) As Float	Return (c * fValue) As FloatEndFunctionFloat Function CalculatePercentageOfValue(Actor akTarget, String sAttribute, Bool bBaseValue, Float fPercentage)	Float fAttributeValue = http://forums.bethsoft.com/topic/1356558-lose-of-a-stat/0.0	If bBaseValue		fAttributeValue = akTarget.GetBaseActorValue(sAttribute) As Float	Else		fAttributeValue = akTarget.GetActorValue(sAttribute) As Float	EndIf		Return CalculatePercentageOf(fPercentage, fAttributeValue)EndFunction


;Calculate the total Magicka the player has, return 50% of the valuefloat fNewMagicka = CalculatePercentageOfValue(player, "Magicka", true,  50.0);Calculate the current Stamina the player has, return 25% of the valuefloat fCurrentMagicka = CalculatePercentageOfValue(player, "Stamina", false,  25.0)

From here you can either DestroyAV or RestoreAV
User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Tue Jun 19, 2012 5:40 pm

Heya Taewon, thanks for jumping in. Can you elaborate a little on what you wrote above?

The first part is reusable? So that would be attached to, say, an item... What of the second part?

Some other members added some ideas on page one and Xtynct wrote a script that wraps up my initial idea in a nice little bow. I'm curious about the way you've written what you've written though as I'm not particularly code savvy.
User avatar
willow
 
Posts: 3414
Joined: Wed Jul 26, 2006 9:43 pm

Post » Tue Jun 19, 2012 8:07 pm

Both code are reusable, one is just normal calculations... let say you want to calculate a % of a total number..
Example, lets restore the players 3% of his total health he has

;Param 1 - Target to gather information from;Param 2 - Attribute we are getting the information from;Param 3 - Are we using the total base value, or the current value;Param 4 - Percentage to calculate from either Base or Current Valuefloat fHealing = CalculatePercentageOfValue(player, "Health", true,  3.0);Restore 3% of the players health;Player has total base health 200, so 3% of 200 is 6 health points we will be restoringplayer.RestoreAV("Health",fHealing)

;Property that is editable by userfloat property fBaseDamage autofloat fTotalDamage = fBaseDamageif player.HasPerk(OurIncreasedDamagePerk)	  ;Increase the damage by 25% since we have the perk	  fTotalDamage += CalculatePercentageOf(25.0,fBaseDamage)endiftarget.DamageAV("Health",fTotalDamage)
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Wed Jun 20, 2012 4:34 am

could this be applied to Hp damage as well? in order to make "Gravity" spells ala FF?
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Tue Jun 19, 2012 4:08 pm

Yes you can make gravity / demi type spells with my code
User avatar
NO suckers In Here
 
Posts: 3449
Joined: Thu Jul 13, 2006 2:05 am

Post » Tue Jun 19, 2012 4:47 pm

thank you :D always excellent stuff from you :D
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Wed Jun 20, 2012 3:47 am

Your welcome :)
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am

Post » Wed Jun 20, 2012 7:03 am

what about calculating percentage of a current number?
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm

Previous

Return to V - Skyrim