Jump to content

Scripting Help - Adding/Removing Spells Upon Selecting Class


Recommended Posts

Hello,

 

I am in the process of updating my SZCO - New and Improved Classes mod (https://www.nexusmods.com/oblivion/mods/49991), by adding new powers/abilities to each class. I have created the new powers and abilities, however adding them to the player character through scripting is proving rather difficult. I can do this through some 'if' functions (as shown in the spoiler below) however for 40+ classes this would create a ridiulously long script.

 

 

 

scn SZSpellDistributionScript

begin GameMode

if (GetPCIsClass SZAlchemist)

player.addspell SZAlchemistAlchemicalInnovation
player.addspell SZAlchemistMithraditism
player.addspell SZAlchemistNoxiousFumes

player.removespell SZSmithMasterofMetal
player.removespell SZSmithLongNightsbytheForge
player.removespell SZSmithImpenetrableBulwark

endif

if (GetPCIsClass SZSmith)

player.addspell SZSmithMasterofMetal
player.addspell SZSmithLongNightsbytheForge
player.addspell SZSmithImpenetrableBulwark

player.removespell SZAlchemistAlchemicalInnovation
player.removespell SZAlchemistMithraditism
player.removespell SZAlchemistNoxiousFumes

endif

end

 

 

 

Instead of this, does anyone know if it possible to have a script run once upon either opening the class selection window, or upon picking a class (irrespective of which one). This would allow me to create 2 scripts of much shorter length, instead of one ridiculously long one. I have looked, but cannot seem to find a way to do this.

 

Thank you in advance.

 

All the best.

Edited by Swizzarmyzzz
Link to comment
Share on other sites

I do think you can add the spells direct to each race but not direct to any class what I know of. What you can do is make a script that checks the class and add spells according to that with IF as you must be able to check the class with GetClass even and you did use GetPCIsClass so what I say is more or less the same you already wrote. A menu with options in a quest will do it but adding the spells to a vendor, anywhere, at the starting area or whatever, a current or custom vendor is more optimal, both for you and the player, no doubt and that is what I mostly do myself as I use at least 4 custom merchants for this only. A merchant sell the spells that specific NPC has in its own spell list.

Link to comment
Share on other sites

Hello,

 

Yes unfortunately there is no point 'n' click way of adding spells to classes as their is for races, if only :/. Thank you for the idea, but I would like to stray away from adding an extra merchant into the game for this purpose if I can. I will have a look into a menu interface for adding spells, this could be a very good way of implemeting the new class specific spells, would you happen to know of a guide for this sort of thing?

 

Do you know if it is possible to run a script upon either opening the class selection window, or upon picking a class (irrespective of which one)?

 

Thank you for the suggestions.

Link to comment
Share on other sites

Menues are made with Messagebox and today we use the OBSE messageBoxEX so avoid combining Messagebox with MessageboxEX, if possible or you might create a crash. I do have loads of MessageBoxEX and MessageBox examples

 

Adding a couple of extra merchants will not effect the game negative at all. Do not let stuff or thoughts like that stop your creativity as an artist. Do what you want and try it and if it works for you, it will work for everyone.

 

No matter what, learning to use menus and messageboxes will give you new ideas for sure and we shouls never stop learning things. Messageboxes is the most perfect way to interact with the player in any script really, if we do not do it with a dialog, which is better from an immersive perspective. You could add the spells to a Quest, add the topic to your race and add the spells that way but lets do a Messagebox example first as that is much easier and faster to do.

scn SwizzAddspellstoClassSCR

short State
short DoOnce
short Button

begin GameMode

	If ( DoOnce == 1 )
		Set State to 20
	Else
		MessageBoxEX "Which Class spells do you want to add?|Alchemist|Smith|None|Piss off"
		Set State to 10
	Endif
	
	If ( State == 10 )
		Set Button to GetButtonPressed
		
		If (Button > -1)
			Set State to Button
		Endif
	Endif
		
	
	

	if ( State == 0 )

	  player.addspell SZAlchemistAlchemicalInnovation
	  player.addspell SZAlchemistMithraditism
	  player.addspell SZAlchemistNoxiousFumes
	 
	  player.removespell SZSmithMasterofMetal
	  player.removespell SZSmithLongNightsbytheForge
	  player.removespell SZSmithImpenetrableBulwark

	   endif

	if ( State == 1 )

	  player.addspell SZSmithMasterofMetal
	  player.addspell SZSmithLongNightsbytheForge
	  player.addspell SZSmithImpenetrableBulwark
	 
	  player.removespell SZAlchemistAlchemicalInnovation
	  player.removespell SZAlchemistMithraditism
	  player.removespell SZAlchemistNoxiousFumes

	endif

	If ( State ==  3 )
		Set State to 20
	ElseIf ( State == 4 )
		MessageBox "The player responds that this is not the game Daggerfall (from 1995)", "WTF", "Piss off your self"
		Set State to 20
	Endif
	
	
end

The script above will work best as a quest script but you can attach it to an object as an object script as well, inside a cell and will get executed as soon as you enter that cell and only run once. If the player wants to run it again if it is an object, well use the command:

Set <ObjectRef>.state to 10

An object or a spell can execute the questscript again as well.

Set <QuestID>.state to 10 

It took me 10 min to make this script. If I made a quest adding a dialogue, it might taken me 30 min as it is a bit more complicated but I show you how to do it if you want me too. But CS Wiki will explain how to do it. Use that Wiki before you try to make the dialogues and before asking us to help you with it. It is made for any new beginner modder and it is extremely easy to read for any dummy like myself. Even my GF that hate games would been able to make it within 2 hours and the only game she tried was 2 hours of WoW until she told me to Piss off.

 

Do not incude the piss off stuff though, as it was just an example how to combine MessageBox and MessageBoxEX and to show the differences between them. But the biggest difference is that MessageBoxEX will be able to show any form of variable type, which MessageBox cannot and you also see that it is a difference how you add the buttons and the way you do it in the MessageBox will also work with a MessageBoxEX but not vice verse and if you add a variable type to a MessageBox that it cannot read, the game crashes immediate, within one single frame. Integers are no problems but mostly all other types of variables.

 

State, DoOnce and Button is variables of the type integer, a short integer but the game will not see any difference between a short nor long integer any way, so that is just an illusion anyway.

 

MessageBoxEX will require OBSE and MessageBox was created by Bethesda and released 2004. Daggerfall used the C# language and object orientation for everything but I do not know if they used the command MessageBox as we do in Morrowind. But something similar though. That old game is so damn dynamic and all NPC will tell you to piss off until you increased your speechcraft. Piss Off is the most common sentence that Bethesda ever used, well at least before 2004.... ;)

Edited by Pellape
Link to comment
Share on other sites

Hello,

 

Thank you for informing me of this qwertyasdfgh, I didn't realise MenuQue could be used for this. But I think you are right, and doing it this way may well be overkill.

 

Wow...thank you for taking your time to create a new script for me, I will give this a try ASAP. I think adding the new spells through menus/messageboxes or an object/spell you can interact with is a very good way of doing it. I will use these suggestions and have a mess about in the CSE to see what works. I appreciated the offer for further help, and if I get truly stumped I will ask for help :smile:

 

Thank you.

 

All the best.

 

Edit:

 

Haha well I found the piss off stuff rather amusing, but yes...I'll make sure not to include it. I've never played Morrowind, so unfortunately I am not able to comment...but yes I have heard that it is very different to Oblivion :)

Edited by Swizzarmyzzz
Link to comment
Share on other sites

What differs most is Daggerfall really. I added a link to Daggerfall Unity, the new engine at the common Oblivion forum. Daggerfall came 1995, Morrowind 2004 and Oblivion 2005. We mod the 2 last games the same way. Daggerfall use dynamic small C# stuff, both binary and simple text scripts, that we add to the modding folder with a simple texteditor, just as they are without any CS. That game is free and do not cost any player nor the authors a nickle to play nor mod :D

 

Edited by Pellape
Link to comment
Share on other sites

Hi Swizzarmyzzz

I have a working solution with low overhead.
All I need is a text file in the following format...

SZAlchemist
SZAlchemistAlchemicalInnovation
SZAlchemistMithraditism
SZAlchemistNoxiousFumes

SZSmith
SZSmithMasterofMetal
SZSmithLongNightsbytheForge
SZSmithImpenetrableBulwark

and so on

I'll use a program to read that file and write the CS
Please include your latest esp so I can update and test it.

The process only runs 3 lines of code until the Player changes Class.
On Class Change

  • 7 lines of code to remove all previous SZSpells - if any
  • Minimal lines of code to add SZSpells if the new class is in fact an SZClass

I'll add a hands on tutorial so that you won't need me for maintenance.

Link to comment
Share on other sites

Hello,

 

I have always thought about playing Daggerfall, but I barely have the time to mod and play Oblivion let alone another Elder Scrolls game, hopefully one day I'll give it a go. :)

 

Hi Glowplug, thank you that sounds great. That was my original plan for how I wanted the mod to work, I could just never figure it out haha. I'll add the two requested files as an optional file to the mod page. I will let you know when I have.

 

All the best.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...