jim555511 Posted November 3, 2017 Share Posted November 3, 2017 Hi there, thanks for the help.So i'm trying to create a script that will read the actors health each time they are hit and based off their health percent will cast mage light on them. I've almost got everything working but the only problem is the onhit function. Heres my script Scriptname SecondaryLeonardoScript extends Activemagiceffect Spell Property Magelight autoActor myself event oneffectstart(actor aktarget,actor akcaster)myself = aktargetendevent Event onhit(ObjectReference aktarget, Form aksource,Projectile akprojectile,Bool abPowerAttack,Bool abSneakAttack,Bool abHitBloacked) Float Health = myself.GetActorValue("Health")Float BaseHealth = myself.GetBaseActorValue("Health")Float HealthPercent = (Health/BaseHealth) * 100 if HealthPercent < 0.5Magelight.Cast(myself,myself)endif endevent It gives me a compiling issue and tells me that the onhit function doesn't match the parent script and i am out of ideas, please help :) Link to comment Share on other sites More sharing options...
JonathanOstrus Posted November 3, 2017 Share Posted November 3, 2017 First problem I see is you are missing a parameter. You're missing a bool for abBashAttack before blocked. Easiest thing is to copy the declaration line from the source file or copy from the wiki page https://www.creationkit.com/index.php?title=OnHit_-_ObjectReference. That way you don't miss things like that. Though the variable names will differ slightly from what you have written. Here's the lines from ObjectReference.psc for simple copying. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) EndEvent Rather than getting 2 actor values and doing the math yourself you could just use Float HealthPercent = myself.GetActorValuePercentage("health") That will return a float between 0 and 1 for the percentage. The event would then look like this Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Float HealthPercent = myself.GetActorValuePercentage("health") if HealthPercent < 0.5 Magelight.Cast(myself,myself) endif EndEvent Something to keep in mind though, is that if the health ever went back up above 50% and then got hit again it would retrigger without any check if the spell is already active or any cooldown between casts. Maybe this is desired. Link to comment Share on other sites More sharing options...
jim555511 Posted November 5, 2017 Author Share Posted November 5, 2017 (edited) First problem I see is you are missing a parameter. You're missing a bool for abBashAttack before blocked. Easiest thing is to copy the declaration line from the source file or copy from the wiki page https://www.creationkit.com/index.php?title=OnHit_-_ObjectReference. That way you don't miss things like that. Though the variable names will differ slightly from what you have written. Here's the lines from ObjectReference.psc for simple copying. Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) EndEvent Rather than getting 2 actor values and doing the math yourself you could just use Float HealthPercent = myself.GetActorValuePercentage("health") That will return a float between 0 and 1 for the percentage. The event would then look like this Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Float HealthPercent = myself.GetActorValuePercentage("health") if HealthPercent < 0.5 Magelight.Cast(myself,myself) endif EndEvent Something to keep in mind though, is that if the health ever went back up above 50% and then got hit again it would retrigger without any check if the spell is already active or any cooldown between casts. Maybe this is desired.Thank you so much, your help is greatly appreciated, makes me feel stupid that i was only missing one thing haha Edited November 5, 2017 by jim555511 Link to comment Share on other sites More sharing options...
Recommended Posts