Jump to content

Need help with a new script for the Vampire Lord


Durai

Recommended Posts

So with the release of Dawnguard, we got a few new jewelry items that affect the Vampire Lord. However, Bethesda made it so we couldn't duplicate what they did with the creation kit. If you make an item similar to the Ring of the Beast/Erudite, your Vampire lord won't gain any effects. They simply become unequipped (much like the werewolf). I'm not much a fan of being short changed, so I'm working on some scripts that work when the items are unequipped and you are in your Vampire Lord form. Here's what I have so far:

 

Scriptname VampireAmulet001 extends ObjectReference

 

Race Property VampireBeastRace Auto

 

Event OnUnequipped(Actor akActor)

if akActor == Game.GetPlayer()

If Game.GetPlayer().GetRace()==VampireBeastRace

Game.GetPlayer().ModAV("Health", 100)

endif

endIf

endEvent

 

Now I'm in a bit of a predicament: I need to make it so that when you equip the item, the players base health is restored. If I do and OnEquipped event with the Player losing 100 Health, it'll subtract the health each time the item is equipped, even if the player never turned into a Vampire Lord. So is there a script that can simply reset the Health value when equipped? Any help is greatly appreciated!

 

P.S.

 

Is there a way I can make it so that while the item is in the inventory, the Vampire Lord does extra damage and gains health? This one has me stumped too.

Link to comment
Share on other sites

Okay so I did a bit more digging and found a script that could help me out:

 

BaseHealth = Game.GetPlayer().GetActorValue("Health")

 

My question is where do I put this line of code? Do I write it outside of the function, or is it part of the function?

 

Brownie points if you can help me out even a little!

Link to comment
Share on other sites

Okay so I'm making some progress but I'm still not close to getting what I want to work:

 

Scriptname VampireAmulet001 extends ObjectReference  

Race Property VampireBeastRace Auto

int BaseHealth 

Function BaseHealth (Actor TargetActor)
BaseHealth = TargetActor.GetAV("Health") as int
TargetActor = Game.Getplayer()
EndFunction

Event OnEquipped(Actor akActor)
		if akActor == Game.Getplayer()
			Game.GetPlayer().SetAV("Health", BaseHealth)
		endif
endEvent

Event OnUnequipped(Actor akActor)
		if akActor == Game.GetPlayer()
			If Game.GetPlayer().GetRace()==VampireBeastRace
				Game.GetPlayer().ModAV("Health", 100)
			endif
		endIf
endEvent

 

For now, when equipping the item, it makes the players health 0; I need to to store the players current health and reset it each time the item is equipped. Any help guys?

Link to comment
Share on other sites

I have made a few changes to your code, firstly, I have changed the function a bit so that it will get the base actor value for health, I removed the

TargetActor = Game.Getplayer()

As i felt that it was simply pointless as the actor which it uses it sent when you call the function, which I have added into the OnEquipped event. Originally you were not calling the function, which meant that while the code for it was there, it was not being used by the script. I changed BaseHealth to a float, just a common habit on my part really for that though.

This should now work, as it is similar to code I use in my Vampire Mod which finds the base health of the feed victim so that the feed hurts them by a percentage of their base health.

 

Hope this now works :D

 

Scriptname VampireAmulet001 extends ObjectReference  

Race Property VampireBeastRace Auto

float BaseHealth 

Function BaseHealth (Actor TargetActor)
BaseHealth = TargetActor.GetBaseActorValue("Health") as Float
EndFunction

Event OnEquipped(Actor akActor)
BaseHealth(akActor)
if akActor == Game.Getplayer()
	Game.GetPlayer().SetAV("Health", BaseHealth)
endif
endEvent

Event OnUnequipped(Actor akActor)
If akActor == Game.GetPlayer()
	If Game.GetPlayer().GetRace()==VampireBeastRace
		Game.GetPlayer().ModAV("Health", 100)
	EndIf
EndIf
EndEvent

Link to comment
Share on other sites

Thanks for your help SoulLimit, but it still does what I was afraid of: constantly adding 100 health each time it is unequipped. I know why it does it too; when being re-equipped to the player, it redoes the whole process over again. Namely, it checks the players current health. So if I am 550 when equipping the ring, then gain 100 hp from transforming, when I revert back to normal I am still at 650, and the ring set my health to what it currently is. Is there a way to set the health without including the modded actor value?
Link to comment
Share on other sites

