Force An If Check With None-data?

Post » Fri Feb 18, 2011 7:47 pm

I'm working on a Mod that uses a check for Vanilla Oblivion Cells (Specifically, the Town Cells, like Anvil).

Right now, I'm keeping the Mod separate from Oblivion itself, which means none of the Oblivion data exists inside the Mod/no dependency on Oblivion.esm, et cetera.

Is there a way to force the Script to allow "If ( Player.GetInCell Anvil == 1 )", even if Anvil does not exist?
User avatar
Lynne Hinton
 
Posts: 3388
Joined: Wed Nov 15, 2006 4:24 am

Post » Fri Feb 18, 2011 8:13 pm

Is there a way to force the Script to allow "If ( Player.GetInCell Anvil == 1 )", even if Anvil does not exist?

You can do something like this:

ref player_cellstring_var cell_id...let player_cell := player.GetParentCelllet cell_id := GetEditorID player_cellif eval (sv_Find "Anvil" cell_id) == 0	; string cell_id starts with Anvil	...endif

User avatar
R.I.P
 
Posts: 3370
Joined: Sat Dec 01, 2007 8:11 pm

Post » Sat Feb 19, 2011 8:21 am

Excellent, that seems to work! Thank-you.

One thing though: == 0 normally means "Does not equal", so why does this line end with it?
User avatar
Lillian Cawfield
 
Posts: 3387
Joined: Thu Nov 30, 2006 6:22 pm

Post » Fri Feb 18, 2011 6:08 pm

Excellent, that seems to work! Thank-you.

One thing though: == 0 normally means "Does not equal", so why does this line end with it?
Because the sv_Find function doesn't return found/not found (0/1), but the position of the match, or a negative number if not found at all. So checking for 0 means checking that the match is at the start. If you change " == 0" to ">= 0" you will get all matches, not only those that match at the start.
User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm

Post » Sat Feb 19, 2011 7:14 am

Alternatively, get the formID string of the cell and compare the mod index byte with "00".
User avatar
Damned_Queen
 
Posts: 3425
Joined: Fri Apr 20, 2007 5:18 pm

Post » Sat Feb 19, 2011 9:38 am

Thanks for the help, guys :D Everything seems to be working perfectly :D
User avatar
Nick Tyler
 
Posts: 3437
Joined: Thu Aug 30, 2007 8:57 am

Post » Sat Feb 19, 2011 4:57 am

OK, now I'm confused. I thought that GetInCell effectively worked exactly the way TheNiceOne's code emulates. The string "Anvil" is not being compiled into anything, it's a literal value to be compare to the start of the current cell name. It doesn't matter if there is no Anvil, because the only source of that string is the script itself, so the lack of Oblivion.esm is irrelevant.

What I'm not sure of is how GetInCell or GetParentCell give you anything useful in a town. The wiki says they work in interior and not exterior cells, and IIRC a town's worldspace is exterior but they still appear to work provided the dummy (interior?) cell exists. They even work with Open Cities where the cities are part of the Tamriel worldspace. It appears that the interior/exterior restriction may be an exaggeration of the facts. It's also unclear why the dummy cells need to be defined, but that may be from existence checks in the script compiler. In that case, the lack of Oblivion.esm is relevant as the source of the dummy definition to get you past the syntax check, but that's only needed when you build the mod and not when you run it.

Can anyone clarify?
User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Sat Feb 19, 2011 5:12 am

Alternatively, get the formID string of the cell and compare the mod index byte with "00".
That is a simpler way, provided he's looking for one specific cell (or a small number), but not for a general check of whether the player is in Anvil (or another city).

In Enhanced Economy I have an array of names that I check similar to how I posted above (except that instead of checking for "Anvil", it loops through my name array until it finds a match), in order to look up the right index in another array that defines the local prices for that city (and some other stuff). This works for any correctly named cell in a city, even mod-added cells - and even for mod-added cities like Rimmen.


OK, now I'm confused. I thought that GetInCell effectively worked exactly the way TheNiceOne's code emulates. The string "Anvil" is not being compiled into anything, it's a literal value to be compare to the start of the current cell name. It doesn't matter if there is no Anvil, because the only source of that string is the script itself, so the lack of Oblivion.esm is irrelevant.

What I'm not sure of is how GetInCell or GetParentCell give you anything useful in a town. The wiki says they work in interior and not exterior cells, and IIRC a town's worldspace is exterior but they still appear to work provided the dummy (interior?) cell exists. They even work with Open Cities where the cities are part of the Tamriel worldspace. It appears that the interior/exterior restriction may be an exaggeration of the facts.
Well, GetParentCell has no such restriction as far as I can see. As for for GetInCell, it doesn't say that the player must be in an interior cell, but that it must be used with a valid interior cell name (or actually Editor ID). And "Anvil" is a valid interior cell editor ID (Just check the CS).

It's also unclear why the dummy cells need to be defined, but that may be from existence checks in the script compiler. In that case, the lack of Oblivion.esm is relevant as the source of the dummy definition to get you past the syntax check, but that's only needed when you build the mod and not when you run it.
I'm not sure exactly what type GetInCell's parameter is supposed to be, but it is clear that it requires it to be a valid Editor ID and not merely a string, in order to compile. So to me it looks like GetInCell requires a reference to an interior cell as parameter - which means that it effectively requires Oblivion.esm as master if you want to check for cells in Oblivion.esm.

But the way I suggested goes around this by checking for string names instead.
User avatar
Carlos Vazquez
 
Posts: 3407
Joined: Sat Aug 25, 2007 10:19 am


Return to IV - Oblivion