Jump to content

Enchantment through scripts?


Urwy

Recommended Posts

Solved

 

Greetings fellow modders!

 

As of recently i've been messing around a bit more with the CK, and now im stuck at a point at which i really want to put an enchantment on an item, that doesnt accept enchantments through the use of a dropdown box like the weapons and armor have, but does accept papyrus scripts.

 

I am aware that it is possible to attach a magic effect by using a script (though i havent got it to work) but it has to be an enchantment.

 

So that leaves me with the question: Is it possible to use a script to attach an enchantment to an item? If so, can anyone give me a quick rundown on how to do this?

And if there's an alternative way to do this, i'd like to hear that as well =)

 

Please do be aware that my scripting skills are near to nothing, as i'm more a modelling, texturing and Basic CK kinda guy.

 

Thanks in advance!

Edited by Urwy
Link to comment
Share on other sites

From what i know it's not possible to attach a magic effect or an enchantment to an item.

 

What you can do via script is attaching a magic effect to the player/NPC when that item is in the inventory.

 

Hmm that might work as well, but is it also possible to cast a spell on activation? (when blocking for example)

I'm trying to get a torch give off a fire blast when blocking... i wanted to base this off the spellbreaker enchant, but i guess that's out the door now. :P

Link to comment
Share on other sites

I think it's doable, but i don't know if my script could work

 

Spell property mySpell auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
   if Game.Getplayer().GetEquippedItemType(0) == 11
        if abHitBlocked == true
            Game.GetPlayer().DoCombatSpellApply(mySpell, akAggressor)
        endif
   endif
EndEvent

 

This script should fire everyone you get hit. On every hit, the script will check if you have a torch in your left hand (the blocking one) and then if the hit was blocked.

 

If yes, a spell will fire from the player to the aggressor. So you have to create a fire and forget spell.

 

I don't know how the spellcasting will work, but i think you ust need the enemy to be set on fire and apply a shader?

 

EDIT: also, to avoid compatibility issues, it's better if you create an empty quest with a player alias, then assign this script to that alias.

Edited by gasti89
Link to comment
Share on other sites

I think it's doable, but i don't know if my script could work

 

Spell property mySpell auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
   if Game.Getplayer().GetEquippedItemType(0) == 11
        if abHitBlocked == true
            Game.GetPlayer().DoCombatSpellApply(mySpell, akAggressor)
        endif
   endif
EndEvent

 

This script should fire everyone you get hit. On every hit, the script will check if you have a torch in your left hand (the blocking one) and then if the hit was blocked.

 

If yes, a spell will fire from the player to the aggressor. So you have to create a fire and forget spell.

 

I don't know how the spellcasting will work, but i think you ust need the enemy to be set on fire and apply a shader?

 

EDIT: also, to avoid compatibility issues, it's better if you create an empty quest with a player alias, then assign this script to that alias.

 

I tried to modify the script a bit so it would work on a shield, with a lightning bolt as spell, but no luck so far.

Here's my version of the script:

 

 

Scriptname SpellwardBlocking extends ObjectReference  

{Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
   if Game.Getplayer().GetEquippedItemType(0) == 39
        if abHitBlocked == true
            Game.GetPlayer().DoCombatSpellApply(Myspell, akAggressor)
        endif
   endif
EndEvent
}

SPELL Property mySpell  Auto  

 

 

So far, i havent got it to fire.. still messing around with some enchantments to see if i can do it that way, since shields to accept enchantments.

 

Edit¹:

Yeah, enchants eem to do the trick. Added a IsRecoiling condition to the target (meaning you've just blocked him.) and added a IsStaggered condition to the player to make things interesting :)

 

Edit²:

I never thanked you for your help... How unpolite of me.

Thank you Gasti89, for putting me on the right track! :thumbsup:

Edited by Urwy
Link to comment
Share on other sites

WTF is that 39? :P

 

0: Nothing

 

1: One-handed sword

 

2: One-handed dagger

 

3: One-handed axe

 

4: One-handed mace

 

5: Two-handed sword

 

6: Two-handed axe/mace

 

7: Bow

 

8: Staff

 

9: Magic spell

 

10: Shield

 

11: Torch

 

These are the Ints for the item types.

 

Anyway, this command is to use only for torches, because they don't work otherway.

 

Shields safely work when using OnEquipped, so:

 

Armor property myShield auto

Spell property mySpell auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
   if Game.Getplayer().IsEquipped(myShield)
        if abHitBlocked == true
            Game.GetPlayer().DoCombatSpellApply(mySpell, akAggressor)
        endif
   endif
EndEvent

 

Anyway yes, if you use a shield is far easier to attach an enchantment to it instead of using scripts. Scripts are good for the torch since it is a non-enchantable equippable item.

Link to comment
Share on other sites

WTF is that 39? :P

 

0: Nothing

 

1: One-handed sword

 

2: One-handed dagger

 

3: One-handed axe

 

4: One-handed mace

 

5: Two-handed sword

 

6: Two-handed axe/mace

 

7: Bow

 

8: Staff

 

9: Magic spell

 

10: Shield

 

11: Torch

 

These are the Ints for the item types.

 

Anyway, this command is to use only for torches, because they don't work otherway.

 

Shields safely work when using OnEquipped, so:

 

Armor property myShield auto

Spell property mySpell auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
   if Game.Getplayer().IsEquipped(myShield)
        if abHitBlocked == true
            Game.GetPlayer().DoCombatSpellApply(mySpell, akAggressor)
        endif
   endif
EndEvent

 

Anyway yes, if you use a shield is far easier to attach an enchantment to it instead of using scripts. Scripts are good for the torch since it is a non-enchantable equippable item.

 

Eh....

I've been looking for those item numbers all over the place! Only thing i could find was that 39 for the shields :blush:

I'll have a look what works best of the two in the morning: enchants, or your script :)

 

Gosh, i'd probably have blown up my PC if you hadnt come along ;D

Link to comment
Share on other sites

Still had no luck on that latest script.... Its probably just me doing something wrong, so i've resorted to enchantments to trigger the effects.

The mod itself is already released, but i'll keep fiddling with the script for future mods :)

http://skyrim.nexusmods.com/mods/21357

Link to comment
Share on other sites

  • Recently Browsing   0 members

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