I don't know if this will be the solution for you.... it didn't work out for me but I was trying to get objectreferences of weapons to apply effect shaders to them. Actually, I could apply effect shaders but they didn't work the way I wanted to (hardly visible, at the tip of the weapon only). Since I couldn't get it the next step I stopped. I thought of this idea when I had to figure out whether or not to re-add a certain item in the player inventory (which are not objectreferences) or how to re-associate an item with a referencealias which only works with object references. This may open the door for you. I dunno.
Here's my alias reference fixup function, declerations at the top of the script:
ReferenceAlias Property JournalAlias autoBook Property mm_BeluaVampireJournal auto
Some code in my fixup function:
; Fixup the journal alias if that needs to be done if JournalAlias.GetReference() == None Trace("Fixing Journal Alias: " + JournalAlias) ObjectReference Journal = Player.PlaceAtMe(mm_BeluaVampireJournal) JournalAlias.ForceRefTo(Journal) Player.RemoveItem(mm_BeluaVampireJournal,10) Player.AddItem(JournalAlias.GetReference()) Else Trace("JournalAlias NOT None: " + JournalAlias.GetReference()) EndIf
As you can see here I'm checking to see if an alias in my quest is already filled. If it's not I need to fill it with an object. To get the objectreference for an object that isn't actually of ObjectReference type, you can call PlaceAtme with any formtype. PlaceAtMe, however, returns an ObjectReference ID of the object you placed regardless of the formtype. Then I removed any existing items of that type from the player, and re-added the journal to the player using the aliases GetReference() function.
My code for getting at the weapons object reference was similar but I didn't take it too far because the effectshaders just didn't work right on the object (and even in the debug log it said it wouldn't play although .... something.... was going on). I deleted that code so this is from memory:
Weapon lefthandWeaponWeapon righthandWeaponObjectReference LeftHandWeaponObjectObjectReference RightHandWeaponObjectEvent OnEffectStart(Actor target, Actor caster) LeftHandWeapon = target.GetEquippedWeapon(abLeftHand = true) RightHandWeapon = target.GetEquippedWeapon(abLeftHand = false) if LeftHandWeapon != None LeftHandWeaponObject = target.PlaceAtMe(LeftHandWeapon) EndIf if LeftHandWeapon != None LeftHandWeaponObject = target.PlaceAtMe(LeftHandWeapon) EndIf ;... do more work...EndEvent
So the problem with THIS code is you end up with a duplicate item sitting at the targets feet. I was then able to apply a shader, again it didn't work as expected or I would have taken it a step farther. I did try re-equipping the item but the call failed when using the objectreference. There might be a way around that using the same method I used in my journal sample above, and that's to assign the object to a reference alias and then get the reference back out.
I don't know if any of this will help you.... but it might give you some ideas to make some progress without attaching a script to every blessed object.
Finally if you want to know when someone hit another actor create a cloak spell with like a 20 foot radius. Have the cloak spell apply a dummy effect with a script. In the script you can use the OnHit event to get access to who it was, and what form object they used to attack with:
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
bool abBashAttack, bool abHitBlocked)
Parameters - akAggressor: The http://www.creationkit.com/ObjectReference_Script_(Papyrus) that attacked this reference.
- akSource: The http://www.creationkit.com/Weapon_Script, http://www.creationkit.com/Spell_Script, http://www.creationkit.com/Explosion_Script, http://www.creationkit.com/Ingredient_Script, http://www.creationkit.com/Potion_Script, or http://www.creationkit.com/Enchantment_Script that hit this reference.
- akProjectile: The http://www.creationkit.com/Projectile_Script_(Papyrus) that hit this reference.
- abPowerAttack: Was the hit caused by a power attack?
- abSneakAttack: Was the hit caused by a sneak attack?
- abBashAttack: Was the hit caused by a bash attack?
- abHitBlocked: Was the hit blocked?
Good luck!!!
- MM