Jump to content

Detecting fire weapon enchantments on hit


Recommended Posts

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

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

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

I would consider something like

Bool 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 false

Endfunction

Link to comment
Share on other sites

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...