Jump to content

Scripting help? How to tell if an actor is attacking?


ArcticZero

Recommended Posts

Basically, I'm trying to get a script to detect when the player is attacking, and apply certain buffs to the player's stats. I don't see anything under the CK scripting reference that seems to address this condition.

 

Second question, is it possible to "trick" the game into thinking that the player is performing a certain action (e.g. blocking, jumping) even if they aren't?

 

Thanks in advance to anyone who can help! :)

Link to comment
Share on other sites

if Player.GetAnimationVariableInt("iRightHandType") for attacks with right hand

if Player.GetAnimationVariableInt("iLeftHandType") for attacks with left hand

 

If you want them to only trigger if the player is using weapons you'll have to add extra conditionals like the GetEquippedItemType conditional

Link to comment
Share on other sites

Script:

 

 

Scriptname Monitor_Combat_State extends Actor  
{
Trigers when the player enters combat.
}
;=================================


Event OnCombatStateChanged(Actor akTarget, int aeCombatState)

aeCombatState = GetCombatState() ; I find "aeCombatState" to be unreliable. This is a reliable bugfix.
akTarget = GetCombatTarget()	      ; I find "aktarget" to be unreliable. This is a reliable bugfix.

If aeCombatState == 2			; I'm in searching mode.
;		Debug.Notification("[Monitor_Combat_State] CombatState = 2")
;		do my cool stuff
	Return
ElseIf aeCombatState == 1			; I started combat
;		Debug.Notification("[Monitor_Combat_State] CombatState = 1")
;		do my cool stuff
	Return
ElseIf aeCombatState == 0			; I have ceased combat
;		Debug.Notification("[Monitor_Combat_State] CombatState = 0. No longer in combat")
;		combat has ended, so here we need to remove any special stuff that we did earlier.
	Return
Else
;		Debug.notification("[Monitor_Combat_State] Something unexpected has gone wrong.")
EndIf

EndEvent

 

 

I designed the script written above to be put on an NPC. If you put this script on a player quest alias, you will probably need to make the script extend ReferenceAlias instead of Actor.

 

Edit: there are also Condition Functions such as "GetCombatState", "IsAttacking" and "GetAttackState" that you could use to make a Magic Effect activate/deactivate when in combat or not.

Edited by steve40
Link to comment
Share on other sites

Thanks for the replies!

 

@steve40 - Looks like a great script to try, however what I'm trying to do is determine if the player is actually in the process of swinging his weapon (attacking), and not simply if he is in combat mode.

 

I'm sorry for all the questions, but I'm new at Skyrim scripting and absolutely none of my web development/programming knowledge is helping me at all. Not to mention all the documentation on the wiki isn't very beginner-friendly.. So I'm a total noob at this point. :P

 

I'm trying to attach this script to the player so that it activates each time the player attacks with his weapon. It doesn't necessarily have to be hitting anything though. Right now I'm doing it by creating a quest and using OnUpdate() and RegisterForUpdate(0.1). I'm sure there are better ways of doing this so the script only runs when it detects the player attacking. Perhaps there's a better way of attaching the script to the player that I'm not aware of. :)

 

Again, thanks for the replies! Much appreciated.

Link to comment
Share on other sites

Try this:

 

 

Event OnEffectStart(Actor akTarget, Actor akCaster)

RegisterForAnimationEvent(akCaster, "BashStart")

RegisterForAnimationEvent(akCaster, "BowRelease")

RegisterForAnimationEvent(akCaster, "WeaponLeftSwing")

RegisterForAnimationEvent(akCaster, "WeaponSwing")

Debug.Trace("Registering for animation event!")

EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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