Back to blog
Apr 25, 2024
3 min read

Skyrim: How to make weapon attacks cost Magcika?

How to make weapon attacks cost Magcika? or damage Health/Magicka/Stamina at the same time?

Method: Weapn —> Attach a Magic Effect —> Use Script to Damage Player’s attributes

Damage Magicka:

1
Scriptname MyMagickaDamageSelfScript extends ActiveMagicEffect
2
3
Event OnEffectStart(Actor akTarget, Actor akCaster)
4
akCaster.DamageActorValue("Magicka", 35.0)
5
EndEvent

Explain: Whenever the Magic Effect is activated, the game will deal 35.0 damage to “Magcika”. We can change the value of course. Similarly, we can do this to “Health” and “Stamina”.

Damage 3 Attributes:

1
Scriptname MyDamageSelfAllScript extends ActiveMagicEffect
2
3
Event OnEffectStart(Actor akTarget, Actor akCaster)
4
akCaster.DamageActorValue("Health", 50.0)
5
akCaster.DamageActorValue("Magicka", 35.0)
6
akCaster.DamageActorValue("Stamina", 40.0)
7
EndEvent

More Dynamic:

We can use “Property” of the in creation kit to change values dynamicly.

1
Scriptname MyDynamicDamageSelfScript extends ActiveMagicEffect
2
3
int Property HealthDamage auto
4
int Property MagickaDamage auto
5
int Property StaminaDamage auto
6
int Property TargetHPDamage auto
7
int Property TargetMPDamage auto
8
int Property TargetSPDamage auto
9
10
Event OnEffectStart(Actor akTarget, Actor akCaster)
11
akCaster.DamageActorValue("Health", HealthDamage)
12
akCaster.DamageActorValue("Magicka", MagickaDamage)
13
akCaster.DamageActorValue("Stamina", StaminaDamage)
14
15
akTarget.DamageActorValue("Health", TargetHPDamage)
16
akTarget.DamageActorValue("Magicka", TargetMPDamage)
17
akTarget.DamageActorValue("Stamina", TargetSPDamage)
18
EndEvent

Explain: We define a few Properties that can be changed in Creation Kit, both for the Caster and the Target. When the magic effect is used, it will deal damage to both sides.

Note:

we can use Game.GetPlayer() to take effect on Player directly. But we should avoid this because: If a follower is using this weapon(secript enabled), it will deal damage to Player as well. We should use akCaster instead.

Rarely use:

1
Game.GetPlayer().DamageActorValue("Health", HealthDamage)
2
Game.GetPlayer().DamageActorValue("Magicka", MagickaDamage)
3
Game.GetPlayer().DamageActorValue("Stamina", StaminaDamage)
  • Pros: Change damage values without touching the sript once it’s compiled.
  • Cons: We need to launch the Creation Kit everytime if we are not satisfied with the values. It also means the .esp plugin changes.

Note:

If we attach a same Script to two different weapns, the value changes will apply to this Script, the game just don’t handle them as 2 intances. So, We should make 2 separate Scripts then attach them. Even though the code is the same except the Scriptname. This is what I learned when making the mod Elden Ring Katanas

What’s The Best?

Really depend on how you use the Creation kit…

But I recommend just using the first one, it’s simple and straight, and the nice thing is we can compile the script with third party tools, without lauching Creation Kit. But other options are still available. Thanks for reading.