Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (IsMortal()) return;
- uint8_t prototype = g_Config.PrototypeType();
- if (!m_bCanShoot) return;
- Vector center = CalculateBoidCentralPosition();
- auto shootCross = GetFlockEdges();
- std::vector<Cell*> possibleBullets = SelectCellsToFire();
- size_t numberOfPoints = floor(possibleBullets.size() / g_Config.GetBulletsPerBoid());
- numberOfPoints = numberOfPoints == 0 ? 1 : numberOfPoints;
- if ((prototype == 1 && possibleBullets.size() <= numberOfPoints) || possibleBullets.size() == 0) return;
- Vector dir = shootCross[0];
- Vector middleF = center + dir;
- Vector middleFL = middleF - shootCross[1];
- Vector middleFR = middleF + shootCross[1];
- Vector delta = (middleFR - middleFL) / (numberOfPoints + 1);
- double x = middleFL.x;
- double y = middleFL.y;
- std::vector<size_t> actualBulletsId;
- for (size_t point = 1 ; point <= numberOfPoints ; point++) {
- std::vector<distPoint> distances;
- for (size_t i = 0 ; i < possibleBullets.size() ; i ++) {
- if (std::find(actualBulletsId.begin(), actualBulletsId.end(), i) != actualBulletsId.end()) continue;
- Cell* cell = possibleBullets[i];
- auto dist = distPoint{DistanceSquared(x + point * delta.x, y + point * delta.y, cell->x, cell->y), i};
- distances.push_back(dist);
- }
- std::sort(distances.begin(), distances.end(), [](const distPoint d1, const distPoint d2) -> bool {
- return d1.distance < d2.distance;
- });
- actualBulletsId.push_back((distances[0]).id);
- }
- double velFactor = g_Config.GetBulletSpeedInfo().Value(numberOfPoints);
- double lifetimeTick = g_Config.GetBulletLifetimeTick().Value(numberOfPoints, velFactor);
- for ( size_t i = 0 ; i < numberOfPoints; i++) {
- auto b = possibleBullets[actualBulletsId[i]];
- // if(g_Config.InterpolateShooting()) {
- // dir.x = b->m_fBoidVelocityX;
- // dir.y = b->m_fBoidVelocityY;
- // }
- if (prototype == 2) {
- auto c = m_pRealm->CreateCell(CellCreationOptions(true, m_iTeam));
- if(m_bHasAccount){
- c->SetCustomSkin(m_Account.selected_skin);
- }
- c->AddMass(GetBonusSpawnMass());
- c->SetClientCellCounter(m_CellCount);
- c->SetIsPlayer(true);
- c->SetColor(m_CustomColor.r, m_CustomColor.g, m_CustomColor.b);
- c->x = b->x;
- c->y = b->y;
- ++*m_CellCount;
- AddCell(c, false);
- c->SetSize(g_Config.GetSwarmBulletSize());
- if(IsMortal()) {
- c->SetHP(b->GetHP());
- }
- c->Fire(dir.x, dir.y, lifetimeTick, velFactor, m_fScale);
- }else{
- b->Fire(dir.x, dir.y, lifetimeTick, velFactor, m_fScale);
- }
- }
- m_bCanShoot = false;
- m_iFireCooldown = g_Config.GetFireCooldownTick().Value(numberOfPoints);
- m_iFireCooldownTotal = m_iFireCooldown;
- return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement