Question about GameMode

Post » Thu Mar 24, 2011 10:14 am

Hello all,

Well, started to get some things working in the GECK so now I'm starting a mini project.

Well, I was pretty good with Morrowind scripting back in the day but I'm trying to get my head around what the most appropriate equivalents are in FO3.

Would I be right in thinking that an object in the cell with a script in a GameMode blocktype acts as the equivalent of Morrowind's local scripts? i.e. they will only run whilst the player is in the cell with the object in it?

And whilst not totally relevant at this point, are scripts set up as Quest scripts, as opposed to Object scripts, FO3's version of Global scripts?

Thanks :)
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Thu Mar 24, 2011 7:48 pm

Morrowind scripting is so limited compared to Oblivion and finally, Fallout3 scripting. I have modded all three...

Check this out for the different 'begin' modes:
http://geck.gamesas.com/index.php/Begin

GameMode will run when its 'loaded' into memory. That is usually when the player is in the cell. Dependant on the object it is on, it may even run when the player is not in the cell, but the object is loaded into memory. For example, a gamemode block on an NPC that is persistant, may have its script running even if the NPC is totally somewhere else.

Quest scripts are scripts that are attached to a 'Quest' object. When the quest runs, and the conditions are met, the script attached to the quest will run.

You will find things are much different from Morrowind...
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Thu Mar 24, 2011 11:05 pm

Thanks for the answer :)

I am finding a lot of the principals of scripting that I learnt in MW are still useful in FO3 (never did much beyond some building in Oblivion) but I think what is holding me back is I still think in terms of MW scripting, which at times I need to make adjustments (a habit which, I'm sure, I'll break in time).

I was looking at the workbench script (it's a useful one for me to learn from tbh as it does a few things I'm trying to do myself) - I notice that it starts with an OnActivate block then a GameMode block - what I'm wondering is that is the GameMode block still running whilst the player is in the cell or does in only run when the workbench is activated due to the preceding OnActivate block?

Also, I think I might be able to avoid GameMode for what I'm trying to do, would the following work...

Item A enables/disables something depending on it's item count. However, options B and C, as well as A, can all alter the item count.

A GameMode on item A, checking the item count, would obviously work.

Now, suppose I add item D with an OnActivate block that checks the item count and does the necessary enabling/disabling. I then set items A, B and C to activate item D once they've been interacted with.

Would this work and would it be more efficient, in terms of how often scripts are running?

Hope this makes sense and once again, thanks for the help :goodjob:
User avatar
kristy dunn
 
Posts: 3410
Joined: Thu Mar 01, 2007 2:08 am

Post » Thu Mar 24, 2011 11:14 am

I was looking at the workbench script (it's a useful one for me to learn from tbh as it does a few things I'm trying to do myself) - I notice that it starts with an OnActivate block then a GameMode block - what I'm wondering is that is the GameMode block still running whilst the player is in the cell or does in only run when the workbench is activated due to the preceding OnActivate block?

The gamemode block will always run if the player is in the same cell, and CAN be made to keep running when the player isn't, otherwise it stops when the containing object/actor is cleaned from memory.
No, OnActivate doesn't prevent another blocktype from running.. if it's in the script, it will run according to it's designed type.
The OnActivate block is very useful for changing variables, and have those changes satisfy conditions for IF statements in the gamemode block. That way you can exclude most, if not nearly all of the code in the gamemode block until a predefined condition is met.

Yes, as long as all the count queries and item swaps can be done in one pass, you could use OnActivate blocks exclusively. Since OnActivate only runs once per activate, any constant monitoring of something has to be done in another blocktype that contantly repeats.
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Thu Mar 24, 2011 5:04 pm

Yes, as long as all the count queries and item swaps can be done in one pass, you could use OnActivate blocks exclusively. Since OnActivate only runs once per activate, any constant monitoring of something has to be done in another blocktype that contantly repeats.


Well, in my example item A is a scripted container - interaction is via messagebox so it's very controlled in that sense and the item count check only needs to be done once the player has clicked the exit button, item B is actually an npc, whom will alter the item count depending on the player dialogue choice so again, the item count only needs doing after the player has chosen the appropriate dialogue and item C is a terminal which can also affect the item count.

I will get some scripts in place this weekend and do some tests but hopefully this should work and avoid the need for GameMode blocks, which I am sure would have minimal impact but I don't want to have a script running unless absolutely necessary.

The gamemode block will always run if the player is in the same cell, and CAN be made to keep running when the player isn't, otherwise it stops when the containing object/actor is cleaned from memory.


