Permalink
Browse files

make spawn groups always spawn in their entirety

Also select the first creature to be spawned by a spawn point randomly,
and don't let the '0' default for BG2 spawngrp.2da make us try to spawn
'0' creatures.
  • Loading branch information...
1 parent 1c65766 commit 8f27767ae92c1a4a201864f6c98fd7dc01f84e9c @fizzet fizzet committed Jul 20, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 gemrb/core/Map.cpp
View
10 gemrb/core/Map.cpp
@@ -187,7 +187,7 @@ static void InitSpawnGroups()
int j=tab->GetRowCount();
while (j--) {
const char *crename = tab->QueryField( j,i );
- if (crename[0] != '*') break;
+ if (strcmp(crename, tab->QueryDefault())) break;
}
if (j>0) {
SpawnGroup *creatures = new SpawnGroup(j);
@@ -3053,9 +3053,9 @@ bool Map::SpawnCreature(const Point &pos, const char *creResRef, int radiusx, in
if (Spawns.Lookup(creResRef, lookup)) {
sg = (SpawnGroup *) lookup;
- if (level >= (int) sg->Level) {
+ if (first || (level >= (int) sg->Level)) {
count = sg->Count;
- } else if (!first) {
+ } else {
count = 0;
}
}
@@ -3066,7 +3066,7 @@ bool Map::SpawnCreature(const Point &pos, const char *creResRef, int radiusx, in
// ensure a minimum power level, since many creatures have this as 0
int cpl = creature->Modified[IE_XP] ? creature->Modified[IE_XP] : 1;
- //SpawnGroups normally are all or nothing but make sure we spawn
+ //SpawnGroups are all or nothing but make sure we spawn
//at least one creature if this is the first
if (level >= cpl || sg || first) {
AddActor(creature, true);
@@ -3116,7 +3116,7 @@ void Map::TriggerSpawn(Spawn *spawn)
}
//create spawns
int difficulty = spawn->Difficulty * core->GetGame()->GetPartyLevel(true);
- unsigned int spawncount = 0, i = 0;
+ unsigned int spawncount = 0, i = rand() % spawn->Count;
while (difficulty >= 0 && spawncount < spawn->Maximum) {
if (!SpawnCreature(spawn->Pos, spawn->Creatures[i], 0, 0, &difficulty, &spawncount)) {
break;

0 comments on commit 8f27767

Please sign in to comment.