**Game Version number: 1.6.0.95**
**Modded?:** No
**Issue Description: **
The SCR_AIGroup class has an Event_OnInit ScriptInvoker that is usually invoked once the group has finished spawning characters.
The normal place where it is invoked is in the end of the SpawnGroupMember method, if it was the last character to spawn.
However, a few lines prior to this invoke call, there are return statements for the case that the group member failed to spawn.
This is an issue because it means that if the last group member did not spawn successfully, the groups init event is never invoked.
There is actually a mitigation for a similar issue in the bottom of the CreateUnitEntities method:
```
//--- Call group init if it cannot be called by the last spawned entity
if (m_iNumOfMembersToSpawn == 0 && Event_OnInit)
Event_OnInit.Invoke(this);
```
However this only takes effect if the number of characters to spawn was 0 in the first place, so it does not help here.
The most elegant way to fix this (i. e. without calling Invoke on every return statement in the method) is to remove the isLast parameter and invoke calls from SpawnGroupMember entirely, and just handle invocation in the SpawnDelayedGroupMember method, the only place from which SpawnGroupMember is called.
Current:
```
bool SpawnDelayedGroupMember(int spawnIndex)
{
return SpawnGroupMember(
m_delayedSpawnList.Get(spawnIndex).snapToTerrain,
m_delayedSpawnList.Get(spawnIndex).index,
m_delayedSpawnList.Get(spawnIndex).resourceName,
m_delayedSpawnList.Get(spawnIndex).editMode,
spawnIndex == 0 // isLast
);
}
```
New:
```
bool SpawnDelayedGroupMember(int spawnIndex)
{
bool b = SpawnGroupMember(
m_delayedSpawnList.Get(spawnIndex).snapToTerrain,
m_delayedSpawnList.Get(spawnIndex).index,
m_delayedSpawnList.Get(spawnIndex).resourceName,
m_delayedSpawnList.Get(spawnIndex).editMode
);
if (spawnIndex == 0 && Event_OnInit)
Event_OnInit.Invoke(this);
return b;
}
```
This not only fixes the bug but also simplifies the SpawnGroupMember method slightly.