How often can I reference an object?

Post » Thu Sep 09, 2010 5:25 am

How many times can you safely reference the same person or object in one script? I would like to make a script so that it checks for and removes 34 different factions (or just deletes all factions the actor is in), but I'm not sure if the game would just stop processing that after doing the first few. Also, it needs to only affect the reference, not the base actor. I would like to know if this is possible, or if I will just have to let unwanted factions act as a wild card in my mod.
User avatar
David Chambers
 
Posts: 3333
Joined: Fri May 18, 2007 4:30 am

Post » Thu Sep 09, 2010 3:42 pm

Asfar as I know, there is NO limit to how many times you can reference the same object-- I've had scripts which reference the Player a couple of hundred times, and there's not been any problem at all :)

I believe "This" is the command you need to get just the Reference, as "GetSelf" will also call the Base Reference-- but I am not completely sure on this, so hopefully someone else will confirm/correct that :)
User avatar
Emma Louise Adams
 
Posts: 3527
Joined: Wed Jun 28, 2006 4:15 pm

Post » Thu Sep 09, 2010 6:41 am

Mind explaining why you need to remove ALL factions? Usually only a single faction affects anything in the game (ownership, reactions etc). There aren't any script functions that allow a test with a wildcard, (or your request would have been trivial, too!), so I don't understand why you need to remove any more than one or two that directly relate to the quest.

The main concern is that you may be making a mod that is automatically incompatible with any other mod that uses factions - ones that yours can't possibly know about. Most quests mods will add several new ones, if only to make a character sleep in his own bed.

(Edit:) Nevermind, just found your other thread. You'll need OBSE. That has a pair of functions to get a list of the NPC's factions, and let you retrieve each one in turn (GetNumFactions and GetNthFaction) so you can set the rank to -1 in each.

However, I'd still expect potential problems here. There are a few cases where an NPC is placed into a faction to prevent them from attacking the player or another NPC and breaking a quest. You're removing those safety nets, and could have problems.
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Thu Sep 09, 2010 11:10 am

Only base actors belong to factions. It's not possible to add or remove select actor references from factions without affecting the base object.

"this" and "getself" are two names for exactly the same function returning the calling reference.

There is no limit to how many times you can refer to a particular object in a script, or for that matter how many unique objects a script can refer to.

I second ghastley's comments about mod compatibility.
User avatar
Dagan Wilkin
 
Posts: 3352
Joined: Fri Apr 27, 2007 4:20 am

Post » Thu Sep 09, 2010 3:38 am

"this" and "getself" are two names for exactly the same function returning the calling reference.


I'm not sure about this... I recall a thread recently, where it was mentioned that "GetSelf" returns the base Reference on NPCS (hence why Spells get Added to all future versions, for example), and "This" returns the actual instance... But I've not messed with it too much, and can't recall the thread, so I may just be misunderstanding it... The CS Wiki doesn't say anything about this, and does confirm what you're saying that they're the same, so... :shrug:

Edit:
Found it :)

Well, for the most part, an ability spell will "stay" on ONLY the person you add it to, since it's not on the base object *if* you don't use GetSelf anywhere, since GetSelf can return the base ref on respawnable characters, I'd sift through the entire code and do a replace of "GetSelf" with "This".

From this Thread : http://www.gamesas.com/index.php?/topic/1080073-unholy-darkness-complete-vampire-overhaul/page__hl__GetSelf__st__60

Looking at it, yes, it sounds like I just misinterpeted the meaning (I.e., "GetSelf == BaseRef", This==InstanceRef").
User avatar
Lew.p
 
Posts: 3430
Joined: Thu Jun 07, 2007 5:31 pm

Post » Thu Sep 09, 2010 4:54 pm

I'm not sure about this... I recall a thread recently, where it was mentioned that "GetSelf" returns the base Reference on NPCS (hence why Spells get Added to all future versions, for example), and "This" returns the actual instance

They have the same opcode and do the same thing.
The quote you posted is a couple of months old so there's probably no point in correcting it in the original thread, but it shouldn't be taken as fact.
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm

Post » Thu Sep 09, 2010 8:47 am

http://www.gamesas.com/index.php?/topic/1080785-does-getself-work-in-dialogue-result-scripts/ where a difference between this and getSelf is reported - so what happens finally :confused:
User avatar
Chenae Butler
 
Posts: 3485
Joined: Sat Feb 17, 2007 3:54 pm

Post » Thu Sep 09, 2010 12:05 pm

Scruggsy and the OBSE team have done more work on Oblivion's functions than anyone-- if he says they're the same, they probably are :) So GetSelf and This should be the same :)
User avatar
chinadoll
 
Posts: 3401
Joined: Tue Aug 22, 2006 5:09 am

Post » Thu Sep 09, 2010 5:58 pm

Scruggsy and the OBSE team have done more work on Oblivion's functions than anyone-- if he says they're the same, they probably are :) So GetSelf and This should be the same :)

Yes I know - I just wanted him to explain what happens in http://www.gamesas.com/index.php?/topic/1080785-does-getself-work-in-dialogue-result-scripts/, which I forgot to link to :)
Curiosity :D
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Thu Sep 09, 2010 9:13 am

Yes I know - I just wanted him to explain what happens in http://www.gamesas.com/index.php?/topic/1080785-does-getself-work-in-dialogue-result-scripts/, which I forgot to link to :)
Curiosity :D

News to me.
The difference is very minor, but often missed. I suppose it can be best explained by usage within an item script, which as you know, does not work well with getself as the reference ID is temporary. However, when This is used, it seems to ignore this check of the temporary reference and returns the object. This can also be directly used in functions whereas Getself needs to be stored before it can be used. The reason why it works here is probably related to the more direct way that This works. It's one of the more arcane functions, so can't really think of any good examples at the moment.

Both getSelf and this produce compiler errors if used in expressions like
this.disablemoveto this

The editor appears to do a direct string comparison of script text against "getself" when loading scripts on carryable objects. This should have no effect on runtime behavior.

In case it's not clear: every command can have two different names. Both names refer to the same opcode, parse routine, runtime handler, etc.
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Thu Sep 09, 2010 10:20 am

News to me.

Both getSelf and this produce compiler errors if used in expressions like
this.disablemoveto this

The editor appears to do a direct string comparison of script text against "getself" when loading scripts on carryable objects. This should have no effect on runtime behavior.

In case it's not clear: every command can have two different names. Both names refer to the same opcode, parse routine, runtime handler, etc.

Thanks :)
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm


Return to IV - Oblivion