GetMagickaCost, is this function in default skyrim?

Post » Tue Nov 20, 2012 5:20 pm

can we get the cost of a spell via script?
User avatar
Del Arte
 
Posts: 3543
Joined: Tue Aug 01, 2006 8:40 pm

Post » Tue Nov 20, 2012 8:23 pm

None. Bring it to SKSE. Unless someone adept in scripting knows a clever way around this missing function.
User avatar
Esther Fernandez
 
Posts: 3415
Joined: Wed Sep 27, 2006 11:52 am

Post » Tue Nov 20, 2012 8:17 pm

I shall ask the SKSE team, thank you. I would like it to exist in vanilla skyrim but it will suffice.
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Tue Nov 20, 2012 11:04 pm

can we get the cost of a spell via script?

In what context would you want to get the cost of a spell, can you elaborate further?

Would you want to get the cost of any spell, or the cost of a specific spell, and whether this would be from a specific actor, any actor or just the player.
User avatar
Laura-Lee Gerwing
 
Posts: 3363
Joined: Fri Jan 12, 2007 12:46 am

Post » Tue Nov 20, 2012 7:41 am

right, I should explain.

I want to make a sustained mode: Blood Magic.
this should make a few things:
-all spells are cast from health, but they cost 50% of their effective cost in magicka (1 health is 2 magicka). with a special ring (or perk) the ration should become 1 health=3 magicka
-all healing effects on the one using blood magic are impeded by 90%, or totally (except a "consume corpse" spell and drain life spells)
-there are a few spells that can only be cast while the mode is active.

however, as I said, I am stopped at the first step because of this lack of "Getspellcost" function/condition.-
User avatar
Damian Parsons
 
Posts: 3375
Joined: Wed Nov 07, 2007 6:48 am

Post » Tue Nov 20, 2012 7:29 pm

I have an idea, will work on a proof of concept then post back
User avatar
joeK
 
Posts: 3370
Joined: Tue Jul 10, 2007 10:22 am

Post » Tue Nov 20, 2012 9:28 pm

I have an idea, will work on a proof of concept then post back
well, thanks :D
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Tue Nov 20, 2012 7:53 pm

I got this to work with one spell, firebolt
I haven't worked on the script to tidy it up or to adapt it use to use multiple spells.
In theory it could be attached to the caster multiple times (making a copy and renaming), i'm not sure what impact this would have on the game.

I created a perk which had 2 Perk Entries
1 - Mod Spell Magnitude SetValue 0 - This reduces the cost of all spells to 0 magic
2 - Mod Incoming Spell Magnitude MultiplyValue 0.1
The second perk entry had a condition so that only healing was reduced by 90% using EPMagic_HasKeyword MagicRestoreHealth

I then created a quest with the player as an alias, i then attached the following script to the player.

Spoiler
Scriptname BloodMagicCastScript_CONCEPT extends ReferenceAlias  {Uses health instead of magicka to cast spells}Import MathActor Property PlayerRef Auto;INPUT THE PERK THAT APPLIES TO THE COST OF THE SPELLPerk Property AssociatedPerk AutoPerk Property BloodMagicPerk AutoKeyword Property BloodMagicRing Auto;SPELL TO CASTSpell Property MySpell AutoString Property AssociatedSkill Auto;INPUT THE FORTIY MOD example - DestructionModString Property FortSkillMod AutoInt Property BaseMagicCost AutoFloat HealthCostFloat MagicCostFloat PKReductionFloat SklRedFloat FortRedEvent OnSpellCast(Form akSpell)	if PlayerRef.HasPerk(BloodMagicPerk) && akSpell == MySpell		;CALL FUNCTIONS		PerkReduction(PlayerRef)		SkillReduction(PlayerRef)		FortifyReduction(PlayerRef)		CalcMagCost(PlayerRef)		DamageHealth(PlayerRef)			endif	EndEvent;FUNCTION TO CALCULATE PERK REDUCTION;Example for the FireBolt spell this would be DestructionApprenticeFunction PerkReduction (Actor akCaster)	if PlayerRef.HasPerk(AssociatedPerk)		PKReduction = 0.5	else			PKReduction = 1	endif	EndFunction;FORMULA TO CALCULATE MAGIC COST REDUCTION BASED ON SKILL - THIS IS THE FORMULA USED IN GAME;Example - AssociatedSkill for the FireBolt spell would be DestructionFunction SkillReduction (Actor akCaster)Float AssociatedSkillLvl = PlayerRef.GetActorValue(AssociatedSkill)SklRed = pow((AssociatedSkillLvl/400), 0.65)EndFunction;FUNCTION TO CALCULATE COST REDUCTION DUE TO FORTIFY SKILL;Example - For the Firebolt, this would be DestructionModFunction FortifyReduction (Actor akCaster)FortRed = PlayerRef.GetActorValue(FortSkillMod)	EndFunction	;FUNCTION TO CALCULATE MAGIC COSTFunction CalcMagCost(Actor akCaster)MagicCost = BaseMagicCost*(1-SklRed)*(PKReduction)*(1-(FortRed/100))EndFunction;FUNCTION TO CALCULATE DAMAGE HEALTH BASED ON MAGIC COST AND IF THE PLAYER IS WEARING THE RINGFunction DamageHealth(Actor akCaster)	if PlayerRef.WornHasKeyword(BloodMagicRing)		HealthCost = MagicCost/3			debug.notification("Health cost = "+HealthCost)	else		HealthCost = MagicCost/2			debug.notification("Health cost = "+HealthCost)	endif	PlayerRef.DamageActorValue("Health", HealthCost)EndFunction	
When the quest was running, but the player did not have the perk, the player used magic to cast a firebolt (Cost 35)
When the perk was added, the player used health ( cost 17.57)
With the ring worn, the cost became 11.71
With the perk Apprentice destruction the health cost reduced to 5.86

I put this together fairly quickly so haven't done any extensive testing
User avatar
carrie roche
 
Posts: 3527
Joined: Mon Jul 17, 2006 7:18 pm

Post » Tue Nov 20, 2012 4:35 pm

well wow. one only needs to tell the game "unless mode is on you cna't cast spell X" and it will be integrated.
Can I give kudos?

do you think it would be something performance-hungry?
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Tue Nov 20, 2012 12:38 pm

There could be a way to achieve it using a additional perk entry. Why the hell didn't i think of this method when creating cooldown spells?
If you are creating new spell, such as "Consume Corpse" that you mentioned, you could make the spell cost so high, that the player shouldn't be able to achieve it in-game.
However with the perk that sets the magic cost of spells to zero, "Consume Corpse" would then be able to be cast.
The script would take care of the health cost.
User avatar
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Tue Nov 20, 2012 10:03 pm

I may be missing something in this conversation but there is a GetMagickaCost() function provided by SKSE. It isn't listed on the wiki but it is in their spells.psc file.
I use it to check if a spell has no magicka cost.
If I recall the return isn't an exact figure. It may possibly be the cost before any perks etc. It may also need to be multiplied by cast time. Not really sure but it does work and returns a relevant value, you'll have to play with it.

EDIT: BTW it must be called on a spell type.
User avatar
Elle H
 
Posts: 3407
Joined: Sun Aug 06, 2006 3:15 am


Return to V - Skyrim