Jump to content

Creating a Skill Check?


QuentinVance

Recommended Posts

Yeah, I know I'm always asking here and it's frustrating to keep teaching stuff to the little kid ( :D), but most of the times I need something I seem to be unable to actually find an answer elsewhere. I've also tried browsing the forums but still no results.

 

So, another part of the mod I'm currently trying to develop requires the player to open a door not directly from it, but from a control panel located next to it (and I can do it so far). However, I was thinking about a one-time Repair Skill check to actually get the control panel working before it can be actually used, and I have literally no idea about how to do it - except for I guess there's a little scripting involved.

 

 

If anyone could help me figure this out, that would help my mod a lot!

Link to comment
Share on other sites

Speaking in very general terms, break your problem down into steps.

 

Your "control panel" is essentially a "terminal" provided by the game. You have to link the terminal to the door. This is described in the GECK tutorial "Non-NPC Population". There are several scripts in the game which do this, though I can't recall specific instances off the top of my head. (Typically these are found in vaults.)

 

A "skill check" is just a comparison of the "getactorvalue < skill >" against the threshold you want to set. You can then prompt the player with a message telling them the (initially inactive) terminal is "broken" and asking if they want to attempt to repair it, and perform the skill check at that time. Once they pass the skill check, your script makes the terminal "active". Once active, the terminal will open the door.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Thanks for answering!
​The object I'm currently using is not a Terminal but a "control pod" activator.

 

However, the problem here is that I understand what needs to be done, but I do not know how​ to actually do it.

Link to comment
Share on other sites

Again: break your problem down into steps. What part are you having trouble with implementing if you understand what you need to do?

 

A "control pod" is no different than a "terminal" as far as acting as a "activator". Just a different piece of artwork. Are you having problems placing the item or linking it to the door following the tutorial linked earlier?

 

