Jump to content
ℹ️ Intermittent Download History issues ×

[Papyrus] Need Some Help with the scripting


Recommended Posts

Hello,

My aim was to force a follower to summon another character when her health had dropped below 20% during combat.

But now it has 2 problems:

1) it does not play the shout animation;

2) every time she is hit, she summons the character over and over again.

 

Is there any way to 1) force the shout animation playing; and 2) stop recasting the spell when the spell is active (say the spell is effective for 50 seconds. During that 50 seconds, the spell won't be recasted every time the follower is hit)?

 

Thank you in advance.

 

 

Scriptname _DBsummon extends ActiveMagicEffect

;-- Properties --------------------------------------
spell property Voicecallsofia auto
Float property PercentHealth = 100.000 auto
OBJECTREFERENCE PROPERTY caster AUTO
FLOAT PROPERTY waitTimer AUTO
;-- Variables ---------------------------------------
;-- Functions ---------------------------------------
function OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)
PercentHealth = self.GetTargetActor().GetAVPercentage("Health")
if PercentHealth < 0.200000
Debug.SendAnimationEvent (Caster as ObjectReference, "Shout Start")
voicecallsofia.Cast(self.GetTargetActor() as ObjectReference, none)
utility.wait(waitTimer)
endIf
endFunction
; Skipped compiler generated GotoState
; Skipped compiler generated GetState

 

Link to comment
Share on other sites

I may be a bit scrappy wth my scripting knowhow- but shouldnt the OnHit be an Event?

 

Event OnHit(.......)

do the stuff you mentioned

endEvent

 

From what you are showing there, I see no reason why the spell would keep casting, unless the function is being called lots of times.. which may also be breaking the animation.

Link to comment
Share on other sites

;-- Properties --------------------------------------

bool b

 

Event OnInit()

b = 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 && b)
Debug.SendAnimationEvent (Caster as ObjectReference, "Shout Start")
voicecallsofia.Cast(self.GetTargetActor() as ObjectReference, none)
b = false
endIf
EndEvent
Use something like that and change boolean b to true again for example when health reaches 100%.
Link to comment
Share on other sites

Are you sure that the bool doesn't get dropped on the next OnHit event?

 

What you could do is:

 

Create a dummy magic effect named mgef_spellalreadycast

Create a dummy spell named spell_spellalreadycast with your mgef_spellalreadycast with a duration of 50seconds.

 

OnHit, if the follower has no mgef_spellalreadycast effect active you let the follower cast its summoning spell and the spell_spellalreadycast on self.

Edited by dvkkha
Link to comment
Share on other sites

 

Scriptname _DBsummon extends ActiveMagicEffect

;-- Properties --------------------------------------
spell property Voicecallsofia auto
spell property Voicecallsofiadummy auto
magiceffect property voicecalleffectcastalready auto
Float property PercentHealth = 100.000 auto
OBJECTREFERENCE PROPERTY caster AUTO
FLOAT PROPERTY waitTimer AUTO
;-- Variables ---------------------------------------
;-- Functions ---------------------------------------
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)
if !caster.HasMagicEffect(voicecalleffectcastalready)
PercentHealth = self.GetTargetActor().GetAVPercentage("Health")
if PercentHealth < 0.200000
Debug.SendAnimationEvent (Caster as ObjectReference, "Shout Start")
voicecallsofia.Cast(self.GetTargetActor() as ObjectReference, none)
utility.wait(waitTimer)
endIf
endif
endEvent
; Skipped compiler generated GotoState
; Skipped compiler generated GetState

 

Sorry for my ignorance. Now the script returns the following error: "HasMagicEffect is not a function or does not exist". What have I missed? Event oneffectstart ?

Link to comment
Share on other sites


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)

Cast = false

endif

else

Cast = true

endIf


EndEvent

Edited by NexusComa
Link to comment
Share on other sites

 

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)
Cast = false
endif
else
Cast = true
endIf
EndEvent

 

 

 

Do I need to use wait utility.wait to force a cool down time?

Link to comment
Share on other sites

 

 

Scriptname _DBsummon extends ActiveMagicEffect

;-- Properties --------------------------------------
spell property Voicecallsofia auto
spell property Voicecallsofiadummy auto
magiceffect property voicecalleffectcastalready auto
Float property PercentHealth = 100.000 auto
OBJECTREFERENCE PROPERTY caster AUTO
FLOAT PROPERTY waitTimer AUTO
;-- Variables ---------------------------------------
;-- Functions ---------------------------------------
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked)
if !caster.HasMagicEffect(voicecalleffectcastalready)
PercentHealth = self.GetTargetActor().GetAVPercentage("Health")
if PercentHealth < 0.200000
Debug.SendAnimationEvent (Caster as ObjectReference, "Shout Start")
voicecallsofia.Cast(self.GetTargetActor() as ObjectReference, none)
utility.wait(waitTimer)
endIf
endif
endEvent
; Skipped compiler generated GotoState
; Skipped compiler generated GetState

 

Sorry for my ignorance. Now the script returns the following error: "HasMagicEffect is not a function or does not exist". What have I missed? Event oneffectstart ?

 

 

I'm not totally sure but you're trying to use .HasMagicEffect() on caster wich is defined as objectreference. You need to use an Actor like Game.GetPlayer() or in this case self.GetTargetActor() if I'm not mistaken.

https://www.creationkit.com/index.php?title=HasMagicEffect_-_Actor

 

Try:

if !(self.GetTargetActor().HasMagicEffect(voicecalleffectcastalready))

And don't forget to deploy the magiceffect on your follower after the shout.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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