Jump to content

Scripting Help - Wanting Animal Follower To "Explode" At Low Health


Recommended Posts

Hello! Down to the nitty gritty: Assuming this is even possible, I have an animal follower who I would like to “explode” an icy blast like a frost rune explosion -- as in have the explosion play an at the NPCs location -- when they are at 25% of their health. Then, after they explode, they restore their health to 100%.

 

Since I’m no coding-ninja, forgive if it's laughable hehe but below is what I pieced together...and it doesn’t work when it's attached to the NPC or on a magic effect (which is attached to an ability/spell which is then placed in the NPCs spell list. The animal doesn’t explode at all after I'm hitting it. It compiles no problem.

 

Any help filling in the gaps, maybe providing examples, would be appreciated!

The script I have so far, again it's attached directly to the actor.
Oh and if there's a better way to do this -- like via a magic effect > spell/ability > spell in actor's spell list, guide me. Thanks!
Scriptname MYSCRIPT extends ObjectReference
{Once the animal actor/follower reaches down to a quarter of their health, they release an icy blast explosion and restore all their health.}

Actor Property MYANIMAL Auto
Explosion Property ICEBLAST Auto

Event OnDying()

float MYANIMALHEALTH = MYANIMAL.GetAVPercentage("Health")

   if (MYANIMALHEALTH < 0.25)
      Debug.Notification("Your animal companion has less than 25% health remaining") ;this doesn’t even fire
      MYANIMAL.PlaceAtMe(ICEBLAST)
      MYANIMAL.SetAV("Health", 1000.0)  ;When MYANIMAL explodes, he restores 1000 points of his health -- is there a SetAVPercentage? I guess it doesnt matter
   endIf
endEvent
Edited by justinglen75
Link to comment
Share on other sites

It should look something like this :

(i didn't compile or tested it, but is a simple script that should be just fine)

 

 

Actor Property MYANIMAL Auto
Explosion Property ICEBLAST Auto
 
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    if (GetActorValuePercentage("Health") <= 0.25 || IsDead() == true)
        MYANIMAL.PlaceAtMe(ICEBLAST)
        MYANIMAL.RestoreActorValue("Health", 1000.0)
    endif   
endEvent

 

 

 

OR

 

 

 

Explosion Property ICEBLAST Auto
 
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    if (GetActorValuePercentage("Health") <= 0.25 || IsDead() == true)
        self.PlaceAtMe(ICEBLAST)
        self.RestoreActorValue("Health", 1000.0)
    endif   
endEvent

 

 

 

* If the actor has a start point of 1000 health points then the "RestoreActorValue" should be 750, i put 1000 because so it was in your post (i don't know your actor's base health).

Edited by maxarturo
Link to comment
Share on other sites

You can also try Start/EndDeferredKill(), these will not work with the OnDying/Death events, you will need to call StartDeferredKill from elsewhere, and then track health for when it reaches < 0.25 and then do the explosion, etc, and then call EndDeferredKill().

Edited by Rasikko
Link to comment
Share on other sites

@Maxarturo I appreciate the suggestions but, unfortunately neither one will compile.

C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\source\JWDSnowvakIceBlast.psc(8,8): GetActorValuePercentage is not a function or does not exist
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\source\JWDSnowvakIceBlast.psc(8,42): cannot compare a none to a float (cast missing or types unrelated)
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\source\JWDSnowvakIceBlast.psc(8,42): cannot relatively compare variables to None
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\source\JWDSnowvakIceBlast.psc(8,53): IsDead is not a function or does not exist
C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\Data\Scripts\source\JWDSnowvakIceBlast.psc(8,62): cannot compare a none to a bool (cast missing or types unrelated) 
Edited by justinglen75
Link to comment
Share on other sites

I saw again your first post and your code is ok, except the fact that you copy/paste it exactly as it is from "creationkit.com".

 

 

Actor Property MYANIMAL Auto
Explosion Property ICEBLAST Auto
 
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
          MYANIMALHEALTH = MYANIMAL.GetAVPercentage("Health")
      if (MYANIMALHEALTH < 0.25)
          MYANIMAL.PlaceAtMe(ICEBLAST)
          MYANIMAL.RestoreActorValue("Health", 1000.0)
 endIf
endEvent

Link to comment
Share on other sites

@Maxaturo - the below script worked flawless, compiled and in-game:

It's what I originally had except for the OnHit event (+ parameters) you added, and the RestoreAV. Thanks again!

I'm just curious though -- to make the explosion NOT effect the player, is that something that can be done in the script? Would hate for the explosion to kill myself albeit the explosion's damage is set somewhat low (30). Just curious :smile:

Scriptname MYANIMALEXPLOSIONSCRIPT extends ObjectReference
{Makes my animal companion explode using an explosion of my choice -- currently an ice-blast -- when at 25% of his health. He then restores his health.}   

Actor Property MYANIMAL Auto
Explosion Property ICYBLAST Auto
  
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
	Float ANIMALHEALTH = MYANIMAL.GetAVPercentage("Health")
		if (ANIMALHEALTH < 0.25)
			Debug.Notification("Your animal has less than 25% health remaining")
			MYANIMAL.PlaceAtMe(ICYBLAST)
			MYANIMAL.RestoreActorValue("Health", 500)
		endIf
endEvent
Edited by justinglen75
Link to comment
Share on other sites

Yes there is a way to do this, but i don't remember the code for it. There should be something related to this in "creationkit.com", sorry but i'm not where near my PC as i mentioned before.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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