An "activator" has a script attached to it. (It's a property of the "activator".) It should be fairly obvious that you need a "Begin OnActivate" block in the script called by the "Activator". Within that block you place your message to the player asking if they want to attempt to repair the "control pod". Do you understand how to prompt and get the response?

 

Do you have any experience writing a script? If not then you need to read up on the basics of scripting. Please see the 'Scripting' section under "Tutorials" in the wiki "Getting started creating mods using GECK" article. (It's an essential skill if you are going to create mods. It IS basic programming.)

 

However the player responds, you need to have your script provide a reaction either way.

 

If in the affirmative, then you perform your "skill check", and if it passes, set a "Do Once" flag variable so you can bypass the entire "prompt and check" set of code in future. (A "do once" variable is just that: a variable you define and use as a "true/false" flag to tell if some event has already occurred and the following code should not be processed if it has.) You also want to use the "Activate" function to enable the "control pod" to now function correctly.

 

If the player declines to try, or fails to pass the skill check, then you want to enable them to try again (unless you don't). Which is why you only set the "Do Once" flag if they succeed in this case.

 

If that doesn't cover your problem, then you need to think about exactly where the difficulty lies. Seems pretty straightforward to me, and I'm not a "mod creator". It often helps to write out what you think is needed as "pseudo-code": simple statements of what the code should be doing at each step of the process to help you visualize the progress and conditions. (The above is just a description of the logic; not "pseudo-code".) That then guides you in determining exactly what functions and syntax are needed to actually accomplish what you want.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

The "understanding" part is okay, I used to code in the past so I still remember a little about how to do things. I've also started reading the scripting section in the tutorials, and this is helping me with later stages of the mod. Linking objects one to another also seems okay for me.

 

What I really can't find is any info on how to actually let the player choose between one or another option: is there a page where I can find commonly-used scripts? The main problem is I don't really know the Geck's language, so I just can't give the proper commands to it.

 

Also a question: if I plan to add a quest involving the use of different activators, can I start adding quest stages after​ everything else is ready, or is it required that I move further as I add quest stages?

Link to comment
Share on other sites

Choices require a "menu". Take a look at the GECK "Adding an Options Menu" tutorial. (I'll add that to the list of tutorials.) It's more elaborate than you need (with sub-menus), but covers all the basics required of a menu: accessing the menu, ShowMessage, and GetButtonPressed. I suggest rather than attempting to write yours by following it step by step, you instead try to understand why each section does what it does, and then take only the elements you need. By the time you are done with that you will have a solid understanding of how a menu works.

 

Think of quests as wrappers around various stages. Each stage is distinct, but the quest presents them in order and when you have completed one it then presents the next. When all stages are complete, the quest is done. So yes, you can build the different stage components and scripts and then use the quest script to tie them all together. But it helps to plan out the quest first, at least in skeletal form. It provides a handy place to setup and store variables used by the various stage scripts.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Choices require a "menu". Take a look at the GECK "Adding an Options Menu" tutorial. (I'll add that to the list of tutorials.) It's more elaborate than you need (with sub-menus), but covers all the basics required of a menu: accessing the menu, ShowMessage, and GetButtonPressed. I suggest rather than attempting to write yours by following it step by step, you instead try to understand why each section does what it does, and then take only the elements you need. By the time you are done with that you will have a solid understanding of how a menu works.

 

 

I'm not entirely sure since I still haven't finished reading the tutorial you've linked, but I think there might have been a misunderstanding: what I meant with "letting the player choose between options" was something like choosing the floor while using an elevator and such.

 

What I need to do now is something like this:

blah blah blah you can either repair the thingy blah blah or break it to scrap metal

 

And then let the player choose between one of the two options.

 

Is this what that tutorial is about? I'm asking simply because that doesn't seem to be what I was looking for.

Link to comment
Share on other sites

Here's how I'd do it:

 

 

scriptname TerminalScript
int bRepaired
int bAwaitingInput
int iButtonID

; This block will run when the terminal is activated by any actor. This bypasses the normal activation
; of an object, meaning that nothing will happen unless you explicitly allow it.
begin OnActivate

	; The following code should only run when the terminal is activated by the player.
	if (IsActionRef PlayerRef)
	else
		return
	endif

	; The bRepaired variable is set to true when the terminal has been repaired. If it is true, manually
	; activate the terminal with the player as the actionref. This will count as a normal activation,
	; opening the terminal menu.
	if (bRepaired)

		Activate PlayerRef
		; Note: this line does NOT activate the player, the player is passed as the actionref
		; argument to the function.
		; The function is called ON (or by) the terminal using implicit reference syntax (this script is
		; attached to the terminal, which means that if you want the terminal to be the calling object, you
		; don't  have to explicitly define it).
		; Further explanation: https://geck.foesmm.org/index.php/Reference_functions
		return
	endif

	; If the script made it past the conditions, it's time to prompt the player for some input.
	ShowMessage TerminalRepairPrompt
	set bAwaitingInput to 1

end

; This block only runs while the message menu (1001) is open.
begin MenuMode 1001

	; You don't want to do anything if you're not currently expecting input.
	if (bAwaitingInput)
	else
		return
	endif

	; Fetch the index of the last pressed button. GetButtonPressed returns -1 if no button has been 
	; pressed yet, so check for this value before proceeding.
	set iButtonID to GetButtonPressed
	if (iButtonID == -1)
		return
	endif

	; A button has been pressed, you don't expect additional input.
	set bAwaitingInput to 0

	; The button index returned by GetButtonPressed corresponds to the button index from the message form.
	; In this case, 0 is the repair button, 1 is the exit button.
	if (iButtonID == 0)

		; Flag the variable to let the terminal know that it's been repaired.
		set bRepaired to 1

		; If you want, you can reward the player some XP. It's a good way to signal that they've succeeded.
		RewardXP 10

		; Alternatively, you can show another message upon success. Some additional flavor text never hurts.
		; Note: this doesn't seem to work for box type messages unless you switch to a GameMode block.
		ShowMessage TerminalRepairSuccess

	elseif (iButtonID == 1)
		; This is the exit button, so you don't strictly have to check for it, unless you want something
		; special to happen if the player exits prematurely.
	endif

end

 

Attach that script to your terminal. I've added some comments to help you understand how things work.

 

Before saving the script, you need to create a message form and give it the ID "TerminalRepairPrompt" and two buttons. Button index 0 is the repair button and index 1 is the exit button.

 

I've attached a condition to the first button so that it only appears if the player has the required skill level. Saves me from writing a condition for this in the script.

 

Here's an example screenshot:

 

 

 

Edited by Ladez
Link to comment
Share on other sites

Thanks Ladez, I've understood how the code works and I've managed to get it to work in-game.
However, I was thinking about a third possibility, which would be not to repair or leave the terminal, but instead to break it down and gather components from it.

So I've decided to edit your code a little:

 

 

I've added one more button in the Message screen, then edited the last piece of the code as follows:

if (iButtonID == 0)
   set bRepaired to 1
   RewardXP 50
   DoorREF.Unlock
if (iButtonID == 1)
   set bRepaired to 1
   DoorREF.Lock 255
if (iButtonID == 2)
endif

 

 

 

If I actually understood your code correctly, the Button2 option will now have the terminal count as "repaired", so it can't be interacted with anymore, but also lock the door so that it will be locked forever.

Button2 now is the "don't do anything" button and Button1 still works as you intended it to do.

However, simply adding an option between the original Button1 and Button2 gets me a âmismatched if/else/endif block âerror (I'm using the Geck PoweUp thingy to see it) which immediately disappears if I remove those two lines and leave everything else as it is now.

 

I know having someone else look at your code is the easist way to spot any mistakes, so... what could be wrong in those two lines?

Link to comment
Share on other sites

You need to use "elseif" when chaining multiple mutually exclusive conditions together:

 

 

if (iButtonID == 0)
   set bRepaired to 1
   RewardXP 50
   DoorREF.Unlock
elseif (iButtonID == 1)
   set bRepaired to 1
   DoorREF.Lock 255
elseif (iButtonID == 2)
endif

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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