Jump to content

Scripting: How to hook into this event?


BigBizkit

Recommended Posts

I am using the popular "Better Vampires mod" and although I like it a lot, one thing that has always bugged me is that it does not count the vampire lord finishing move bite killing of NPCs as feeding. So I woud like to change that.

 

I thought the simplest thing to do was to look for the vanilla perk "blood healing" which heals the player 100% every time the bite killing is performed.

 

I found the script that governs how that perk functions. However, I cannot recompile it, even though I have all Dawnguard scripts and source scripts in the main folder. I cannot recompile the script even if I do not change anything.

 

Here is the important part from the "DLC1PlayerVampireChangeScript":

Event OnAnimationEvent(ObjectReference akActor, string akEventName)
    actor PlayerActor = Game.GetPlayer()
    Debug.Trace("VAMPIRE: Animation Event! " + akActor + " " + akEventName)
    if akActor == PlayerActor

        if (akEventName == TransformToHuman)
        	ActuallyShiftBackIfNecessary()
        endif

        If akEventName == BiteStart
            Debug.Trace("VAMPIRE: Handle BiteStart")

; THIS IS WHERE I WOULD PUT MY LINE OF CODE IF I COULD RECOMPILE THIS SCRIPT

            DLC1VampireBloodPoints.Value += 1
    		If DLC1VampireTotalPerksEarned.Value < DLC1VampireMaxPerks.Value
    			DLC1BloodPointsMsg.Show()
    			Debug.Trace("VAMPIRE: Bite kill move, Blood " + DLC1VampireBloodPoints.value)
    			if DLC1VampireBloodPoints.Value >= DLC1VampireNextPerk.Value 
    				DLC1VampireBloodPoints.Value -= DLC1VampireNextPerk.Value
    				DLC1VampirePerkPoints.Value += 1
    				DLC1VampireTotalPerksEarned.Value += 1
    				DLC1VampireNextPerk.Value = DLC1VampireNextPerk.Value + 2
    				DLC1VampirePerkEarned.Show()
    ;				Debug.Trace("VAMPIRE: New perk (Blood points " + DLC1VampireBloodPoints.Value +", Next perk " + DLC1VampireNextPerk.Value + ", Perk pionts " + DLC1VampirePerkPoints.value + ")")
    			endIf
    			PlayerActor.SetActorValue("VampirePerks", DLC1VampireBloodPoints.Value / DLC1VampireNextPerk.Value*100)				
    		endif
    		if PlayerActor.HasPerk(DLC1VampireBite) == 1
    			PlayerActor.RestoreActorValue("Health", DLC1BiteHealthRecover)
    		endif
    		PlayerActor.SetActorValue("VampirePerks", DLC1VampireBloodPoints.Value / DLC1VampireNextPerk.Value*100)				
    ;		Debug.Trace("VAMPIRE: Actor value " + PlayerActor.GetActorValue("VampirePerks") + ")")
    		Game.IncrementStat( "Necks Bitten" )
    ;            we actually want the glow to stop playing at the begining of the landing anim.
        endif

        If akEventName == LandStart
            Debug.Trace("VAMPIRE: Handle LandStart")
            DCL1VampireLevitateStateGlobal.SetValue(1)
        endif

        If akEventName == Ground
           Debug.Trace("VAMPIRE: Handle GroundStart")
           DCL1VampireLevitateStateGlobal.SetValue(1)

            ; Save off the spell currently equipped in the left hand.
            CurrentEquippedLeftSpell = PlayerActor.GetEquippedSpell(0)
            debug.trace("VAMPIRE: saving equipped left spell " + CurrentEquippedLeftSpell)
            if ( CurrentEquippedLeftSpell != None )
                PlayerActor.UnequipSpell( CurrentEquippedLeftSpell, 0 )
            endif
            
            ; Now remove and unequip whatever spells are in the left & right hands.
            PlayerActor.UnequipSpell(LeveledDrainSpell, 1)
            PlayerActor.RemoveSpell(LeveledRaiseDeadSpell)
            PlayerActor.RemoveSpell(DlC1CorpseCurse)
            PlayerActor.RemoveSpell(DLC1VampiresGrip)
            PlayerActor.RemoveSpell(DLC1ConjureGargoyleLeftHand)

        endif

        If akEventName == LiftoffStart
;           we actually want the glow to start playing at the begining of the takoff anim.
            Debug.Trace("VAMPIRE: Handle LiftoffStart")
            DCL1VampireLevitateStateGlobal.SetValue(2)
        endif

        If akEventName == Levitate
            Debug.Trace("VAMPIRE: Handle LevitateStart")
            DCL1VampireLevitateStateGlobal.SetValue(2)

            ; Always equip a Vampire Drain in the right hand.
            PlayerActor.EquipSpell( LeveledDrainSpell, 1 )

            ; Now we'll re-equip whatever spell was previously eqiupped in the left hand.
            ; This was stored when we went to Ground. It'll be None the first time
            ; we transition, so we'll set it to the default Reanimate Corpse spell.
            ;debug.trace("VAMPIRE: CurrentEquippedLeftSpell = " + CurrentEquippedLeftSpell)
            If (DialogueGenericVampire as VampireQuestScript).LastLeftHandSpell == none
                (DialogueGenericVampire as VampireQuestScript).LastLeftHandSpell = DLC1VampireRaiseDeadLeftHand01
            EndIf
    		If CurrentEquippedLeftSpell == none
                CurrentEquippedLeftSpell = (DialogueGenericVampire as VampireQuestScript).LastLeftHandSpell
    			Debug.Trace("VAMPIRE: Spell from last session set as current last spell = " + CurrentEquippedLeftSpell)
    		EndIf

            ; Check to see if we need to add any perk-related spells.
            ; We need to do this here because the player may have added new perks since
            ; the last time.
            CheckPerkSpells()
            PlayerActor.AddSpell(LeveledRaiseDeadSpell, false)
            PlayerActor.EquipSpell(CurrentEquippedLeftSpell, 0)
            Debug.Trace("VAMPIRE: Last spell left eqiupped = " + CurrentEquippedLeftSpell)
            PlayerActor.EquipSpell(LeveledDrainSpell, 1)
            Debug.Trace("VAMPIRE: Last spell right eqiupped = " + LeveledDrainSpell)

       endIf
    endif
EndEvent

Anyways, it would probably be better to not alter vanilla scripts at all in the first place. I am not sure what would be the best way of achieving my goal.

 

What I want is: Every time the player performs the vampire lord bite killmove -> execute a function,

Link to comment
Share on other sites

Well, yes but how would it work?

 

Having it constantly check for the player performing the killmove seems non efficient. I do not fully understand how the dawnguard quest handles that. I doubt it is running checks constantly. But it fires its stuff (e.g. perk progression) without fail when it is needed.

Link to comment
Share on other sites

It's not constantly checking except in the sense that all scripts are constantly checking for events that they are registered for. Somewhere in the vampire lord quest script is a RegisterForAnimationEvent function. Copy it. Then there is an OnAnimationEvent event. Copy the event declaration (the line that starts with event OnAnimationEvent...). Put them into your own quest or magic effect script and fill in the event with your function.
Link to comment
Share on other sites

I did just that and added the following script to the DLC1VampireQuest, to no avail:

Event OnAnimationEvent(ObjectReference akActor, string akEventName)

    actor PlayerActor = Game.GetPlayer()

if akActor == PlayerActor && Game.GetPlayer().GetRace() == DLC1VampireBeastRace

        If akEventName == BiteStart

debug.notification("BiteStart detected")


        endif

endif
 EndEvent

Function RegisterForEvents()
    Debug.Trace( "Registering for Animation Events" )
    actor PlayerActor = Game.GetPlayer()
    RegisterForAnimationEvent(PlayerActor, BiteStart)

EndFunction

Function UnregisterForEvents()
    Debug.Trace( "Unregistering for Animation Events" )
    actor PlayerActor = Game.GetPlayer()
    UnRegisterForAnimationEvent(PlayerActor, BiteStart)

EndFunction

The notification is not shown, so the event is not detected. All properties are filled correctly. Any ideas?

Link to comment
Share on other sites

What event calls RegisterForEvents?

 

You don't need the extra checks in the OnAnimationEvent event block unless you are also registering for other animation events. If this is the only animation event you are registered for, then it will on ever fire for when the player executes a bite attack, so you only have to check the race.

Link to comment
Share on other sites

Sorry to intrude, but where do you get the names of the animation events like BiteStart? Im trying google, not useful thus far. Need something to tell me when im jumping, right now it does things when i press jump key, but sometimes the character doesnt jump so its unreliable. Need the actual animation event. This post will help me out how to do that since it touches the animation events.

Link to comment
Share on other sites

I found a few .txt files in the update.bsa which seem to have some info on the, what i guess, speeds of the different animations. The names seem familiar to the declarations needed for the event to register the animation. Tho, i didnt find the BiteStart. I found JumpBegin which i need (yet to test tho, will report if it works). Perhaps BigBizkit used a wrong animation call? There was no txt or xml file in the dawguard.bsa and in the update.bsa theres lots of bite declarations but no BiteStart.

Edit: Ok, found this, CKs page tends to hide things from me sometimes. xD
http://www.creationkit.com/Animation_Events
Some base animation event calls. Might come in handy. Sure will for me. First time im trying the animations in scripts. YEY! excitements! xD

Edited by theimmersion
Link to comment
Share on other sites

So i have a little problem with the animations. I cant even compile the script. Never tried to work with animations before so i have no idea what im doing. xD

Trying to learn along the way.

 

MY SCRIPT:
Scriptname theimmersionTestScript extends Quest

Actor PlayerRef

Event OnInit()
PlayerRef = Game.GetPlayer()

RegisterForAnimationEvent(PlayerRef, BiteStart)
RegisterForAnimationEvent(PlayerRef, JumpStart)
RegisterForAnimationEvent(PlayerRef, JumpBegin)
RegisterForAnimationEvent(PlayerRef, JumpFall)
RegisterForAnimationEvent(PlayerRef, JumpDown)
RegisterForAnimationEvent(PlayerRef, JumpLand)
EndEvent

COMPILER ERROR MESSAGE:

C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(146,39): variable BiteStart undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(147,39): variable JumpStart is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(148,39): variable JumpBegin is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(149,39): variable JumpFall is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(150,39): variable JumpDown is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\theimmersionTestScript.psc(151,39): variable JumpLand is undefined

 

So, BigBizkit didnt mention script compile errors, so im assuming he complied it. Tho, he never Triggered the RegisterForEvents() evidently or didnt post that port of the code.
I even tired this: xD

Event OnInit()

PlayerRef = Game.GetPlayer()

RegisterAnimEvents()

EndEvent

 

Function RegisterAnimEvents()

RegisterForAnimationEvent(PlayerRef, BiteStart)

EndFunction

 

Same Compiling errors. It doesnt know what BiteStart is. It treats it as a variable. How do i declare it?

String BiteStart perhaps? I have no clue. xD

I mean, RegisterForControl and i put the control name in, its not a variable that needs declaration, or RegisterForKey i put in the dxSC number. -.-#

Link to comment
Share on other sites

  • Recently Browsing   0 members

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