Magic Effect: Add duration time, instead of stacking

Post » Wed Jun 20, 2012 10:26 am

Hi, i noticed that if you apply 2 times the same effect with a duration, u will have 2 instances running in parallel.
If you add a keyword and select "Dispel effects with these keywords", the new one will dispel the old one (like a refresh)

Is there a way, when re-apply the same effect, to add "Duration" to the old effect, intead of adding an instance of that?
User avatar
El Khatiri
 
Posts: 3568
Joined: Sat Sep 01, 2007 2:43 am

Post » Wed Jun 20, 2012 10:47 am

I don't think this is possible, because magic effect durations are not accessible by script (and thus, you can't perform math operations on them). You could potentially cheese it a little and create several "tiers" of the effect with different maximum durations, and apply the next one up in the list when recasting the spell before the duration is complete.
User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm

Post » Wed Jun 20, 2012 10:02 am

i was hoping for a checkbox hidden somewhere :D
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Wed Jun 20, 2012 8:33 am

My magiceffects don't stack - if I cast the same spell twice it cancels the original MGEF and creates a new instance of the script.
User avatar
Roy Harris
 
Posts: 3463
Joined: Tue Sep 11, 2007 8:58 pm

Post » Wed Jun 20, 2012 12:48 pm

Sry i dind't specified that i wa talking about effects without scripts assigned.
But good to know skyrim behavior with ActiveMagicEffects ;)
User avatar
Laura Cartwright
 
Posts: 3483
Joined: Mon Sep 25, 2006 6:12 pm

Post » Wed Jun 20, 2012 8:35 am

You can do it with scripts, but its requires global variables and processing power eating loops and stuff.
User avatar
[ becca ]
 
Posts: 3514
Joined: Wed Jun 21, 2006 12:59 pm

Post » Wed Jun 20, 2012 8:47 pm

My magiceffects don't stack - if I cast the same spell twice it cancels the original MGEF and creates a new instance of the script.

AFAIK this only applies to certain spell effects.

I.E. I can get my SpeedMult magic effects to "stack", in the sense that I can have 4 different speedmults going that both add 20% speed to my character, for a total of 80% for four different items equipped. They all use the same magic effect too, though I have a seperate "spell" for each piece.
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Wed Jun 20, 2012 3:28 pm

Hi, i noticed that if you apply 2 times the same effect with a duration, u will have 2 instances running in parallel.
If you add a keyword and select "Dispel effects with these keywords", the new one will dispel the old one (like a refresh)

Is there a way, when re-apply the same effect, to add "Duration" to the old effect, intead of adding an instance of that?
Off the top of my head:

Peak value modifier prevents stacking but it refreshes.

Value modifier causes stacking.

Creating timers is a different story and I'm not the one to tell how you do this(but I have a way through script to disable spellcasting a PVM until the effect is completly worn off, however there's no guarant-freaking-tee that InterruptCast() or HasMagicEffect will let me do this /rant. Even so, this isn't what you're wanting to accomplish).
User avatar
Gracie Dugdale
 
Posts: 3397
Joined: Wed Jun 14, 2006 11:02 pm

Post » Wed Jun 20, 2012 7:19 am

You can do it with scripts, but its requires global variables and processing power eating loops and stuff.

No, you can't. I'd love to be proven wrong on this, but from what I've seen, http://www.creationkit.com/ActiveMagicEffect_Script that uses the duration of an ActiveMagicEffect as a parameter, nor is there a function to return that value. If I can't return it, that means that I don't know what it is in my script.

What others have suggested (and this may have been what you meant), managing the duration exclusively through a script, is completely doable, but then you're not actually using the duration mechanic as found in the game (the UI would not be able to display it through the conventional means). And if the OP thinks that this is acceptable for is application, then that would be the route to go.
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm

Post » Wed Jun 20, 2012 12:58 pm

Actually, it's pretty simple with scripting. How simple depends on what to affect. So, what do you want to change,Mastrocane?
User avatar
meghan lock
 
Posts: 3451
Joined: Thu Jan 11, 2007 10:26 pm

Post » Wed Jun 20, 2012 9:04 pm

I'm working on negative effects of raw food, so something like malus on stamina, health and magicka regen rates.
It was just a detail, refreshing is acceptable. The problem now is that i was wrong in the first post and "Dispel effects with these keywords" checkbox, seems not to work as i was expecting (like a refresh). Effects with same keyword stacks and don't dispel each other. What is the right procedure? Peak Value Modifier?
User avatar
Susan Elizabeth
 
Posts: 3420
Joined: Sat Oct 21, 2006 4:35 pm

Post » Wed Jun 20, 2012 4:04 pm

