mgb519 Posted April 6, 2016 Share Posted April 6, 2016 (edited) I was looking into skyrim modding, and I thought it would be cool if there was a sort of spell that dealt damage to enemies based on their own magicka usage.As I lack experience, it didn't work and resulted in a CTD.I was implementing it as a concentration spell, so that as long as the player kept casting it the npc would continue to take damage.So I set up an active magic effect as follows: Scriptname ManaBurnEffect extends activemagiceffect Hidden Float lastMagickaValue Event OnEffectStart(Actor akTarget, Actor akCaster) lastMagickaValue = akTarget.GetActorValue("Magicka") EndEvent Event OnUpdate() GetTargetActor().DamageAV("Magicka", (lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))) GetTargetActor().DamageAV("Health", (lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))*100) lastMagickaValue = GetTargetActor().GetActorValue("Magicka") EndEvent Does anything seem suspect here, or should I look elsewhere for the problem? Edited April 6, 2016 by mgb519 Link to comment Share on other sites More sharing options...
Darkxenoth Posted April 6, 2016 Share Posted April 6, 2016 (edited) I don't know how to mess with concentration spells, so I can't help you there... but I did create and test a Feedback spell. My spell was targeted, and caused the hit target to cast another spell that actually had the effect that caused them to take damage when they cast spells (this was just the way my mind went to straight away after reading your post, could probably be done easier/differently). Here's the scripts I came up with: scriptName DarkxEffectFeedbackScript extends ActiveMagicEffect Spell Property DarkxSpellManaBurn Auto Event OnEffectStart(Actor akTarget, Actor akCaster) DarkxSpellManaBurn.Cast(akTarget) ;make the hit target cast the spell containing the damaging effect EndEvent and scriptName DarkxEffectManaBurnScript extends ActiveMagicEffect Float initMana Float curMana Actor aCaster Event OnEffectStart(Actor akTarget, Actor akCaster) initMana = akCaster.GetActorValue("Magicka") ;grab the caster's initial magicka aCaster = akCaster ;save the caster to aCaster, so that it can be referenced elsewhere EndEvent Event OnSpellCast(Form akSpell) ;should fire when the actor the effect is applied to casts a spell curMana = aCaster.GetActorValue("Magicka") ;grab the caster's mana after they cast a spell aCaster.DamageActorValue("Health", (initMana - curMana)) ;damage the caster's health by the amount of magicka they used EndEvent DarkxEffectFeedbackScript was on the targeted spell, DarkxEffectManaBurnScript on the spell that applies the damaging effect. I did things this way so I could test things easier (I added the ManaBurn spell and the Feedback spell to my spellbook, then cast each to test their effects).EDIT: I included comments in the scripts to explain what they were doing, hopefully ensuring you understood them properly and could use them as reference for what to do with your own. Edited April 6, 2016 by Darkxenoth Link to comment Share on other sites More sharing options...
Darkxenoth Posted April 6, 2016 Share Posted April 6, 2016 (edited) I was looking into skyrim modding, and I thought it would be cool if there was a sort of spell that dealt damage to enemies based on their own magicka usage.As I lack experience, it didn't work and resulted in a CTD.I was implementing it as a concentration spell, so that as long as the player kept casting it the npc would continue to take damage.So I set up an active magic effect as follows: Scriptname ManaBurnEffect extends activemagiceffect Hidden Float lastMagickaValue Event OnEffectStart(Actor akTarget, Actor akCaster) lastMagickaValue = akTarget.GetActorValue("Magicka") EndEvent Event OnUpdate() GetTargetActor().DamageAV("Magicka", (lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))) GetTargetActor().DamageAV("Health", (lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))*100) lastMagickaValue = GetTargetActor().GetActorValue("Magicka") EndEvent Does anything seem suspect here, or should I look elsewhere for the problem? Taking another look at your initial post, I wanted to give my thoughts...One thing to note: as posted, your script doesn't actually cause the target to take damage when they cast a spell necessarily... you have it scripted to cause damage to their magicka, then damage their health based on the difference between their current magicka and the amount they had when you first started hitting them with your spell, thus it causes damage to them regardless of whether they cast a spell or not because you're already damaging their magicka. In other words, if you only wanted it to cause damage to them if THEY cast a spell you would need to remove the line that causes damage to their magicka to ensure it only changes when they, themselves, cast a spell.Oh, and if you leave it multiplying the difference between their initial magicka and current magicka by 100 then it is going to do RIDICULOUS amounts of damage. Even if they only cast a spell that costs 5, that's already 1000 damage as you have it; seeming as you have it scripted to cause damage to their magicka equal to the difference in their initial magicka and current magicka (which, in theory, should basically amount to making their magicka be used twice for any spell they cast) - 5 magicka cost spell = 10 magicka difference during the line that damages health, thus 1000 damage. Edited April 6, 2016 by Darkxenoth Link to comment Share on other sites More sharing options...
mgb519 Posted April 6, 2016 Author Share Posted April 6, 2016 That doesn't fix my CTD problem. Is there anything under visual effects or anywhere else that I should watch for? Link to comment Share on other sites More sharing options...
gulogulo Posted April 6, 2016 Share Posted April 6, 2016 Try this: Float lastmagickavalueActor Victim Event OnEffectStart(Actor akTarget, Actor akCaster) lastmagickavalue ..................... Victim = akTargetRegisterForSingleUpdate(1.0)EndEvent Event OnUpdate() Victim.DamageAV ..............................Victim.DamageAV ............................. RegisterForSingleUpdate(1.0) EndEvent Link to comment Share on other sites More sharing options...
lofgren Posted April 6, 2016 Share Posted April 6, 2016 I don't think the problem is your script. You don't even register for an update anywhere so nothing except the first block is actually being executed anyway. Link to comment Share on other sites More sharing options...
mgb519 Posted April 6, 2016 Author Share Posted April 6, 2016 Well, that worked. As implemented now: Scriptname FeedbackScript extends activemagiceffect Float lastmagickavalue Actor Victim Event OnEffectStart(Actor akTarget, Actor akCaster) Victim = akTarget lastmagickavalue = Victim .GetAv("Magicka") RegisterForSingleUpdate(0.1) EndEvent Event OnUpdate() Victim.DamageAV ("Health", GetMagnitude()/8*(lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))) Victim.DamageAV ("Magicka", GetMagnitude()/16*(lastMagickaValue - GetTargetActor().GetActorValue("Magicka"))) lastMagickaValue = Victim.GetAv("Magicka") RegisterForSingleUpdate(0.1) EndEvent Out of curiosity, what's the update rate for a vanilla concentration spell? Link to comment Share on other sites More sharing options...
lofgren Posted April 6, 2016 Share Posted April 6, 2016 Every second. Link to comment Share on other sites More sharing options...
mgb519 Posted April 6, 2016 Author Share Posted April 6, 2016 I figured it had to be smaller than that since the health bar drains pretty continuously when you're using flames. Setting the update rate to 1 second didn't seem to work the same.In other news, would it be possible to make a concentration spell that is a ritual spell (2 hands) and casts over a radius the way firestorm does, but is still a concentration spell that you have to keep channeling? Link to comment Share on other sites More sharing options...
lofgren Posted April 6, 2016 Share Posted April 6, 2016 It looks continuous because it's being applied by the engine rather than by a script, and the engine smooths out the health bar narrowing. I think Apocalypse has spells like you describe. Link to comment Share on other sites More sharing options...
Recommended Posts