(Papyrus Help) Trying to add a silence effect to spells.

Post » Wed Jun 20, 2012 9:14 pm

So, I'm trying to replace Disintegrate with a perk that has a random chance of silencing the target for a bit (let's say 5 seconds). I'm starting with Lightning Bolt, so I've edited the Lightning Bolt spell to change the duration of the Disintegrate effect to 5 seconds, edited PerkDisintegrateFFAimed to be a Script Effect Archetype, changed the GetActorValuePercent condition to a GetRandomPercent condition, removed the disintegrate effect script, and replaced it with this script:

Spoiler
Scriptname GUUM02PerkShockedSilenceEffect extends ActiveMagicEffect{Prevents casting of spells when silence effect is active.}actor victimEvent OnEffectStart(Actor Target, Actor Caster)victim = targetvictim.InterruptCast()Debug.Notification("Target was silenced!")EndEvent

In game, I'm getting the "Target was silenced" when hitting a spellcaster with lightning bolt, but it's not actually silencing them. My guess is that it's probably interrupting them if it catches them mid-cast, but the duration that I thought was being passed from the LightningBolt spell is having no effect on the script. Is there some sort of While loop I could use to continuously prevent the target from casting for a specified duration? Or am I going to have to set a "silenced" property on the target and then edit the magic effects for every other spell to check for whether that target is silenced? Or is there some other solution I don't know about? I'm a papyrus newbie and not a CK expert, so please talk slowly and use small words. :wink:
User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am

Post » Wed Jun 20, 2012 11:29 pm

The OnEffectStart event only happens when the spell first hits the target. So the InterruptCast only happens once. I suggest that instead of using a script effect archetype, change to using a Peak Value Modifier. Assoc. Item should be Magicka, and it should have the Detrimental flag checked. Then in your spell effects, change this to some really high number. This would mean that the target has 0 magicka while the spell is in effect, making it impossible for him/her to cast spells.
User avatar
Greg Swan
 
Posts: 3413
Joined: Tue Jun 05, 2007 12:49 am

Post » Wed Jun 20, 2012 2:23 pm

The OnEffectStart event only happens when the spell first hits the target. So the InterruptCast only happens once. I suggest that instead of using a script effect archetype, change to using a Peak Value Modifier. Assoc. Item should be Magicka, and it should have the Detrimental flag checked. Then in your spell effects, change this to some really high number. This would mean that the target has 0 magicka while the spell is in effect, making it impossible for him/her to cast spells.

Thanks. I had considered doing something similar, but it had the feel of a workaround, and I was hoping that maybe there was a more direct path. But this seems to be the way to go. I'll give it a shot.
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Wed Jun 20, 2012 10:07 pm

If you really want to do it through scripting, this would be the script I'd try:

Event OnEffectStart(Actor akTarget, Actor akCaster)	RegisterForAnimationEvent(akTarget, "BeginCastLeft")	RegisterForAnimationEvent(akTarget, "BeginCastRight")EndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)	GetTargetActor().InterruptCast()EndEvent

But since the NPC will still have magicka, they'll keep on trying to cast spells. Doesn't seem very immersive to have an NPC keep trying to cast when he/she is silenced.
User avatar
Kayleigh Mcneil
 
Posts: 3352
Joined: Thu Jun 29, 2006 7:32 am

Post » Thu Jun 21, 2012 2:35 am

If you really want to do it through scripting, this would be the script I'd try:

Event OnEffectStart(Actor akTarget, Actor akCaster)	RegisterForAnimationEvent(akTarget, "BeginCastLeft")	RegisterForAnimationEvent(akTarget, "BeginCastRight")EndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)	GetTargetActor().InterruptCast()EndEvent

But since the NPC will still have magicka, they'll keep on trying to cast spells. Doesn't seem very immersive to have an NPC keep trying to cast when he/she is silenced.

Good point. Thanks for the script anyway though. I'll probably go with the magicka drain suggestion, but I want to try the other one just so I know how to do it if for no other reason. ;)
User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm


Return to V - Skyrim