Jump to content

Quick Script Help... Sword/Spell Combos


zazz825

Recommended Posts

Hello, just a quick request for some Oblivion script help. Basically, I've created a new sword, and I have it so that when the player equips it, he gets a lesser power added to his spellbook, and when the sword is unequipped, the lesser power is removed. However, my issue is that this only happens when the *player* equips the sword, and I want the spell to be available for NPCs to use as well. This is what I've got so far...

 

 

 

scn AAFangBladeScript
begin OnEquip player
player.addspell 0FangAbilitiesA
player.addspell 0FangAbilitiesB
player.addspell 0FangAbilitiesC
end
begin OnUnequip player
player.removespell 0FangAbilitiesA
player.removespell 0FangAbilitiesB
player.removespell 0FangAbilitiesC
end
Obviously, the issue is that the script is specifically targetted at the player, since it's "player.script" But how am I supposed to make it so that the script activates on a variable target? (Hopefully that makes sense)
Any help is greatly appreciated, thanks in advance!
Edited by zazz825
Link to comment
Share on other sites

Would something like GetContainer work? I cannot test at the moment, but it sounds like it might work. But then again, it might not. I added the effect lines for visual feedback, I might have misspelled the effect visual names, but something like that might help you add visual feedback to see if the reference is the intended one.

scriptname YourPrefixFangBladeScript
 
ref ContainerRef
 
begin OnEquip
    set ContainerRef to GetContainer
    if ( ContainerRef == 0 )
        return
    elseif ( ContainerRef.IsActor == 0 || ContainerRef.GetIsCreature )
        set ContainerRef to 0
    else
        ContainerRef.PlayMagicShaderVisuals effectEnchantIllusion 3.0
        ContainerRef.AddSpell YourPrefixFangAbilityA
        ContainerRef.AddSpell YourPrefixFangAbilityB
        ContainerRef.AddSpell YourPrefixFangAbilityC
    endif
end
 
begin OnUnequip
    if ( ContainerRef )
        ContainerRef.PlayMagicShaderVisuals effectEnchantIllusion 3.0
        ContainerRef.RemoveSpell YourPrefixFangAbilityA
        ContainerRef.RemoveSpell YourPrefixFangAbilityB
        ContainerRef.RemoveSpell YourPrefixFangAbilityC
    endif
end

Hopefully that helps a little. There is a list of functions available on the Construction Set wiki if you have not yet found it.

Edited by Contrathetix
Link to comment
Share on other sites

Would something like GetContainer work? I cannot test at the moment, but it sounds like it might work. But then again, it might not. I added the effect lines for visual feedback, I might have misspelled the effect visual names, but something like that might help you add visual feedback to see if the reference is the intended one.

scriptname YourPrefixFangBladeScript
 
ref ContainerRef
 
begin OnEquip
    set ContainerRef to GetContainer
    if ( ContainerRef == 0 )
        return
    elseif ( ContainerRef.IsActor == 0 || ContainerRef.GetIsCreature )
        set ContainerRef to 0
    else
        ContainerRef.PlayMagicShaderVisuals effectEnchantIllusion 3.0
        ContainerRef.AddSpell YourPrefixFangAbilityA
        ContainerRef.AddSpell YourPrefixFangAbilityB
        ContainerRef.AddSpell YourPrefixFangAbilityC
    endif
end
 
begin OnUnequip
    if ( ContainerRef )
        ContainerRef.PlayMagicShaderVisuals effectEnchantIllusion 3.0
        ContainerRef.RemoveSpell YourPrefixFangAbilityA
        ContainerRef.RemoveSpell YourPrefixFangAbilityB
        ContainerRef.RemoveSpell YourPrefixFangAbilityC
    endif
end

Hopefully that helps a little. There is a list of functions available on the Construction Set wiki if you have not yet found it.

 

 

Yes, GetContainer will work inside OnEquip/OnUnequip blocks exactly that way. :thumbsup:

Worked like a charm, thanks for the help. Great idea, adding the shader to confirm it, thanks! :laugh:

Link to comment
Share on other sites

No problem, happy to help. Also thank you to Drake for confirming that the function actually works, I have non-gaming things to do and booting up my desktop with all gaming stuff on it would be detrimental to my productivity. Self control fails when all the games are just a few clicks away. :blush:

 

Also, as an idea, you could maybe try not starting any editor IDs with a number, just to make sure the game does not get confused by it. And if you want to prefix your forms with something other than "AAA", for example "XYZ", and still have all of them sorted at the top of the lists, in an easy-to-find manner, you could give the Construction Set Extender by shademe a try. It will sort all your active plugin's forms, as well as forms from other plguins that you have modified, at the top of the lists, and colour them green. It is a great alternative to prefixing everything with "00aaa" or such. For example I myself use an acronym or abbreviation of the mod's name as the prefix. Just an idea, nothing too serious, and you are free to use whatever prefix you want. This is a hobby, and therefore nothing too serious. :tongue:

 

Happy modding. :thumbsup:

Edited by Contrathetix
Link to comment
Share on other sites

  • Recently Browsing   0 members

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