How can I make a weapon with a Proc effect?

Post » Fri Nov 16, 2012 11:11 pm

Getting back to a previous post i made id like to start over with my issue.
Im making a mod and part of it requires weapons with Proc effects. That means that the weapon has a magical effect on it that only has a small percentage chance of activating for every hit.

The issue is for these proc effects id like to use magical effects that are not normally used for weapons, this has yielded mixed results.

So here is what ive tried, a no scripting approach.

Take the magical effect and change its property to contact, that makes it pop up in the effects slider for enchantments and allows me to place it on weapons.
Back in the magical effect window i add a target condition: GetRandomPercent <= 15.000 (or whatever)

Ive tested this on chain lightning, Fire Storm and Paralyze, and im getting different results.

With Chain lightning there is no visual effect, and it seems not to work sometimes, but I think sometimes it did...

With Fire Storm (tested just to try) the visual effects are there (and awesome) but it activates for EVERY HIT no matter what I do.

Then I tried Paralyze since that one is actually designed for weapons anyway, but now its paralyzing enemies randomly INDEPENDANT OF MY HITS. In other words ill hit and enemy with my weapon, enemy gets hit but no paralyze, then as im readying my next hit (tested with a warhammer so it was slow) ill suddenly see the green effect shoot out and paralyze the enemy.
Not bad, but not what im after.


So I figure a non-scripting approach to this is not going to work, so now I need to make a script I can add to the weapons that allows this, as Im new to scripting id like some pointers how to go about doing this.

-Exo
User avatar
Stacyia
 
Posts: 3361
Joined: Mon Jul 24, 2006 12:48 am

Post » Fri Nov 16, 2012 3:13 pm

Probably something like this:

ScriptName SpellProcEnchScript Extends ActiveMagicEffectActor PlayerActor CasterObjectReference ReferenceCasterObjectReference ReferencePlayerEvent OnEffectStart(Actor akTarget, Actor akCaster)	Player = Game.GetPlayer()	ReferencePlayer = (Player as ObjectReference)	Caster = akCaster	ReferenceCaster = (Caster as ObjectReference)EndEventEvent OnHit(ObjectReference akAggressor, Form akSource)	Int Chance = Utility.RandomInt(0, 100)        ; 10% chance to proc	If Chance >= 0 && Chance <= 9		If(akSource as Spell) != None			(akSource as Spell).Cast(Caster, akAggressor)		EndIf	EndIfEndEvent
User avatar
Far'ed K.G.h.m
 
Posts: 3464
Joined: Sat Jul 14, 2007 11:03 pm

Post » Fri Nov 16, 2012 9:46 pm

U wonderful person you, i love ur face!

-Exo
User avatar
Harry Leon
 
Posts: 3381
Joined: Tue Jun 12, 2007 3:53 am

Post » Sat Nov 17, 2012 4:58 am

Ok, I'm a bit confused.

Since its ActiveMagicEffect Im assuming I need to add this script to the Magic effect the enchantment is based on, not the weapon itself?

That's all fine, but how do I add the spell to the akSource part, also can this be done if I wanted several spells?
Also, If I wanted the weapon hit to trigger a beneficial effect on the player, would that be possible?

I'm learning as I go so any help is appreciated here.

-Exo
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Sat Nov 17, 2012 4:32 am

I have been playing around with trying to get a chain lightning effect on a random hit. I managed to achieve this without the use of scripts but found no way in which to prevent the chain effect from displaying, even if the magic effect wasn't applied.

I therefore went down the route of using a small script, which was successful. I ended up creating the following objects, you can name any of the following as you see fit. This is just the naming conventions i use, so i can see all the objects in the object window by using "SBAC*Nec" in the object window filter

This is a step by step guide on how this was achieved.
Firstly, duplicate the Magic Effect ShockDamageFFAimedArea 2 times and rename the duplicated effects
to the two magic effects below.

Mfx_SBAC_NECMAS
I added the following condition to this effect

Target - Subject
Function – GetRandomPercent
Function Info - NONE
Comp - <=
Value – 9
AND


I also made some changes to some of the settings
Delivery to CONTACT
Projectile to NONE
Explosion to NONE


I then renamed the second duplicated magic effect to
MFx_SBACchain_NECMAS
I added the following optional condition to this effect. This is purely to stop the chain effect applying to non-hostile targets

Target - Subject
Function – IsHostileToActor
Function Info - Reference'PlayerRef'
Comp - ==
Value – 1
AND


Next I created a new enchantment and named it
Ench_SBAC_NECMAS

Type - Enchantment
Casting - Fire and Forget
Delivery – Contact

I then added the magic effect Mfx_SBAC_NECMAS to the enchantment, and set Magnitude to 5, Area to 0, Duration to 1

I then created a new spell and named it
Spell: SP_SBAC_NECMAS

Type - Spell
Casting - Fire and Forget
Delivery – Aimed

I then added the magic effect Mfx_SBACchain_NECMAS to the spell, and set Magnitude to 5, Area to 40, Duration to 1.

