Jump to content

Detecting fire weapon enchantments on hit


Recommended Posts

The torch component would be particularly quirky to pull off. If SKSE was in play, you could registerforcontrol upon entering a trigger area near the wood or root or whatnot, and when block is hit, aka you nudging your torch, and x distance away, that could be detected. But you could well maybe have an animation to listen for, which would not need SKSE

 

Previous me from a couple years ago would prolly solve this really well for you lol. Used to spend way too much time with Papyrus and I enjoy solving things with out of the box thinking. Sadly I dont believe there is really an exact method that will fully encompass every feature you are wanting for this project. I like where your imagination is though

Edited by Sphered
Link to comment
Share on other sites

Okay - thanks Sphered and dylbill!

 

So I think I'm going to go for the root activator coupled with a trigger box to detect if the player is holding a torch linked to each other. I'm detecting it just being held rather than 'applying' it - as I think this will get complex, and the animation only really turns the torch on its side. So the activator script is...

Scriptname TheSidratUnderTreeRootBarrierScript extends ObjectReference  

Keyword property MagicDamageFire auto
FormList property TheSidratFireWeaponList auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    if((akSource && (akSource.hasKeyword(MagicDamageFire) || TheSidratFireWeaponList.hasForm(akSource)) || hasFireEffect(akSource)) || (akProjectile && akProjectile.hasKeyword(MagicDamageFire)))
        shrivelRoot()
    endif
endEvent

Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)
    if(akEffect.hasKeyword(MagicDamageFire))
        shrivelRoot()
    endif
EndEvent

bool function hasFireEffect(Form akSource) ;SKSE only, returns false without. Does not find player added enchantments
    Weapon ourWeapon=akSource as weapon
    if(ourWeapon)
        Enchantment ourEnchantment=ourWeapon.GetEnchantment()
        if(ourEnchantment)
            return ourEnchantment.hasKeyword(MagicDamageFire)
        endif
    endif
    return false
endfunction

function shrivelRoot() ;player hit the root with the correct weapon
    playAnimation("Open")
    (GetLinkedRef() as TheSidratUnderTreeRootTriggerScript).shutdown()
endfunction

And the trigger script as...

Scriptname TheSidratUnderTreeRootTriggerScript extends ObjectReference  

Actor property playerRef auto

event onCellDetach()
	unregisterforupdate()
endevent

event onupdate()
	checkForTorch()
endevent

event OnTriggerEnter(ObjectReference actronaut)
	if(playerRef==actronaut as actor)
		registerForUpdate(1.0) ; every second
		checkForTorch()
	endif
endevent

event OnTriggerLeave(ObjectReference actronaut)
	if(playerRef==actronaut as actor)
		unregisterforupdate()
	endif
endevent

bool function checkForTorch()
	if(playerRef.getEquippedItemType(0)==11)
		(getLinkedRef() as TheSidratUnderTreeRootBarrierScript).shrivelRoot()
	endif
endfunction

function shutdown()
	unregisterforupdate()
	disable()
endfunction

The trigger box could also have further 'parent enabled' collision boxes linking to it to stop the player from finding away around or over the root.

 

Note I have included the SKSE only 'getEnchantment()' code but this apparently DOESN'T pick up player enchanted items when the item is in a container (ie the player, whether equipped or not), so the only advantage it gains over checking the form in a fire weapons list is for new items from other mods. https://www.creationkit.com/index.php?title=GetEnchantment-_ObjectReference

 

Thanks again everyone!

 

dafydd99

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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