Jump to content

?? - No spell.GetBaseCost()? Anyone know a work around?


mountainmover88

Recommended Posts

I'm making a mod that allows players to cast spells using The Voice (freeing up hands for weapon-based combat, but sacrificing your ability to use shouts). I've got it mostly working (custom shout casts spells appropriately and cooldown works and everything), but I have no way to determine the magicka cost of the spell the player just shout-cast other than by hard-coding in the cost of every spell in the game and subtracting (no SpellTheyCast.GetBaseCost() function). Lame!

Spells are cast using the .cast(Game.GetPlayer()) functionality.

Also, hard-coding would make it so that spells from other mods would no longer be compatible so I really want to avoid that.

 

Anyone think of/know a work around?

Link to comment
Share on other sites

How about a script that causes the amount of damage dealt to the target is also dealt to the player, as in a no-hands warrior spell costs the warrior health instead of magicka? How much/how often the player can cast depends on basically health and risk.

 

Just tryin to think outside the box.

 

I personally would love to sacrifice shouts for no hands spells, since I refuse to start the main quest line and therefore can't use shouts anyway.

Link to comment
Share on other sites

The Cast() function doesnt return the spell cost, I am also having this issue with my flying mod, right now what I do is consume a % of the player's health and stamina until SKSE brings some function to do the trick. Also we need function to get enchanments, check for perks and all that.
Link to comment
Share on other sites

Figured it out!

The newest version of SKSE includes a spell.GetMagickaCost() function so I can just use that. Yay!

Not sure if this function was included in previous versions of SKSE, but build 1.5.10 has it. http://skse.silverlock.org/

The new SKSE version also has a function that lets you check for perks associated with the spell and, with enough workarounds, I bet we can now charge the player an appropriate amount.

Thanks for the replies.

Edited by mountainmover88
Link to comment
Share on other sites

OK!! Found out a way to get the equipped armor pieces, using the GetWornForm() function, now to figure out how to get the enchants :/

Edit: Hell yeah (Player.GetWornForm(4) as armor).GetEnchantment())

Edit2: This is going to take a lot of code lol, I will post the function later.

Edit3: Finished the function for Restoration and Destruction spells, its missing the enchant for the ring because my mod works by equipping a ring.

 

Here is the code:

Function GetRLCost()
curLeft = Player.GetEquippedSpell(1)
curRight = Player.GetEquippedSpell(0)
SpellPerkL = curLeft.GetPerk()
SpellPerkR = curRight.GetPerk()
magickacostl = curLeft.GetMagickaCost()
magickacostr = curRight.GetMagickaCost()

chestEnchant = (Player.GetWornForm(4) as armor).GetEnchantment()
bootsEnchant = (Player.GetWornForm(80) as armor).GetEnchantment()
handsEnchant = (Player.GetWornForm(8) as armor).GetEnchantment()
helmetEnchant = (Player.GetWornForm(2) as armor).GetEnchantment()
AmuletEnchant = (Player.GetWornForm(20) as armor).GetEnchantment()

if Player.HasPerk(SpellPerkL)
	magickacostl = magickacostl / 2
endIf
if Player.HasPerk(SpellPerkR)
	magickacostr = magickacostr / 2
endIf
while i < chestEnchant.GetNumEffects()
	i += 1
	if chestEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Destruction"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
	if chestEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Restoration"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
endWhile
i = 0
while i < bootsEnchant.GetNumEffects()
	i+= 1
	if bootsEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Destruction"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
	if BootsEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Restoration"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
endWhile
i = 0
while i < handsEnchant.GetNumEffects()
	i+= 1
	if handsEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Destruction"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
	if handsEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Restoration"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
endWhile
i = 0
while i < HelmetEnchant.GetNumEffects()
	i+= 1
	if HelmetEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Destruction"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
	if HelmetEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Restoration"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
endWhile
i = 0
while i < AmuletEnchant.GetNumEffects()
	i+= 1
	if AmuletEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Destruction"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
	if AmuletEnchant.GetNthEffectMagicEffect(i).GetName() == "Fortify Restoration"
		magickacostr = magickacostr - ((magickacostr*chestEnchant.GetNthEffectMagnitude(i))/100)
		magickacostl = magickacostl - ((magickacostl*chestEnchant.GetNthEffectMagnitude(i))/100)
	endIf
endWhile
endFunction

Edited by porroone
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...