Event fired when player uses a weapon?

Post » Sun Nov 18, 2012 3:30 am

I have an ObjectReference to the player from a Quest, which I've been told is a good way to attach scripts to the player. Is an event fired when the player uses a weapon (swings a sword, etc)? I know there's one for firing a bow. I'd also like to be able to tell if the weapon hit anything other than air (e.g. hit nothing = false, hit a wall = true, hit Nazeem = true).
User avatar
Roberto Gaeta
 
Posts: 3451
Joined: Tue Nov 06, 2007 2:23 am

Post » Sun Nov 18, 2012 3:41 am

There are animation EVENTs for weapon swings:

if asEventName == "WeaponSwing" || asEventName == "WeaponLeftSwing"

BUT this will not detect power attacks where the actor is moving left, right, or forward or backward, will not detect "fake" attacks (magic spells that LOOK like melee attacks) as when the giants do the ground shaking attacks with clubs (however I am not sure if there are any for the player other than the shield charge), and will not give you any of the other data you asked for. You are going to have to have a fairly long somewhat complicated script to get all that info.
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Sun Nov 18, 2012 1:22 pm

The creationkit.com page for "OnAnimationEvent" (can't post the link, which is understandable) states that OnAnimationEvent "is not relayed to any aliases or magic effects attached to the form". I just tested it, and the event doesn't fire when I swing my sword- would I need to put it in a script attached to a weapon?

Also, there aren't other animations I could specify (other than "WeaponSwing" and "WeaponLeftSwing") for power attacks while moving? I'm trying to implement a durability mod, and that would be an easy way to circumvent damage being applied. How would I detect when the player uses any attack?

I've got no problem with complicated. I'm not new to programming, just completely new to scripting (and Papyrus scripting specifically).
User avatar
Lucy
 
Posts: 3362
Joined: Sun Sep 10, 2006 4:55 am

Post » Sun Nov 18, 2012 7:20 am

Another technique I recently discovered and haven't seen mentioned anywhere yet (spooky might be interested in this for his mod as well):

Go to either the Race or the NPC you want to detect attacks on. Edit the form, and go to the Attack Data tab. It describes several different attacks available for that race. When you select an attack, under it a dropdown menu will enable called Attack Type, referring to a Keyword. For a good number of these attacks no Keyword has been specified. Make new Keywords for any attacks that are missing and select them in this drop down menu.

Now you can either create Magic Abilities or Perk Entries (or both) and add new conditions to them using "IsAttackType", for which you can select a Keyword parameter. The Keyword refers to the ones selected in the Attack Type drop down menu in the Attack Data tab of Races/NPC's. You can do a lot of stuff this way, changing stats during a specific attack, or having scripts run either through a Magic Effect or using Apply Combat Hit Spell Perk Entries, etc.

The good thing about using IsAttackType conditions is the fast execution. If you are just looking for increased damage or something else non-scripted the execution will be instant.

The only drawback is that you have to modify NPC or Race forms for this technique. We might consider making a mod that does this as a resource on which we can make our mods dependent, so that multiple mods can make use of IsAttackType without conflicting Attack Data data.
User avatar
Kill Bill
 
Posts: 3355
Joined: Wed Aug 30, 2006 2:22 am

Post » Sun Nov 18, 2012 5:21 am

That is VERY tempting and very very clever but there is no way I can bring myself to making edits to the RACE tabs. That is asking for trouble down the road. :shrug:
Once SKSE can do this on the fly (edits to the race tabs) I will be overjoyed as there are a lot A LOT ...of changes I would make if I could edit the race tab!

Another technique I recently discovered and haven't seen mentioned anywhere yet (spooky might be interested in this for his mod as well):

Go to either the Race or the NPC you want to detect attacks on. Edit the form, and go to the Attack Data tab. It describes several different attacks available for that race. When you select an attack, under it a dropdown menu will enable called Attack Type, referring to a Keyword. For a good number of these attacks no Keyword has been specified. Make new Keywords for any attacks that are missing and select them in this drop down menu.

Now you can either create Magic Abilities or Perk Entries (or both) and add new conditions to them using "IsAttackType", for which you can select a Keyword parameter. The Keyword refers to the ones selected in the Attack Type drop down menu in the Attack Data tab of Races/NPC's. You can do a lot of stuff this way, changing stats during a specific attack, or having scripts run either through a Magic Effect or using Apply Combat Hit Spell Perk Entries, etc.

The good thing about using IsAttackType conditions is the fast execution. If you are just looking for increased damage or something else non-scripted the execution will be instant.

The only drawback is that you have to modify NPC or Race forms for this technique. We might consider making a mod that does this as a resource on which we can make our mods dependent, so that multiple mods can make use of IsAttackType without conflicting Attack Data data.
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Sun Nov 18, 2012 6:19 pm

That is VERY tempting and very very clever but there is no way I can bring myself to making edits to the RACE tabs. That is asking for trouble down the road. :shrug:

It is rather annoying for compatibility reasons. That's why I suggested this:

We might consider making a mod that does this as a resource on which we can make our mods dependent, so that multiple mods can make use of IsAttackType without conflicting Attack Data data.

Though a problem is that other people who mod Races would also need to make it compatible with this "resource" mod. It would take quite some effort to make it a well known standard, although in the end it would be very valuable to combat mods.

Grmpf, why didn't Bethesda just add unique Keywords for every attack to begin with!
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Sun Nov 18, 2012 8:45 am

I use it in Magic Effects all the time. Abilities given to actors "on the fly" and thru aliases .... a LOT!

Don't know what to tell you about the Wiki, it is not always right.
But it could be some small difference in the way I am doing it that makes it work.


The creationkit.com page for "OnAnimationEvent" (can't post the link, which is understandable) states that OnAnimationEvent "is not relayed to any aliases or magic effects attached to the form". I just tested it, and the event doesn't fire when I swing my sword- would I need to put it in a script attached to a weapon?


User avatar
Patrick Gordon
 
Posts: 3366
Joined: Thu May 31, 2007 5:38 am

Post » Sun Nov 18, 2012 4:07 am

I wonder if there is ANY way we could get them to do that for the next update? They claim they are dedicated to updating this game over the next few months or years.

And they gave us Combat Moders SO LITTLE LOVE to begin with for Skyrim, do you think they would listen to us about this?

If this keyword idea of yours will give me instant reactions for attacks in my scripts I am willing to EMAIL/Post/Tweet/Petition/BEG/Give my first born...what ever it takes to try to get them to help combat moding by making this change.

It would not effect the Xbox or other platforms right?


Grmpf, why didn't Bethesda just add unique Keywords for every attack to begin with!
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Sun Nov 18, 2012 4:59 am

They would just need to create the new Keywords and apply them to all Races Attack Data. It wouldn't change any functionality by itself, so it wouldn't affect consoles. It would just provide hooks for IsAttackType conditions. Although, this would be updated into Update.esm and many modders still don't load it when modding. Though that would be their fault ofcourse.

But, adding Perks to NPC's in runtime would also be kinda necessary to take full advantage of this without incompatibility issues. Although SkyProc is an alternative to this, it would still be far better if we could just add Perks through scripts and such. Who knows, perhaps the SKSE team could implement this some day? The engine should be capable of it.


What we as a modding community need, is our own community-run equivalent to Update.esm. It would contain stuff that doesn't change anything by itself such as these Keywords but are invaluable resources to all kinds of mods. It would solve a [censored]load of incompatibilities and open up so many more possibilities to us modders.
User avatar
BRAD MONTGOMERY
 
Posts: 3354
Joined: Mon Nov 19, 2007 10:43 pm

Post » Sun Nov 18, 2012 6:55 am

What we as a modding community need, is our own community-run equivalent to Update.esm. It would contain stuff that doesn't change anything by itself such as these Keywords but are invaluable resources to all kinds of mods. It would solve a [censored]load of incompatibilities and open up so many more possibilities to us modders.

Wouldn't that be something which would fit well into something like Common Skyrim Library (http://skyrim.nexusmods.com/mods/13322)?

Long time ago I made a suggestion on these forums if anyone felt like making a skyrim version of COBL, and AliTheLord decided to pick it up and made this, but seems like it didn't get a lot of development anymore after initial release :(
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm


Return to V - Skyrim