/** * perform logic() for all enemies */ void EnemyManager::logic() { if(player_blocked) { player_blocked_ticks--; if(player_blocked_ticks <= 0) player_blocked = false; } handleSpawn(); std::vector<Enemy*>::iterator it; for (it = enemies.begin(); it != enemies.end(); ++it) { // new actions this round (*it)->stats.hero_stealth = hero_stealth; (*it)->logic(); } }
/** * perform logic() for all enemies */ void EnemyManager::logic() { handleSpawn(); for (int i=0; i<enemy_count; i++) { int pref_id = -1; // hazards are processed after Avatar and Enemy[] // so process and clear sound effects from previous frames // check sound effects for (int j=0; j<sfx_count; j++) { if (sfx_prefixes[j] == enemies[i]->stats.sfx_prefix) { pref_id = j; break; } } if (pref_id == -1) { printf("ERROR: enemy sfx_prefix doesn't match registered prefixes (enemy: '%s', sfx_prefix: '%s')\n", enemies[i]->stats.name.c_str(), enemies[i]->stats.sfx_prefix.c_str()); } else { if (enemies[i]->sfx_phys) Mix_PlayChannel(-1, sound_phys[pref_id], 0); if (enemies[i]->sfx_ment) Mix_PlayChannel(-1, sound_ment[pref_id], 0); if (enemies[i]->sfx_hit) Mix_PlayChannel(-1, sound_hit[pref_id], 0); if (enemies[i]->sfx_die) Mix_PlayChannel(-1, sound_die[pref_id], 0); if (enemies[i]->sfx_critdie) Mix_PlayChannel(-1, sound_critdie[pref_id], 0); } // clear sound flags enemies[i]->sfx_hit = false; enemies[i]->sfx_phys = false; enemies[i]->sfx_ment = false; enemies[i]->sfx_die = false; enemies[i]->sfx_critdie = false; // new actions this round enemies[i]->stats.hero_pos = hero_pos; enemies[i]->stats.hero_alive = hero_alive; enemies[i]->logic(); } }