Posts

Showing posts from April 17, 2019

Finds a Character based on distance and health

Image
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0; } 1 $begingroup$ I need to improve the efficiency of my program and, using the profiler, have narrowed the problem down to 2 key areas, but I am having trouble coming up with ways to make the program run better. Based on my profiler's report, it seems to be telling me that my if functions are inefficient. Whats a better way to achieve a better result? Character* FindAttackTarget() const { float weakestHp = FLT_MAX; Character* weakestEnemy = nullptr; uint64_t weakestCharId = INT64_MAX; //Only attack characters that are within attack range auto& gameChars = m_pGame->m_gameChara