Jump to content

Scripting Help with Event OnHit


BrotherBob

Recommended Posts

I created a new Actor and gave it an Ability. The Ability consists solely of a MagicEffect with a script attached:

Projectile Property SteelArrowProjectile auto
Spell Property SpecialSpell auto
Actor Target

Event OnEffectStart(Actor akTarget, Actor akCaster)
Target = akTarget
endEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
if akProjectile == SteelArrowProjectile
SpecialSpell.Cast(Target, Target)
endif
endEvent

Despite properly setting the properties, the Actor never casts the spell when hit by a Steel Arrow. Am I doing something wrong?

Link to comment
Share on other sites

Don't you have to have a line at the top something like

 

Scriptname YourProjectileScript extends ObjectReference ?

 

This is actually very interesting to me if this can work because if silver weapons do extra damage against undead and werewolves because of the nature of the metal that hits them, it should be silver arrows and bolts, not silver bows and crossbows, that do extra damage in a mod that has such weapons available for crafting.

 

Cheers

Link to comment
Share on other sites

Sorry, that's part of a Magic Effect that is attached to the Actor, not the Projectile. I just didn't include the first line. I'm just wondering why it won't work. I figure that if I can get this script to work, I can get another of my scripts to work, which is much longer, but I can upload it if anyone is interested. Incidentally, it involves using Silver projectiles against vampires.

Link to comment
Share on other sites

Using trace statements, it appears that the Projectile part of Event OnHit is pretty much useless. It always returns None.

egocarib suggested the following on another forum:

I just searched around a bit and it appears that the projectile part of onHit() is just borked, and always returns none. However, you should be able to check this by doing something like:
if akAggressor.getEquippedItemType == 12   ;(12 == crossbow)
  if akAggressor.wornHasKeyword(WeaponTypeAmmo)
    ;(vampire must have been hit by the bolt)
  endif
endif
Just replace WeaponTypeAmmo with whatever keyword the silver bolt has. I don't have Dawnguard loaded to check the keywords for bolts right now. If it has a generic keyword that all bolts share, you could add your own custom keyword that will only be on silver bolts, which should then work.

 

 

I'm just reposting in case anyone needs help with that.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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