Calling a Function in an If based on % of target value.

Post » Wed Jun 20, 2012 7:12 pm

If (Victim as Actor).GetActorValuePercentage("Health" <= 0.4)   MyFunction()EndIf


Here is the full Function. It is part of Vampire Siring. Currently being worked on for the next update of my mod. The idea I'm trying to formulate is the player chooses to kill the target by over-feeding on the victim. After which the target dies, rises again and becomes a slave of the vampire.

However at the moment it is not triggering "Infect()" function because I believe my syntax for GetActorValuePercentage is incorrect. If I remove the GetActorValuePrecentage the function triggers and works. Turning the target into a new slave (based on an alias reference. Written mostly by my good bud rmbackslash, hes the man). I appreciate any help, thanks.

Function VampireFeed(ObjectReference Victim)(Victim as Actor).DamageActorValue("Health", 35)   If (Victim as Actor).GetActorValuePercentage("Health" <= 0.4)	 (Victim as Actor).KillSilent()     Utility.Wait(5.0)     (Victim as Actor).Resurrect()	 Infect(Victim as Actor)     (Victim as Actor).MakePlayerFriend()   Endif    ;Effects for hiding the change    ;VampireChangeFX.play(game.getPlayer())    VampireTransformDecreaseISMD.applyCrossFade(2.0)    utility.wait(2.0)    imageSpaceModifier.removeCrossFade()    ;VampireChangeFX.stop(game.getPlayer())        Game.IncrementStat( "Necks Bitten" )    VampireFeedMessage.Show()    VampireFeedReady.SetValue(0)    ;Player has fed, regress to Stage 1 Vampirisim    ;Remove Stage 2 buffs and spells    LastFeedTime = GameDaysPassed.Value    VampireStatus = 1    VampireProgression(Game.GetPlayer(), 1)                ;Start checking GameTime again if we weren't already    UnregisterforUpdateGameTime()    RegisterForUpdateGameTime(12)        EndFunction
User avatar
Zosia Cetnar
 
Posts: 3476
Joined: Thu Aug 03, 2006 6:35 am

Post » Wed Jun 20, 2012 12:45 pm

If (Victim as Actor).GetActorValuePercentage("Health") <= 0.4
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm

Post » Wed Jun 20, 2012 2:38 pm

I will try that, thanks RN.


EDIT: That fixed it, thanks mate :)
User avatar
Soph
 
Posts: 3499
Joined: Fri Oct 13, 2006 8:24 am


Return to V - Skyrim