Scriptname VampireAmulet001 extends ObjectReference  

Race Property VampireBeastRace Auto
GlobalVariable Property WasVampireLord Auto

float BaseHealth 

Function BaseHealth (Actor TargetActor)
       BaseHealth = TargetActor.GetBaseActorValue("Health") as Float
EndFunction

Event OnEquipped(Actor akActor)
       BaseHealth(akActor)
       if akActor == Game.Getplayer()
               If WasVampireLord.Value == 1
                       Game.GetPlayer().SetAV("Health", BaseHealth - 100)
                       WasVampireLord.SetValue(0)
               Else
                       Game.GetPlayer().SetAV("Health", BaseHealth)
               EndIf
       endif
endEvent

Event OnUnequipped(Actor akActor)
       If akActor == Game.GetPlayer()
               If Game.GetPlayer().GetRace()==VampireBeastRace
                       WasVampireLord.SetValue(1)
                       Game.GetPlayer().ModAV("Health", 100)
               EndIf
       EndIf
EndEvent

 

Okay, to deal with this problem, the best way I could think of is to create a global variable (WasVampireLord in this) which tracks if the player was a vampire lord. If they are a vampire lord, it will turn to 1, so that when they revert form and re-equip the amulet, they will go back down to their original health and the tracking variable will be reset to 0.

Link to comment
Share on other sites

Great! Thanks!

 

That actually got the health mod to function just like I wanted!

 

However I came across a snag when trying to expand on the formula:

 

 

 

Scriptname VampireAmulet001 extends ObjectReference  

Race Property VampireBeastRace Auto
GlobalVariable Property WasVampireLord Auto

float BaseHealth 
float BaseDResist

Function BaseHealth (Actor TargetActor)
       BaseHealth = TargetActor.GetBaseActorValue("Health") as Float
EndFunction

Function BaseDResist (Actor TargetActor)
 BaseDResist = TargetActor.GetBaseActorValue("DamageResist") as Float
EndFunction

Event OnEquipped(Actor akActor)
       BaseHealth(akActor)
 BaseDResist(akActor)
       if akActor == Game.Getplayer()
               If WasVampireLord.Value == 1
		    Game.GetPlayer().SetAV("DamageResist", BaseDResist - 100)
                       Game.GetPlayer().SetAV("Health", BaseHealth - 100)
                       WasVampireLord.SetValue(0)
               Else
                       Game.GetPlayer().SetAV("Health", BaseHealth)
		    Game.GetPlayer().SetAV("DamageResist", BaseDResist)
               EndIf
       endif
endEvent

Event OnUnequipped(Actor akActor)
       If akActor == Game.GetPlayer()
               If Game.GetPlayer().GetRace()==VampireBeastRace
                       WasVampireLord.SetValue(1)
                       Game.GetPlayer().ModAV("Health", 100)
		    Game.GetPlayer().ModAV("DamageResist", 100)
               EndIf
       EndIf
EndEvent

 

 

 

I'm trying to get the amulet to do a couple mods when being un/equipped from the V-Lord transformation. The health function works flawlessly, however when I try and use the same formula to increase/decrease the players armor resistance, the increase occurs, but not the decrease. Am I doing something wrong or can the script not handle multiple mods to actor values? Thanks again for your help, I truly appreciate it!

Link to comment
Share on other sites

EDIT - actually, what I put would not work, I cannot see anything that you are doing wrong really... One thing I would say is put some traces in there to help you out

 

 

 


Scriptname VampireAmulet001 extends ObjectReference  

Import Debug

Race Property VampireBeastRace Auto
GlobalVariable Property WasVampireLord Auto

float BaseHealth 
float BaseDResist

Function BaseHealth (Actor TargetActor)
       BaseHealth = TargetActor.GetBaseActorValue("Health") as Float
EndFunction

Function BaseDResist (Actor TargetActor)
        BaseDResist = TargetActor.GetBaseActorValue("DamageResist") as Float
EndFunction

