Jump to content

IWD: Of areas, DVs, and mystery flags


Recommended Posts

I'm trying to wrap my head around some DV funk in IWD. Take a look at ar9200--the area script has all sorts of Dead() checks for non-existent DVs such as SKEL_4 and GOB_2. However, they do correspond to the 'actor name' set in the area file. This is used many places in HoW and TotL, and also one area (ar4002) in bogstandard IWD.


I know in BG2 there's a bit that can be set in the area file that tells the engine to use the creature's file name as a DV, overriding the one that's set in the creature file. I can not find anything appreciable different (i.e. some flag or heretofore unknown) with creatures, actor listings, or the area file itself that could flag these as such in IWD. Is this an engine feature or am I looking in the wrong place?

Link to comment

I just entered AR1000 and did a quick save, then looked at Apsel's embedded CRE file.


Initially he has no script name, his actor name is Scrimshander, and a byte/word at 0x02BE in his CRE file is set to 0x00.


In the saved game, his script name is the same as his actor name, and the byte/word at 0x02BE (immediately following the second DeathVar) is set to 0x01. This is the only unknown I have left in IWD CRE files. The same thing happens to generic NPCs with actor names like Townsperson, and so on. Apparently the game auto-assigns the actor name, if present, to the CRE's script name when loading them into memory, then sets the flag at 0x02BE. That's just a guess based on what I've seen. The only other CRE values that changed were the global/area enumeration values.


I also killed him to test all the various CRE variables, which he has conveniently enabled. The KILL_<race>_CNT variable was created and set to 1, the <scriptname>_DEAD variable was created and set to 1, the first DeathVar (TOWNIE_DEAD) was created and set to 1 (but the area script reset it to zero), and the second DeathVar (KILLED_INNOCENT) was created and set to 1. The default SPRITE_IS_DEAD<scriptname> variable was also created and set to 1.


Update: setting 0x02BE in APSEL.CRE to 1, deleting AR1000.ARE from the SAV file, reloading the game and then saving it, does not prevent the actor name from overriding the creature's scriptname. This functionality is much like that of the actor flag that is set to 1 after its associated CRE file is loaded and attached, meaning that the particular flag is a memory bit that is set by the game regardless of its initial value.

Link to comment

Avenger's post was rather vague, so I was inspired to do some further testing.


If the actor name is present when the CRE is loaded, it will be assigned as the CRE's scriptname. If no actor name is present, as is the case with spawned creatures, and the creature has a scriptname, that scriptname will be assigned as the creature's actor name. If the creature has no script name, it will be added to the area with a null actor name.


In either case, the CRE value at 0x02BE is set to 1. In the case of spawned creatures, bit 31 of the actor schedule dword is cleared. In IWD actor schedules are set to 0xFFFFFFFF for 24-hour visibility, but spawned creatures have schedules of 0x7FFFFFFF (the highest eight bits have no effect on the schedule, as there are only 24 hours in a game day but 32 bits in the schedule field.) Is this the flag you were referring to, Avenger?


IWD doesn't use any other bits of the actor flags except bit 0 to signal CRE loaded, and it doesn't seem to use the actor Spawned flag.


I agree about the scriptname. It's not a death variable until created as such in memory (to be written to the GAM file later) and prepended with SPRITE_IS_DEAD. The CRE itself doesn't contain death variables, but it controls which are created and, in the case of two, what names they're given.

Link to comment

Hmm, i referred to another bit, but i might be mistaken, and this bit is used only in BG2.

The bit I referred to is in the byte (word, dword) which marks a creature loaded (embedded in area).


IWD creatures do contain fields for real death variables as FredRichardson discovered maximum 3 such variables are possible.


What you wrote about spawned creatures seems interesting.

Either the highest bit has no effect, and the editor was simply written differently than the game, or that bit has some significance.

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...