Out of interest, what would make a GameMode block run when a player isn't in the cell, I know WillieSea mentioned scripts from npcs but I'm interested to know - I read the GameMode entry on the wiki, including the link to the Oblivion wiki entry, but it isn't overly descriptive.

I really miss GhanBuriGhan's scripting for dummies lol that was so useful for MW, wished their was an FO3 equivalent :D
User avatar
Ezekiel Macallister
 
Posts: 3493
Joined: Fri Jun 22, 2007 12:08 pm

Post » Thu Mar 24, 2011 3:03 pm

You might want to check this site out. There is a scripting class with several learning classes as well as scholars that help people with questions.
http://www.invision.tesalliance.org/forums/index.php?/forum/15-scripting/

Its geared to Oblivion, but they also support Morrowind and Fallout scripts.
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Thu Mar 24, 2011 9:19 pm

Out of interest, what would make a GameMode block run when a player isn't in the cell, I know WillieSea mentioned scripts from npcs but I'm interested to know - I read the GameMode entry on the wiki, including the link to the Oblivion wiki entry, but it isn't overly descriptive.

It's not just NPCs.. pretty much anything that you can set as a persistant reference will keep the script running when the player isn't around. There's also quest scripts that always run if the quest is enabled/started and it's conditions are met.
User avatar
Carlos Vazquez
 
Posts: 3407
Joined: Sat Aug 25, 2007 10:19 am

Post » Thu Mar 24, 2011 10:24 am

I use questscripts for making GameMode blocks always run.
User avatar
Tessa Mullins
 
Posts: 3354
Joined: Mon Oct 22, 2007 5:17 am

Post » Thu Mar 24, 2011 3:02 pm

Thanks for the answers, even though it throws up some more questions hehe

So basically, if I have 50 scripted items in my cell, they're all persistant references, those scripts will still be running after I leave the cell?

The reason for so many scripted items btw is that they're containers but the player doesn't access them directly but through options (up to 3) in a message box (a bit like the workbench message box set up, which the scripts are based on) so that in effect is 50 GameMode blocks running.

I might be able to not have them as persistant references, though the work around would take longer, but I'm wondering what the potential performance issues of that many scripts running might be.
User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Post » Thu Mar 24, 2011 9:47 am

You must use 'effeciency' in your gameMode blocks so they only run when you want them to.

You use varaibles to do that.

short myStateBegin OnActivate   if myState == 0      set myState to 1   endifendBegin GameMode   if myState == 1      player.addItem Caps001 100      set myState to 0   endifend


Remember, OnActivate only runs ONCE and only when activated by the PLAYER or an NPC.
It can be used to control when the GameMode is performed with the myState variable I made.
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Thu Mar 24, 2011 10:44 am

You must use 'effeciency' in your gameMode blocks so they only run when you want them to.

You use varaibles to do that.

short myStateBegin OnActivate   if myState == 0      set myState to 1   endifendBegin GameMode   if myState == 1      player.addItem Caps001 100      set myState to 0   endifend


Remember, OnActivate only runs ONCE and only when activated by the PLAYER or an NPC.
It can be used to control when the GameMode is performed with the myState variable I made.


That seems a good idea, thanks. :tops:

So, I think I have my script now, though a couple of things trouble me.

scn pilotlightboxscriptShort Button ; Which option on the menu is choseShort BoxCount ; The count of pilot lights in the boxShort PlayerCount ; The count of how many pilot lights the player hasShort Running ; Whether the GameMode block needs to continueBegin OnActivate	If IsActionRef Player == 1		Set Running to 1		Set BoxCount to GetItemCount PilotLight		ShowMessage mytestpilotlightboxmsg, BoxCount	EndIfEndBegin GameMode		Set Button to GetButtonPressed	If Running == 0		Return		ElseIf Button == 0									; 0 = Exit the menu		Set Running to 0	ElseIf Button == 1									; 1 = take a pilot light from the box			If GetItemCount PilotLight == 0 		; Check there are pilot lights in the box - (Needed?)			ShowMessage mytestboxisempty			Set Running to 0		Else			RemoveItem PilotLight 1			Player.AddItem PilotLight 1			Set Running to 0		EndIf	ElseIf Button == 2									; 2 = take all pilot lights from the box			If GetItemCount PilotLight == 0 		; Check there are pilot lights in the box  - (Needed?)			ShowMessage mytestboxisempty			Set Running to 0		Else			RemoveItem PilotLight BoxCount			player.AddItem PilotLight BoxCount			Set Running to 0		EndIf	ElseIf Button == 3										; 3 = put all pilot lights in the box			If Player.GetItemCount PilotLight == 0	; check the player has pilot lights to put in the box  - (Needed?)			ShowMessage mytestplayernothave			Set Running to 0		Else			Set PlayerCount to Player.GetItemCount PilotLight			Player.RemoveItem PilotLight PlayerCount			AddItem PilotLight PlayerCount			Set Running to 0		EndIf	EndIfEnd


