Jump to content

First time creating a script/mod... need some help


carnageX333

Recommended Posts

So since summer break just started for me, I decided to get into Skyrim modding a bit. Quick background: made a "Lycanpire" character after I completed the Dawnguard's main quest and became a vampire lord. Still wanted vampire perks, but I also wanted my previous Werewolf perks... mainly wanted to remove Weakness to Fire and Weakness to Sunlight. Was able to make a batch file to remove the active effects easily enough. But, every time I transformed from Vampire Lord back to human, I would have to re-run my batch file to get rid of the previously mentioned 2 effects. So, being the programmer I am, I figured I could just make a script to execute automatically whenever I loaded the game and whenever I revert from Vampire Lord form back to human.

 

So I made a script, and compiled it, and tried to figure out how to attach it to my player whenever 2 events occur. Here's where it's getting hairy for me, since I'm new to Papyrus & the Creation Kit.

 

Here's my script (not sure if this is the proper way to do the script, but hey, I'm learning):

 

 

 
Scriptname RemoveVampireWeaknesses extends Alias
 
    Spell property WeaknessToFire auto 
    Spell property WeaknessToSun auto 
    Spell property RevertVLForm auto
 
    Event OnPlayerLoadGame() 
        Debug.Trace("loaded game...spells should be removed?")
 
        Game.GetPlayer().RemoveSpell(WeaknessToFire)
        Game.GetPlayer().RemoveSpell(WeaknessToSun)
    EndEvent
 
    Event OnSpellCast(Form akSpell)
        Spell spellCast = akSpell as Spell
        Debug.Trace("Entered spell cast event.")
        if spellCast && spellCast == RevertVLForm
            Debug.Trace("revert form was cast... spells should be removed?")
            Game.GetPlayer().RemoveSpell(WeaknessToFire)
            Game.GetPlayer().RemoveSpell(WeaknessToSun)
        endIf
    endEvent

 

And then in Creation Kit, I made a new "quest" (I've heard this is how I should attach things to my player that should be automatically run... please correct me if I'm wrong because this is just what I found during some extensive Googling). Here's the steps I went through in Creation Kit:

 

Loaded Dawnguard file.

Created a new object under Quests with the following properties:

  • Form ID: RemoveVampireWeaknesses
  • Quest Name: Remove Vampire Weaknesses
  • Event: None
  • Type: None
  • Start Game Enabled: Checked
  • Run Once: Unchecked

That's all I changed from the defaults. I then went to Quest Aliases, and added a new Alias property with the name "Remove Effects".

I kept all the defaults, except for I checked "Reuse in quest" option.

Under "Fill Type" I selected "Unique Actor" and chose "Player"

I then added my script through this Alias window, and attached the properties to what I thought were the correct spells.

  • RevertVLForm attached to DLC1RevertForm spell
  • WeaknessToFire attached to AbVampire04b spell
  • WeaknessToSun attached to VampireSunDamage04 spell

Saved the file, and enabled it in the Data Files section. Ran the game, and the active effects were still there on game load. So I tried transforming / reverting to human... still there. Not sure what I'm doing wrong.

 

Enabled Papyrus debugging logs, and originally I had my script header set to "Extends ObjectReference" but I was getting errors about not being the same base type, so I changed the script to "Extends Alias" to see if that worked. It got rid of the errors in Papyrus, but the script still doesn't seem to be actually working. I also don't see my Debug trace messages being outputted in the log file either, so I'm guessing the events aren't actually being hit... so I'm not sure if I'm even using the correct events or not.

 

I know using the player.removeSpell with the ID's for AbVampire04b and VampireSunDamage04 work fine through the console, so I'm assuming my events in my script just aren't being hit.

 

tl;dr: I'm a newb to Papyrus / modding, and not sure if what I'm doing is correct or not.

 

Thanks a bunch in advance, I really appreciate it.

Link to comment
Share on other sites

Great, thanks for the tip! That seems to have fixed the OnPlayerLoadGame event. Still having trouble with the OnSpellCast, however.

Could it be because I'm trying to remove the active effects too soon, and it could possibly be getting re-added when I become human again? Would there be a way around that (i.e. another way to invoke the remove spell sections, after the Revert spell is cast)? Or a way to wait until after the spell has been cast maybe?

Edit: tried using a counter in regards to the the spell cast time. Didn't work.

Edited by carnageX333
Link to comment
Share on other sites

Not sure what you mean by "trouble"?

 

Try something like this perhaps (not compiled or tested):

Scriptname RemoveVampireWeaknesses extends ReferenceAlias
 
Spell property WeaknessToFire auto 
Spell property WeaknessToSun auto 
Spell property RevertVLForm auto
 
Event OnPlayerLoadGame() 
	Debug.Trace("loaded game...spells should be removed?")
 
	if GetActorRef().HasSpell(WeaknessToFire)
		GetActorRef().RemoveSpell(WeaknessToFire)
	endIf

	if GetActorRef().HasSpell(WeaknessToSun)
		GetActorRef().RemoveSpell(WeaknessToSun)
	endIf
EndEvent
 
AUTO STATE WAITING
Event OnSpellCast(Form akSpell)
	Debug.Trace("Entered spell cast event.")
	Spell spellCast = akSpell as Spell

	if spellCast != none && spellCast == RevertVLForm
		Debug.Trace("revert form was cast... spells should be removed?")

		GoToState("DONE")	; prevent further calls while we're in the While loop

		while GetActorRef().HasSpell(WeaknessToFire) || GetActorRef().HasSpell(WeaknessToSun)
			if GetActorRef().HasSpell(WeaknessToFire)
				GetActorRef().RemoveSpell(WeaknessToFire)
			endIf
			if GetActorRef().HasSpell(WeaknessToSun)
				GetActorRef().RemoveSpell(WeaknessToSun)
			endIf

			utility.wait(0.02) ; latent function, gives other threads a chance to jump the queue
		endWhile
		Debug.Trace("Weakness to Fire and Weakness to Sun successfully removed!")
	endIf

	GoToState("WAITING")	; re-enable the OnSpellcast event
endEvent
ENDSTATE

STATE DONE
ENDSTATE
Edited by steve40
Link to comment
Share on other sites

Thanks for the help, steve, really appreciate it.

 

The trouble I mean I'm having is that its still not working for the OnSpellCast. I cast Vampire Lord to turn into the VL, and I get the weakness to fire and Weakness to Sun effects back (this is fine... IMO more "realistic" since I'm in a vampire form). However, the problem is, that when I cast Revert Form, and turn into a human, I still have the Weakness to Fire and Weakness to Sun effects.

 

I wonder if I'm even using the right spell to hook into in the Creation Kit... Is there a way to properly find out which spell it actually is?

 

Tested your revised script (I do like the edits you made to the LoadGame event to make sure the player actually has the spell before trying to remove it... wasn't sure how to check for that), and it's still doing the same thing that I described above.

Edited by carnageX333
Link to comment
Share on other sites

Are the spells removed and the effect is still active or does it actually do nothing?

 

Another idea, you could try DispelSpell function to stop the effects, then remove the spells. DLC1RevertForm seems to be the right spell to check for.

ScriptName RemoveVampireWeakness extends ReferenceAlias

Spell property WeaknessToFire auto
Spell property WeaknessToSun auto
Spell property RevertVLForm auto
Actor property Player auto

Event OnPlayerLoadGame()
    Debug.Trace("loaded game...spells should be removed?")
    if Player.HasSpell(WeaknessToFire)
        Player.RemoveSpell(WeaknessToFire)
    endif
    if Player.HasSpell(WeaknessToSun)
        Player.RemoveSpell(WeaknessToSun)
    endif
EndEvent
 
Event OnSpellCast(Form akSpell)
    Spell spellCast = akSpell as Spell
    Debug.Trace("Entered spell cast event.")
    if spellCast && spellCast == RevertVLForm
        Debug.Trace("revert form was cast... spells should be removed?")
        if Player.HasSpell(WeaknessToFire)
            Player.DispelSpell(WeaknessToFire)
            Player.RemoveSpell(WeaknessToFire)
        endif
        if Player.HasSpell(WeaknessToSun)
            Player.DispelSpell(WeaknessToSun)
            Player.RemoveSpell(WeaknessToSun)
        endif
    endif
endEvent
Link to comment
Share on other sites

Carnage,

 

I made a mod once that did what you are asking. Although your method will work, why not change the Vampire Lord and Werewolf quests themselves? You may continue with your code that reverses the process, sure, but here was my approach:

 

In the Creation Kit, go to Quests/PlayerWerewolfQuest/Scripts/PlayerWerewolfChangeScript and edit the source to get a better understanding of the werewolf transformation process (any editing of werewolf abilities may involve editing this source script and saving it). This isn't required for your goal, but it is interesting.

 

As you may have noticed, the PlayerWerewolfChangeScript calls a script from C00. Go to Quests/C00/Scripts/companionshousekeepingscript and find the function named "PlayerJoin(...)". In this function comment out (place a ; before) all the lines that have the effect of storing your race from vampire type race to normal type race. This will make it so that if you are a vampire when you join the companions, you will be a vampire (as far as races go) after you use beast form. You may want to go back to the "PlayerWerewolfChangeScript" from before and edit the line that calls this stored value, to instead change to the race you initially had when you called beast form... you would, of course, have to store the race at some earlier point in the script (perhaps right before your race is changed to the werewolfrace).

 

In Skyrim/Data/Scripts/Source/Dawnguard (*EDIT* forgot that it was in the dawnguard folder) open the file DLC1PlayerVampireChangeScript.psc (I could not find a way to access this script from the creation kit, so go ahead and access it directly). Find the function named "ActuallyShiftBackIfNecessary(...)" and the block of code that handles adding vampire perks and abilities when the Vampire Lord power is being reversed. Edit this code to your liking so that vampire powers you don't want to have aren't added. I recommend adding "GlobalVariable property PlayerIsWerewolf auto" to the top of the code, linking this globalvariable in the CreationKit/Quests/DLC1PlayerVampreQuest/Scripts to the globalvariable object "PlayerIsWerewolf", and using an if statement here to say that if you are a werewolf (as well as a Vampire Lord, obviously) you add/remove certain spells/perks and if you are not, you do the original effect (your preference). Make sure when you're done editing the .psc you go into the CreationKit/Gameplay Menu/Compile Papyrus Scripts... Option, scroll down to this .psc script, and compile it.

 

If you have done as I mentioned before, you will have beast form set to not cure you of being in the vampire race, and vampire lord set to give you no defects if you are also a werewolf. The final step (which I never got around to doing) is to locate the regular, non-vampire lord, vampire tracking script and modify the effects it has on the player (perhaps to include different effects based on your werewolf status, as before?). Also, it would be beneficial to locate the quest that MAKES you a vampire lord and make sure it doesn't remove Lycanthropy. Without these last two steps, you must become a vampire lord BEFORE joining the companions (so that your initial race is stored as vampire race, when you do, because you will not be able to contract vampirism after you become a werewolf). Once you have both, the Vampire Lord ability should permanently remove vampire weaknesses.

 

Hope that helps!

Edited by mathern
Link to comment
Share on other sites

Update: In CreationKit/Quests/DLC1VampireTurn/Scripts/dlc1vampireturnscript there is a line that will cure the player of lycanthopy if the player has it. I would recommend commenting that out. Also, it directly follows a line that changes a normal player into a vampire race if they are not a vampire. You may have to go to Skyrim/Data/Scripts/Source/Dawnguard/ to find the "DlC1VampireTurnScript.psc" source code. The function within the code that contains my mentioned lines is the "RecieveHarkonsGift(...)" function.

 

Update2: The last script I can see that will possibly need editng is the CreationKit/Quests/PlayerVampireQuest/Scripts/PlayerVampireQuestScript source code. This code manages the Vampire disease affliction.. Modify this script so that days without feeding do not add distasteful vampire perks/spells if you are a werewolf (again, i recommend linking this script to the PlayerIsWerewolf Global Variable Creation Kit Object to check if the player is a werewolf before applying any changes).

Link to comment
Share on other sites

@carnageX333: what trace messages do you get from my revised script? Is the OnSpellCast event firing?

It might simply be that RevertVLForm is the wrong spell to check for.

Link to comment
Share on other sites

 

Are the spells removed and the effect is still active or does it actually do nothing?

 

Another idea, you could try DispelSpell function to stop the effects, then remove the spells. DLC1RevertForm seems to be the right spell to check for.

 

ScriptName RemoveVampireWeakness extends ReferenceAlias

Spell property WeaknessToFire auto
Spell property WeaknessToSun auto
Spell property RevertVLForm auto
Actor property Player auto

Event OnPlayerLoadGame()
    Debug.Trace("loaded game...spells should be removed?")
    if Player.HasSpell(WeaknessToFire)
        Player.RemoveSpell(WeaknessToFire)
    endif
    if Player.HasSpell(WeaknessToSun)
        Player.RemoveSpell(WeaknessToSun)
    endif
EndEvent
 
Event OnSpellCast(Form akSpell)
    Spell spellCast = akSpell as Spell
    Debug.Trace("Entered spell cast event.")
    if spellCast && spellCast == RevertVLForm
        Debug.Trace("revert form was cast... spells should be removed?")
        if Player.HasSpell(WeaknessToFire)
            Player.DispelSpell(WeaknessToFire)
            Player.RemoveSpell(WeaknessToFire)
        endif
        if Player.HasSpell(WeaknessToSun)
            Player.DispelSpell(WeaknessToSun)
            Player.RemoveSpell(WeaknessToSun)
        endif
    endif
endEvent

The active effects remain listed in the 'Active Effect' screen, so it seems like it does nothing.

 

Carnage,

 

I made a mod once that did what you are asking. Although your method will work, why not change the Vampire Lord and Werewolf quests themselves? You may continue with your code that reverses the process, sure, but here was my approach:

 

In the Creation Kit, go to Quests/PlayerWerewolfQuest/Scripts/PlayerWerewolfChangeScript and edit the source to get a better understanding of the werewolf transformation process (any editing of werewolf abilities may involve editing this source script and saving it). This isn't required for your goal, but it is interesting.

 

As you may have noticed, the PlayerWerewolfChangeScript calls a script from C00. Go to Quests/C00/Scripts/companionshousekeepingscript and find the function named "PlayerJoin(...)". In this function comment out (place a ; before) all the lines that have the effect of storing your race from vampire type race to normal type race. This will make it so that if you are a vampire when you join the companions, you will be a vampire (as far as races go) after you use beast form. You may want to go back to the "PlayerWerewolfChangeScript" from before and edit the line that calls this stored value, to instead change to the race you initially had when you called beast form... you would, of course, have to store the race at some earlier point in the script (perhaps right before your race is changed to the werewolfrace).

 

In Skyrim/Data/Scripts/Source/Dawnguard (*EDIT* forgot that it was in the dawnguard folder) open the file DLC1PlayerVampireChangeScript.psc (I could not find a way to access this script from the creation kit, so go ahead and access it directly). Find the function named "ActuallyShiftBackIfNecessary(...)" and the block of code that handles adding vampire perks and abilities when the Vampire Lord power is being reversed. Edit this code to your liking so that vampire powers you don't want to have aren't added. I recommend adding "GlobalVariable property PlayerIsWerewolf auto" to the top of the code, linking this globalvariable in the CreationKit/Quests/DLC1PlayerVampreQuest/Scripts to the globalvariable object "PlayerIsWerewolf", and using an if statement here to say that if you are a werewolf (as well as a Vampire Lord, obviously) you add/remove certain spells/perks and if you are not, you do the original effect (your preference). Make sure when you're done editing the .psc you go into the CreationKit/Gameplay Menu/Compile Papyrus Scripts... Option, scroll down to this .psc script, and compile it.

 

If you have done as I mentioned before, you will have beast form set to not cure you of being in the vampire race, and vampire lord set to give you no defects if you are also a werewolf. The final step (which I never got around to doing) is to locate the regular, non-vampire lord, vampire tracking script and modify the effects it has on the player (perhaps to include different effects based on your werewolf status, as before?). Also, it would be beneficial to locate the quest that MAKES you a vampire lord and make sure it doesn't remove Lycanthropy. Without these last two steps, you must become a vampire lord BEFORE joining the companions (so that your initial race is stored as vampire race, when you do, because you will not be able to contract vampirism after you become a werewolf). Once you have both, the Vampire Lord ability should permanently remove vampire weaknesses.

 

Hope that helps!

I'll have to look into these. I was just trying to a simple mod, but it seems like it's becoming not as simple as I thought lol.

Thing is, I already gave myself the abilities and such for Werewolf, so I have those abilities/effects and such. The perks work when I transform into Beast Form as well. So everything works for both Vamp / Werewolf (except possible quest lines and such). I'm fine with being considered a vampire for now, so not a big deal there. I just wanted to try to get rid of the Fire/Sun weakness effects.

 

@carnageX333: what trace messages do you get from my revised script? Is the OnSpellCast event firing?

It might simply be that RevertVLForm is the wrong spell to check for.

I'm not getting any traces from the OnSpellCast (not even the "Entered spell cast event." trace).

Edited by carnageX333
Link to comment
Share on other sites

  • Recently Browsing   0 members

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