Jump to content

[LE] Need help with echantment and script


Recommended Posts

Hello,

 

I asked my question in the troubleshooting section of the forum until i realized it was the wrong section.

But i will benefit from this by explaining what i intend to do.

 

So basically what i am trying to achieve is very simple in itself:

to apply an enchantment to my weapon (or attach a .nif file to my equipped weapon) when i am in combat. And when there i am not in combat anymore, the enchantment is not there anymore.

 

I tried numerous things and searched almost everywhere.

I found something that could be intersting, a script that could add an enchantment:

QuoteScriptname _NewScript extends ObjectReference

Enchantment Property WeaponEnchant Auto

Event OnEquipped(Actor akActor)
    ;This can be changed to cast as Armor instead to set an armor enchantment.
    (GetBaseObject() as Weapon).SetEnchantment(WeaponEnchant)
EndEvent

Event OnUnEquipped(Actor akActor)
    ;This can be changed to cast as Armor instead to set an armor enchantment.
    (GetBaseObject() as Weapon).SetEnchantment(WeaponEnchant)
EndEvent

 

I could start with this but i need some guiding to do so.

The real reason i need an enchantment is that it was the only way i found that could apply an external .nif file to the weapon. So if an enchantment is too complicated to do, maybe finding a way to directly attach a .nif file to the weapon during combat could maybe be possible?

 

EDIT:

i made a small script attached to the weapon to check if player is in combat but i get a compilation error when compiling.

This is the error:

HeadlessAxeHeatActivate.psc(12,0): the parameter types of function onupdate in the empty state on script headlessaxeheatactivate do not match the parent script form
No output generated for HeadlessAxeHeatActivate, compilation failed.

 

this is the script

    QuoteScriptname HeadlessAxeHeatActivate extends ObjectReference  

    Actor Property PlayerRef  Auto
    bool done=false

    Event OnEquipped(Actor akActor)

            RegisterForSingleUpdate(1)

    endEvent

    Event onUpdate(Actor akActor)

        if !done
            if akActor == PlayerRef && PlayerRef.IsInCombat()
                Debug.Notification("Player is in combat")
            Else
                Debug.Notification("Player is NOT combat")
            Endif
        Endif

    endEvent

    Event OnUnequipped(Actor akActor)

        done = true

    endEvent


Edited by joebenz
Link to comment
Share on other sites

I'm halfway there. I created a quest with a reference alias with specific referance pointed to the player, added this script:

Scriptname HeadlessAxeScriptQuest extends ReferenceAlias  

Float Property TimeBetween Auto
Weapon Property WeaponRequired Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If akBaseObject as Weapon
		If akBaseObject as Weapon == WeaponRequired
         		Debug.Notification("Weapon Equipped")
			RegisterForSingleUpdate(TimeBetween)
		EndIf
	Endif
EndEvent

Event OnUpdate()
	If Game.GetPlayer().IsEquipped(WeaponRequired)
		if Game.GetPlayer().IsInCombat()
         		Debug.Notification("Is in Combat")
			RegisterForSingleUpdate(TimeBetween)
		Else
         		Debug.Notification("is NOT in combat")
			RegisterForSingleUpdate(TimeBetween)
		Endif
	EndIf
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If akBaseObject as Weapon
		If akBaseObject as Weapon == WeaponRequired
         		Debug.Notification("Weapon Unequipped")
			UnregisterForUpdate()
		EndIf
	EndIf
EndEvent 

Now whenever i get my specific weapon equipped, the script will succefully detect if i am in combat or not.

 

Now all i need is a way to apply an existing enchantment to the weapon when i'm in combat and when i am not, the enchantment is removed from the weapon. Or maybe a way to swap the meshes or apply an additional effect.

http://www.creationkit.com/index.php?title=WornObject_Script

But for now i find it difficult doing so and my searches have proven unfruitful.

 

EDIT:

 

Found a way of adding an external enchant to the weapon using this line:

WeaponRequired.SetEnchantment(WeaponEnchant)

But when the enchantment is applied, i have to unequip the weapon and reequip for it to show up which is troublesome.

 

My second option is to apply a .nif mesh to the weapon or dynamically swap a mesh through scripting.

Edited by joebenz
Link to comment
Share on other sites

Ok i found my awnser. Instead of directly applying an enchant on the weapon through script, i made an "enhance weapon" spell that applies the enchantment. Now the effects shows up when i'm in combat without me having to unequip and reequip and it works perfectly.

I just need to make a few adjustments to specify in which hand it will be blabla.

This thread looks more like a tutorial than a call for help. Ha!

Edited by joebenz
Link to comment
Share on other sites

  • Recently Browsing   0 members

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