Difference between revisions of "Toggling Objects Tutorial"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Qazaaq
(quest scripts hardly result in FPS loss, this one definitely not)
imported>Qazaaq
(rewriting)
Line 1: Line 1:
==Introduction==
This tutorial will help you make objects that were previously disabled to become enabled, such as when you complete a certain stage of a quest or eat a certain item items that were previously invisible will become visible
This tutorial will help you make objects that were previously disabled to become enabled, such as when you complete a certain stage of a quest or eat a certain item items that were previously invisible will become visible


I had a lot of trial-and-error creating objects that appear only when you do a specific action. For instance: A trophy getting added to your Megaton Home when you get acquire and achievement, so I'm going to write a tutorial for that:
I had a lot of trial-and-error creating objects that appear only when you do a specific action. For instance: A trophy getting added to your Megaton Home when you get acquire and achievement, so I'm going to write a tutorial for that:


1. You're going to want to make an xmarker, these can be found in World Objects -> Static, '''tick the "Initially Disabled" box'''
==Placing the object==
Place an [[XMarker]] in the area of the object you want to toggle. These can be found under World Objects > Static in the [[Object Window]]. Double click the XMarker you just placed to open the [[reference]] property window, and tick the '''initially disabled''' box. Also fill in a '''Reference Editor ID''', we will need that later.


2. Change the "Reference ID" on the xmarker by double-clicking the XMarker you placed.
Now create the object you want to enable when you do a specific action. In this case we will trigger it when you get an achievement. Double click the object you just placed and scroll over to the "Enable Parent" tab. Click "Select Reference in Render Window" and select your XMarker, if you want you can do the same for other objects, those objects will also get enabled once the XMarker does.


3. Create the object you want to enable when you do a specific action (in this case, getting an achievement)
==Triggering the object==
To trigger the appearance of the object(s) we're going to use a questscript. For that we first need a new [[quest]].
{{CreateObject|ActorData}}
#Fill in a name and ID and make sure the ''Start Game Enabled'' box is checked.


4. Double click the object you just placed and scroll over to "Enable Parent"
Click the '''...''' button next to dropdown box where you can select a script. The [[Edit Scripts]] window will pop-up. Go to Script > New... to create a new script. We're going to use the "Slayer of Beasts" achievement here, where you have to kill 300 beasts. This is the script that triggers the achievement (copied from AchievementScript):
 
5. Click "Select Reference in Render Window and select your xmarker, if you want you can do the same for other objects, those objects will also get enabled once your first prop does.
 
6. Go to ActorData and select the quests and select the "Achievement Quests", if you look a little below the questID box you'll see a "..." button next to the script name, click it.
 
6,5. I personally just make another script and copy/paste the Achievement's script into it to avoid conflicts with other mods. If you want to do that you have to create another quest, tick the "Start Game Enabled" box and select the script from the drop-down menu.
 
7. In your new (or old) script find the achievement you want so that when you earn it you enable your prop, if you don't know what achievement does what you can check [http://www.xbox360achievements.org/game/fallout-3/achievements/] for a full list, note that you won't find any quest-achievements here, I'll get on that subject later in this tutorial.
 
8. I'm going to use the "Slayer of Beasts" achievement here, where you have to kill 300 beasts, this is the OLD script:
  ;Slayer of Beasts
  ;Slayer of Beasts
  If CreaturesKilled == 0
  If CreaturesKilled == 0
Line 28: Line 23:
  endif
  endif


This is the new script:
We can modify it to enable our trophy at the same time you get the achievement. We don't need to remember that the creatures have been killed, so we'll leave that bit out:
;Slayer of Beasts
  If GetPCMiscStat "Creatures Killed" > 299
  If CreaturesKilled == 0
; AddAchievement 42
If GetPCMiscStat "Creatures Killed" > 299
'''[YOUR XMARKER'S REFERENCE ID HERE].enable'''
AddAchievement 42
Set CreaturesKilled to 1
                '''[YOUR XMARKER'S REFERENCE ID HERE].enable'''
endif
  endif
  endif
Don't use the "[ ]" in your script.
Don't use the square brackets "[ ]" in your script.


9. Okay, let's say you want something to enable once you complete ANY quest or quest can, can be official or your own, or even someone elses, repeat stages 1 through 5 here,
We commented out the [[AddAchievement]], as we don't need to handle that in our script, and we added a line that enables the XMarker we placed. By enabling the XMarker we also enable all objects that have the XMarker as parent; our trophy.


10. Go to ActorData -> Quests and find the quest ID you're looking for, if you know the in-game name of the quest but not the ID scroll a little to the right untill you come to the "Name", find your quest here, be sure not to click the "Dialogue, Fin etc." versions of the quest.
Finally, we can add a [[Scriptname]] and [[GameMode]] block. The GameMode block makes sure the script runs continuously, for a detailed explanation have a look at the [[:Category:Scripting|scripting section]]. Because the script no longer needs to run when the trophy is enabled, we also add a StopQuest command (note that you may have to close the Quest window before the script compiler accepts your quest ID).
 
ScriptName EnableSlayerOfBeastsTrophyScript
11. Go the the "Quest Stages" tab of that quest and click the stage you want to enable the object with. If the quest has the "Complete Quest" box ticked, that's the final stage, some multiple-choice quests have 2 stages with the complete quest box ticked, go over to the "Result Script" box and click "Edit"
   
 
12. Just put your "[xmarker reference ID here].enable" right under that.
 
And you're done, I hope this helped in any way!
 
== Retro-Active achievements ==
If you do this the person who starts your mod AFTER completing a certain achievement will still get the whole ".enable" process.
1.Make a new Quest and Script for that (make sure the script is in the "Quest" category)
 
2.The script should start like this:
 
  SCN YourScriptName
  Begin GameMode
  Begin GameMode
If GetPCMiscStat "Creatures Killed" > 299
; AddAchievement 42
Set TrophyEnabled to 1
              [your XMarker Reference Editor ID here].Enable
StopQuest [your QuestID here]
endif
End


and obviously end like this:
Save the script and exit the Quest window to refresh the list of scripts. Reopen the quest and select the script you just saved.


end
And you're done! Unless you want to know about different kinds of trigger scripts.


2.Go to the original achievements script and copy the part which includes the achievement you want to make retroactive.
==Quest stage related trigger==
Let's say you want something to enable once you complete ''any'' quest, can be official or your own, or even someone else's. Repeat ''placing your object'' and then continue here.


OLD:
Go to ActorData > Quests in the Object Window and find the quest you're looking for, if you know the in-game name of the quest but not the ID scroll a little to the right until you come to the ''Name'' column. Be sure not to click the Dialogue and/or Fin versions of the quest.
;Slayer of Beasts
If CreaturesKilled == 0
If GetPCMiscStat "Creatures Killed" > 299
AddAchievement 42
Set CreaturesKilled to 1
endif
endif


NEW:
Open the quest and go the the "Quest Stages" tab and click the stage you want to enable the object in. If the quest has the "Complete Quest" box ticked, that's the final stage, some multiple-choice quests have 2 stages with the complete quest box ticked, go over to the "Result Script" box, click "Edit" and put the following line there:
;Slayer of Beasts
[XMarker Reference Editor ID here].enable
If GetPCMiscStat "Creatures Killed" > 299
This method is fast, but will conflict with any other mods that changes the result script of that particular stage of the quest.
          YourXMarker.Enable
endif

Revision as of 03:48, 23 July 2009

Introduction

This tutorial will help you make objects that were previously disabled to become enabled, such as when you complete a certain stage of a quest or eat a certain item items that were previously invisible will become visible

I had a lot of trial-and-error creating objects that appear only when you do a specific action. For instance: A trophy getting added to your Megaton Home when you get acquire and achievement, so I'm going to write a tutorial for that:

Placing the object

Place an XMarker in the area of the object you want to toggle. These can be found under World Objects > Static in the Object Window. Double click the XMarker you just placed to open the reference property window, and tick the initially disabled box. Also fill in a Reference Editor ID, we will need that later.

Now create the object you want to enable when you do a specific action. In this case we will trigger it when you get an achievement. Double click the object you just placed and scroll over to the "Enable Parent" tab. Click "Select Reference in Render Window" and select your XMarker, if you want you can do the same for other objects, those objects will also get enabled once the XMarker does.

Triggering the object

To trigger the appearance of the object(s) we're going to use a questscript. For that we first need a new quest.

  1. In the Object Window, go to ActorData.
  2. Press left-click in the list and press Insert or right-click in the list and select New.
  3. Fill in a name and ID and make sure the Start Game Enabled box is checked.

Click the ... button next to dropdown box where you can select a script. The Edit Scripts window will pop-up. Go to Script > New... to create a new script. We're going to use the "Slayer of Beasts" achievement here, where you have to kill 300 beasts. This is the script that triggers the achievement (copied from AchievementScript):

;Slayer of Beasts
If CreaturesKilled == 0
	If GetPCMiscStat "Creatures Killed" > 299
		AddAchievement 42
		Set CreaturesKilled to 1
	endif
endif

We can modify it to enable our trophy at the same time you get the achievement. We don't need to remember that the creatures have been killed, so we'll leave that bit out:

If GetPCMiscStat "Creatures Killed" > 299
	; AddAchievement 42
	[YOUR XMARKER'S REFERENCE ID HERE].enable
endif

Don't use the square brackets "[ ]" in your script.

We commented out the AddAchievement, as we don't need to handle that in our script, and we added a line that enables the XMarker we placed. By enabling the XMarker we also enable all objects that have the XMarker as parent; our trophy.

Finally, we can add a Scriptname and GameMode block. The GameMode block makes sure the script runs continuously, for a detailed explanation have a look at the scripting section. Because the script no longer needs to run when the trophy is enabled, we also add a StopQuest command (note that you may have to close the Quest window before the script compiler accepts your quest ID).

ScriptName EnableSlayerOfBeastsTrophyScript

Begin GameMode
	 If GetPCMiscStat "Creatures Killed" > 299
		; AddAchievement 42
	 	Set TrophyEnabled to 1
              	[your XMarker Reference Editor ID here].Enable
		StopQuest [your QuestID here]
	endif
End

Save the script and exit the Quest window to refresh the list of scripts. Reopen the quest and select the script you just saved.

And you're done! Unless you want to know about different kinds of trigger scripts.

Quest stage related trigger

Let's say you want something to enable once you complete any quest, can be official or your own, or even someone else's. Repeat placing your object and then continue here.

Go to ActorData > Quests in the Object Window and find the quest you're looking for, if you know the in-game name of the quest but not the ID scroll a little to the right until you come to the Name column. Be sure not to click the Dialogue and/or Fin versions of the quest.

Open the quest and go the the "Quest Stages" tab and click the stage you want to enable the object in. If the quest has the "Complete Quest" box ticked, that's the final stage, some multiple-choice quests have 2 stages with the complete quest box ticked, go over to the "Result Script" box, click "Edit" and put the following line there:

[XMarker Reference Editor ID here].enable

This method is fast, but will conflict with any other mods that changes the result script of that particular stage of the quest.