Jump to content

[LE] How to script 2 magic effects with different conditions and they nullify each other?


Recommended Posts

First of all, thanks for your concern and interest in this question from me :smile:

 

About my question, i'm currently trying to make 2 magic effects which are linked to a single spell, but whenever the spell is casted by the player, only one of them will be active depends on the conditions (in other words, they nullify each other). I'm going to narrate it better by writing the details here so that people will get the better idea of what i'm trying to do.

 

I'm working on a mod which gives transformation feature to the player. The transformation is triggered by casting a spell. Lets call it "Transform Spell". This spell is not an easy-to-use spell, but one with trade offs: it has negative effects to the player after he transformed back to normal. To achieve this, i made many magic effects with different effects, and two of them are quite identical but with different purposes. Lets call them Magic Effect 1 and Magic Effect 2. Magic Effect 1 is the main effect to transform the player into the transformed form. It has a specific duration and will wear off with the passing of time. Once it's been worn off, other magic effects (not Magic Effect 2) come in which triggers the negative effects i talked earlier. These 'negative' magic effects also have specific durations and will eventually wear off. The player is supposed to wait until all those negative effects worn off, then he can cast the spell again if he wants to transform again (i intentionally didn't create cooldown for this simple reason). But if he cast it nonetheless, then the Magic Effect 2 will come instead of Magic Effect 1. So yes, Magic Effect 2 is the same transformation with the Magic Effect 1, but with more severe negative effects as a consequence. This means that both magic effects are casted from a single spell, but only one of them will be activated in different conditions as i stated above. They should not be activated at the same time.

 

What i've been trying was using different keywords to each magic effects, and put some conditions in each magic effects so that one of them won't be active if the other one is active. But i'm afraid if this doesn't give me the mechanism i really want, because when i tried to cast it in the game, it didn't seem to work properly. The spell was only activated in brief seconds then suddenly worn off. I'm not sure if relying on keywords and conditions will do the trick, but please do tell me if it really does (just in case if i put it incorrectly hence it didn't work as intended).

That's why, what i'm thinking is employing a script to manage this mechanism. I just learned papyrus recently, so i don't really have enough clue on what should i write in the script to make this mechanism. So please, if anyone have the knowledge and/or idea on what should be written in the script? Any helps would be appreciated. Thanks in advance. :smile:

 

PS. The mod has been scripted in some parts and it requires SKSE, so any SKSE functions are okay to be used

Edited by qwertypol012
Link to comment
Share on other sites

Not 100% sure this will work.

 

Apply a script to the first magic effect which sets a global variable to a specific value when the effect starts.

Apply a script to the last magic effect intended to wear off before casting again and have this script re-set the global variable to your initial value when that effect ends.

 

Then use that global variable as a condition for your magic effects. Anything you want to run when normal, value should be equal to your initial value. Anything you want to run when the "cooldown" is not complete, value should be equal to the changed value. Anything you want to run under any circumstance, skip the global variable as a condition.

Link to comment
Share on other sites

What's more, the global-variable condition allows you to set up further gradations of severity, which sounds like it might be helpful. It does have a limitation in that it means you can really only have one person using the spell, but if it's intended to be player-only, that's not a big deal.

Link to comment
Share on other sites

When reading this for the first time, to be honest I was really quite confused so i decided to make a summary or easier outline of sorts. You'll see that by doing this, the problem and all possible solutions become much clearer.

 

TRANSFORM SPELL

  • Negative side effects to player after transformation
  • Done by using different magic effects, 2 most important are ME1 and ME2

ME1

  • Main effect
  • Does transformation
  • Once worn off, others take place (NOT ME2) to trigger negative effects (we'll call these NMEs)
  • Once all NMEs have worn off, player can cast spell again.
    • âIf player is stubborn and casts it anyway, activate ME2

ME2

  • Same as ME1 but with more negative side effects

ONLY ONE should be activated based on conditions. Not simultaneously.

 

Right then!

Although there are many ways of doing this, I'm just going to give the one that I find easiest, and as you've stated your a beginner at papyrus so no need for anything to challenging.

 

On a NME (only needs to be put on 1 if they all end at the same time, or perhaps the one with the longest duratiob as this marks the final end of the negative effects) make a script which looks something like this*:

 

1 global property - let's call it PlayerSufferState

OnMagicEffectStart()

PlayerSufferState.SetValue(1)

; player is experiencing negative effects now

OnMagicEffectFinish()

PlayerSufferState.SetValue(0)

; player is done experiencing effects

Then on ME1:

 

Make a condition that it will only run if PlayerSufferState is set to 0. It will of course be 0 be default.

 

Do the same on ME2 but make it so that it will only run when PlayerSufferState is equal to 1.

 

And don't forget to add a OnMagicEffectFinish() to the NMEs to make sure they only run when ME1 is finished (you can use a global for this as well)

 

Like I said previously, there are many solutions but I believe this one is the most simple and less script-y etc.

 

* Not exact papyrus! Just a guide :)

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Not 100% sure this will work.

 

Apply a script to the first magic effect which sets a global variable to a specific value when the effect starts.

Apply a script to the last magic effect intended to wear off before casting again and have this script re-set the global variable to your initial value when that effect ends.

 

Then use that global variable as a condition for your magic effects. Anything you want to run when normal, value should be equal to your initial value. Anything you want to run when the "cooldown" is not complete, value should be equal to the changed value. Anything you want to run under any circumstance, skip the global variable as a condition.

This could work. I'll try to make it. This seems like one of the most simple solutions to get it work. Thanks for the idea! :smile:

 

What's more, the global-variable condition allows you to set up further gradations of severity, which sounds like it might be helpful. It does have a limitation in that it means you can really only have one person using the spell, but if it's intended to be player-only, that's not a big deal.

I see. That actually sounds possible. Thanks for the heads up! :smile:

 

When reading this for the first time, to be honest I was really quite confused so i decided to make a summary or easier outline of sorts. You'll see that by doing this, the problem and all possible solutions become much clearer.

 

TRANSFORM SPELL

  • Negative side effects to player after transformation
  • Done by using different magic effects, 2 most important are ME1 and ME2

ME1

  • Main effect
  • Does transformation
  • Once worn off, others take place (NOT ME2) to trigger negative effects (we'll call these NMEs)
  • Once all NMEs have worn off, player can cast spell again.
    • âIf player is stubborn and casts it anyway, activate ME2

ME2

  • Same as ME1 but with more negative side effects

ONLY ONE should be activated based on conditions. Not simultaneously.

 

Right then!

Although there are many ways of doing this, I'm just going to give the one that I find easiest, and as you've stated your a beginner at papyrus so no need for anything to challenging.

 

On a NME (only needs to be put on 1 if they all end at the same time, or perhaps the one with the longest duratiob as this marks the final end of the negative effects) make a script which looks something like this*:

 

1 global property - let's call it PlayerSufferState

OnMagicEffectStart()

PlayerSufferState.SetValue(1)

; player is experiencing negative effects now

OnMagicEffectFinish()

PlayerSufferState.SetValue(0)

; player is done experiencing effects

Then on ME1:

 

Make a condition that it will only run if PlayerSufferState is set to 0. It will of course be 0 be default.

 

Do the same on ME2 but make it so that it will only run when PlayerSufferState is equal to 1.

 

And don't forget to add a OnMagicEffectFinish() to the NMEs to make sure they only run when ME1 is finished (you can use a global for this as well)

 

Like I said previously, there are many solutions but I believe this one is the most simple and less script-y etc.

 

* Not exact papyrus! Just a guide :smile:

 

Oh right, yes you just made it look more neat and easy to read. Thanks for the outline :laugh:

And yes, since i'm still a beginner, i would prefer to use the easiest solutions possible, at least for the time being. So thanks for the guide! Will try to elaborate and make it :smile:

 

I'll try to write the script and see how it is going in the game. I'll ask again if i find some problems later. :smile:

Edited by qwertypol012
Link to comment
Share on other sites

  • Recently Browsing   0 members

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