Jump to content

Recommended Posts

Posted (edited)

 

Bool Cast = true
Event OnInit()
Cast = true
EndEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)
PercentHealth = self.GetTargetActor().GetAVPercentage("Health")
if (PercentHealth < 0.200000)
if(Cast == true)
Debug.SendAnimationEvent (Caster as ObjectReference, "Shout Start")
voicecallsofia.Cast(self.GetTargetActor() as ObjectReference, none)
RegisterForUpdate(10.0) ; enter cooldown time here in seconds
Cast = false
endif
else
Cast = true
endIf
EndEvent
Event OnUpdate()

Cast = true

UnregisterForUpdate()

EndEvent

 

... Edit ... with an added cooldown

Edited by NexusComa
Posted (edited)

Maybe the following script could be useful. It's different to your source.

 

Scriptname _Follower20P extends ActiveMagicEffect  
{rewritten by ReDragon 2016}

  Spell       PROPERTY Voicecallsofia     auto        ; the follower will cast if under 20% health

 ;Spell       PROPERTY FollowerSummon     auto        ; the spell you cast or the ability the follower should have
  MagicEffect PROPERTY MGE_FollowerSummon auto        ; the magicEffect of this script
 
  Float PROPERTY waitTimer auto                       ; fill with your desired time

  Actor target                                        ; for speed and make persistent
  Float fHealth                                       ; take it out of event
 

; **********************************************************************
; You wrote: "My aim was to force a follower to summon another character
;             when her health had dropped below 20% during combat."
; **********************************************************************

; -- EVENTs -- 3 + "Waiting"

; Event received when this effect is first started (OnInit may not have been run yet!)
EVENT OnEffectStart(Actor akTarget, Actor akCaster)
    Debug.Trace("Summon: OnEffectStart() - target = " +akTarget+ ", caster = " +akCaster)       ; remove this line if you do not need it anymore

IF akTarget.HasMagicEffect(MGE_FollowerSummon) || !akTarget.IsPlayerTeammate()
    self.Dispel()
    RETURN    ; - STOP -    follower already has this magiceffect or is not by your side
ENDIF
;---------------------
    target = akTarget        ; == self.GetTargetActor()
ENDEVENT


; Event received when this effect is finished (effect may already be deleted, calling functions on this effect will fail)
EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
    Debug.Trace("Summon: OnEffectFinish() - target = " +akTarget+ ", caster = " +akCaster)   ; a bit info, remove the whole event if all is fine
;;;    target = None        ; use with caution !!!
ENDEVENT

 
EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)
IF (akAggressor as Actor) && (target)
ELSE
    RETURN    ; - STOP -    safety first
ENDIF
;---------------------
    fHealth = target.GetAVPercentage("Health")

IF (fHealth > 0.2)
    RETURN    ; - STOP -    health is higher than 20%
ENDIF
;---------------------
    gotoState("Waiting")            ; ### STATE ### go out of empty state until OnUpdate() is running
    myF_Cast()
    RegisterForSingleUpdate(120.0)                                          ; 2 min, summoned creature should be max alive, casting cool down
    Utility.Wait(waitTimer)                                                 ; wait until idle is over, which is running on the follower
ENDEVENT


FUNCTION myF_Cast()
;------------------
IF ( target )
    Debug.SendAnimationEvent(target as ObjectReference, "Shout Start")      ; let the follower doing a special idle, hopefully the right string
    voicecallsofia.Cast(target as ObjectReference, None)                    ; follower is casting the summon spell
ENDIF
ENDFUNCTION


;==========================
state Waiting    ; already Waiting
;============
EVENT OnUpdate()
IF (target) && target.Is3DLoaded()
    gotoState("")                    ; ### STATE ###    go back to empty state, OnHit() above is available again
ENDIF
ENDEVENT

EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProj, Bool b1, Bool b2, Bool b3, Bool b4)
ENDEVENT
;=======
endState

 

 

Edited by ReDragon2013
  • Recently Browsing   0 members

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