RangerEdas Posted April 19, 2022 Posted April 19, 2022 I'm trying to write a script that allows a player to use a spell to add an item to their inventory based on their race and the spell has an 8 hour cooldown. I got the "add item" part already but I can't figure out how to script the cooldown part. Any help would be appreciated. Sample script: Spoiler Scriptname MySpell extends ActiveMagicEffect ;Defines the ingredients used in this script Ingredient Property DaedraHeart Auto Ingredient Property BriarHeart Auto ;Defines the races used in this script Race Property ImperialRace Auto Race Property ImperialRaceVampire Auto Race Property NordRace Auto Race Property NordRaceVampire Auto ;Defines the target actor Actor Property PlayerREF Auto Event onEffectStart(Actor akTarget, Actor akCaster) Race PlayerRace = PlayerREF.GetRace() If PlayerRace == ImperialRace || PlayerRace == ImperialRaceVampire PlayerREF.AddItem(DaedraHeart,1,true) debug.notification("Daedra Heart Added") Elseif PlayerRace == NordRace || PlayerRace == NordRaceVampire PlayerREF.AddItem(BriarHeart,1,true) debug.notification("Briar Heart Added") Endif EndEvent
Tlam99 Posted April 19, 2022 Posted April 19, 2022 Check the script of the perk avoid dead, restoration line
Seijin8 Posted April 19, 2022 Posted April 19, 2022 25 minutes ago, RangerEdas said: I'm trying to write a script that allows a player to use a spell to add an item to their inventory based on their race and the spell has an 8 hour cooldown. I got the "add item" part already but I can't figure out how to script the cooldown part. Any help would be appreciated. Sample script: Hide contents Scriptname MySpell extends ActiveMagicEffect ;Defines the ingredients used in this script Ingredient Property DaedraHeart Auto Ingredient Property BriarHeart Auto ;Defines the races used in this script Race Property ImperialRace Auto Race Property ImperialRaceVampire Auto Race Property NordRace Auto Race Property NordRaceVampire Auto ;Defines the target actor Actor Property PlayerREF Auto Event onEffectStart(Actor akTarget, Actor akCaster) Race PlayerRace = PlayerREF.GetRace() If PlayerRace == ImperialRace || PlayerRace == ImperialRaceVampire PlayerREF.AddItem(DaedraHeart,1,true) debug.notification("Daedra Heart Added") Elseif PlayerRace == NordRace || PlayerRace == NordRaceVampire PlayerREF.AddItem(BriarHeart,1,true) debug.notification("Briar Heart Added") Endif EndEvent Assuming you want to do this through script alone (not always the best, but should work fine for this), you'd ideally create two states (active/inactive) with inactive being the default state. After consuming the ingredient, the spell goes to the active state, where it either tracks time internally ("registerforsingleupdate(28800.0)") or tracks current game time and checks every x amount of time to see if that has passed. You will want a system in there for detecting sleep/wait events as well so that the system behaves appropriately. If the spell is triggered again during the "active" state, it does nothing and no ingredient is consumed. Once the active state finishes (8 hrs), it flips back to the inactive state and the spell effects terminate (either though built-in cooldown on the spell itself, or through a dispel/removespell option). Thats just top of my head, there may be more efficient ways of doing it. (Still on my first coffee).
RangerEdas Posted June 27, 2022 Author Posted June 27, 2022 On 4/19/2022 at 7:14 PM, Seijin8 said: Assuming you want to do this through script alone (not always the best, but should work fine for this), you'd ideally create two states (active/inactive) with inactive being the default state. After consuming the ingredient, the spell goes to the active state, where it either tracks time internally ("registerforsingleupdate(28800.0)") or tracks current game time and checks every x amount of time to see if that has passed. You will want a system in there for detecting sleep/wait events as well so that the system behaves appropriately. If the spell is triggered again during the "active" state, it does nothing and no ingredient is consumed. Once the active state finishes (8 hrs), it flips back to the inactive state and the spell effects terminate (either though built-in cooldown on the spell itself, or through a dispel/removespell option). Thats just top of my head, there may be more efficient ways of doing it. (Still on my first coffee). On 4/19/2022 at 7:03 PM, Tlam99 said: Check the script of the perk avoid dead, restoration line Sorry for the necro but I just wanted to say thanks for your help. I couldn't get the cooldown to work using states but using the script of the avoid dead perk worked perfectly. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now