dafydd99 Posted June 13, 2023 Share Posted June 13, 2023 Hi, I'm trying to get a root to recall on exposure to fire - ideally fire spells, torches touching it, fire enchanted hand weapons and arrows fired from a fire enchanted bows. In the onHit event I can check that MagicDamageFire is a keyword on the form of the weapon used, but that only seems to detect fire spells, and torches don't seem to create a hit event. Am I missing something, or is this harder than I imagined? I've taken a look at how TrapOilPool does it - but it also appears to have these problems. Thanks for any advice, Cheers - dafydd99 Link to comment Share on other sites More sharing options...
Sphered Posted June 13, 2023 Share Posted June 13, 2023 Could use a formlist with all the valid spells that qualify for the criteria. And do a HasForm() call to check for a hit Link to comment Share on other sites More sharing options...
dafydd99 Posted June 14, 2023 Author Share Posted June 14, 2023 Thanks Sphered. Actually, the spells seem to work fine, as I can use the MagicDamageFire keyword on them with no issue. It's that a weapon with an enchantment doesn't seem to pass that on to an onhit event on a static.The 'form' is just eg a plain iron sword. Below is my current script by means of explaination - and this works fine for spells, but receives no onhit event for torches, and only a physical weapon attack, not its enchantments. Scriptname TheSidratUnderTreeRootBarrierScript extends ObjectReference Keyword property MagicDamageFire auto FormList property TheSidratTorchList auto Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Debug.Notification("Hit!") Actor actorRef = akAggressor as Actor if(actorRef == game.getPlayer() && (akSource.hasKeyword(MagicDamageFire) || akProjectile.hasKeyword(MagicDamageFire) || TheSidratTorchList.hasForm(akSource))) ;player hit the root with the correct weapon playAnimation("Open") endif endEvent Link to comment Share on other sites More sharing options...
dylbill Posted June 14, 2023 Share Posted June 14, 2023 Have you tried the OnMagicEffectApply event? https://www.creationkit.com/index.php?title=OnMagicEffectApply_-_ObjectReference Link to comment Share on other sites More sharing options...
dafydd99 Posted June 14, 2023 Author Share Posted June 14, 2023 Nope I have not dylbill! I shall try that right now! Edit: Right. We're getting there! That works for arrows fired from a fire enchanted bow! However it does not seem to pick up any enchantments from handheld weapons, whether the enchantment was added by the player or not. I think I could do the formlist for weapons that are pre-enchanted (though would miss out any ones added by other mods), and also could check if the player had a torch in their hands when coming close by, as 'holding out the torch' doesn't seem to trigger an event - but that still leaves player enchanted handheld weapons. Any thoughts? Scriptname TheSidratUnderTreeRootBarrierScript extends ObjectReference Keyword property MagicDamageFire auto FormList property TheSidratTorchList auto Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Dafbug.Notification("Hit!") Actor actorRef = akAggressor as Actor if(actorRef == game.getPlayer() && (akSource.hasKeyword(MagicDamageFire) || akProjectile.hasKeyword(MagicDamageFire) || TheSidratTorchList.hasForm(akSource))) shrivelRoot() endif endEvent Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect) Dafbug.Notification(akCaster + " applied the " + akEffect + " on root") if(akEffect.hasKeyword(MagicDamageFire)) shrivelRoot() endif EndEvent function shrivelRoot() ;player hit the root with the correct weapon playAnimation("Open") endfunction Link to comment Share on other sites More sharing options...
scorrp10 Posted June 14, 2023 Share Posted June 14, 2023 I would consider something likeBool function IsFireEffectWeapon(Form akSource) Weapon _weapon = akSource as Weapon If _weapon == none return false Endif Enchantment _enchantment = _weapon.GetEnchantment() If _enchantment == none return false Endif Int _idx = 0 While _idx < _enchantment.getnumeffects() MagicEffect _effect = _enchantment.getNthEffectMagicEffect(_idx) If(some way to check if _effect is fire type) return true Endif _idx+=1 EndWgile Return falseEndfunction Link to comment Share on other sites More sharing options...
dafydd99 Posted June 14, 2023 Author Share Posted June 14, 2023 Thanks scorrp10 - that's going to need SKSE for the GetEnchantment isn't it? At the moment I've no requirement for SKSE in my mods, but do give an optional improved experience if it is. Perhaps that's what I need to do here. Link to comment Share on other sites More sharing options...
dylbill Posted June 16, 2023 Share Posted June 16, 2023 Yes that would require SKSE. You don't have to cycle through the effects though. You can just do If _weapon.GetEnchantment().HasKeyword(MagicDamageFire) . If any of the magic effects in the enchantment have the keyword, it will return true. Link to comment Share on other sites More sharing options...
dafydd99 Posted June 16, 2023 Author Share Posted June 16, 2023 Thanks dylbill - great tip. I guess we're looking at one of the weaknesses of the creation engine here. You'd imagine getting the elemental effects of an attack would be straightforward - but not only is it complex, there's actually no vanilla way to do it comprehensively at all. Cheers - dafydd99 Link to comment Share on other sites More sharing options...
dylbill Posted June 16, 2023 Share Posted June 16, 2023 Yep, unfortunately that seems to be the case all too often. Link to comment Share on other sites More sharing options...
Recommended Posts