Jump to content

Recommended Posts

I wanted to make some spells that would not cost magicka or cast at all if the crosshairs aren't over a non-dead actor.
I wanted to reference the telekinesis spell for this feature but for the life of me I cannot find it!

Also how can I enable a spell to be used for an item enchant. For instance, the game disables Reflect Magic from the Enchanting menu, you can only make potions. I would love to be able to unlock that feature, without having to close my game, jump into CS and create custom clothing. I cannot find an answer anywhere.

Link to comment
Share on other sites

Thank you!
Now how can I cancel a cast, for instance I cast my spell on a target & he already has a debuff? I want to check the target for said debuff and cancel if he has it. So as to prevent certain spells from stacking.

 

Do I use GetActiveEffectCodes? How do I know the effect code of my custom effect?

Link to comment
Share on other sites

If IsMagicEffectOnTargetAllowed == 0
return
If IsMagicEffectOnTargetAllowed == 1
set IsMagicEffectOnTargetAllowedC == 0
Endif

Perhaps something similar to this?

 

Or will recasting the spell just automatically refresh the duration of my spell? lol obviously I haven't begun play testing just yet...

Edited by freemodspls
Link to comment
Share on other sites

Sorry for the spam, I THINK that I got it so here is my current script with use of IsSpellTarget. What I'm not sure of is:
Am I using the right MagicID? I intend to use this Magic Effect script for multiple Tiers of spells so I hope that even though those spells are different names they use the same Effect aka MagicID?

scn xoSnapFlame

ref Target

short Magnitude
short Duration
short SpellCost
short Damage
short InitialHealth
short RemainingHealth
short Courage
short Hope
short Timesince
short Timer
short TPercent

Begin ScriptEffectStart
	set Target to GetCrosshairRef
If Target.IsActor == 0
	Return
EndIf
If Target.IsSpellTarget xoSnapFlame == 0 
	Return
Endif
Set InitialHealth to Target.GetAV Health
Set Courage to Target.GetAV Confidence
Set RemainingHealth to (Target.GetAV Health) - Magnitude * (100 - GetAV ResistFire)/200 * (Duration * 2 / Duration)
If Target.GetAV Health == Target.GetBaseAV Health && RemainingHealth <= InitialHealth * .1
Target.ForceAV Confidence 0
Set Hope to 0
else
Set Hope to 1
Endif
If RemainingHealth <= 0
Target.ForceAV Confidence 0
Endif
Set Magnitude to xoSpellBookQuest.SnapFlameMag
Set Duration to xoSpellBookQuest.SnapFlameDur
Set SpellCost to (1.4 - 0.012 * Player.GetAV Destruction) * xoSpellBookQuest.SnapFlameCost
End

Begin ScriptEffectUpdate
If Target.IsActor == 0
	Return
EndIf
Set Timesince to Timesince + GetSecondsPassed
if Timesince < .5
Return
Endif
Set Timer to Timer + Timesince
Set Timesince to 0
Set TPercent to Timer * 2 / Duration
Set Damage to Magnitude * (100 - GetAV ResistFire) / 200 * TPercent
Set Damage to -Damage
Target.ModAV2 Health Damage
End


Begin ScriptEffectFinish
If (Target.GetAV Health > Target.GetBaseAV Health * .1) && Hope == 0 || Target.GetAV Health != 0
Target.ForceAV Confidence Courage
Endif
End

 

Link to comment
Share on other sites

I'm not sure I understand the question, what is "MagicID" and where do you use it?

 

Regarding the script you posted:

1.) I'm assuming "Target" is supposed to be the actor spell is cast on? Replace "set Target to GetCrosshairRef" with "set Target to GetSelf"

Also, storing spell target in ref variable is actually not needed - you can run commands like "GetAV" in magic effect script without specified reference and it'll default to spell target.

 

2.) You may want to read this article I wrote and include the code from there

 

3.) For variables related to time (you seem to have 2 of those) use "float" type instead of "short"

 

4.) Don't use ForceAV command, the wiki page explains why.

 

5.) It seems to me that "If Target.IsSpellTarget xoSnapFlame == 0" will never be true in this context, what's the point if this condition?

Link to comment
Share on other sites

Hello qwertyasdfgh thank you for the response!

