Adding a timed debuff via script.

Post » Mon Nov 16, 2015 12:36 pm

I'm working on a small personal mod for RP purposes where a character can cast a spell to consume magicka and create a custom soul gem out of it. As of right now I have the mod working perfectly. The player can cast a spell causing a menu to show up. Depending on the player's enchanting level a certain number of options show up and each option gives you the appropriate gem.

My problem is that I want to add a custom debuff to each choice. First off I want the spell to consume a certain amount of your magicka depending on what choice you pick except cancel. So picking the Petty version would consume 100 magicka while picking Grand might consume 500 magicka. Second I want a timed debuff put on the player that makes the magicka regen reduced to 0% or 10% (I haven't decided which, but want to add this just so this spell can't be abused in case I release it to the public. I am currently wanting to set it to 0% to stop all regen for the timed debuff.) This timed debuff's duration would change depending on what choice you picked. So picking Petty might make the debuff last a few minutes while picking Grand might make it last a couple of hours.

If I could get any assistance on these I would greatly appreciate it.

Here is my code.

Spoiler
Scriptname CreateEssenceGem extends activemagiceffectMessage Property EssenceMenu0 AutoMessage Property EssenceMenu20 AutoMessage Property EssenceMenu40 AutoMessage Property EssenceMenu60 AutoMessage Property EssenceMenu80 AutoSoulGem Property Petty_Essence_Gem AutoSoulGem Property Lesser_Essence_Gem AutoSoulGem Property Common_Essence_Gem AutoSoulGem Property Greater_Essence_Gem AutoSoulGem Property Grand_Essence_Gem AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)    Menu()EndEventFunction Menu(Int aiButton = 0)    Float EnchantLevel = game.getPlayer().getAV("Enchanting")    If EnchantLevel >= 80        aiButton = EssenceMenu80.show()        If aiButton == 0            Game.GetPlayer().Additem(Petty_Essence_Gem,1,False)        ElseIf aiButton == 1            Game.GetPlayer().Additem(Lesser_Essence_Gem,1,False)        ElseIf aiButton == 2            Game.GetPlayer().Additem(Common_Essence_Gem,1,False)        ElseIf aiButton == 3            Game.GetPlayer().Additem(Greater_Essence_Gem,1,False)        ElseIf aiButton ==4            Game.GetPlayer().Additem(Grand_Essence_Gem,1,False)        ElseIf aiButton == 5        EndIf    ElseIf  EnchantLevel >= 60        aiButton = EssenceMenu60.show()        If aiButton == 0            Game.GetPlayer().Additem(Petty_Essence_Gem,1,False)        ElseIf aiButton == 1            Game.GetPlayer().Additem(Lesser_Essence_Gem,1,False)        ElseIf aiButton == 2            Game.GetPlayer().Additem(Common_Essence_Gem,1,False)        ElseIf aiButton == 3            Game.GetPlayer().Additem(Greater_Essence_Gem,1,False)        ElseIf aiButton ==4        EndIf    ElseIf EnchantLevel >= 40        aiButton = EssenceMenu40.show()        If aiButton == 0            Game.GetPlayer().Additem(Petty_Essence_Gem,1,False)        ElseIf aiButton == 1            Game.GetPlayer().Additem(Lesser_Essence_Gem,1,False)        ElseIf aiButton == 2            Game.GetPlayer().Additem(Common_Essence_Gem,1,False)        ElseIf aiButton == 3        EndIf    ElseIf EnchantLevel >= 20        aiButton = EssenceMenu20.show()        If aiButton == 0            Game.GetPlayer().Additem(Petty_Essence_Gem,1,False)        ElseIf aiButton == 1            Game.GetPlayer().Additem(Lesser_Essence_Gem,1,False)        ElseIf aiButton == 2        EndIf    ElseIf EnchantLevel >= 0        aiButton = EssenceMenu0.show()        If aiButton == 0            Game.GetPlayer().Additem(Petty_Essence_Gem,1,False)        ElseIf aiButton == 1        EndIf    EndIf

User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Mon Nov 16, 2015 12:13 am

Can you not just do it as another spell effect? Damage actor value and set the duration accordingly.

User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Mon Nov 16, 2015 4:54 am

That is what I am trying to figure out sorta, still new to the creation kit haha. You can only give a duration to a magic effect if you cast it through a spell can't you?

User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Mon Nov 16, 2015 8:25 am

There's a few ways to do it.

One way might be to attach the effect to an ability. You can add that as a spell and it automatically takes effect. Add the ability-spell through a script attached to magic effect of the primary spell, and in the ability script set a timer to remove the effect after so many game hours have passed.

There's probably easier ways to do it, but that should work.

User avatar
gandalf
 
Posts: 3400
Joined: Wed Feb 21, 2007 6:57 pm

Post » Sun Nov 15, 2015 10:06 pm

Would setting the time of the debuff via script show the time in the player's perk window? That is the big thing I am wanting.

User avatar
Tanya Parra
 
Posts: 3435
Joined: Fri Jul 28, 2006 5:15 am

Post » Mon Nov 16, 2015 11:35 am

Nope. You could show the time in the ability tab of the spell menu though. Although even then it would be the total time rather than a "time remaining" display. If you want that, best bet is to ether to use a notification message or else set up an MCM screen.

If you wanted, you could hide the debuff ability and add another one with the same name that cast a spell to display the notification message, which sounds more complicated than it is. Even so, I'd be tempted to popup a notification every so often telling the player how long they had left.

User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am

Post » Mon Nov 16, 2015 11:46 am

Sorry, still a little new to this. If I wanted to fix it so it had a countdown then in the ability window like if you casted a mage armor spell on yourself how would I apply that? I would love to get that timer feature added, and maybe after that add to it so the spell grays out until the debuff's timer counts all the way down. Thanks for the replies on this.

I have a bad habit of trying to get in over my head with projects like these.

User avatar
Eve Booker
 
Posts: 3300
Joined: Thu Jul 20, 2006 7:53 pm

Post » Mon Nov 16, 2015 1:26 am

Well, usually you'd do that sort of thin with text substitution. The trouble is that it only works in a few places, and I don't think spell effect descriptions is one of them

So if you really wanted a countdown in the spell window, you'd need a separate spell for each duration: For instance, say you had a hour long debuff - you could have six spells each with 10 minutes duration. The first one would say "one hour to go" and when it expired it would chain the next one which would say "50 minutes to go" and so on. But getting any sort of fine details is going to need a lot of spells - probably more than is practical.

If it was me, I'd use a timed notification message and substitute the time remaining into the message. That way you're playing to the engine's strengths.

User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am


Return to V - Skyrim