Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[SKY] Spell magnitude based on skill


gstark1
 Share

Recommended Posts

I've searched the forums, and can't find what I'm looking for, so here's a simple question with hopefully a simple answer.

I'm creating a three pack of spells. Harm Undead (Lesser, Normal, and Greater). I know how to create the spells and modify the effects, and how to add tomes, but what I'm missing is how to make the spell magnitude change based off the player's skill. For example, the Lesser Harm would do damage equal to the players Restoration skill / 2.

I'm assuming this will have to be scripted, and I'm hoping the calculations will happen on the fly (haha, fire and forget joke) and I won't have to do a bunch of behind the scenes work. I'm not all that good with scripting, but willing to give it a go if someone can point me in the right direction. Thanks!

Link to comment
Share on other sites

What i did was make a magic effect with the visuals that you want. Then attach a script with this:


ScriptName LesserHarmUndeadSpell Extends ActiveMagicEffect

{}

Event OnEffectStart(Actor akTarget,Actor akCaster)

Float rLvl = akCaster.GetAV("Restoration")

Float dmg = (rlvl/2)

akTarget.DamageActorValue("Health", dmg) 

EndEvent

Make sure that the magic effect has a condition checking to see if the target is undead or has the actortypeundead keyword.

Hope that helped

  • Upvote 1
Link to comment
Share on other sites

That helped! First problem down, next issue I thought up...

I'd like the spell cost to be variable as well, based on the damage the spell does. As the spell gets more powerful, the cost goes up. I tried working that into the script last night, but was only charged mana when the cast hit an undead target. I'd like to find a way to get charged like any normal spell. Suggestions?

Link to comment
Share on other sites

Sadly, Magic effects only take effect when they encounter a valid target.

You'll have to do it the hard way.

If you insist on having a single spell that has a varying magicka/mana cost, you will need to make a separate script to attach to the player, that contains a OnSpellCast(akSpell) event, get the restoration level in that script, and make sure it is a public variable.

In the event block, provide some conditional statements such as:

HarmUndead = akSpell

Float mDmg01 = ;smallcost

Float mDmg02 = ;mediumcost

Float mDmg03 = ;largecost

If rLvl >= 0 && rLvl < 33

Game.GetPlayer().DamageAV("Magicka", (mDmg01))

ElseIf rLvl >= 33 && rLvl < 66

Game.GetPlayer().DamageAV("Magicka", (mDmg02))

Else

Game.GetPlayer().DamageAV("Magicka", (mDmg02))

EndIf

Just an example, but if you know how to handle conditional statements, you can get quite creative with it.

The downside of doing it this way is that if you make the spell cost zero to accommodate these scripts, it will show that spell has a 0 cost, but the script will see otherwise.

Otherwise, you could just make each instance of the spell like BethSoft did, and vary the magicka/mana cost depending on the the equipped spell. I haven't encountered an easier way to achieve this. I ran into this a whole lot in my mod, Tristram In Skyrim.

Link to comment
Share on other sites

Ok, I have got the script working kind of. My debug message box appears, but the script doesn't go into the If statement...or the statement is wrong.



Spell Property aaHarmUndead auto

actor property player auto



Event OnSpellCast(Form akSpell)

Float manacost

Spell spellCast = akSpell as Spell

debug.MessageBox("You cast a spell")

if spellCast && spellCast == aaHarmUndead

manacost = (player.GetAV("Restoration") * ((player.GetAV("Destruction") / 100) + 1 )) / 2

Debug.MessageBox(manacost)

if player.getav("Magicka") < manacost

player.InterruptCast()

Else

player.DamageActorValue("Magicka", manacost)

EndIf


Else

debug.MessageBox("Who knows what that was...")

endIf

endEvent

Like I said, the if statement is never entered. aaHarmUndead is the Editor ID of the spell in CK. I do see the "You have cast a spell" box, and the "Who knows what that was" one, so either what I'm casting isn't a spell (it is) or the name is wrong or...something.

Edit: further testing with the debug boxes and variables shows me the spellCast variable = SPELL<1F000D62> My aaHarmUndead spell is 01000D62. Those aren't equal...why is that happening?

Edited by gstark1
Link to comment
Share on other sites

Got it to work! Here's the new code, just changes to how the mana reduction is calculated..


Spell Property aaHarmUndead auto


Event OnSpellCast(Form akSpell)

  Float manacost

  Spell spellCast = akSpell as Spell

  debug.MessageBox("You cast a spell")

  if spellCast && spellCast == aaHarmUndead

manacost = (Game.GetPlayer().GetActorValue("Restoration") * ((Game.GetPlayer().GetActorValue("Destruction") / 100) + 1 )) / 2

Debug.MessageBox(manacost)

if Game.GetPlayer().GetActorValue("Magicka") < manacost

  Game.GetPlayer().InterruptCast()

Else

  Game.GetPlayer().DamageActorValue("Magicka", manacost)

EndIf

  Else

debug.MessageBox("Who knows what that was...")

  endIf

endEvent

The real trick is in the Player Actor. I had to go into the Player and set the property of the script to the spell. Screenshot:

KfmIUmQ.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...