Quick and Dirty Workbench Schematic Tutorial

Post » Mon Dec 20, 2010 2:42 pm

Seems I wasn't the only one looking for something like this. I just finished writing it, any comments, error catching appreciated.



Quick and Dirty Weapon Schematic Tutorial
by strungout



You have your weapon ready and you want to make it available at the Workbench. I couldn't find much info on doing this, so, I'll show you the way I modified my way through it, without much scripting knowledge, just copying what I saw was done with other workbench created weapons like the Dart Gun.




- 1 - Schematic Item

First, adding the Blueprint Schematic Item. Fire up your G.E.C.K. editor. In the Object Window, go to Items > Misc Item > Clutter > Junk and find "SchematicsDartGunItem". We'll edit one that already exists because it already has the "Inventory image" and blueprint "Model" attached to it, so we don't have to add them ourselves.

Right-Click > edit "SchematicsDartGunItem". In the window that pops up, notice the consistency of the naming, that makes things alot simpler to understand and remember.

ID: Replace the part that says "DartGun" with the name of your weapon. For the purpose of this tutorial, I'll call it "SchematicsYourWeaponItem".

Name: Again, replace it with "Schematic - YourWeapon". Here, spaces are allowed.

Script: The script that is associated with this item, which we'll create later. Leave it alone for now, as our script isn't ready, so, it's not in the pull-down list.

Weight: The weight of your weapon.

Value: The value in caps of your weapon.

Everything else in the window can be left alone. Close it and choose "Yes" to create a new "Form ID". Everytime you'll change an editor ID, it'll ask you if you want a new form created. If you say no, you'll overwrite the original one, which will cause problems because the original reference doesn't exist anymore.





- 2 - Schematic Note

Next, we need a note that will be able to be read in the Pipboy Notes. In the object window, go to Items > Note > Junk and find SchematicsDartGunNote. There are 3 of them, corresponding to each version of the schematic, the basic one and 2 improvements, labeled 10 and 20 for the percentage it is improved by.

Right-Click > edit "SchematicsDartGunNote".

Name: Same name you used earlier.

ID: Replace with "SchematicYourWeaponNote".

We can skip the other options.

Note Data: Here you can write whatever you want, in plain text, but to keep it simple we'll just use the same idea and replace the Paint gun, Radscorpion poison gland, Toy car and Surgical tubing with our own components and description of the item created with them. This is to tell the player what items they need and what they'll be making.


When you're done, close the window, say "Yes" to create a new "Form ID".
Then, re-open the edit box, change the ID to "SchematicsYourWeaponNote10" to create a new "Form ID" for the first improvement to your schematic. Remember to add "Now improved 10%" in the text box.
Repeat once more to create a new "Form ID" named "SchematicsYourWeaponNote20". These will be refered to in the weapon's script. Remember the "Now improved 20%".





- 3 - Global Variables

Now we need to set up a variable that will be used in the item and workbench scripts. It will store the weapon's condition when created, depending on how many times the schematic has been gotten.

At the top of the GECK window, go to Gameplay > Globals. Find "countDartGunBonus", right-click > duplicate. Click twice on this duplicate to edit its name and call it "countYourWeaponBonus". Leave the other options untouched.

You might notice another variable named "countDartGun". This is used to add an achievement when you've created a workbench weapon, the ones you see on the loading screens. If you want yours to be counted, create this variable "countYourWeapon", the same way as the one we just did.




- 4 - Form Lists

Then, we need "Form Lists" One to establish what items are associated with the creation of our weapon, the second, to define what weapon or items can be used to repair it.

Go to your object window, the "Form List" category should be right above "Global", where we added the variable. Find "CustomDartGun" and right-click > edit.

ID: Change it to "CustomMyWeapon".

Now, find your components in the Object Window > Items or the appropriate list. You need the actual items you'd find in-game. Just drag and drop them in the "Form List" you're editing. The "<<" and ">>" buttons will move the items up or down in the "Form List", order them as you want, it has no use except for clarity. When you're done, close and create a new "Form ID".

