Jump to content

Attaching scripts


Recommended Posts

Hey all, I`ve got a question about attaching scripts and I`ll be very thankfull if somebody helps me to clarify some things.

I have created a weapon and attached a script to it. The script checks for some conditions and casts my spell from player when the weapon is equipped.

 

It works pretty similar to recon scope effect which I used as an example for creating my script. I could do it all using a quest instead of attraching a script to a weapon. The recon scope effect is created with a quest alias that checks if the player is using a recon scope and casts a spell from player. This makes sence, there are lots of different weapons that can have a recon scope and using a quest is efficient in this case.

I have a single weapon that is only for player and I just wonder if there is any point to create a quest for it in my case...Is there any difference at all if the script is attached to a weapon or to a quest ?

Link to comment
Share on other sites

Hmm... I think there are other differencies too, but the first one I've got in my mind is that, if you attach script to vanilla weapon and other mod also modifies that weapon there will be compatibility issues, but if you create a quest, attach script on player alias and pass your weapon with OnItemEquipped() there won't be such issue.

Link to comment
Share on other sites

Hmm... I think there are other differencies too, but the first one I've got in my mind is that, if you attach script to vanilla weapon and other mod also modifies that weapon there will be compatibility issues, but if you create a quest, attach script on player alias and pass your weapon with OnItemEquipped() there won't be such issue.

Thank you very much for your suggestion! I know it`s not a good idea to change vanilla object when I can avoid this. My weapon is not a vanilla object. I have made a duplicate for my mod so it won`t affect any vanilla files. I have attached one enchantment to a custom weapon mod which works fine. I was hoping that I can attach another enchantment to the weapon, but it does not let me to attach enchantments that are not the "contact" delivery type. So I added the script directly to the weapon. I though that it`s more efficient to add the sctiipt to my weapon than to a quest so it does not have to check every equipped item, but only runs when this certain weapon is equipped/unequipped. But I`m not an experienced modder so I decided to ask more experienced people. I also don`t know if a script(enchatment) attached to a weapon mod recieves "OnEquip" event from the weapon. Then I could add both enchantments with the weapon mod. Can`t find any information about this.

 

 

Edit: It works with weapon mod and enchantment :) Just need to replace Event OnEquip with OnEffectStart. I guess it`s better this way. The the enchantment will be optional.

Edited by kitcat81
Link to comment
Share on other sites

  • Recently Browsing   0 members

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