No, you can't. I'd love to be proven wrong on this, but from what I've seen, http://www.creationkit.com/ActiveMagicEffect_Script that uses the duration of an ActiveMagicEffect as a parameter, nor is there a function to return that value. If I can't return it, that means that I don't know what it is in my script.

What others have suggested (and this may have been what you meant), managing the duration exclusively through a script, is completely doable, but then you're not actually using the duration mechanic as found in the game (the UI would not be able to display it through the conventional means). And if the OP thinks that this is acceptable for is application, then that would be the route to go.

That is what I meant, managing the duration through the script. Giving the effect in the spell a duration of 999days, then inside the script using dispel() to get rid of it prematurely (at the intended duration). And using a global variable to store the time remaining, so that on a recast, you set the duration to your base time plus the float in the global variable and then remove the previous effect. May also require a quest script to keep track of all the effects so that you can get the reference of the previous effect to remove it.

You can get the time elapsed by simple doing

Float Property Interval Auto
GlobalVariable Property GlobalVar Auto

Event OnEffectStart()
RegisterForSingleUpdate(Interval)
Float ElapsedTime = 0.0
EndEvent

Event OnUpdate()
RegisterForSingleUpdare(Interval)
ElapsedTime += Interval
GlobalVar.Set(ElapsedTime)
If (GlobalVar.Get() <= 0.0)
GlobalVar.Set(0.0)
Dispel()
EndIf
EndEvent

Event OnEffectFinish()
UnregisterForUpdate()
EndEvent



Of course, that wont be exactly precise, you would probably need to use something to get the time at the start of the effect and then get the time again during each onupdate and compare it to be more precise. You will also run into problems if you cast the spell on a different target before the spell runs out, if it is a targetted spell that isn't just going to be on the player. Then of course, you need a way to get the old magic effect and get rid of it when recasting. You could probably do a lot of this through a quest script with reference alias's, but its going to be a lot of work to get it working this way properly because I would imagine you would need to set up quite a few alias's and global variables to accommodate casting it on many targets successively.
User avatar
Shelby McDonald
 
Posts: 3497
Joined: Sat Jan 13, 2007 2:29 pm

Post » Wed Jun 20, 2012 9:27 pm

An alternative is to add a Condition, like "GetQuestVariable", on the spell that will apply the magic effects (not on the magic effect himself), so during the 999day of duration, the spell will be active only when the condition is valid (it's checked every second by the game). But i was searching for something simple, so a refresh is a good compromise :)
User avatar
Sierra Ritsuka
 
Posts: 3506
Joined: Mon Dec 11, 2006 7:56 am

Post » Wed Jun 20, 2012 6:40 pm

I thought of something along the lines of ...

Prolong-able Disease:
Spoiler
scriptname XsProlongableDisease extends ActiveMagicEffect;////////////////////////////////////////////////////////////////////////////// Imports/////////////////////////////////////////////////////////////////////////////;import Utility;////////////////////////////////////////////////////////////////////////////// Properties/////////////////////////////////////////////////////////////////////////////;XsProlongableDiseaseHistory property History autofloat property Duration autofloat property ExpiresAt auto hidden;////////////////////////////////////////////////////////////////////////////// Events/////////////////////////////////////////////////////////////////////////////;event OnEffectStart(Actor target, Actor caster)	float actualDuration = Duration	XsProlongableDisease prev = History.Register(self)	if (prev)		actualDuration += prev.GetRemainingDuration()		prev.Dispel()	endif	ExpiresAt = GetCurrentRealTime() + actualDuration	RegisterForSingleUpdate(actualDuration)endeventevent OnUpdate()	Dispel()endevent;////////////////////////////////////////////////////////////////////////////// Functions/////////////////////////////////////////////////////////////////////////////;float function GetRemainingDuration()	float remaining = ExpiresAt - GetCurrentRealTime()	if (remaining > 0.0)		return remaining	endif	return 0.0endfunction

Prolong-able Disease History:
Spoiler
scriptname XsProlongableDiseaseHistory extends Quest;////////////////////////////////////////////////////////////////////////////// Properties/////////////////////////////////////////////////////////////////////////////;XsProlongableDisease property LastDisease auto;////////////////////////////////////////////////////////////////////////////// Functions/////////////////////////////////////////////////////////////////////////////;XsProlongableDisease function Register(XsProlongableDisease disease)	XsProlongableDisease prev = LastDisease	LastDisease = disease	return prevendfunction

I used GetCurrentRealTime, but you might to use GetCurrentGameTime instead. Anyway the basic pattern, is pretty simple.
You could easily add other diseases to the history and differentiate between them using GetBaseObject and keywords. That would allow you to have different disease (spells) prolong the same symptoms (magic effects).

Edit: Maybe I should mention, diseases should be permanent, no weird 999days thing, the script will remove the effect.
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm


Return to V - Skyrim