Adding Spells on Startup

Post » Sun Jun 17, 2012 11:36 pm

Playing around with the scripting / Questing i found this solution, not sure if there is a better way of doing this but i thought i post it incase anyone was looking for such thing

Creating a Dummy Quest

ID: AA_GiveSpellsQuest (Name this as you wish)
Quest Name: Give Spells
Type: None
Priority: 80
Event: None
Run Once

Scripts-> Attach Script -> Add Properties (Spells you wish to include)
The Script checks to see if you already have the spell located in your player spell inventory, if you do then have the spell it will skip otherwise it will add it to the player

Scriptname AA_GiveSpells  extends QuestSpell Property AASpellOne Auto Spell Property AASpellTwo Auto Spell Property AASpellThree Auto EVENT OnInit()    Actor player = Game.GetPlayer()if !player.HasSpell(AASpellOne)  player.AddSpell(AASpellOne)EndIfif !player.HasSpell(AASpellTwo)  player.AddSpell(AASpellTwo)EndIfif !player.HasSpell(AASpellThree)  player.AddSpell(AASpellThree)EndIfEndEvent
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Mon Jun 18, 2012 3:48 am

wait: does this auto-give you a quest that gives you spells? Could you say in laymans terms what this does?
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Sun Jun 17, 2012 3:21 pm

Yes the quest is AUTO, What this basically does is runs in the background once and checks if you have the desired spells the modder wants to give you. If you do not have the spells then the script will automatically give the desired spells to the player. The quest it self is hidden and is not shown in the quest log to prevent pile up useless information
User avatar
+++CAZZY
 
Posts: 3403
Joined: Wed Sep 13, 2006 1:04 pm

Post » Mon Jun 18, 2012 4:47 am

very impressive.
User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am

Post » Sun Jun 17, 2012 7:21 pm

Do we have any way to keep this quest restarting every game load?

Currently it seems to start once, and thats it
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Mon Jun 18, 2012 6:25 am

You can call Reset() on your quest if you want to restart it, or you check the flag "Start game enabled" in the Quest Dialog with a OnUpdate / registered etc
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Sun Jun 17, 2012 9:38 pm

There's no GetGameLoaded function and OnInit() is only for the first time the script runs. What you could do is make a bGameLoaded global with its constant flag set and value set to 1. Set it to 0 with your quest after checking it and conditionalize the code you only want to run.


ScriptName YourScript extends QuestGlobalVariable Property bGameLoaded Auto;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnInit()	RegisterForUpdate(5) ; Equivalent to (fQuestDelayTime == 0)EndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnUpdate()	If (bGameLoaded.GetValue() == 1) ; GetGameLoaded		bGameLoaded.SetValue(0)		;Stuff you want to do every save load	EndIfEndEvent
Edit: "Constants" can no longer be set in game ={
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Sun Jun 17, 2012 4:00 pm

Well if your only adding the spells on Startup for the player, theres really no need to continue the quest on a update, unless you want to check for Quest Stages which add different things
User avatar
^_^
 
Posts: 3394
Joined: Thu May 31, 2007 12:01 am

Post » Sun Jun 17, 2012 7:47 pm

The mod I'm developing will involve constant re-adjustment of perks, faction var updates, spells, etc. I just figured a repeating quest would be more efficient then making a new quest every time I want to add a 'feature'.

Edit:

Thank you Justin @ Taewon, I got it working exactly how I wanted it to.
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Mon Jun 18, 2012 1:50 am

Get this sample script on the wiki somewhere if you can.
User avatar
Laura Shipley
 
Posts: 3564
Joined: Thu Oct 26, 2006 4:47 am

Post » Sun Jun 17, 2012 6:59 pm

That's really helpful to test spells ingame, I was getting sick of having to adding them via console every single time...

Also, I have modified it to use a FormList, so I can drag and drop spells in the list since I'm testing a few and it was easier than changing the properties every time


Scriptname ShanaTestingSpellsQuestScript extends Quest;===============  PROPERTIES  ==========================================;FormList Property ShanaTestingSpellsFormList auto;===============  VARIABLES   ==========================================;Spell SpellFormActor Player;===============    EVENTS    ==========================================;Event OnInit()  int CurrentSpell = 0  int FormListSize = ShanaTestingSpellsFormList.GetSize()  Player = Game.GetPlayer()  while ( CurrentSpell < FormListSize )    SpellForm = ShanaTestingSpellsFormList.GetAt( CurrentSpell ) As Spell    Player.AddSpell(SpellForm)    CurrentSpell += 1  endWhileEndEvent

Hope it helps!
User avatar
joannARRGH
 
Posts: 3431
Joined: Mon Mar 05, 2007 6:09 am

Post » Mon Jun 18, 2012 12:42 am

Huh. That's a fascinating idea. You can just add spells to the player actor in the CK, but spells added that way can't be removed with RemoveSpell(), and it's asking for compatibility problems. However, your idea of using a quest allows you to dynamically alter the player, while avoiding conflicting with any other mods that might want to alter the player. Neat!
User avatar
JUDY FIGHTS
 
Posts: 3420
Joined: Fri Jun 23, 2006 4:25 am


Return to V - Skyrim