Event OnEquipped(Actor akActor)
       BaseHealth(akActor)
       trace("The Base Health of the actor is :" + BaseHealth)
       BaseDResist(akActor)
       Trace("The Base Damage Resistance Of the Actor is :" + BaseDResist)
       if akActor == Game.Getplayer()
               If WasVampireLord.Value == 1
                       Game.GetPlayer().SetAV("DamageResist", BaseDResist - 100)
                       Game.GetPlayer().SetAV("Health", BaseHealth - 100)
                       WasVampireLord.SetValue(0)

               Else
                       Game.GetPlayer().SetAV("Health", BaseHealth)
                       Game.GetPlayer().SetAV("DamageResist", BaseDResist)
               EndIf
           Trace("New Damage Resistance is " + Game.GetPlayer().GetActorValue("DamageResist") + " and the new Health is " +  Game.GetPlayer().GetActorValue("Health"))
       endif
endEvent

Event OnUnequipped(Actor akActor)
       If akActor == Game.GetPlayer()
               If Game.GetPlayer().GetRace()==VampireBeastRace
                       WasVampireLord.SetValue(1)
                       Game.GetPlayer().ModAV("Health", 100)
                       Game.GetPlayer().ModAV("DamageResist", 100)
                       Trace("New Health & Damage Resistance are : " + Game.GetPlayer().GetActorValue("Health") + " & " + Game.GetPlayer().GetActorValue("DamageResist"))
               EndIf
       EndIf
EndEvent

 

 

 

Then activate the tracing in your Skyrim.ini

[Papyrus]

fPostLoadUpdateTimeMS=500.0

bEnableLogging=1

bEnableTrace=1

bLoadDebugInformation=1

 

You can use whatever tracing you feel like btw, the added tracing is just a recommendation.

 

Then look through your logs and find the correct lines, and it will give you an idea of the changing values

Edited by SoulLimit
Link to comment
Share on other sites

Aaaaaaand now I feel dense.... The answer was so obvious that I didn't realize it until I stopped thinking about it.

 

 

 

Scriptname VampireAmulet001 extends ObjectReference  

Race Property VampireBeastRace Auto
GlobalVariable Property WasVampireLord Auto

float BaseHealth 
float BaseDResist
float BaseUnarmed

Function BaseHealth (Actor TargetActor)
       BaseHealth = TargetActor.GetBaseActorValue("Health") as Float
EndFunction

Function BaseDResist (Actor TargetActor)
        BaseDResist = TargetActor.GetBaseActorValue("DamageResist") as Float
EndFunction

Function BaseUnarmed (Actor TargetActor)
  BaseUnarmed = TargetActor.GetBaseActorValue("UnarmedDamage") as Float
EndFunction

Event OnEquipped(Actor akActor)
       BaseHealth(akActor)
       BaseDResist(akActor)
 BaseUnarmed(akActor)
       if akActor == Game.Getplayer()
               If WasVampireLord.Value == 1
                       Game.GetPlayer().ModAV("DamageResist", -100)
                       Game.GetPlayer().ModAV("Health", BaseHealth - 100)
		    Game.GetPlayer().ModAV("UnarmedDamage", - 25)
                       WasVampireLord.SetValue(0)
               Else
                       Game.GetPlayer().SetAV("Health", BaseHealth)
                       Game.GetPlayer().SetAV("DamageResist", BaseDResist)
		    Game.GetPlayer().SetAv("UnarmedDamage", BaseUnarmed)
               EndIf
       endif
endEvent

Event OnUnequipped(Actor akActor)
       If akActor == Game.GetPlayer()
               If Game.GetPlayer().GetRace()==VampireBeastRace
                       WasVampireLord.SetValue(1)
                       Game.GetPlayer().ModAV("Health", 100)
                       Game.GetPlayer().ModAV("DamageResist", 100)
		    Game.GetPlayer().ModAV("UnarmedDamage", 25)
               EndIf
       EndIf
EndEvent

 

 

 

As the old saying goes: "What goes up, must come down."

 

Since we used ModAV to increase the values, we had to use them again to decrease the values. But I didn't discover the answer until I used your ModAV("XX", BaseXX - 100) syntax and found that the values were near doubling. I thought to myself "But I just wanted the base minus 100! Why is this happening?!"

 

Then it struck me: I was telling the script I wanted to INCREASE the VALUE by the Base - 100, instead of simply just decreasing the BASE by 100! Now the script works perfectly!

 

Thanks again SoulLimit, your help has been invaluable to my script!

 

P.S. Do you happen to know a script that forces an item to equip after a transformation? I.E. the Werewolf? I want to use this for the Werewolf as well but this particular script works because the items are forced to equip once the player reverts. If I tried it for the werewolf, the increases would occur due to the transformation, but by not re-equipping the items the player can avoid the decreases...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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