How do scripts in spell effects work?

Post » Wed Jun 20, 2012 8:24 am

I made this spell effect called Psywave (its exactly like the pokemon move, 80% chance to hit and if it does it damages you 0.5-1.5 times the player's level) but for some reason it isn't actually doing any damage. It looks okay, and does hit (my character grunts when I get hit) but it isn't actually damaging. I was hoping someone could point out a flaw in my script:
Scriptname PKPsyWaveScript extends ActiveMagicEffect import Utility    function Psywave()   int DamageBase = Utility.RandomInt(5,15)   int Damage = ((DamageBase/10) * Game.GetPlayer().GetLevel())   GetTargetActor().DamageAV("Health",Damage)endFunctionEvent OnEffectStart(Actor akTarget, Actor akCaster)  Psywave()endEvent
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Wed Jun 20, 2012 1:33 pm

Why do you feel the need to make it a function? You have the target reference already. akTarget.

Scriptname PKPsyWaveScript extends ActiveMagicEffectimport UtilityEvent OnEffectStart(Actor akTarget, Actor akCaster)   int DamageBase = Utility.RandomInt(5,15)   int Damage = ((DamageBase/10) * Game.GetPlayer().GetLevel())   akTarget.DamageAV("Health",Damage)endEvent

Also, what level are you testing this at?
And you don't need to import 'Utility' if your going to prefix the random command with it.
Another thing you can do is put a message box in there just to make sure the effect is even running. Otherwise you may have a setup issue instead.
User avatar
Luna Lovegood
 
Posts: 3325
Joined: Thu Sep 14, 2006 6:45 pm

Post » Wed Jun 20, 2012 9:32 am

Why do you feel the need to make it a function? You have the target reference already. akTarget.

Scriptname PKPsyWaveScript extends ActiveMagicEffectimport UtilityEvent OnEffectStart(Actor akTarget, Actor akCaster)   int DamageBase = Utility.RandomInt(5,15)   int Damage = ((DamageBase/10) * Game.GetPlayer().GetLevel())   akTarget.DamageAV("Health",Damage)endEvent

Also, what level are you testing this at?
And you don't need to import 'Utility' if your going to prefix the random command with it.
Another thing you can do is put a message box in there just to make sure the effect is even running. Otherwise you may have a setup issue instead.

Thanks for all the suggestions. Yeah, I had it in a function just out of habit. It's how I structure things usually, the events just run functions.
User avatar
Lily Evans
 
Posts: 3401
Joined: Thu Aug 31, 2006 11:10 am

Post » Wed Jun 20, 2012 12:25 pm

Hmmm. It seems to become really rarely effective when I put the GetRandomPercent <= 80 condition on there. I wonder if maybe it should be == 80 instead?
User avatar
Robyn Howlett
 
Posts: 3332
Joined: Wed Aug 23, 2006 9:01 pm

Post » Wed Jun 20, 2012 5:20 am

A percent is between 0.0 and 1.0 isnt it? Try this:

if RandomInt(1,100) <= 80

and if you have int values for your 0 or 1, not 0.5 to 1.5 - remember, Int has no decimal. if you want decimals, use float.
User avatar
Steve Fallon
 
Posts: 3503
Joined: Thu Aug 23, 2007 12:29 am

Post » Wed Jun 20, 2012 5:31 am

A percent is between 0.0 and 1.0 isnt it? Try this:

if RandomInt(1,100) <= 80

and if you have int values for your 0 or 1, not 0.5 to 1.5 - remember, Int has no decimal. if you want decimals, use float.

I'm talking about a condition, in which case you use the condition GetRandomPercent
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am

Post » Wed Jun 20, 2012 2:26 am

I'm talking about a condition, in which case you use the condition GetRandomPercent

Well DamageBase is still going to be 0 or 1...and DamageBase/10 will always be 0

And anything times 0 is 0.
User avatar
AnDres MeZa
 
Posts: 3349
Joined: Thu Aug 16, 2007 1:39 pm

Post » Wed Jun 20, 2012 6:03 am

Right, I need a float. Thanks.
User avatar
Fanny Rouyé
 
Posts: 3316
Joined: Sun Mar 25, 2007 9:47 am

Post » Wed Jun 20, 2012 12:35 pm

I feel my question is also relevant here, how do I go about stopping certain effects from firing in a spell if their conditions are no longer valid? I have a spell that changes effects per set of levels and base health (will include stam/magicka soon) but after I past the levels the effects still fire


for example the effect -invinsibility- in the spell is set to start at levels 10-15 and Paralyze 15-20. I get my char into a fight all the effects play >_>. I tried setting them to AND & OR in the spells effect list but to no avail. these spells are auto triggered not casted. anyhelp? no matter what level my char is the effects play outside their params
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Wed Jun 20, 2012 5:12 pm

I feel my question is also relevant here, how do I go about stopping certain effects from firing in a spell if their conditions are no longer valid? I have a spell that changes effects per set of levels and base health (will include stam/magicka soon) but after I past the levels the effects still fire


for example the effect -invinsibility- in the spell is set to start at levels 10-15 and Paralyze 15-20. I get my char into a fight all the effects play >_>. I tried setting them to AND & OR in the spells effect list but to no avail. these spells are auto triggered not casted. anyhelp? no matter what level my char is the effects play outside their params

How exactly do you "trigger" the effects?
Could be a problem with the effects not wearing off due to not having a duration (if they are like abilities). If the Trigger has the condition, it should work.
Have you set the conditions to "Target" or to "Subject"? It seems that with regard to spell effects, "Target" and "Subject" are switched, with "Target" being the Caster and "Subject" the target of the effect.

A (kind of) related question: Is it possible to fire a magic effect directly from a script? Right now what I am doing is having the "in-game" Spell trigger a script effect, which then fires another invisible spell if the conditions are met. But that kinda seems redundant.
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Wed Jun 20, 2012 4:49 pm

for mine all the effects have a duration, to trigger the effects I use a stripped down version of konahriks privilage script(dragonpriestmaskultra). one spell has a series of effects tied to conditions, I've kept it simple and made two of those spells with 3 effects each and varying conditions and they are tied together into one spell via Script. the script itself isn't the problem, its the stupid effects not obeying the conditions. they are set to effect the player, and I did not check the "switch Target and Subject" box :(

any ideas?
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am

Post » Wed Jun 20, 2012 12:36 pm

for mine all the effects have a duration, to trigger the effects I use a stripped down version of konahriks privilage script(dragonpriestmaskultra). one spell has a series of effects tied to conditions, I've kept it simple and made two of those spells with 3 effects each and varying conditions and they are tied together into one spell via Script. the script itself isn't the problem, its the stupid effects not obeying the conditions. they are set to effect the player, and I did not check the "switch Target and Subject" box :(

any ideas?

Um, there is no "switch target and subject" box. They are just switched. If your conditions are there specifically to END the effect, then this could be the problem. For some reason, "Target" is actually the caster, while "Subject" is the target of a spell effect. At least that is the case for e.g. the Stagger effect on Destruction spells.
User avatar
ladyflames
 
Posts: 3355
Joined: Sat Nov 25, 2006 9:45 am

Post » Wed Jun 20, 2012 4:41 pm

In Spell > Effects >Effect Item, there is a tick box that says switch Subject and Target, I thought this was what you mean. If you're talking about the script, I'll take a second look but as far as I am aware Konahrik's privilage only works on the caster.

The Condtitions in the spells effects, not the script :ohmy:, are getlevel conditions. my issue is no matter what the range I set, the spell effects stil trigger at the levels they should not.

and this is the portion of the script that handle's who's who

Spoiler

EVENT OnEffectStart(Actor Target, Actor Caster)

selfRef = caster

endEVENT
 
EVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
User avatar
noa zarfati
 
Posts: 3410
Joined: Sun Apr 15, 2007 5:54 am

Post » Wed Jun 20, 2012 3:30 am

In Spell > Effects >Effect Item, there is a tick box that says switch Subject and Target, I thought this was what you mean. If you're talking about the script, I'll take a second look but as far as I am aware Konahrik's privilage only works on the caster.

The Condtitions in the spells effects, not the script :ohmy:, are getlevel conditions. my issue is no matter what the range I set, the spell effects stil trigger at the levels they should not.

and this is the portion of the script that handle's who's who

Spoiler

EVENT OnEffectStart(Actor Target, Actor Caster)

selfRef = caster

endEVENT
 
EVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

Should the conditions be based on the caster or the target?
I am not sure, but it might be that the spells fired from a script ignore caster conditions. You can make anyone cast a master level spell via script, after all.
In that case, you could just script the conditions in.
And you should really check whether the conditions in your spell are "subject" or "Target" conditions and try switching them around, in case you have not done so yet.
User avatar
Kayla Bee
 
Posts: 3349
Joined: Fri Aug 24, 2007 5:34 pm

Post » Wed Jun 20, 2012 5:00 pm

Like pretty much all my little tiffles so far in this mod, my issue came from NOT PAYING ATTENTION, sigh..these are noobish mistakes I swear. the issue was in the conditions, the Highest level was <= (less than or equal too) and the Lowest was >= , that was the problem, don't know why but changing it to simply greater than fixed everything, tested it out and the Tiers fire perfectly. Thanks for the consideration and patience :biggrin:

the conditions were on caster, and making the appropriate adjustments fixed it :D
User avatar
Khamaji Taylor
 
Posts: 3437
Joined: Sun Jul 29, 2007 6:15 am


Return to V - Skyrim