diff options
-rw-r--r-- | src/GameTick.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 47e6af3..1193c3c 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -550,13 +550,18 @@ void spawnNpc(Game* game) { // Pick a random unfull block close to the player int blockspawnx, blockspawny; - auto& player = game->person[0]; - auto block = player.playercoords / block_spacing; - for (auto i = 0; i < 10; ++i) { + auto block = game->person[0].playercoords / block_spacing; + auto npc_type = (game->type == zombie_type) ? zombietype + : randUint(game->evilprobability) ? civiliantype : eviltype; + auto& vip = game->person[1]; + for (auto i = 0; i < 42; ++i) { blockspawnx = block.x + 0.5f + randInt(-1, 1); blockspawny = block.z + 0.5f + randInt(-1, 1); - if (game->citypeoplenum[blockspawnx][blockspawny] - < max_people_block) + if ((game->citypeoplenum[blockspawnx][blockspawny] + < max_people_block) + && (npc_type == civiliantype + || blockspawnx != vip.whichblockx + || blockspawny != vip.whichblocky)) break; } if (game->citypeoplenum[blockspawnx][blockspawny] >= max_people_block @@ -584,27 +589,28 @@ void spawnNpc(Game* game) npc.whichblockx = blockspawnx; npc.whichblocky = blockspawny; npc.whichcostume = casualcostumes + randUint(numcasual); - if (game->type == zombie_type) { - npc.type = zombietype; + switch (npc.type = npc_type) { + case zombietype: npc.aiming = false; npc.existing = true; npc.pathsize = 1.04; npc.speedmult = 0.7f + 0.2f * game->difficulty; npc.targetanimation = zombiewalkanim; - } else if (randUint(game->evilprobability)) { - npc.type = civiliantype; + break; + case civiliantype: npc.aiming = false; npc.existing = false; npc.pathsize = 0.98f + 0.04f * randFloat(); npc.speedmult = 0.8f + 0.4f * randFloat(); npc.targetanimation = walkanim; - } else { - npc.type = eviltype; + break; + case eviltype: npc.aiming = true; npc.existing = true; npc.pathsize = 1.04; npc.speedmult = 1.0f + 0.3f * game->difficulty; npc.targetanimation = walkanim; + break; } npc.pathnum = -1; |