Making additem script add just 1 item per actor.

Post » Thu Oct 23, 2014 1:55 pm

Here's the script in question... It's ALMOST perfect but has one major flaw. Rather than adding ONE potion to the inventory of a dead humanoid or dead animal you casted a spell on, it adds as many as times you casted the spell or swung the weapon. It works like this: You cast a drain life spell on an enemy, or enchant a weapon with the blood absorption enchantment, and when they die a blood potion is added to their inventory.

It's a remarkably simple script, and I was surprised it worked so well... Only one problem it produces an extra item every time you hit something with a spell or weapon, which... Is imbalanced/immersion breaking/overpowered/etc/.

Can someone please offer some advice, as to what I might add to this script to fix that dilemma?

Scriptname ALectraVampBloodExtractScript extends activemagiceffect  Potion Property akpotion AutoEvent OnEffectFinish(Actor akTarget, Actor akCaster)aktarget.Additem( akpotion, 1)EndEvent

It works great only one thing... I only want this script to add ONE blood potion to an actor after killing them. Not an additional blood potion every time they get hit by this spell. Is there something I can add to this script, which would make it ONLY add one blood potion to each actor this script adds a blood potion to, upon their death?

I'd be extremely thankful of anyone has any advice for this dilemma.

User avatar
Talitha Kukk
 
Posts: 3477
Joined: Sun Oct 08, 2006 1:14 am

Post » Thu Oct 23, 2014 1:33 pm

Hmm, perhaps some form of DoOnce. But you'd have to track a variable for each target, I presume. I'll come back to this tomorrow morning, right now I'm oretty tired and probably wouldn't think of anything efficient.
User avatar
Shianne Donato
 
Posts: 3422
Joined: Sat Aug 11, 2007 5:55 am

Post » Thu Oct 23, 2014 3:00 pm

how's...

if ( ( akTarget as Actor ).GetItemCount ( akPotion ) < 1 )

akTarget.AddItem ( akPotion, 1 )

endif

...sound...? :-D

User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Thu Oct 23, 2014 1:01 pm

I found the solution... And it isn't in the script but the conditions. I added to the Magic Effect Conditions, GetItemCount, Blood Potion=0 AND. On top of all the AND =0 Dwemer machine and all that. Now it only gives one blood potion as it should. So if anyone ever wants to make a very similar type of spell or enchantment that's how to do it I just learned tonight.

That all said, thanks everyone who responded to this thread, trying to help me find a solution to this, I appreciate it.

User avatar
Rach B
 
Posts: 3419
Joined: Thu Mar 08, 2007 11:30 am


Return to V - Skyrim