How would you use "Form akSource" to filter out all

Post » Wed Jun 20, 2012 9:41 pm

When using :

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)



I am checking to filter out some magic and arrows by doing this:

akProjectile == none


But how would YOU use "Form akSource" to further filter and insure only Melee weapons?
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Thu Jun 21, 2012 12:22 am

What do you mean, to only filter melee weapons? You are trying to write a script that only does something when the hit comes from a melee weapon? In that case, I would create a FormList with all the weapons I want to trigger the OnHit() and then use the following script:

FormList Property MeleeWeapons AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)if (MeleeWeapons.HasForm(akSource) ;;do stuffEndifEndEvent
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Wed Jun 20, 2012 10:28 am

If you want to be able to test for modded weapons, you could try using

akForm.HasKeyword(WeapTypeSword)

and hope that the creator added the keywords to the weapon(s).
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Wed Jun 20, 2012 8:13 pm

If you want to be able to test for modded weapons, you could try using

akForm.HasKeyword(WeapTypeSword)

and hope that the creator added the keywords to the weapon(s).


FormList Property MeleeWeapons AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)if (MeleeWeapons.HasForm(akSource) || akForm.HasKeyword(WeapTypeSword) ;; Repeat this for every melee weapon type on this if statement ;;do stuffEndifEndEvent
User avatar
katsomaya Sanchez
 
Posts: 3368
Joined: Tue Jun 13, 2006 5:03 am

Post » Wed Jun 20, 2012 10:39 am

mmmmm... I have not gotten into using or even understanding "formlist" yet. But I found that the following seems to do the job for me:

(Attacker.GetEquippedItemType(Hand) <= 6 || abBashAttack == true || Attacker.GetEquippedItemType(Hand) <= 11)

Thanks guys, you did actually help me a lot on this even if I did not in the end use your suggestions.
User avatar
noa zarfati
 
Posts: 3410
Joined: Sun Apr 15, 2007 5:54 am

Post » Wed Jun 20, 2012 11:35 am

mmmmm... I have not gotten into using or even understanding "formlist" yet.
FormLists are great! They're merely indexed lists of FormIDs which can be used in scripts just like the items they contain, so if you create a MeleeWeaponFLST, dragondrop all the appropriate weapons into it, you can conditionalize w/ 'If Attacker.GetEquipped(MeleeWeaponFLST)' or 'If MeleeWeaponFLST.HasForm(akSource)' . Anyhow, once you tinker with FLSTs, I'll bet you'll find they're extraordinarily useful.
User avatar
Matthew Barrows
 
Posts: 3388
Joined: Thu Jun 28, 2007 11:24 pm

Post » Wed Jun 20, 2012 5:54 pm

(Attacker.GetEquippedItemType(Hand) <= 6 || abBashAttack == true || Attacker.GetEquippedItemType(Hand) <= 11)

I think that will always return true. It will return a value from 0 to 11. I think you meant "== 10" for shield, or "== 11" for torch. (I've never tried bashing with a torch, does that work?)
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Thu Jun 21, 2012 12:04 am

FormLists are great! They're merely indexed lists of FormIDs which can be used in scripts just like the items they contain, so if you create a MeleeWeaponFLST, dragondrop all the appropriate weapons into it, you can conditionalize w/ 'If Attacker.GetEquipped(MeleeWeaponFLST)' or 'If MeleeWeaponFLST.HasForm(akSource)' . Anyhow, once you tinker with FLSTs, I'll bet you'll find they're extraordinarily useful.

ha!...ok... I see, then I will never be using form lists as they are not "moded weapons" work-able without patching for every weapons mod out there. :shrug:
But thanks for explaining that to me.
User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Wed Jun 20, 2012 7:48 pm

GOOD CATCH! Thank you! Thank you! Thank you!

I think that will always return true. It will return a value from 0 to 11. I think you meant "== 10" for shield, or "== 11" for torch. (I've never tried bashing with a torch, does that work?)
User avatar
sharon
 
Posts: 3449
Joined: Wed Nov 22, 2006 4:59 am

Post » Wed Jun 20, 2012 12:49 pm

ha!...ok... I see, then I will never be using form lists as they are not "moded weapons" work-able without patching for every weapons mod out there. :shrug:
But thanks for explaining that to me.

That's a bad reason for not using them ever. Unless you don't actually mean NEVER. In any case, you can use literals like || (or) . The important thing is script efficiency, and the FormLists provide that.
User avatar
Heather M
 
Posts: 3487
Joined: Mon Aug 27, 2007 5:40 am

Post » Wed Jun 20, 2012 2:34 pm

You could set up an OnEquip() event to try to determine if the equipped item was a meele weapon, and have it add that to the formlist if it determines that it is and it's not in there already.
User avatar
Nick Pryce
 
Posts: 3386
Joined: Sat Jul 14, 2007 8:36 pm

Post » Wed Jun 20, 2012 8:05 pm

How about

If(!(akSource As Weapon))returnElseDebug.MessageBox("Yay I'm a weapon!")EndIf
User avatar
Dawn Farrell
 
Posts: 3522
Joined: Thu Aug 23, 2007 9:02 am

Post » Thu Jun 21, 2012 1:30 am

How about

If(!(akSource As Weapon))returnElseDebug.MessageBox("Yay I'm a weapon!")EndIf

Would that work to filter out bows? Bows are still weapons, right?
User avatar
Arnold Wet
 
Posts: 3353
Joined: Fri Jul 07, 2006 10:32 am

Post » Thu Jun 21, 2012 1:35 am

Would that work to filter out bows? Bows are still weapons, right?

Could filter those out using either the method spooky already mentioned in the OP (if (akProjectile == None)) or checking akSource for the bow keyword (think it was something like WeapVendorTypeBow)
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Wed Jun 20, 2012 6:47 pm

In appreciation of you guys helping I thought I should report that I discovered that (akProjectile ) will not detect arrows and in fact no combination using akProjectile would work for me for what ever reason:

if (akProjectile)
if (akProjectile) > 0
if akProjectile == true
if akProjectile != None


I finally just ended up checking if the attacker is using a bow with: GetEquippedItemType (and that worked).

Could filter those out using either the method spooky already mentioned in the OP (if (akProjectile == None)) or checking akSource for the bow keyword (think it was something like WeapVendorTypeBow)
User avatar
Janette Segura
 
Posts: 3512
Joined: Wed Aug 22, 2007 12:36 am

Post » Wed Jun 20, 2012 2:01 pm

Why don't you use:

http://www.creationkit.com/GetEquippedItemType_-_Actor

On attacker? I think it's unlikely that the actor will switch weapon types before your script checks it.

Edit: Oh, someone already suggested that.
User avatar
YO MAma
 
Posts: 3321
Joined: Thu Dec 21, 2006 8:24 am


Return to V - Skyrim