Jump to content

Help with a script please


Recommended Posts

Hi friends I need help with a script that I can attach to a Toggle constant magic effect, that when the effect is toggled on it will equip armor that can't be removed and equips silently, then toggling off the magic effect also removes the armor. I'm trying to perfect a mist form spell, invisibility and set actor alpha aren't total invisibility so a helpful modder advised me to turn some armor transparent and use it for total invisibility. Thanks.

Edited by Dashyburn
Link to comment
Share on other sites

Hey, yep that's not too difficult:

 

Scriptname TM_ActiveMagicEffectScript extends ActiveMagicEffect 

Armor Property TheArmor Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    akTarget.EquipItem(TheArmor, abPreventRemoval = true, abSilent = true)
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    akTarget.UnequipItem(TheArmor, abPreventEquip = false, abSilent = true)
EndEvent

You can also use the SetAlpha function for complete invisibility.

 

Scriptname TM_ActiveMagicEffectScript extends ActiveMagicEffect 

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    akTarget.SetAlpha(0.0)
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    akTarget.SetAlpha(1.0)
EndEvent

Change the name of the script to something more unique

Link to comment
Share on other sites

Hey dylbill, what's up my friend?


If you don't already know, the 'Player' cannot be set to 'SetAlpha(0.0)', the player will always remain partially visible, the 'SetAlpha(0.0)' works only on all other actors.

Also you can't 'SetAlpha(0.0)' imidiately, you need to 'SetAlpha(0.1) > wait, and then > 'SetAlpha(0.0)', otherwise it won't work.


The easiest way to make the player absolute invisible is to equip an invisible armor, but this script also needs to obtain the real equipped armor > store it, and when the fx is finish, re-equip the stored armor.

* Otherwise every time he uses the spell he will end up butt naked.... :woot:


There is one more alternative that could be done:

Use the vanilla 'Invisible Actor', duplicate or custom made its race and actor's set up, and then instead of equiping an armor just change the player's race to that of the invisible actor.

Edited by maxarturo
Link to comment
Share on other sites

Hi dylbill and maxarturo, thank you for the script you are a scholar and gentleman, thank you in general for all the help you give on the forums, you are a genius. Max thank you for further assistance, I have found that actor alpha 0.0 doesn't provide total invisibility in some light/background settings, sometimes the PC is unseen but as you move around you can often see an opaque PC. If my understanding is correct having it at 0.1 then have it fade to 0.0 only affects the actual fade transition, that is the PC will slowly fade as opposed to instantly fade. I was provided with an armor piece from another helpful gentleman (sphered) that is set in every slot and has no skin which does work better than actor alpha, there is a tiny discrepancy but it may be due to a mod I use. I use vanilla body mesh and textures, racemenu with an NPC texture mod, with the invisible suit on there is still a tiny trace but it looks as though it's because there is something altering the PC. I will add this method to the mod and get some feedback how it's working for others. I appreciate the solid help, thank ya's.

 

dylbill, when the script fires it will remove all the PC's equipped items, if it isn't a large addition are you able to add something to make it re-equip when the magic effect it's attached to is deactivated? If it's too much code please ignore the request you've already gone above and beyond writing the script for me. Cheers gentlemen.

 

EDIT I will also give the actor alpha script a try, I have been using the script that's attached to the ghost effect, it's the same setting technically but this is Skyrim, you gents know alot more than what I do so you're well aware what I mean :)

Edited by Dashyburn
Link to comment
Share on other sites

Were you just using the script on a new magic effect? Or were you using the vanilla ghost magic effect? The ghost magic affect has an effect shader, which is probably what you're seeing. I just tested .SetAlpha(0.0) with no magic effect in a bunch of different lightings / times of day and couldn't see the player at all.

 

If you find that .SetAlpha(0.0) doesn't work though, here is how you would get current equipped armor, and re-equip it when the effect ends:

Armor Property TheArmor Auto 
Armor[] EquippedItems

Event OnEffectStart(Actor akTarget, Actor akCaster) 
    EquippedItems = New Armor[31] ;create new armor array list
    Int SlotIndex = 30
    Int ArrayIndex = 0 
    While ArrayIndex < 31 ;save all current equipped armor to array
        EquippedItems[ArrayIndex] = akTarget.GetEquippedArmorInSlot(SlotIndex)
        SlotIndex += 1 ;add 1
        ArrayIndex += 1 ;add 1
    EndWhile
    
    akTarget.EquipItem(TheArmor, abPreventRemoval = true, abSilent = true)
EndEvent 

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    akTarget.UnequipItem(TheArmor, abPreventEquip = false, abSilent = true)
    
    Int ArrayIndex = 0 
    While ArrayIndex < 31
        If EquippedItems[ArrayIndex] ;does current array form exist? 
            akTarget.EquipItem(EquippedItems[ArrayIndex])
        EndIf
        ArrayIndex += 1 ;add 1
    EndWhile
EndEvent
Link to comment
Share on other sites

I was using a new magic effect with the script from the ghost potion effect that you can set actor alpha with, I was originally using Invisibility until I discovered that script, I tried it out but invisibility seemed better so changed it back. But now that you mention it I just may have had the GhostFX shader (the clear no mist one) running simultaneously with set actor alpha, or it may have even been before I discovered you can set it to 0.0, either way you have enlightened me. I'm going to try it again, using your script, If the effect via your script is all that's needed you did not waste time writing the armor script, another mod I have planned needs it. You have been an incredible help and I am grateful for the time you gave to write the scripts, thank you dylbill :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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