Scriptname VampireDrainAddition Extends ActiveMagicEffect  
  
  
GlobalVariable Property VampireDrainExperienceGained Auto
GlobalVariable Property EnableVampireBloodPoints Auto
GlobalVariable Property VampireDrainBloodPointsGained Auto
GlobalVariable Property VampireBloodPoints Auto
GlobalVariable Property VampireDynamicStages Auto
GlobalVariable Property VampireStageGlobal Auto
GlobalVariable Property AdjustingVampireSatiation Auto

Race Property DLC1VampireBeastRace Auto

Keyword Property ActorTypeDwarven Auto

PlayerVampireQuestScript Property PlayerVampireQuest  Auto


Event OnEffectStart(Actor Target, Actor Caster)

	If Caster == Game.GetPlayer()
	
		RegisterForUpdate(1.0)
		
	EndIf	
		
EndEvent



Event OnUpdate() 

	If Game.GetPlayer().GetCombatTarget().HasKeyword(ActorTypeDwarven)
	
	Else
	
		Float ExperienceGained = (VampireDrainExperienceGained.GetValue() + (VampireDrainExperienceGained.GetValue()*(Game.GetPlayer().GetActorValue("Destruction")/100)))
		Game.AdvanceSkill("Destruction",ExperienceGained)
		
		If EnableVampireBloodPoints.GetValue() <= 10000 && VampireDrainBloodPointsGained.GetValue() == 10000
		
			Float AddingBP = (VampireBloodPoints.GetValue() +2)
		
			;Debug.Notification("Dual Casting = " + Game.GetPlayer().GetAnimationVariableBool("IsCastingDual"))
			
			If (Game.GetPlayer().GetEquippedSpell(0) == Game.GetPlayer().GetEquippedSpell(1)) ;&& Game.GetPlayer().GetAnimationVariableBool("IsCastingDual")
				AddingBP = (VampireBloodPoints.GetValue() +4)
			EndIf
		
			If Game.GetPlayer().GetRace() == DLC1VampireBeastRace
				AddingBP = (VampireBloodPoints.GetValue() +3)
			EndIf

			If VampireDynamicStages.GetValue() == 20000 && VampireBloodPoints.GetValue() < 100
				VampireBloodPoints.SetValue(AddingBP)
				If VampireBloodPoints.GetValue() >= 99
					VampireBloodPoints.SetValue(100)
				EndIf	
			EndIf
			
			If VampireDynamicStages.GetValue() <= 10000 && VampireBloodPoints.GetValue() < 300
				VampireBloodPoints.SetValue(AddingBP)
				If VampireBloodPoints.GetValue() >= 299
					VampireBloodPoints.SetValue(300)
				EndIf				
			EndIf
			
		EndIf	
		
	EndIf	
		
EndEvent



Event OnEffectFinish(Actor Target, Actor Caster)

		UnregisterForUpdate()
		
		If Caster == Game.GetPlayer()
		
			If AdjustingVampireSatiation.GetValue() == 0
			
				While Game.GetPlayer().IsInCombat()
					AdjustingVampireSatiation.SetValue(1)
				EndWhile
		  
				Utility.Wait(3.0)		  
		  
				If EnableVampireBloodPoints.GetValue() <= 10000 && VampireDrainBloodPointsGained.GetValue() == 10000  
		  
					If VampireDynamicStages.GetValue() == 20000 && VampireStageGlobal.GetValue() >= 4 && VampireBloodPoints.GetValue() > 0 && EnableVampireBloodPoints.GetValue() == 10000
					
						PlayerVampireQuest.SetVampireSatiation()
						
					ElseIf VampireDynamicStages.GetValue() == 20000 && VampireStageGlobal.GetValue() >= 4 && VampireBloodPoints.GetValue() > 20 && EnableVampireBloodPoints.GetValue() == 0
					
						PlayerVampireQuest.SetVampireSatiation()	
						
					;--------------------------------------------	
						
					ElseIf VampireDynamicStages.GetValue() == 10000 && VampireStageGlobal.GetValue() >= 4 && VampireBloodPoints.GetValue() >= 0 && VampireBloodPoints.GetValue() < 100
		  
						PlayerVampireQuest.SetVampireSatiation()
		  
					ElseIf VampireDynamicStages.GetValue() == 10000 && VampireStageGlobal.GetValue() >= 3 && VampireBloodPoints.GetValue() >= 100 && VampireBloodPoints.GetValue() < 200
		  
						PlayerVampireQuest.SetVampireSatiation()

					ElseIf VampireDynamicStages.GetValue() == 10000 && VampireStageGlobal.GetValue() >= 2 && VampireBloodPoints.GetValue() >= 200 && VampireBloodPoints.GetValue() < 300
		  
						PlayerVampireQuest.SetVampireSatiation()
			
					ElseIf VampireDynamicStages.GetValue() == 10000 && VampireStageGlobal.GetValue() >= 2 && VampireBloodPoints.GetValue() >= 300
		  
						PlayerVampireQuest.SetVampireSatiation()
						
					;--------------------------------------------		
						
					ElseIf VampireDynamicStages.GetValue() == 0 && VampireStageGlobal.GetValue() >= 4 && VampireBloodPoints.GetValue() >= 0 && VampireBloodPoints.GetValue() < 100
		  
						PlayerVampireQuest.SetVampireSatiation()
		  
					ElseIf VampireDynamicStages.GetValue() == 0 && VampireStageGlobal.GetValue() >= 3 && VampireBloodPoints.GetValue() >= 100 && VampireBloodPoints.GetValue() < 200
		  
						PlayerVampireQuest.SetVampireSatiation()

					ElseIf VampireDynamicStages.GetValue() == 0 && VampireStageGlobal.GetValue() >= 2 && VampireBloodPoints.GetValue() >= 200 && VampireBloodPoints.GetValue() < 300
		  
						PlayerVampireQuest.SetVampireSatiation()
			
					ElseIf VampireDynamicStages.GetValue() == 0 && VampireStageGlobal.GetValue() >= 2 && VampireBloodPoints.GetValue() >= 300
		  
						PlayerVampireQuest.SetVampireSatiation()	
					
					EndIf
				
				EndIf	
				
			EndIf	
			
			Utility.Wait(5.0)
			AdjustingVampireSatiation.SetValue(0)	
			
		EndIf	
  
EndEvent