I'm not really sure what MagicID is either! I pulled it from this page of the wiki for the IsSpellTarget function.
1) I run "set Target to GetCrosshairRef" purely because that was what was recommended to me in the first response above, and elsewhere... I suppose the lines are interchangeable? I'm not really sure what difference it makes except I want to be positive I can cancel the spell effect as long as Target.IsActor == 0.

Thanks for the tip about storing the target ref too, that's good to know.

 

2) That article is pretty confusing as a novice, essentially using your script for every unique magic effect script will prevent my save files from corrupting? Is it necessary if I'm not using OBME? Or should I just to be compatible with other mods incase other users want to play my mod?

 

3) Sounds like solid advice.

 

4) & the ForceAV command was intentional, my logic was that if I used ForceAV I could override any other effect that would boost the targets Confidence such as spells/potions/enchantments. But I suppose I could ModAV -1000? or would that just lock it to 0?

 

5) That string I think was supposed to actually be "If Target.IsSpellTarget xoSnapFlame == 1". Basically I want to completely halt the script if the Target already has the spell debuff in effect.

 

I appreciate your input!

Link to comment
Share on other sites

Oh, for that function "magicID" is just and EditorID of your spell. Re-reading your initial question, no - different spells will have different IDs.

 

1.) I suspect it was recommended to you because people didn't fully understand your intentions. GetCrosshairRef will return the reference to an object currently under player's crosshair, but only if it's within the range to be normally activated.

GetSelf in the context of magic effect script will just return the reference to the target that was hit by the spell.

 

2.) Yeah, it mostly for compatibility. If you don't intend to share your mod publicly, and is absolutely certain you'll never want to install Magic Extender, I suppose you don't need it.

But I don't really see the harm in including it, especially since you already have the check to stop a script if it hits a non-actor.

 

4.) The danger of using ForceAV is potential interaction with other mods. If you're not worried about that, you can continue using it.

 

5.) With "If Target.IsSpellTarget xoSnapFlame == 1" your script will never run past that line, because the target is already being affected by that spell.

Link to comment
Share on other sites

Okay I figured out the magicID haha I actually ended up needing OBME, it was exactly what I needed so thank you for pointing me in that direction!

 

In regards to using GetSelf vs GetCrossHairRef

I think I need to use GetCrossHairRef because my spell is not a projectile. I want it to be instantaneous on my target regardless of range. Ontop of that I want them to visibly catch on fire & I think I either need to use a fire magic effect on my spell or use Addflames?

 

However, here is another spell I put together with OBME, for the sake of clarity, it SHOULD function to toggle the spell effect on the player whenever the spell is cast whilst the effect is active. The solution I needed was ref.Dispel MagicID. And of course I needed OBME to in order to create my own Magic Effect.

 

 

 

scn xoReboundHarmScript
short InitMag
short CostpTick
short NegCpT
short MagSpent
short Duration
float RHtimesince
float RHtimer
short index

Begin ScriptEffectStart
set index to GetScriptActiveEffectIndex
If IsActor == 0
DispelNthActiveEffect index
return
endif
If HasMagicEffect REBO == 1
Player.Dispel xoReboundHarm
endif
Set InitMag to GetAV Magicka
Set Duration to 1 ;WIP
Set CostpTick to 1 ;Cost = BaseCost * (1.4 - 0.012 * Skill)
Set NegCpT to -CostpTick
Cast xoReboundHarm Player
End

Begin ScriptEffectUpdate
If HasMagicEffect REBO == 0
return
elseif GetAV Magicka < CostpTick || MagSpent >= InitMag || RHtimer >= Duration
Player.Dispel xoReboundHarm
endif
Set RHtimer to RHtimer + GetSecondsPassed
if RHtimesince < .5
return
Endif
Set RHtimer to RHtimer  + RHtimesince
Set RHtimesince to 0
ModAV Magicka NegCpT
Set MagSpent to MagSpent + CostpTick
End 

 

 

 

 

Link to comment
Share on other sites

When you say it's not a projectile, do you mean it's only available on touch range? Even if that's true, there's no benefit in using GetCrosshairRef. GetSelf will always reliably return the spell target + it's actually a faster function.

 

As for the second script, the "Cast xoReboundHarm Player" command seems very weird to me? What are you trying to do?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...