Now onto the script, open up the first magic effect (MFx_SBAC_NECMAS) and add the following script


Spoiler
Scriptname SBAC_NECMAS extends activemagiceffect  {Causes a chain lightning effect to be cast from the target which has just been hit}Actor Property Target Auto HiddenMagicEffect Property Mfx_SBAC_NECMAS AutoSpell Property SP_SBAC_NECMAS AutoEvent OnEffectStart (Actor akCaster, Actor akTarget)Target = GetTargetActor()	if Target.HasMagicEffect(Mfx_SBAC_NECMAS)		SP_SBAC_NECMAS.cast(Target)	endif		EndEvent  

If you used the exact naming conventions i used, then you can auto-fill the properties, otherwise you will have to manually fill them.

Lastly, place the enchantment Ench_SBAC_NECMAS, on the melee weapon of your choice. Test in game, if everything is set correctly, you should have a 10% chance of chain lightning being cast
User avatar
Princess Johnson
 
Posts: 3435
Joined: Wed Feb 07, 2007 5:44 pm

Post » Sat Nov 17, 2012 3:32 am

Thanks a lot for sharing this.
Did u test this? Are u confident u re getting 10% chain lightnings on hits?

-Exo
User avatar
biiibi
 
Posts: 3384
Joined: Sun Apr 08, 2007 4:39 am

Post » Fri Nov 16, 2012 11:53 pm

I tested it, i didn't count how many occurences of chain lightning i was getting. I originally tested with a 50% chance, then dropped the number for a 10% chance, and there was a noticeable decrease in the ocurrences.
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Sat Nov 17, 2012 3:34 am

Then there is something wrong om my end, im getting the same issue I had using GetRandomPercent the first time, every hit is a chain lightning. Not sure if its just animation or damage as well though.
I started the companion questline where u have to fight Vilkas in the yard to prove ur mettle. Well whenever id hit him he would tell me that spells where not allowed. Thats fair enough, probably due to how the script casts a spell on top of the effect, no worries.
But the issue was it would happen with EVERY hit no matter what.

As I said, this is the same issue I had originally with GetRandomPercent leading me to believe it works differently then you and I assumed.


-Exo
User avatar
joseluis perez
 
Posts: 3507
Joined: Thu Nov 22, 2007 7:51 am

Post » Sat Nov 17, 2012 5:38 am

Heilghast: That was a pretty confusing explanation. He could just add a target condition on whatever spell effect he wants with "GetRandomPercent":
http://www.creationkit.com/GetRandomPercent
Example: If you want it to activate 20% of the time, set the condition to:
GetRandomPercent <= 20

Also, I have something to say about conditions: The thing about them that "svcks" is that if they change before the effect duration ends, the effect is applied again until it's duration is over. The effect isn't actually dispelled if the conditions aren't met, it's basically just hidden and negated. This is probably what happens when you've tried use this; the condition changes later for some reason unknown to me, and then the effect is applied for the rest of its duration.

So, Here are some scripts to do something similar:

ScriptName SpellProcEnchScript Extends ActiveMagicEffect{Attach this script to a dummy magic effect, then fill chance and spellToCast.}int property chance auto   		   ;Chance out of 100, set it in the properties dialogue on the dummy magic effect.spell property spellToCast auto		   ;Set this to the REAL spell, make it a self effect.Event OnEffectStart(Actor akTarget, Actor akCaster)		if ( Utility.RandomInt(1, 100) <= chance )			akTarget.cast(spelltoCast)		endifEndEvent

There's one problem, which is that it will always have the magnitude/duration that was set in the spellToCast spell. That may seem fine, but the problem is that if you enchant a weapon in-game with this effect, the duration and magnitude can't be changed. There's no way to get the duration and magnitude from the active effect in a magic effect script, so you can't just change those in the script. So basically it should be perfect for "pre-made" weapons in your mod, but will not really be good for in-game enchanting.

If that's is a big problem for you, here's something that MIGHT work instead, but you'll have to test it:
ScriptName SpellProcEnchScript Extends ActiveMagicEffect{Attach this script to a REAL magic effect.}int property chance autoEvent OnEffectStart(Actor akTarget, Actor akCaster)		if ( Utility.RandomInt(1, 100) > chance )			Dispel()		endifEndEvent

With this, the effect is just dispelled instantly if randomint is between chance and 100. This will probably only work on effects with a duration though, because instant effects are probably applied before the event is sent, or at least before the randomint and dispel functions can be processed. But if I'm understanding what's happening correctly, I think you're using effects with durations, so this should work.

If neither of these work for you, and you really really want it, I can try to think of a way for you to do it on instant effects and still have enchanting work properly. It would probably be somewhat complicated and hack-ish though, so I'll try in a few days if you still need it.
User avatar
X(S.a.R.a.H)X
 
Posts: 3413
Joined: Tue Feb 20, 2007 2:38 pm

Post » Fri Nov 16, 2012 10:19 pm

@SeventyFour
.He could just add a target condition on whatever spell effect he wants with "GetRandomPercent":
http://www.creationkit.com/GetRandomPercent
Example: If you want it to activate 20% of the time, set the condition to:
GetRandomPercent <= 20