The next "Form List" to edit is "RepairDartGun".

ID: Change to "RepairYourWeapon".

Just like before, find the items you want to be able to repair your weapon and drag and drop them in the list. Close and create new "Form ID".





- 5 - Workbench Failure/Success Message

We could just use the generic Failure/Success message, but I wanted one for my weapon specifically. In the Object Window > Miscellaneous > Message find "SchematicsWorkbenchFailureDartGunMsg" and right-click > edit it.

ID: Same principle, rename to "SchematicsWorkbenchFailureYourWeaponMsg".

Message Text: Replace "DartGun" with "YourWeapon" and the item names like "Paint Gun: %.0f," while keeping the ": %.0f," part as-is. It refers to the count of each item that's displayed in the message. Close and create new "Form ID".

The process is the same for the "SchematicWorkbenchSuccessDartGunMsg".





- 6 - The Scripts

Two scripts are needed. An Item script, that will check how many times you've gotten the schematic for the weapon, using that "countYourWeaponBonus" variable we created earlier to give it a value depending on wether your schematic is improved to 10%, 20% or not at all. And the Workbench script that checks if you have the schematic, the items needed and adds the weapon to your inventory.

This part is basically about copying and pasting and replacing some names, it's just as easy.



Item Script

Got to Object Window > Miscellaneous > Script and find "SchematicsDartGunItemSCRIPT" to edit it. The text line that are preceeded by a semi-colon (";") tell you it's a remark added by the person who wrote the script to indicate what the next part of the code does, that helped me alot in figuring out what to do. Here, we just have to find every single occurance of the text "DartGun" and change it to "YourWeapon". You'll notice how all of those refer to the notes, forms and variable we created. You don't need to change anything else. When you're done, close, create new "Form List".



Workbench Script

Right-click > edit the "SchematicsWorkbenchScript" and find the "Begin onActivate" line of code. This checks if which schematics you have and displays them.

This is an "if/endif" block:

		if GetHasNote SchematicsBottlecapMineNote == 1  || GetHasNote SchematicsDartGunNote == 1   || GetHasNote SchematicsDeathclawGauntletNote == 1			set HasItems to 1		endif


It tells the program running to script to check if you have the note ("GetHasNote") and which note(s) to look for. We want it to look for our schematic note, so, we need to add it to the list. For the sake of this tutorial, we'll make a seperate block for our weapon. Copy and paste the "if/endif" block (the "if" and "endif" will be in the same column of text) and remove all but one schematic reference (no difference which one is left, as long as it's just one). It should look like this:

                if GetHasNote SchematicsDartGunNote == 1			set HasItems to 1		endif



Then change "SchematicsDartGunNote" to "SchematicsYourWeaponNote". Reapeat the process for the 2 improvements on your schematic:

                if GetHasNote SchematicsYourWeaponNote10 == 1			set HasItems to 1		endif


and:

                if GetHasNote SchematicsYourWeaponNote20 == 1			set HasItems to 1		endif


It's a good idea to keep each in the same group, 10's with 10's, 20's with 20's...


With that done, we need to copy and paste the block that checks for the components and adds the weapon to the player's inventory. It's after the "Begin GameMode" line. Again, to keep it clear, find the "elseif button == 2" line. This is for the Dart Gun.