I'm undecided whether the Running == 0 bit shouldn't be it's own block i.e.


Spoiler

scn pilotlightboxscript

Short Button ; Which option on the menu is chose
Short BoxCount ; The count of pilot lights in the box
Short PlayerCount ; The count of how many pilot lights the player has
Short Running ; Whether the GameMode block needs to continue

Begin OnActivate
If IsActionRef Player == 1
Set Running to 1
Set BoxCount to GetItemCount PilotLight
ShowMessage mytestpilotlightboxmsg, BoxCount
EndIf
End

Begin GameMode

Set Button to GetButtonPressed

If Running == 0
Return
EndIf

If Button == 0 ; 0 = Exit the menu
Set Running to 0

ElseIf Button == 1 ; 1 = take a pilot light from the box
If GetItemCount PilotLight == 0 ; Check there are pilot lights in the box - (Needed?)
ShowMessage mytestboxisempty
Set Running to 0
Else
RemoveItem PilotLight 1
Player.AddItem PilotLight 1
Set Running to 0
EndIf

ElseIf Button == 2 ; 2 = take all pilot lights from the box
If GetItemCount PilotLight == 0 ; Check there are pilot lights in the box - (Needed?)
ShowMessage mytestboxisempty
Set Running to 0
Else
RemoveItem PilotLight BoxCount
player.AddItem PilotLight BoxCount
Set Running to 0
EndIf


ElseIf Button == 3 ; 3 = put all pilot lights in the box
If Player.GetItemCount PilotLight == 0 ; check the player has pilot lights to put in the box - (Needed?)
ShowMessage mytestplayernothave
Set Running to 0
Else
Set PlayerCount to Player.GetItemCount PilotLight
Player.RemoveItem PilotLight PlayerCount
AddItem PilotLight PlayerCount
Set Running to 0
EndIf
EndIf
End


Is one way better than the other or not (both seem to work but I feel I'm missing something)?

The other niggle I have about this is whether I need to check, after options 1, 2 or 3 are chosen, the count of items in the box or player inventory, as the options in the message box have conditions attached to only display the appropriate option based on the same check.

I notice the Workbench script does something similar with a generic failure message (telling the player they cannot make that item yet) but, like I've done, the options only display based on what the player can make.

In neither my script or the workbench script I cannot see this code being executed as those options would not be given to the player anyway. Am I right in thinking the script checks are superbfluous or should they be in as some kind of failsafe?
User avatar
Luis Longoria
 
Posts: 3323
Joined: Fri Sep 07, 2007 1:21 am

Post » Fri Mar 25, 2011 1:43 am

Well, for starters, you do NOT want to capture all Button Presses with your script. You need to only run that when you are 'looking' for the button press.

Begin GameMode	If Running == 0		Return	endif	Set Button to GetButtonPressed


If the button options in your message 'menu' are conditioned, then you don't need to condition them in the result script since the only values returned will be from the buttons that were shown on the menu.
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Thu Mar 24, 2011 8:52 pm

Well, for starters, you do NOT want to capture all Button Presses with your script. You need to only run that when you are 'looking' for the button press.

Begin GameMode	If Running == 0		Return	endif	Set Button to GetButtonPressed



Ah, of course, seems obvious now you've said hehe thanks, I'll make those changes :)

If the button options in your message 'menu' are conditioned, then you don't need to condition them in the result script since the only values returned will be from the buttons that were shown on the menu.


That's been my gut instinct despite Bethesda's workbench script doing the same thing - I can only guess that the script was based on the old concept of the MessageBox function from the ES games - maybe someone just hadn't gotten into the mindset of the GECK's message set up or something hadn't been implemented yet and the script was reworked afterwards.

Thanks again :)
User avatar
Amie Mccubbing
 
Posts: 3497
Joined: Thu Aug 31, 2006 11:33 pm

Post » Thu Mar 24, 2011 8:41 pm

They probably did it that way so that the player would not complain that "I have that schematic, why isn't it showing up?!!"

Its just less headache...
User avatar
Keeley Stevens
 
Posts: 3398
Joined: Wed Sep 06, 2006 6:04 pm


Return to Fallout 3