Jump to content

Forging scripts


Deridor

Recommended Posts

This thread will be an ongoing pile of questions as I relearn TES scripting in oblivion.

 

First question, how would I go about a "startscript" function like that in morrowind? For the sake of the forge in the mod I am working on, I am creating a script that uses an activator (forge of some sort) and gives a list of materials. This script will check the users armorer stat and reject if their stats are too low for the material they select, fairly simple, but I want it to start the next script in the line if their armorer stat is high enough.

 

But to make things less cluttered, There will be a second page for the items in each material via a second script per material. I wish to handle leveling (iron-fine iron etc...) and the item exchange (remove the required materials, give the player their items) in a third and final script for each item. I don't know where to begin on either of these, but anything will help. I might get by with only the functions that pertain to the above!

 

I plan to make the mod vanilla oblivion only at first, no expansions or OBSE (unless KOTN or SI add a startscript function...).

Link to comment
Share on other sites

Never modded morrowind, so I can't be completely how StartScript worked. What you may need to do is create an OnActivate Block.

 

I'm not sure how much you already know, so I will explain what I mean: Oblivion's scripting uses Blocktypes, which run in response to different events. For example, an OnActivate block will run when the object the script is attached to is "activated", like when you hit the space bar.

 

I'm guessing you do know about how scripting works, so I won't give you a guided tour. I'll just give you something to start you off. Anything else you need can probably be found on the Construction Set Wiki

 

For your script, you will need two blocks - an OnActivate block and a GameMode block. GameMode blocks run every frame, provided there are no active menus (which would allow MenuMode blocks to run every frame). The OnActivate block will "switch on" the forge and the GameMode block will provide the menu system (which may sound counter-intuitive, but it works).

To create the menu, you want to create a series of MessageBoxes. A good demonstration can be found here.

Link to comment
Share on other sites

Actually I'm past that part :) Got the messagebox stuff down, just need to work out buttons and the armorer skill checking (should be like riding a bike!).

 

The point of startscript in morrowind was to start a different script at the end or somewhere within another. Like my example above, you could have the first script handle the selection and a second script handle the removal and adding of items, to keep things less cluttered and avoid too many IFs (a big problem I hit trying to script dawn/duskfang superior in morrowind).

Link to comment
Share on other sites

No matter how experienced a modder you are, Oblivion is quite a different development environment than Morrowind. Really suggest you start at 'The Enclave - TES Alliance Modding School', 'Construction Set (Oblivion) - Bethesda Softworks Forums', and 'Construction Set Extender (CSE) - Bethesda Softworks Forums'. You will also want to at least look at 'Oblivion Script Extender (OBSE)', which adds additional capabilities not available in the stock Construction Set scripts (There is a new release of OBSE in the works, hopefully within the week.) CSE is an OBSE 'add-on' to the Construction Set that fixes many problems people have with the CS interface. Also, be aware you want to be using CS v1.2.

 

-Dubious-

Link to comment
Share on other sites

I understand what you mean by StartScript now. The most closest function to StartScript would be "Call", made available by OBSE. It allows User-Defined functions not unlike how you describe.

 

If OBSE is truly not an option, there are ways around this. The best one for you is probably to attach a script to an activator, then instead of just using StartScript/Call, you move the activator to the player and use "Player.Activate <Activator> 1". The Activator's OnActivate block will kick in, and obviously you can throw in any other blocks you need.

 

The other thing you can do is use SetStage, then create the Result Script for the quest stage(s). The drawback to this is that Result Scripts cannot declare variables.

Link to comment
Share on other sites

http://www.uesp.net/wiki/Tes4Mod:Script_Functions

 

if player.getitemcount Gem0SilverNugget == 5

removeitem

additem

player.getav blunt

 

You can make a container which adds items from Results Script. This will allow you something to check against in other scripting. (If you chest.additem gold001 1, then the chest will add 1 gold. You can then check how many gold there are in the chest with other scripts. As many objects as there are, there are that many variables, so you can make custom objects which only get added when the script runs. You can see this in action with Reznod's Mannequins.

Link to comment
Share on other sites

Hmm... would it work to have a setup like this:

 

"Chest">activator>chest

 

Where the player places items in the first "chest" (most likely some sort of forge mesh modified to be a chest), then uses the activator and receives a list of materials as buttons. This will be scripted to check for armorer skill etc... but if the player has the skill, the script will check the "chest" for the requirements and deposit the item in the second chest (perhaps a barrel of water?). The item will be based on the actual items in the chest and of course the material selected (i.e. 2 iron bars would make a dagger and 3 would make a shortsword).

 

Sigh, I almost want to just make a blacksmith npc, but that's too... unoriginal.

Link to comment
Share on other sites

I've decided how I'm going to do it,but I ran into a bug in my script...

 

ScriptName Forgescript

Short IronValue
Short SteelValue
Short ActorValue
Short ForgeValue
Short button

Begin OnActivate
  MessageBox "Forge Menu", "Iron", "Steel", "Silver", "Ebony"
Set ForgeValue to 1
End

Begin GameMode
If ( ForgeValue == 1 )
set button to GetButtonPressed
 If ( button == 0 )
player.getav Armorer
	If ( ActorValue < 10 )
		Message "Your armorer skill is not high enough to forge Iron"
		Set ForgeValue to 0
		Return
	ElseIf ( ActorValue >= 10 )
		Set IronValue to 1
		Message "Place the required materials in the forge."
		Set ForgeValue to 0
		Return
		Endif
	Endif
Endif
EndIf
End

 

The script works fine, shows the menu and everything, but it only displays the "your armorer skill is not high enough to forge iron" message, even at 100 armorer skill...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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