# Spawn points

## Recommended Posts

I'm hoping the spawn point descriptions on the area page can be clarified a bit, as they seem rather confusing to me.

Firstly, there's this formula:

0x0076 Base creature number to spawn. The actual number to spawn is given by:

(Frequency * Player Level) / Creature Power

With results rounded down.

1. What's "Frequency" - the next field?
0x0078 Seconds between spawning
2. What's "Player Level" - Player1's Level1, the average of all players' levels, all party members' levels?

3. What's "Creature Power" - the field at 0x18 (aka "Current XP" - which often times is undefined)?

Given all that, let's say the formula evaluates to (6*3)/4 = 4.5 = 4 rounded down. That means the creature in the 4th slot spawns? If there's not a Creature 4, does it spawn the next one down (Creature 3 if there is one, etc.)? (Incidentally, if "Creature Power" is zero as it often is, this formula would give a divide-by-zero error.)

Regarding the field at 0x78, aka "Spawn delay" - what exactly does this represent? If it's truly "Seconds between spawning" as advertised, and the value is 6, does that mean a creature is spawned every 6 seconds? That doesn't seem right.

This is possibly the most confusing of all:

0x007a Spawn method

Bit 0: If Bit 2 is set, don't spawn

Bit 1: One-time-spawnpoint (checked for after the spawning, and disables the spawn point if set)

Bit 2: Used internally to disable the spawn point temporarily

Set after a spawning and cleared in two situations:

(1) after the CompressTime() method for the spawn point is called with a time amount of at least 16 hours

(2) if Bit 0 is not set and there are no living spawns in the area

The only setting which sort of makes sense from the description is bit 1. Offhand I can't find any game instances of that, and it seems a bit stupid since you could just use a normal actor for that (i.e. a non-repeating spawn). A lot of spawns are set with bit 0 ("Spawn until paused"?) and some "unknown" bit like 4; others are set with no flags at all, in which case it doesn't seem clear how those are interpreted. I'm guessing like normal repeating spawns, since I've seen said creatures (I'm looking at BG1 outdoor areas since spawns seem a bit more straightforward there). Anyhow, it's not clear when bit 2 comes into play - what exactly is the CompressTime() method?

For the 3 "unknowns" at 0x7c, 0x80 and 0x82, NI seems to have Creature duration, Creature wander distance and Creature movement distance. Not sure what exactly those represent but often times they're all set to 1000.

Finally, does anyone know why the BG1 spawn points were removed in Tutu and scripted instead? Was the BG1 spawn behaviour not reproduceable in the BG2 engine because it works differently or something?

If you find Taimon's notes, you should see specifics. In general, frequency is its own value ("Base creature number to spawn" at 0x76 is frequency in that calculation), level is party level (average), and power is XP (assume minimum 1) or the difficulty field in SpawnGrp (in BG2).

The calculation determines the encounter difficulty (each run through the equation increments the running sum and spits out a spawn until max number of creatures is reached or a multiple of level is reached). I believe the game randomly picks a slot to use when first firing (only one slot is ever chosen per activation); nothing modifies it except including more of the one you most want to spawn.

The delay balances the spawn--it's a best-guess field because it doesn't do much (and the value is continually modified); just use the same value from whatever BioWare ARE you're copying.

The flags, I believe, aren't used in BG/TotSC. It's just garbage there, and spawns are either on or off and repeat after some indeterminate (or I've just forgotten) length of time. compressTime() is the last time the area was packed (i.e., you left the area this long ago and are now returning) IIRC.

The three values are moved to the actor header in the ARE for the spawned creature. Not really useful (duration is time to keep around and should be added to current time when creating the header; wander range is max point distance for random walking; move distance is unused). For the ranges, 0 imposes no limit; for duration, -1 is forever (I think the world editor used 1,000 or 10,000 default, which is what you should see most). They never used these to any actual effect that I recall.

Tutu was done because the behavior changed and the struct wasn't entirely known. It's possible you could use the flags now to replicate BG/TotSC behavior, but even that might not be exact.