Jump to content

Decap with 2h axe not working in script.


Recommended Posts

So I have a script that "forces" decapitation of specific enemies that are using the script.

 

I made duplicates of the "decap" idle animations for the purpose of removing the restrictions (I handle the restrictions in the actor script).

 

for some reason the 2h Axe animation never triggers. (If I give the 2h axe kill move property a reference to the 1h animation it works fine (but is obviously using the 1h animation, which looks out of place all of a sudden swinging this lumbering weapon with speed and precision for the decap)

 

So I know the logic for the 2h axe is getting triggered since if I assign the property like above it works (and when it is assigned to the 2h axe animation) the NPC just dies as their essential flag gets turned off).

 

I've also tried pointing the 2h axe property to the animation for 2h swords (which works for 2h swords). I originally had the greatsword and battle axe in an or statement in the if so they would use the same animation. But it wasn't working for 2h axes. So I sought out the 2h animation that I assume is used for battle axes, it didn't work either. The only thing that works for battle axes so far is the 1h decap. So I am not sure if I am not finding the right animation or what or why the 1h decap works when you would think that one shouldn't.

  bool activated = false
              {play kill move decap for specific weapon types}
              if(akSource.haskeyword(WeapTypeGreatSword))
                  PlayerRef.PlayIdleWithTarget(KillMove2HS, Self)
                  activated = true
              endif
              if(akSource.haskeyword(WeapTypeSword) || akSource.haskeyword(WeapTypeWarAxe))
                  PlayerRef.PlayIdleWithTarget(KillMove1HS, Self)
                  activated = true
              endif
              if(akSource.haskeyword(WeapTypeBattleAxe))
                  PlayerRef.PlayIdleWithTarget(KillMove2HA, Self)
                  activated = true
              endif
              {This if statement is a catch all.  In case the player does hit with the right weapon, but for some reason doesn't enter any of the kill move ifs it will trigger the 1h kill move}
              if (activated == false)
                  PlayerRef.PlayIdleWithTarget(KillMove1HS, Self)
                  activated = true
              endif
{when a decap animation is triggered activated should be true thus we wait for the animation to finish then remove the essential flag from the npc.}
              if(activated == true)
                 wait(4)
                 Self.GetActorBase().SetEssential(false)
                 Self.KillEssential(PlayerRef)
             endif
Edited by tsdobbi
Link to comment
Share on other sites

you wrote: "if statements catch all. In case the player does hit with the right weapon, but for some reason it does not enter any of the killmove it should"

 

Unfortunately you posted only a part of your script, no matter what is happen with the killmove rate or what did you do else with the script.

 

maybe something like this

 

  Keyword PROPERTY WeapTypeGreatSword auto
  Keyword PROPERTY WeapTypeBattleaxe  auto
  Keyword PROPERTY WeapTypeWarhammer  auto
  Keyword PROPERTY WeapTypeSword      auto
  Keyword PROPERTY WeapTypeWarAxe     auto
  Keyword PROPERTY WeapTypeMace       auto

  Idle PROPERTY KillMove1HS auto
  Idle PROPERTY KillMove2HS auto  
  Idle PROPERTY KillMove2HA auto


EVENT OnDying(Actor akKiller)
    gotoState("Done")
ENDEVENT


EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4)
; b1 = abPowerAttack
; b2 = abSneakAttack
; b3 = abBashAttack
; b4 = abHitBlocked

IF ( b4 )
    RETURN    ; - STOP -    hit was blocked
ENDIF
;---------------------
IF ( akProjectile )
    RETURN    ; - STOP - /1    hit by long range weapon
ENDIF
;----------------------
IF (akSource as Weapon)
ELSE
    RETURN    ; - STOP - /2    hit by magic
ENDIF
;---------------------
IF (akAggressor as Actor == Game.GetPlayer())
ELSE
    RETURN    ; - STOP -    player is not the opponent
ENDIF
;---------------------
    ; GetEquippedItemType()
    ;  0: Nothing (Hand to hand) (2)
    ;  7: Bow      (1)                - WeapTypeBow
    ;  8: Staff          (2)          - WeapTypeStaff, VendorItemStaff
    ;  9: Magic spell    (2)
    ; 10: Shield         (2)          - (akSource as Armor)
    ; 11: Torch          (2)
    ; 12: Crossbow (1)                - WeapTypeBow
    ; --------------
    ;  5: Two-handed greatsword (3)
    ;  6: Two-handed battleaxe (3)
    ;  6: Two-handed warhammer (3)
    ; --------------
IF akSource.Haskeyword(WeapTypeGreatSword)
    gotoState("Done")
    myF_Play(akAggressor, KillMove2HS)
    RETURN    ; - STOP -    /3    greatsword
ENDIF
;---------------------
IF akSource.Haskeyword(WeapTypeBattleaxe)
    gotoState("Done")
    myF_Play(akAggressor, KillMove2HA)
    RETURN    ; - STOP -    /3    battleaxe
ENDIF
;---------------------
IF akSource.Haskeyword(WeapTypeWarhammer)
    gotoState("Done")
    myF_Play(akAggressor, KillMove2HA)
    RETURN    ; - STOP -    /3    warhammer
ENDIF
;---------------------
    ; GetEquippedItemType()
    ;  1: One-handed sword   (4)
    ;  2: One-handed dagger
    ;  3: One-handed waraxe  (5)
    ;  4: One-handed mace    (6)

IF akSource.HasKeyword(WeapTypeSword)
    gotoState("Done")
    myF_Play(akAggressor, KillMove1HS)
    RETURN    ; - STOP -    /4    sword
ENDIF
;---------------------
IF akSource.HasKeyword(WeapTypeWarAxe)
    gotoState("Done")
    myF_Play(akAggressor, KillMove1HS)
    RETURN    ; - STOP -    /5    waraxe
ENDIF
;---------------------
IF akSource.HasKeyword(WeapTypeMace)
    gotoState("Done")
    myF_Play(akAggressor, KillMove1HS)
    RETURN    ; - STOP -    /6    mace
ENDIF
;---------------------
;IF akSource.HasKeyword(WeapTypeDagger)
    gotoState("Done")
    myF_Play(akAggressor, KillMove1HS)
;ENDIF
ENDEVENT


;==================================
state Done    ; cover any event you will not run after dead
;=========
    EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4)
    ENDEVENT
;=======
endState


; -- FUNCTION --

;-----------------------------------------------
FUNCTION myF_Play(ObjectReference oRef, Idle IL) ; {play kill move decap for specific weapon types}
;-----------------------------------------------
; https://www.creationkit.com/index.php?title=PlayIdleWithTarget_-_Actor
; see issues and notes

IF (oRef as Actor).PlayIdleWithTarget(IL, self as ObjectReference)
    ; self is an actor, which owns this script
    ; when a decap animation is TRUE, thus we wait for the animation to finish then remove the essential flag from the npc.

    Utility.Wait(4.0)

    actorBase AB = self.GetBaseObject() as ActorBase
    IF AB.IsEssential()
        AB.SetEssential(False)
    ENDIF
    IF AB.IsProtected()
        AB.SetProtected(False)
    ENDIF

    self.Kill(oRef as Actor)
ENDIF

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

you wrote: "if statements catch all. In case the player does hit with the right weapon, but for some reason it does not enter any of the killmove it should"

 

Unfortunately you posted only a part of your script, no matter what is happen with the killmove rate or what did you do else with the script.

 

 

 

Apologies. This block of ifs never gets hit if it doesn't aleady verify that the NPC was hit with one of these weapons. i.e. Im not messing with the killmove system at all, this is basically an independent kill move system.

 

Heres the if blocks before this code is executed.

 Actor PlayerRef = Game.GetPlayer()
  bool IsImmortal = false
  if(PlayerRef.HasPerk(Immortality))
      IsImmortal = true
  endif
  if (akAggressor == PlayerRef && IsImmortal == true)
  float immortalHealth = Self.GetActorValuePercentage("health")
  If (immortalHealth < 0.2)

      if (akSource.haskeyword(WeapTypeSword) || akSource.haskeyword(WeapTypeGreatSword) || akSource.haskeyword(WeapTypeWarAxe) || akSource.haskeyword(WeapTypeBattleAxe))

When playIdleWith is played it forces the killmove 100% (or should). The problem is the in game animation for 2h weapon decaps, doesn't work on the battle axe weapon (although the 1h animation does work for 2h axes).

 

you wrote: "if statements catch all. In case the player does hit with the right weapon, but for some reason it does not enter any of the killmove it should"

 

This if statement "shouldn't" ever be executed. It will only execute if (activated == false) which would mean none of the animations were triggered, but they were hit with a sword or axe when health was below .2 Which should essentially be impossible since to get to this code it would have had to properly identify the weapon type as a sword or axe, meaning it should have entered one of the previous if statements and executed (and if it did activated would be true, so it wouldn't enter this if statement). i.e. it basically doesn't even need to be there because it shouldn't ever do anything.

Edited by tsdobbi
Link to comment
Share on other sites

Thanks for your help. So you definitely solved one problem I was working on, on the side. i.e. There is definitely some hard coded conditions for animations (positioning, distance etc), that you can't just remove in the CK. So the way I had it before it worked like 95% of the time, but sometimes the animation (for any of the approved weapons) just wouldn't trigger and the NPC would get set as not essential and just die without the animation loading.

 

However, putting the play idle animation in the if statement ensures the NPC won't die until the animation actually plays, essentially making sure the NPC wont die unless they are decapped which was the goal, so it may take a couple extra hacks to get it to trigger, but it gets the job done.

 

I put a debug message box in an else on the playwithidle if statement and below for battle axe it is always failing (if the animation passed in is ANY of the 2h decap animations) , if I go into the CK and point the 2hAxe idle properties to 1h decap kill moves it works fine. So it isn't a matter of the script itself executing the code for the battle axe, the PlayIdleWithTarget just doesn't work when you have a battleAxe equipped and the animation is any 2h decap animation. I assume there is some underlying condition I cant see in the CK for the animation to proc.

 

For clarity I made duplicates of all the Decap kill moves in the CK and removed the conditions from them (i.e. perk requirements etc). I've tried all the 2h decap animations with a battle axe and the play with idle just never procs, but if I give it a 1h decap animation it works every time. (I've had no such issues with the Greatsword, the 2h animations seem to work just fine with them).

Function DecapAnim(Actor pRef, Idle akIdle)

    if pRef.PlayIdleWithTarget(akIdle, Self)
        gotoState("Done")
         wait(3)               
         Self.GetActorBase().SetEssential(false)
         Self.KillEssential(pRef)  
    else
         Debug.MessageBox("Animation Failed")   
    endIf

    
endFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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