I had already tried that first, however chain lightning doesn't seem to work as a weapon enchant. With the delivery changed to contact and without any conditions, so that the effect fires on every hit, only the target being attacked has the effect applied. There is never any chain effect. This would seem to be the issue Exodus had mentioned in the original post

Also, I have something to say about conditions: The thing about them that "svcks" is that if they change before the effect duration ends, the effect is applied again until it's duration is over. The effect isn't actually dispelled if the conditions aren't met, it's basically just hidden and negated. This is probably what happens when you've tried use this; the condition changes later for some reason unknown to me, and then the effect is applied for the rest of its duration.

Your explanation is here is in regards to conditions on spells, which are constanly checked every second for the duration.
Conditions on magic effects are checked once, at the time the effect is to be applied. If the conditions are not met, the effect is never applied. This is clearly seen in game through the notification in the top left hand corner of the screen, "x resisted y" where x is the target name and y is the effect


At Exodus - I'm not sure what is going wrong for you, however this might be something worth checking. One of the issues i had when attempting this was if the magic effect (MFx_SBAC_NECMAS) in my above post had an explosion effect such as ChainLightningMassixplosion, the explosion effect always ocurred, triggering the chain effect. This was regardless of any conditions on the magic effect.

I will re-edit my original post to see if i can make it less confusing, however i am quite happy to send you the esp along with the source script and pex.

(@SeventyFour) I'm not sure what you found confusing, in short it was
Duplicate 2 magic effects
Rename those two effects and make changes as detailed.
Create new enchantment and add the specified magic effect
Create a new spell and add the other magic.
Add the script to specified magic effect
Add the enchantment to the weapon of choice
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am

Post » Fri Nov 16, 2012 5:30 pm

Your explanation is here is in regards to conditions on spells, which are constanly checked every second for the duration.
Conditions on magic effects are checked once, at the time the effect is to be applied. If the conditions are not met, the effect is never applied. This is clearly seen in game through the notification in the top left hand corner of the screen, "x resisted y" where x is the target name and y is the effect

Oh, sorry, I had them confused I guess.
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Fri Nov 16, 2012 5:57 pm

@seventyfour: Thanks a lot for the scripts, I'm assuming I can use the first one and it will go by whatever magnitude and duration I set in the magic effect or enchantment.
That works for me, not being able to disenchant and reuse the enchantments are is a drag, but I can live with it.

@heilghast: Thanks again for the help. I dont know what to tell you, I cant make it work, I did set the Projectile and Explosion to none in Mfx_SBAC_NECMAS like you describe.

My first instinct was using slapping on RandomPercent and moving on, but as I said, its not working, I'm getting hits all the time. Tested with Chain lightning and Firestorm. The Firestorm triggers the animation for every hit, but it doesnt do any damage, I'm thinking the heilghast workaround could fix the damage issue, but I'm still stuck with a non-working RandomPercent solution.
I also tested it with Paralyze, something that is actually designed for enchantments, but still to no avail as the results I was getting was weird. (paralyze would shoot randomly, even when im not swinging)

So what I'm thinking is that RandomPercent as a Condition fires off all the time, not just on strike, meaning im bound to luck into a successful hit during any swing animation.
If ur getting a different result then I must be doing something wrong.

Still If this can be solved with a script, avoiding the need for RandomPercent that im happy with that.

-Exo
User avatar
Fanny Rouyé
 
Posts: 3316
Joined: Sun Mar 25, 2007 9:47 am

Post » Fri Nov 16, 2012 8:17 pm

@seventyfour: Thanks a lot for the scripts, I'm assuming I can use the first one and it will go by whatever magnitude and duration I set in the magic effect or enchantment.
That works for me, not being able to disenchant and reuse the enchantments are is a drag, but I can live with it.

It will go by the the duration/magnitude of whatever spell you set to be "spellToCast" in the properties dialogue. So you have to make two different magiceffects with different spells selected if you want different durations.

You can reuse it in enchantments, it's just always going to have the duration and magnitude of spellToCast.
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Fri Nov 16, 2012 5:02 pm

It will go by the the duration/magnitude of whatever spell you set to be "spellToCast" in the properties dialogue. So you have to make two different magiceffects with different spells selected if you want different durations.

You can reuse it in enchantments, it's just always going to have the duration and magnitude of spellToCast.

Right, so ur saying i make a dummy spell, a spell with nothing in it, then replace spellToCast with whatever spell I'm actually casting.
Where do I set the chance though?

-Exo
User avatar
Charleigh Anderson
 
Posts: 3398
Joined: Fri Feb 02, 2007 5:17 am

Post » Sat Nov 17, 2012 1:07 am

Right, so ur saying i make a dummy spell, a spell with nothing in it, then replace spellToCast with whatever spell I'm actually casting.
Where do I set the chance though?

-Exo

The int property chance can be filled with a number in the properties dialogue. Just type it in there.
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm


Return to V - Skyrim