Percentage of health and mana instead of a set value

Post » Wed Jun 20, 2012 10:35 am

Im trying to make a spell that will sap all the mana the player has and do a percentage of the targets total health in damage instead of set values. After searching i found some info on the subject and tried to make a script that removes the players mana for starters, but its not working, anyone thats better at scripting than me have a way to make this happen?

This is the script i have so far:
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/1359834-percentage-of-health-and-mana-instead-of-a-set-value/0.0	    If bBaseValue			    fAttributeValue = akTarget.GetBaseActorValue(sAttribute) As Float	    Else			    fAttributeValue = akTarget.GetActorValue(sAttribute) As Float	    EndIf  	    Return CalculatePercentageOf(fPercentage, fAttributeValue)EndFunctionfloat fNewMagicka = CalculatePercentageOfValue(player,"Magicka", true,  100.0)player.DamageAV("Magicka",fNewMagicka)

And this is the error message:
d:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CVORemoveMagika.psc(18,20): no viable alternative at input 'CalculatePercentageOfValue'd:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CVORemoveMagika.psc(18,46): required (...)+ loop did not match anything at input '('d:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CVORemoveMagika.psc(18,6): Unknown user flag CalculatePercentageOfValue
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Wed Jun 20, 2012 4:54 pm

going out on a limb here, wouldnt you use Hpthreshold somewhere in there??


ehhhh nevermind lol
User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am

Post » Wed Jun 20, 2012 4:57 am

Are those last two lines in a function or event somewhere, or just out in the main body of the script? I don't think you can call functions when initializing variables like that, unless the variable is part of a function or event.
User avatar
I love YOu
 
Posts: 3505
Joined: Wed Aug 09, 2006 12:05 pm

Post » Wed Jun 20, 2012 4:31 pm

Spoiler
Scriptname testspell extends activemagiceffect{Spell removes all mana from the player and deals a %age of health damage to target}Actor Property player Auto HiddenFloat CurMagFloat TarHealth;EVENTS------------------------------------------------------------Event onEffectStart (Actor akTarget, Actor akCaster)player = akCasterCurMag = Player.GetActorValue("Magicka")TarHealth = akTarget.GetBaseActorValue("Health")if (akTarget.isHostiletoActor(player))    akTarget.DamageActorValue("Health", (TarHealth*0.50)) ; this damages the target health by 50% of base value. Change this from 0.01 (1%) to 1 (100%)        player.DamageActorValue("Magicka", -CurMag); This gets the players current magicka value, and then subtracts that value from the playerendif EndEvent
Im not that experienced at scripting, this will be my 4th, but the following script works as i think you want.

It removes all the players magicka and damages the targets health by a set percentage of base health.
I have tested this in-game by duplicating a firebolt spell and the magic effect. Attached this script to the duplicated magic effect.
I then set the magnitude of the firebolt spell to 0 and cost to 20.
Whilst not in your original post, i added the line
 if (akTarget.isHostiletoActor(player)) 
so if the spell misses or hits a friendly target it doesn't use all your magicka or damage a friendly target.
User avatar
Beth Belcher
 
Posts: 3393
Joined: Tue Jun 13, 2006 1:39 pm

Post » Wed Jun 20, 2012 4:11 am

Sorry, bit late reply on this, been busy!

Thanks a lot for making that script, it helps very very much. The damage component works perfectly, but the spell does still not drain all the mana, but that worked on your end?
User avatar
victoria gillis
 
Posts: 3329
Joined: Wed Jan 10, 2007 7:50 pm

Post » Wed Jun 20, 2012 10:56 am

I posted how to use my code here
http://www.gamesas.com/topic/1356558-lose-of-a-stat/page__st__30__p__20473364#entry20473364 if your having trouble
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Wed Jun 20, 2012 1:36 am

Sorry, bit late reply on this, been busy!

Thanks a lot for making that script, it helps very very much. The damage component works perfectly, but the spell does still not drain all the mana, but that worked on your end?

Yes it worked perfectly on my test firebolt.
Just a couple of thoughts
player.DamageActorValue("Magicka", -CurMag)

This is the line which should remove all your current magicka, did you you use the "-" (minus sign) in front of CurMag

I have just tried it again in game, and the magicka does regenerate whilst the damage magicka effect is taking place, so by the time the damage magicka effect has finished, the players magicka is already above 0.

Does this script remove any magicka when you use it?

If it is to do with magicka regenerating straight away, if you insert the following the following lines
Float MagRate
Under Float TarHealth

MagRate = Player.GetBaseACtorValue("MagickaRate")
Under TarHealth = akTarget.GetBaseActorValue("Health")

player.ModActorValue("MagickaRate", -MagRate)            Utility.wait(5)                player.ModActorValue("MagickaRate", MagRate)
and this underneath player.DamageACtorValue("Magicka", -CurMag)

this prevents magicka regenerating for 5 seconds, therefore your magicka should go all the way to o

The script should look like this
Spoiler
Scriptname testspell extends activemagiceffect{Spell removes all mana from the player and deals a %age of health damage to target}Actor Property player Auto HiddenFloat CurMagFloat TarHealthFloat MagRate;EVENTS------------------------------------------------------------Event onEffectStart (Actor akTarget, Actor akCaster)player = akCasterCurMag = Player.GetActorValue("Magicka")TarHealth = akTarget.GetBaseActorValue("Health")MagRate = Player.GetBaseActorValue("MagickaRate")if (akTarget.isHostiletoActor(player))    akTarget.DamageActorValue("Health", (TarHealth*0.50)) ; this damages the target health by 50% of base value. Change this from 0.01 (1%) to 1 (100%)	    player.DamageActorValue("Magicka", -CurMag); This gets the players current magicka value, and then subtracts that value from the player        player.ModActorValue("MagickaRate", -MagRate)            Utility.wait(5)                player.ModActorValue("MagickaRate", MagRate)endifEndEvent
User avatar
Melung Chan
 
Posts: 3340
Joined: Sun Jun 24, 2007 4:15 am

Post » Wed Jun 20, 2012 3:42 am

That works perfectly, thank you very much :)
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm


Return to V - Skyrim