Jump to content

[SE] Trouble trying to make weapons cast spells upon power attacking


Recommended Posts

Hello everyone! I'm trying to make some weapons cast spells upon power attacking, and i've had some success doing so, but the process is so full of details, that it got me stumped right now. The mod Colorful Magic has a version of the Bloodskal script that lets you choose which spell you want to cast for every power attack direction, and this seemed  exactly what i wanted, because the original Bloodskal only has two types of spell to be cast, the horizontal and vertical wave beam. The thing is that while this script works perfectly for greatswords - i can power attack in any direction and it will cast all the spells - it doesn't fully work for one handed swords, it will only work for sideways power attacks and back power attacks. On top of that, it won't work for left handed power attacks, and since i plan to apply this behavior of casting spells on power attack for a dual wielding npc, this is a problem for me. Since i don't have access to the source scripts of Colorful Magic, i can't see how it checks for each type of power attack, so i decided to create my own script based on the vanilla Bloodskal script. I saw that it checks for power attacks, but since i'm a newbie with skyrim scripts, i'm not familiar with what corresponds to one handed right and left power attacks. Upon searching that on google, i actually found a post on reddit that tries to cover basically what i want regarding this script - a way to check for each type of power attack, including left handed and dual wield, and cast a spell accordingly.

https://www.reddit.com/r/skyrimmods/comments/jvkmw8/i_found_a_way_to_apply_the_bloodskal_blade_effect/

I made some changes to the script and compiled it in CK, added it to a magic effect, added the MGEF to an ability, and created a perk that adds this ability. I added the perk to me through console to test it, but since only the npc will have access to this ability, i will add it directly to her perks. The script below is the implementation, but i added properties for two more spells to test if it would work the way i want it to, but i'm having problems with it.

scriptname _MariaEduardaHurtadoWarglaiveAbility extends activemagiceffect

spell property SpellToCast auto
spell property SpellToCast2 auto
spell property SpellToCast3 auto

actor PowerAttacker

event OnEffectStart(Actor akTarget, Actor akCaster)

	PowerAttacker = akTarget
	RegisterForAnimationEvent(PowerAttacker, "WeaponSwing")
	RegisterForAnimationEvent(PowerAttacker, "WeaponLeftSwing")
	RegisterForAnimationEvent(PowerAttacker, "AttackPowerStanding_FXstart")
	RegisterForAnimationEvent(PowerAttacker, "AttackPowerRight_FXstart")
	RegisterForAnimationEvent(PowerAttacker, "AttackPowerLeft_FXstart")
	RegisterForAnimationEvent(PowerAttacker, "AttackPowerBackward_FXstart")
	RegisterForAnimationEvent(PowerAttacker, "AttackPowerForward_FXstart")
endEvent

event OnAnimationEvent(ObjectReference akSource, string asEventName)

	int WeaponType = PowerAttacker.GetEquippedItemType(0)
    bool Rotation = PowerAttacker.GetAnimationVariableBool("bAllowRotation")
	bool LetsSneak = PowerAttacker.IsSneaking()
	if asEventName == "WeaponSwing"
		if (WeaponType == 6)
			if (PowerAttacker.GetAnimationVariableInt("iState") == 12)
				debug.Notification("Fixed 2-H Power Attack for axes and hammers; works with sneak.")
				SpellToCast.Cast(PowerAttacker)
			endIf
		elseIf ((WeaponType > 0) && (WeaponType <5))
			if !LetsSneak
                bool LeftAttack = PowerAttacker.GetAnimationVariableBool("bLeftHandAttack")
			    if LeftAttack && Rotation
				    debug.Notification("Left handed Power Attack")
				    SpellToCast.Cast(PowerAttacker)
			    elseIf !LeftAttack && Rotation
					if (asEventName == "AttackPowerForward_FXstart")
						debug.Notification("Right handed Forward Power Attack.")
						SpellToCast2.Cast(PowerAttacker)
					elseIf (asEventName == "AttackPowerStanding_FXstart")
						debug.Notification("Right handed Standing Power Attack.")
						SpellToCast3.Cast(PowerAttacker)
					else
						debug.Notification("Right handed Power Attack.")
						SpellToCast.Cast(PowerAttacker)
					endIf
			    endIf
            endIf
		endIf
	elseIf asEventName == "WeaponLeftSwing"
		if Rotation && !LetsSneak
			debug.Notification("Dual Wield Power Attack First Hit")
			SpellToCast2.Cast(PowerAttacker)
		endIf
	else ;every other animation event registered
		if WeaponType != 6	;Necessary because for some weird ass reason, Bethesda decided to count hammers and axes power attacks to only count towards these events when sneaking
			debug.Notification("Greatsword power attacks")
			SpellToCast.Cast(PowerAttacker)
		endIf
	endIf
endEvent

The character i created is a demon hunter that unleashes different types of fel fire spells depending on her attacks.

The behavior i want is casting spell1 when performing sideways power attacks with the right hand weapon or any power attack with left hand weapon, casting spell2 when performing a forward power attack with right weapon, and casting spell3 when performing standing power attack with right weapon. What happens, though, is that EVERY right weapon power attack casts spell 1, EVERY left hand power attack casts spell 2 (left weapon power attacks are being registered as dual wield power attacks for some reason), and the two last hits from the dual wield power attack are being registered as left hand power attacks (this causes the dual wield power attack to cast spell2 one time and spell1 TWO TIMES, which is really overpowered, so i don't want dual wield power attacks to cast spells), it's like bethesda inverted them for some reason, or my script is wrongly checking what power attack is being performed.

Can someone help me?

 

 

Link to comment
Share on other sites

Been a while since I done much with swing events... but it seems not-good-practice to register for both power and non power. A power attack will trigger two events I believe. Again, been a while, but I know there's a reason you don't see it done this way usually

Aside, try resolving in a different order. Check for power attacks first. Then if no power attacks, then check for whether it's a left and right regular swing. If written a certain way you might be able to pull off all those registrations

Link to comment
Share on other sites

  • Recently Browsing   0 members

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