It just sounds so simple when you write it out like this.
Enable Papyrus Logging - add to SkyrimEditor.ini Papyrus section
Enable the use of the Dawnguard master file by the Creation Kit - add to the SkyrimEditor.ini General section
Also add all the masters you want to be using ordered by release date in the Archive section. This line should already exist, we are simply elaborating on what is already there. You may need to add the DLC bsa files to the sArchiveList as well - I did.
Add the player to a custom faction on equip - remove from faction on unequip.
Remove the vampiric weakness to sunlight if it exists - reapply on unequip.
I don't know about that faction one, but I definitely think the sunlight one is doable. Partially because the nexus has a mod that does that exact thing if you are wearing any kind of head gear.
For normal vampires it turned out to be very simple - no scripts necessary. Simply find the Sun Weakness spells in the CK and add a condition to them in the same place where it checks to see if you're indoors, or if it's daylight or any of a number of things to see if you will be weakened by the sun.
The condition to add is WornHasKeyword <your item(s) keyword here> == 0
This way if you aren't wearing the item (and the check = 0 because it's not on) then the sun will continue its relentless assault. But if it =/= 0 like when you ARE wearing it, sun weakness will not take effect.
This condition must be added to all of the effects on VampireSunDamage01-04 spells.
For Dawnguard Vampire Lords this begins to be more complex. The transformation sequence into Vampire Lord removes all of your armor and uses multiple scripts all of which are complex and not entirely perfect (go Bethesda). This will use the same concept as the condition check we did for regular vampiric Sun Weakness only instead of a WornHasKeyword check it will be GetGlobalValue <your global(s) here> == 0.
This condition must be added to all of the effects on the DLC1VampireLordSunDamage spell.
There are three items that continue to give their bonuses to the Vampire Lord while transformed and it does this using a global set by the transformation script. If you were wearing it when you transformed the global will be set to 1 - if you weren't it will not change from its default 0.
There are several scripts involving the Vampire Lord transformation. The least risky and simplest way we could find was editing two of the smaller ones. We duplicated the DLC1VampireChangeEffectScript and the DLC1RevertEffectScript. We edited a little, added our code... and they wouldn't compile. The reason for this is that this game was made by Bethesda.
The problem was a really tiny script named VampireQuestScript. It is missing properties for the LastPower and LastLeftHandSpell. But if you edit the VampireQuestScript in the CK - it will compile and quite possibly permanently break the vampirism scripts in your installation. So you have to find the script outside the CK - edit it (recommend using Notepad++), and add the missing properties before you can even start going anywhere with ANY Dawnguard vampirism script changes. To access scripts from the Creation Kit you must first move them out of their respective subfolders and into the main Source folder. Then from within the CK you go to Gameplay>Papyrus Script Manager> and just search for any script you like from there.
So we start by declaring the following properties in VampireQuestScript OUTSIDE the Creation Kit. Add them at the end of the script to be safe.
Then we need to create a global to use - Vampire Lords don't actually wear any of their items, they use globals to keep track of what abilities and bonuses they should be getting from those items.
Now we need to declare the relevant properties in the two scripts which should be renamed copies, never the original scripts.
BoethiahsVampireChangeEffectScript needs both the Armor Property (which should be the unique keyword we used in the vanilla vampire solution) and the GlobalVariable Property with a p in front if it (which is the global we just made - don't ask me what the p means, it just works). Declare these properties at the top with the other properties, any order.
BoethiahsRevertEffectScript only needs the GlobalVariable Property.
There is only one event in each of these scripts. For the Change script we will add the following code before the final endif.
For the Revert script we will again add the following code - this one's a bit easier because you can see where the Globals are reset from the other items the Vampire Lord can wear, just tack yours on the end of it.
Don't forget to compile - this catches most typos and other minor errors and means your script will show up when you want to add it to anything..
Now we will look at the original Revert and Change scripts to see where we need to put our reworked scripts. Right click>Use Info in the Papyrus Script Manager.
The Change script is being used by DLC1VampireChangeEffect, a magic effect. Open it up and Add our new script to it. Select our script's properties and Auto-Fill them - if any don't fill be sure to compare it with the still present unmodified script and when you are satisfied Remove the old script. Don't forget to hit OK before closing the window.
The Revert script is being used by DLC1RevertEffect, another magic effect. Again, Add our new script, Auto-Fill properties, Remove the old script, and hit OK.
Save your mod and you now have working vampirism protection with full Dawnguard compatibility!
Edited by Vain, 13 January 2014 - 05:17 AM.