Enchantment Proc Scripting

Post » Mon Nov 19, 2012 5:12 am

I'm trying to learn some basic scripting for creation kit (I don't know too much about it) and am trying to learn how to make enchantments with scripts. I looked at the script for Konahrik to get a basic idea (I want to make an effect proc at a set HP threshold). To start with, I just wanted to change around HP thresholds for when the effect would proc using the same script that used by Konahrik, however in spite of even just copy and pasting the original script into a new one and changing the float values, the script does not trigger on any test items I put the enchantment on. Can somebody explain what the problem is? I have looked around on the wiki and haven't really found anything similar to what I am trying to achieve, apart from the Konahrik enchantment effect.

I don't get any error logs when I try to trigger it, and have gotten to the appropriate HP threshold many times in case I have just had bad luck.

Script Below:


Spoiler

Scriptname KonahrikScriptRipOffTest extends ActiveMagicEffectactor property selfRef auto hiddenmagicEffect property DragonPriestMaskFireCloakFFSelf autofloat property HPthreshold = 0.80 auto{Below this HP we have a chance of the special effects.  Default 20% (0.2)}float property effectChance = 0.40 auto{effect may happen when HP is below this level DEFAULT 25% (0.25)}float property rareEffectChance = 0.05 auto{Very Rare effect may happen when HP is below this level DEFAULT 5% (0.05)}explosion property fakeForceBall1024 autospell property flameCloak autospell property GrandHealing autospell property rareSpell  automagicEffect property rareEffect autoEVENT OnEffectStart(Actor Target, Actor Caster)selfRef = casterendEVENTEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)  if (selfRef.getActorValuePercentage("Health") < HPthreshold) && \	!(selfRef.HasMagicEffect(DragonPriestMaskFireCloakFFSelf)) && \	!(selfRef.isDead())	  float dice = utility.RandomFloat(0,1)	  ;  debug.trace("Konahrik rolled: "+dice)	  if dice <= effectChance		;  debug.trace("Ultra mask effect Proc'd")		selfRef.placeAtMe(fakeForceBall1024)		selfRef.knockAreaEffect(1,1024)		GrandHealing.cast(selfRef,selfRef)		flameCloak.cast(selfRef,selfRef)	  endif	  if dice <= rareEffectChance && !(selfRef.hasMagicEffect(rareEffect));	   debug.trace("Ultra mask very rare effect Proc'd")		rareSpell.cast(selfRef,selfRef)	  endif	endifendEVENT

Thanks in advance
User avatar
Mason Nevitt
 
Posts: 3346
Joined: Fri May 11, 2007 8:49 pm

Post » Sun Nov 18, 2012 10:50 pm

replace

debug.trace

with

debug.messagebox

Then remove the ";" characters from the start of those lines

Then add:

debug.messagebox("Health: "+selfRef.getActorValuePercentage("Health"))

above the line

if (selfRef.getActorValuePercentage("Health") < HPthreshold) && \


Save your mod. Start Skyrim (check your mod is ticked in Data Files),

What value comes up in the first messagebox?
Which, if any, of the other messageboxes do you see?
User avatar
Agnieszka Bak
 
Posts: 3540
Joined: Fri Jun 16, 2006 4:15 pm

Post » Sun Nov 18, 2012 9:42 pm

Hi, thanks for your help!

Right, the effect is rolling and proccing after all, as indicated by the message boxes. The issue seems to lie in the actual effects that should be happening.. I am just looking into the properties as we speak to check that they are set (I am very sure that I did but hey).

Edit: Some of the properties were set to default, and now having tested it with the appropriate properties it works. Thank you for your help.
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am

Post » Mon Nov 19, 2012 10:21 am

Hi, thanks for your help!

Right, the effect is rolling and proccing after all, as indicated by the message boxes. The issue seems to lie in the actual effects that should be happening.. I am just looking into the properties as we speak to check that they are set (I am very sure that I did but hey).

Edit: Some of the properties were set to default, and now having tested it with the appropriate properties it works. Thank you for your help.
That's OK - And well done you :)
User avatar
Anthony Santillan
 
Posts: 3461
Joined: Sun Jul 01, 2007 6:42 am


Return to V - Skyrim