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:
1Scriptname MyMagickaDamageSelfScript extends ActiveMagicEffect2
3Event OnEffectStart(Actor akTarget, Actor akCaster)4 akCaster.DamageActorValue("Magicka", 35.0)5EndEventExplain: 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:
1Scriptname MyDamageSelfAllScript extends ActiveMagicEffect2
3Event OnEffectStart(Actor akTarget, Actor akCaster)4 akCaster.DamageActorValue("Health", 50.0)5 akCaster.DamageActorValue("Magicka", 35.0)6 akCaster.DamageActorValue("Stamina", 40.0)7EndEventMore Dynamic:
We can use “Property” of the in creation kit to change values dynamicly.
1Scriptname MyDynamicDamageSelfScript extends ActiveMagicEffect2
3int Property HealthDamage auto4int Property MagickaDamage auto5int Property StaminaDamage auto6int Property TargetHPDamage auto7int Property TargetMPDamage auto8int Property TargetSPDamage auto9
10Event 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)18EndEventExplain: 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.
Useful Links:
Links: