Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. if (IsMortal()) return;
  2. uint8_t prototype = g_Config.PrototypeType();
  3. if (!m_bCanShoot) return;
  4.  
  5. Vector center = CalculateBoidCentralPosition();
  6. auto shootCross = GetFlockEdges();
  7. std::vector<Cell*> possibleBullets = SelectCellsToFire();
  8.  
  9. size_t numberOfPoints = floor(possibleBullets.size() / g_Config.GetBulletsPerBoid());
  10. numberOfPoints = numberOfPoints == 0 ? 1 : numberOfPoints;
  11. if ((prototype == 1 && possibleBullets.size() <= numberOfPoints) || possibleBullets.size() == 0) return;
  12.  
  13. Vector dir = shootCross[0];
  14. Vector middleF = center + dir;
  15. Vector middleFL = middleF - shootCross[1];
  16. Vector middleFR = middleF + shootCross[1];
  17. Vector delta = (middleFR - middleFL) / (numberOfPoints + 1);
  18.  
  19. double x = middleFL.x;
  20. double y = middleFL.y;
  21.  
  22. std::vector<size_t> actualBulletsId;
  23.  
  24. for (size_t point = 1 ; point <= numberOfPoints ; point++) {
  25. std::vector<distPoint> distances;
  26.  
  27. for (size_t i = 0 ; i < possibleBullets.size() ; i ++) {
  28. if (std::find(actualBulletsId.begin(), actualBulletsId.end(), i) != actualBulletsId.end()) continue;
  29.  
  30. Cell* cell = possibleBullets[i];
  31.  
  32. auto dist = distPoint{DistanceSquared(x + point * delta.x, y + point * delta.y, cell->x, cell->y), i};
  33. distances.push_back(dist);
  34. }
  35.  
  36. std::sort(distances.begin(), distances.end(), [](const distPoint d1, const distPoint d2) -> bool {
  37. return d1.distance < d2.distance;
  38. });
  39.  
  40. actualBulletsId.push_back((distances[0]).id);
  41. }
  42.  
  43. double velFactor = g_Config.GetBulletSpeedInfo().Value(numberOfPoints);
  44. double lifetimeTick = g_Config.GetBulletLifetimeTick().Value(numberOfPoints, velFactor);
  45.  
  46. for ( size_t i = 0 ; i < numberOfPoints; i++) {
  47. auto b = possibleBullets[actualBulletsId[i]];
  48.  
  49.  
  50. // if(g_Config.InterpolateShooting()) {
  51. // dir.x = b->m_fBoidVelocityX;
  52. // dir.y = b->m_fBoidVelocityY;
  53. // }
  54.  
  55. if (prototype == 2) {
  56. auto c = m_pRealm->CreateCell(CellCreationOptions(true, m_iTeam));
  57.  
  58. if(m_bHasAccount){
  59. c->SetCustomSkin(m_Account.selected_skin);
  60. }
  61.  
  62. c->AddMass(GetBonusSpawnMass());
  63. c->SetClientCellCounter(m_CellCount);
  64. c->SetIsPlayer(true);
  65. c->SetColor(m_CustomColor.r, m_CustomColor.g, m_CustomColor.b);
  66.  
  67. c->x = b->x;
  68. c->y = b->y;
  69.  
  70. ++*m_CellCount;
  71.  
  72. AddCell(c, false);
  73. c->SetSize(g_Config.GetSwarmBulletSize());
  74.  
  75. if(IsMortal()) {
  76. c->SetHP(b->GetHP());
  77. }
  78.  
  79. c->Fire(dir.x, dir.y, lifetimeTick, velFactor, m_fScale);
  80. }else{
  81. b->Fire(dir.x, dir.y, lifetimeTick, velFactor, m_fScale);
  82. }
  83. }
  84.  
  85. m_bCanShoot = false;
  86. m_iFireCooldown = g_Config.GetFireCooldownTick().Value(numberOfPoints);
  87. m_iFireCooldownTotal = m_iFireCooldown;
  88.  
  89. return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement