Jump to content

[LE] Need help with EventOnHit Script


Recommended Posts

I have almost finished my new Sixth House mod. But there is one script I just can not get to work. What I want to happen is for the player to have to hit the Heart of Lorkhan once with Sunder then 5 times with Keening , then the stage is set to 106. This is what I have and its not working. Can anyone help me out please?

Scriptname MWLorkhanHeartHitScript extends ObjectReference  

WEAPON Property Sund  Auto  

WEAPON Property Keen  Auto  

Actor Property DGUR  Auto  

GlobalVariable Property KeenCNT  Auto  

GlobalVariable Property SundCNT  Auto  

Sound Property DNO  Auto  

Quest Property MW6QST  Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \
  bool abBashAttack, bool abHitBlocked)
		if(akSource as weapon) == Sund
		If SundCNT.GetValue() == 0
			SundCNT.SetValueInt(SundCNT.GetValueInt() + 1)
	EndIf
	EndIf
		if(akSource as weapon) == Keen
		If SundCNT.GetValue() >= 1
			KeenCNT.SetValueInt(KeenCNT.GetValueInt() + 1)
		ElseIf KeenCNT.GetValue() >= 4
			 DGUR.GetActorBase().SetInvulnerable(false)
			DNO.play(Game.GetPlayer())
			MW6QST.SetStage(106)
	EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

Well you fixed the mistake by yourself, nevertheless you could make your script a bit better.

 

MWLorkhanHeartHitScript

 

Scriptname MWLorkhanHeartHitScript extends ObjectReference  

; https://forums.nexusmods.com/index.php?/topic/6164528-need-help-with-eventonhit-script/
; morrowind1979 wrote: "What I want to happen is for the player to have to hit the Heart of Lorkhan once with Sunder then 5 times with Keening , then the stage is set to 106."

  Quest PROPERTY MW6QST auto

  GlobalVariable PROPERTY KeenCNT auto  
 ;GlobalVariable PROPERTY SundCNT auto         ; Do not use that,
  Bool bSundHit                                ; take a BoolVar instead! [Default = False]

  WEAPON PROPERTY Sund auto  
  WEAPON PROPERTY Keen auto  

  Sound PROPERTY DNO  auto
  Actor PROPERTY DGUR auto                     ; much better "ActorBase PROPERTY DGURBase auto"


; -- EVENTs --

;=============================
auto State Waiting
;=================
EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool b1, Bool b2, Bool b3, Bool b4)
IF (akSource as Weapon)
ELSE
    RETURN    ; - STOP -    hit does not match
ENDIF
;---------------------
IF ( bSundHit )
    IF (akSource as Weapon == Keen)
        myF_Action()
    ENDIF
    RETURN    ; - STOP -
ENDIF
;--------------------- bSundHit = False
IF (akSource as Weapon == Sund)
    bSundHit = TRUE
ENDIF
ENDEVENT
;=======
endState


;=============================
state Done
;=========
endState


; -- FUNCTION --

;--------------------
FUNCTION myF_Action()
;--------------------
    float f = KeenCNT.GetValue()
    KeenCNT.SetValue(f+1)                            ; update counter

IF (f < 4)
    RETURN    ; - STOP -    not enough counts with Keen weapon
ENDIF
;---------------------
    gotoState("Done")                ; ### STATE ### do not trace OnHit() anymore
;;; DGURBase.SetInvulnerable(False)
    DGUR.GetActorBase().SetInvulnerable(False)
    MW6QST.setStage(106)
    DNO.Play(Game.GetPlayer() as ObjectReference)    ; within OnHit() the player == akAggressor
ENDFUNCTION

 

 

Link to comment
Share on other sites

If its not broken don't fix it. It works and it does what its supposed to do. My quest is running 100% bug free. I'm not tampering with it any more and possibly adding more complications to it. Its done but thanks for the reply lol

Link to comment
Share on other sites

  • Recently Browsing   0 members

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