|
|
|
@ -38,33 +38,34 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const auto TransitionPhase=[&](int newPhase){ |
|
|
|
|
const int MAX_ATTEMPTS=100; //Maximum number of tries to find a valid location.
|
|
|
|
|
Player*player=game->GetPlayer(); |
|
|
|
|
const auto PositionInRangeOfPlayer=[&player](vf2d&pos,float radius){ |
|
|
|
|
return geom2d::line<float>(player->GetPos(),pos).length()<=player->GetSizeMult()*12*2+radius; |
|
|
|
|
}; |
|
|
|
|
const auto SpawnMonsterFromConfig=[&](int phase){ |
|
|
|
|
std::string spawnMonster=ConfigStringArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",0); |
|
|
|
|
int spawnCount=ConfigIntArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",1); |
|
|
|
|
|
|
|
|
|
for(int i=0;i<spawnCount;i++){ |
|
|
|
|
float randomAngle=util::random(2*PI); |
|
|
|
|
vf2d spawnPos=m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12; |
|
|
|
|
for(int attempts=0;attempts<MAX_ATTEMPTS&&PositionInRangeOfPlayer(spawnPos,MONSTER_NAME_DATA[spawnMonster]->GetSizeMult()*12);attempts++){ |
|
|
|
|
randomAngle=util::random(2*PI); |
|
|
|
|
spawnPos=m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12; |
|
|
|
|
} |
|
|
|
|
game->SpawnMonster(spawnPos,MONSTER_NAME_DATA[spawnMonster]);
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
switch(newPhase){ |
|
|
|
|
case 2:{ |
|
|
|
|
std::string spawnMonster=ConfigStringArr("Phase2.MonsterSpawnOnChange",0); |
|
|
|
|
int spawnCount=ConfigIntArr("Phase2.MonsterSpawnOnChange",1); |
|
|
|
|
|
|
|
|
|
for(int i=0;i<spawnCount;i++){ |
|
|
|
|
float randomAngle=util::random(2*PI); |
|
|
|
|
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
|
|
|
|
} |
|
|
|
|
SpawnMonsterFromConfig(2); |
|
|
|
|
}break; |
|
|
|
|
case 3:{ |
|
|
|
|
std::string spawnMonster=ConfigStringArr("Phase3.MonsterSpawnOnChange",0); |
|
|
|
|
int spawnCount=ConfigIntArr("Phase3.MonsterSpawnOnChange",1); |
|
|
|
|
|
|
|
|
|
for(int i=0;i<spawnCount;i++){ |
|
|
|
|
float randomAngle=util::random(2*PI); |
|
|
|
|
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
|
|
|
|
} |
|
|
|
|
SpawnMonsterFromConfig(3); |
|
|
|
|
}break; |
|
|
|
|
case 4:{ |
|
|
|
|
std::string spawnMonster=ConfigStringArr("Phase4.MonsterSpawnOnChange",0); |
|
|
|
|
int spawnCount=ConfigIntArr("Phase4.MonsterSpawnOnChange",1); |
|
|
|
|
|
|
|
|
|
for(int i=0;i<spawnCount;i++){ |
|
|
|
|
float randomAngle=util::random(2*PI); |
|
|
|
|
game->SpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]);
|
|
|
|
|
} |
|
|
|
|
SpawnMonsterFromConfig(4); |
|
|
|
|
}break; |
|
|
|
|
case 5:{ |
|
|
|
|
|
|
|
|
|