Copy this whole block:

		elseif button == 2			; dart gun			; 1. check for schematics			if GetHasNote SchematicsDartGunNote == 0 && GetHasNote SchematicsDartGunNote10 == 0 && GetHasNote SchematicsDartGunNote20 == 0 				ShowMessage SchematicsWorkbenchFailureGenericMsg			else				;2. check for components				if ( player.GetItemCount PaintGun > 0 ) && ( player.GetItemCount RadscorpionPoisonGland > 0 ) && ( player.GetItemCount ToyCar > 0 ) && ( player.GetItemCount SurgicalTubing > 0 )					;3. make it					;message "Dart Gun created."					ShowMessage SchematicsWorkbenchSuccessDartGunMsg					player.RemoveItem PaintGun 1 1					player.RemoveItem RadscorpionPoisonGland 1 1					player.RemoveItem ToyCar 1 1					player.RemoveItem SurgicalTubing 1 1					; calculate condition					set weaponCondition to (weaponCondition * countDartGunBonus)					if weaponCondition > 100						set weaponCondition to 100					endif					player.AddItemHealthPercent WeapDartGun 1 weaponCondition					PlaySound UIRepairWeapon					; increment count					ModPCMiscStat "Weapons Created" 1					set countDartgun to countDartgun + 1					;If the player has made one of each item, add Achievement 40					if countWeapAchievement == 0						if countBottlecap >= 1 && countDartgun >= 1 && countDeathclaw >= 1 && countNuka >= 1 && countRailway >= 1 && countRockit >= 1 && countShishkebab >= 1 							addachievement 40							set countWeapAchievement to 1						endif					endif				else					;failure message					set item1 to player.GetItemCount PaintGun 					set item2 to player.GetItemCount RadscorpionPoisonGland					set item3 to player.GetItemCount ToyCar 					set item4 to player.GetItemCount SurgicalTubing 					ShowMessage SchematicsWorkbenchFailureDartGunMsg, item1, item2, item3, item4					ShowMessage SchematicsWorkbenchMsg				endif			endif	


And paste it right after the last "if/endif" block. Remember each block starts with an "if" or "else" and ends with an "endif" that's right below it, in the same column of text. This makes it easier to read and easier for us to mess with too. Below the block you just pasted, the should be no empty line, and two "endifs" and one "End" (which ends the "Begin GameMode" block).

Now we need to replace the "elseif button == 2" line with "elseif button == 8", the components name with yours (3 times for each of the 4 components and every occurance of the text "DartGun", except the one in this "if/endif" block:

                                        ;If the player has made one of each item, add Achievement 40					if countWeapAchievement == 0						if countBottlecap >= 1 && countDartgun >= 1 && countDeathclaw >= 1 && countNuka >= 1 && countRailway >= 1 && countRockit >= 1 && countShishkebab >= 1 							addachievement 40							set countWeapAchievement to 1						endif					endif


This is where you would add the count for your weapon if you wanted it part of the associated achievement. If you do, add it right after "&& countShiskebab >= 1" in all the corresponding blocks of each weapon (each elseif button == 1 through 8):

                                        ;If the player has made one of each item, add Achievement 40					if countWeapAchievement == 0						if countBottlecap >= 1 && countDartgun >= 1 && countDeathclaw >= 1 && countNuka >= 1 && countRailway >= 1 && countRockit >= 1 && countShishkebab >= 1 && countYourWeapon >= 1 							addachievement 40							set countWeapAchievement to 1						endif					endif



Then, save the "SchematicsWorkbenchScript".

- 7 - Back to Schematic Item

Now's the time to re-open the "SchematicsYourWeaponItem" we created in the first step and specify that it has a script linked to it. The script pull-down menu should now have a "schematicsYourWeaponItemSCRIPT" option to select.





And that should be it. If not, you'll have to retrace your steps and see if you missed anything. Warning when you try to save the script will tell you which line might refer to an ID that doesn't exist. You can hit ctrl-g and type the line number to go to it and check the syntax. Or try the Bethesda Fallout 3 forums for help, I'll be around. Also, I read that the limits on button in the workbench text box, in-game, is 9, 10 including the "none" option. There is a mod out there that allows for more options by way of categories and avoid potential conflicts with other mods' custom weapons.

This is by no means a complete tutorial but it should be of help anyway.
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am

Post » Mon Dec 20, 2010 1:48 pm

Thank you for the post!

I love tutorials, they are the stuff of life.

.. saving this in my notes. :)

Cheers!
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm


Return to Fallout 3