GameMode block question?

Post » Tue May 17, 2011 8:36 am

Just a quick question: does a GameMode block in an object script run when the player is not in the same cell the object is in?

Thanks!
User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm

Post » Tue May 17, 2011 3:06 am

No.

edit - though on actors with low level processing - once in awhile. I think.
User avatar
Kim Kay
 
Posts: 3427
Joined: Fri Oct 13, 2006 10:45 am

Post » Tue May 17, 2011 3:40 am

No.

edit - though on actors with low level processing - once in awhile. I think.


Thanks! Was wondering if it's worthwhile to disable activators I use so their GameMode blocks aren't eating cycles. Appreciate it!
User avatar
Dark Mogul
 
Posts: 3438
Joined: Tue Feb 20, 2007 11:51 am

Post » Mon May 16, 2011 11:24 pm

Disabled objects still run their scripts.
User avatar
Susan
 
Posts: 3536
Joined: Sun Jun 25, 2006 2:46 am

Post » Tue May 17, 2011 4:20 am

That is surprising. So a disabled NPC will still respond to "addscriptpackage" to change its package, for example. Will it respond to "moveto" commands? How about "startcombat"? If it has a sandbox package active, will it move? All of these matter in case the NPC is suddenly enabled.
User avatar
Cash n Class
 
Posts: 3430
Joined: Wed Jun 28, 2006 10:01 am

Post » Tue May 17, 2011 7:33 am

Actors who are disabled do not run AI data, but moveto would move them. Consider a lot of lighting scripts people use that turn off and on lights according to time of day. Even when it's disabled the script is running as long as its cell is loaded.

You could call addscriptpackage to a disabled NPC and when they are enabled that will be their current package. Startcombat would do nothing, and really it's kind of a useless function since FO3. They changed the way it works (I made note of it on the talk page of the wiki). Basically it only works if the actor can detect the target, otherwise it is ignored. My guess is they changed it because startcombat in Oblivion would persist until one of the actors was killed, or stopcombat was called. This prevented the PC from using the wait function, or fast travel even if they put the whole map distance between them and the combat actor.
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Tue May 17, 2011 6:26 am

Disabled objects still run their scripts.


Oh; gee; that's wonderful! :P

Thank you; good to know!
User avatar
Chantelle Walker
 
Posts: 3385
Joined: Mon Oct 16, 2006 5:56 am

Post » Tue May 17, 2011 6:43 am

An easy way to think of this is that whilst disabled objects still run scripts, disabling them can still remove the conditions required for anything to happen.

So say you have a primitive activator with a GameMode block on it. Even when you disable it the script will still run (unless you've used a doOnce or similar check).
However if the same primitive activator has an OnTrigger block, and you set it to disable after triggering, then the script will still run, but as the object is disabled you can't actually trigger it, so in all essence the script and object are disabled.

It all depends on what type of block you've used, and how the activator is set up.
User avatar
Krista Belle Davis
 
Posts: 3405
Joined: Tue Aug 22, 2006 3:00 am

Post » Tue May 17, 2011 5:47 am

An easy way to think of this is that whilst disabled objects still run scripts, disabling them can still remove the conditions required for anything to happen.

So say you have a primitive activator with a GameMode block on it. Even when you disable it the script will still run (unless you've used a doOnce or similar check).
However if the same primitive activator has an OnTrigger block, and you set it to disable after triggering, then the script will still run, but as the object is disabled you can't actually trigger it, so in all essence the script and object are disabled.

It all depends on what type of block you've used, and how the activator is set up.


Ah; what I've done is to create several primitive remote activators, and attached scripts to them with OnActivate and GameMode blocks in them. This removes all real work previously done in GameMode blocks in the actual interactive objects to the remote activators. The OnActivate Player script stub simply enables the remote activator linked to it in order to kick off the activity on the remote activator. When done, the remote activator disables itself in preparation to be called again.

Guess this is all pointless, huh?
User avatar
Robert Jr
 
Posts: 3447
Joined: Fri Nov 23, 2007 7:49 pm

Post » Tue May 17, 2011 9:24 am

Something I do, which may or may not be of use to you, is to move my activators to a holding cell when not in use. For instance the first line of the gamemode section is usually like this...

if active == 0
moveto HoldCell
return
endif

Then when I need the activator I use

MyActivatorRef.Moveto player 100
set MyActivatorRef.active to 1

If you need it to move to a specific spot you can use an xmarker, or xmarkerheading, depending on if you need a specific rotation on it. However you can also just use...

if active == 0
return
endif

Which will keep the bulk of the script from running and is pretty efficient.
User avatar
Marina Leigh
 
Posts: 3339
Joined: Wed Jun 21, 2006 7:59 pm

Post » Tue May 17, 2011 2:55 pm

Something I do, which may or may not be of use to you, is to move my activators to a holding cell when not in use. For instance the first line of the gamemode section is usually like this...

if active == 0
moveto HoldCell
return
endif

Then when I need the activator I use

MyActivatorRef.Moveto player 100
set MyActivatorRef.active to 1

If you need it to move to a specific spot you can use an xmarker, or xmarkerheading, depending on if you need a specific rotation on it. However you can also just use...

if active == 0
return
endif

Which will keep the bulk of the script from running and is pretty efficient.


Yeah; I have been using guard conditions ( if yada-yada ). I was just hoping that disabling would keep objects from even having to do the checks. Ah, well... guess I'll just go back to guard conditions.

This has saved me a lot of wasted effort. OTOH, had my idea worked out, it might have made code isolation a usable concept in TES script.

Thanks! :)
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm


Return to Fallout: New Vegas