revolucion09 Posted May 29, 2010 Share Posted May 29, 2010 Hello there, I am looking for a way to remove all Spells the player has. The idea would be to delete all Spells that are not Powers. Is it possible? And would it be possible to delete all spells that are from a specific school? I would be really thankful ps. sorry for my typo in the title. I meant 'Script Question' instead of 'Script Quest' Link to comment Share on other sites More sharing options...
Cold101 Posted May 29, 2010 Share Posted May 29, 2010 I don't know the script for this, but I know there is a mod that allows you to remove spells, you might want to look into that. Link to comment Share on other sites More sharing options...
revolucion09 Posted May 29, 2010 Author Share Posted May 29, 2010 I guess it is a workaround. Added in my readme to tell people to manually delete their spell list before using my mod, if they are willing to play with their old savegames If anyone comes up with a global script idea please tell me Thx! Link to comment Share on other sites More sharing options...
Argomirr Posted May 30, 2010 Share Posted May 30, 2010 A quick and dirty script:scn RemoveSpellsScript ; Removes all spells from the player that are not powers. OBSE required! array_var spells short index ref cur short doonce begin gamemode if doonce return else let spells := playerref.getspells while index < ar_size spells let cur := spells[index] if getspelltype cur == 0 ; Change to 'if getspellschool cur == 0' to remove all Alteration spells. Magic School types can be looked up in the OBSE docs. playerref.removespellns cur let index += 1 endif loop let doonce := 1 ; May be better to just stop the quest if you're planning on only using this once. endif endRequires OBSE. Just attach it to a quest and you're good to go. :happy:: Link to comment Share on other sites More sharing options...
Pronam Posted May 30, 2010 Share Posted May 30, 2010 Out of curiosity, would it be possible to save the spells to return them later? Link to comment Share on other sites More sharing options...
revolucion09 Posted May 30, 2010 Author Share Posted May 30, 2010 A quick and dirty script:scn RemoveSpellsScript Mister, you are simply a genius. Thank you very much. I am new to scripting and programming, may you point me to some more resources? I never knew about the "let" function. And didnt know oblivion supported loops. So any more resources link you can give me would be handy. Here is my current mod if you are interested (i managed pretty much to achieve what I wantedhttp://tesnexus.com/downloads/file.php?id=31918And I was just looking to make the mod compatible with Advanced SaveGames and I needed to delete the spell list from the characters. My only concern now is about the custom spells (for example configuration spells from other mods or stuff like that). But i will look for a workaround on it. Bye! Link to comment Share on other sites More sharing options...
Argomirr Posted May 30, 2010 Share Posted May 30, 2010 Out of curiosity, would it be possible to save the spells to return them later?Of course! That's easy, but if the mod is deactivated the data will be lost. However that data can also be stored in a way that isn't affected by disabling the mod. A quick and dirty script:scn RemoveSpellsScriptMister, you are simply a genius. Thank you very much.I am new to scripting and programming, may you point me to some more resources? I never knew about the "let" function. And didnt know oblivion supported loops. So any more resources link you can give me would be handy.Here is my current mod if you are interested (i managed pretty much to achieve what I wantedhttp://tesnexus.com/downloads/file.php?id=31918And I was just looking to make the mod compatible with Advanced SaveGames and I needed to delete the spell list from the characters. My only concern now is about the custom spells (for example configuration spells from other mods or stuff like that). But i will look for a workaround on it.Bye!The let function is just OBSE's version of Oblivion's set function. It's the only way to interact with arrays and such; that can't be done with set. Loops are also part of the low-calorie-goodness that is OBSE. Check the OBSE docs if you want to learn more. :tongue: There's no need to worry about spells added by other mods, by the way. This will remove every spell in the player spellbook, regardless of which mod it came from. Link to comment Share on other sites More sharing options...
revolucion09 Posted May 30, 2010 Author Share Posted May 30, 2010 Thank you very much. But I cant still make the script to work. It just freezes when the loop starts (after pressing the Old SaveGame button). New Game button works fine. here is the script I made (by the way, i'd like to know what is the := operation. And if the ar_size returns info about the last array called, or what?) scn RemoveSpellsScript ; Removes all spells from the player that are not powers. OBSE required! array_var spells short index ref cur short doonce short doonce2 short doonce3 short CleanSpells short button float fQuestDelayTime float timer begin gamemode set fQuestDelayTime to 0.001 if GetQuestRunning AOMSInitialize == 0 ; <---- If the mod hasnt been played already if doonce2 == 0 MessageBox "Welcome to Alternative Oblivion Magic System. I Take it this is your first time Playing this mod. Is this an Old Savegame not made with this mod? or Are you playing a New Game?" "New Game" "Old SaveGame" set doonce2 to 1 endif if doonce3 == 0 set button to GetButtonPressed if button == -1 return elseif button == 0 ; <---- New Game Message "Executing Alternative Oblivion Magic System..." StartQuest AOMSInitialize set doonce3 to 1 StopQuest AOMSIAWelcome ; <---- Stops THIS script return elseif button == 1 ; <----- Old SaveGame. Lets Clean Spell List set doonce3 to 1 set CleanSpells to 1 Message "Adapting your Character to be played with Alternative Oblivion Magic System. Please Wait..." endif endif endif if CleanSpells == 1 && timer < 3 set timer to timer + getsecondspassed return elseif CleanSpells == 1 && timer >= 3 if doonce == 0 ; <----- Game is Freezing somewhere here let spells := playerref.getspells while index < ar_size spells let cur := spells[index] if getspelltype cur == 0 ; Change to 'if getspellschool cur == 0' to remove all Alteration spells. Magic School types can be looked up in the OBSE docs. playerref.removespellns cur let index += 1 endif loop let doonce := 1 ; May be better to just stop the quest if you're planning on only using this once. Message "You Character is now ready to play Alternative Oblivion Magic System. Please Save your game now" StartQuest AOMSInitialize set CleanSpells to 2 StopQuest AOMSIAWelcome endif endif end Link to comment Share on other sites More sharing options...
Argomirr Posted May 30, 2010 Share Posted May 30, 2010 Whooops! I misplaced a line causing an infinite loop. It's supposed to be like this:if doonce == 0 let index := 0 ; Added this line to make sure it runs when used more than once. let spells := playerref.getspells while index < ar_size spells let cur := spells[index] if getspelltype cur == 0 ; Change to 'if getspellschool cur == 0' to remove all Alteration spells. Magic School types can be looked up in the OBSE docs. playerref.removespellns cur endif let index += 1 loop let doonce := 1 ; May be better to just stop the quest if you're planning on only using this once. Message "You Character is now ready to play Alternative Oblivion Magic System. Please Save your game now" StartQuest AOMSInitialize set CleanSpells to 2 StopQuest AOMSIAWelcome endif I said it was a quick and dirty script. :tongue: [EDIT](by the way, i'd like to know what is the := operation.It's part of the let operator.Basically, read this: let var := 1 as this: set var to 1 The let operator also supports add and assign (and similar) operations: let var += 1 which means the same as: set var to var + 1 And if the ar_size returns info about the last array called, or what?)ar_Size returns the size of the specified array, which is needed when iterating over the elements so you don't try to access non-existent keys. (Unless you're using a for loop.) If you're interested, I can tell a bit more about arrays. Link to comment Share on other sites More sharing options...
revolucion09 Posted May 30, 2010 Author Share Posted May 30, 2010 Thank you, it is working flawlessly now :-). I will study the block. Thx for the info, you've made my day. Updated my mod to 0.03. Good to know people will be able to continue their characters. Rev Link to comment Share on other sites More sharing options...
Recommended Posts