Jump to content

Questions about changing ObjectReference


BigKevSexyMan

Recommended Posts

Ok, I'm trying to do a mod, and I'm getting sick of the workarounds that aren't........working. So, I'm thinking of trying something drastic. I'm thnking of modifying the ObjectReference Script directly.

 

So, let me tell you what and why I am doing this. In the ObjectReference, there is an event called OnHit:

 

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

 

This one function has ALL the information I need. This issue is, I am not working from a script that inherits from ObjectReference. I'm doing a activemagiceffect script. There is no way to get this information via script calls to an Actor. This data does not persist. What I want to do is simply use this function to add data to all object references.

 

ObjectReference LastAggressor
Projectile LastProjectile
bool LastHitPowerAttack
bool LastHitSneakAttack
bool LastHitBashAttack
bool LastHitBlocked

 

Now, I'm trying to think of a good way to accomplish this without destroying compatability with other mods. So, my question is, is there any other way to accomplish this without having to resort to overriding?? Would it be a terrible move to do this?!

Link to comment
Share on other sites

Before trying to change the core scripts, maybe you would pose the initial problem you're having with using OnHit. It might be easier, and will certainly cause less incompatibilities doing it that way! What is the script trying to do, in particular with the OnHit information?

 

If you edit the ObjectReference script, it will be required by other players for your mod to function and as many of us use SKSE which already does that, there won't be a large number of people installing it.

Link to comment
Share on other sites

Well, I'm trying to make some new enchantments, specifically enchantments built around using shields. So, for example,....when the actor that has this enchantment holds his shield up and gets hit he casts frenzy on the guy who hit him. The problem is, I have no way of finding out who my target is. So my hope was to somehow get ahold of the akAggressor parameter from the OnHit Event from the ObjectReference script.
Link to comment
Share on other sites

I'm thinking outside the box here...

 

Can you have a script on your actor or the alias of the actor which has an OnHit event? At the same time this script checks for the presence of (using arrays) X shield with whatever enchantment type it has. Since you may have multiple shields with different enchantments you use an array to list them instead of duplicating the code for each shield type, you have a corresponding array with the retaliation spell that you've synced up with the shield array.

 

It boils down to...

 

When Actor running script is hit and has shield of X type they will cast Y spell at target Z from the OnHit event.

 

the guts of the script would be something like (with Self replaced with whatever you need to to indicate the actor running the script)

 

Armor[] Property ShieldUsed Auto
Spell[] Property SpellToCast Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
Int ArmorArraySize = ShieldUsed.Length
Int SpellArraySize = SpellToCast.Length
If ArmorArraySize == SpellArraySize  ;safety net so that it doesn't run if you didn't make sure each shield got a matching retaliation spell (or NONE entry)
Int Index = 0
While Index < ArmorArraySize
If (Self.GetEquippedShield() == ShieldUsed[index])
;stuff to make a spell be cast using  SpellToCast[index] @ the target from OnHit
EndIf
EndWhile
EndIf
EndEvent

no clue if that will actually work, but it sounds plausible in theory and much better than modifying the ObjectReference script itself.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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