Advertisement
Guest User

aom

a guest
Mar 1st, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.43 KB | None | 0 0
  1. void setupPlayerPlacementCircle(float radius = -1.0, bool setPlayerLocation = false, int numberOfPlayers = cNumberNonGaiaPlayers, bool half = false, float locX = -1.0){
  2.  
  3.     //First select a random number within the radius
  4.     float distanceConstant = (2.0*PI/numberOfPlayers);
  5.     float startingXpoint = rmRandFloat(0.0, radius);
  6.     if(locX != -1.0){
  7.         startingXpoint = locX;
  8.     }
  9.     float startingZpoint = sqrt(Math_sqr(radius) - Math_sqr(startingXpoint));
  10.     float angle = Math_atan(startingZpoint/startingXpoint);
  11.    
  12.     xA = startingXpoint + 0.5;
  13.     zA = startingZpoint + 0.5;
  14.    
  15.     if(half){
  16.         angle = angle + distanceConstant/2.0;
  17.         xA = radius * Math_cos(angle) + 0.5;
  18.         zA = radius * Math_sin(angle) + 0.5;
  19.     }
  20.     rmEchoInfo("angle = "+angle);
  21.    
  22.     if(numberOfPlayers > 1){
  23.         xB = radius * Math_cos(angle + distanceConstant) + 0.5;
  24.         zB = radius * Math_sin(angle + distanceConstant) + 0.5;
  25.     }
  26.     angle = angle + distanceConstant;
  27.     if(numberOfPlayers > 2){
  28.         xC = radius * Math_cos(angle + distanceConstant) + 0.5;
  29.         zC = radius * Math_sin(angle + distanceConstant) + 0.5;
  30.     }
  31.     angle = angle + distanceConstant;
  32.     if(numberOfPlayers > 3){
  33.         xD = radius * Math_cos(angle + distanceConstant) + 0.5;
  34.         zD = radius * Math_sin(angle + distanceConstant) + 0.5;
  35.     }
  36.     angle = angle + distanceConstant;
  37.     if(numberOfPlayers > 4){
  38.         xE = radius * Math_cos(angle + distanceConstant) + 0.5;
  39.         zE = radius * Math_sin(angle + distanceConstant) + 0.5;
  40.     }
  41.     angle = angle + distanceConstant;
  42.     if(numberOfPlayers > 5){
  43.         xF = radius * Math_cos(angle + distanceConstant) + 0.5;
  44.         zF = radius * Math_sin(angle + distanceConstant) + 0.5;
  45.     }
  46.     angle = angle + distanceConstant;
  47.     if(numberOfPlayers > 6){
  48.         xG = radius * Math_cos(angle + distanceConstant) + 0.5;
  49.         zG = radius * Math_sin(angle + distanceConstant) + 0.5;
  50.     }
  51.     angle = angle + distanceConstant;
  52.     if(numberOfPlayers > 7){
  53.         xH = radius * Math_cos(angle + distanceConstant) + 0.5;
  54.         zH = radius * Math_sin(angle + distanceConstant) + 0.5;
  55.     }
  56.     angle = angle + distanceConstant;
  57.     if(numberOfPlayers > 8){
  58.         xI = radius * Math_cos(angle + distanceConstant) + 0.5;
  59.         zI = radius * Math_sin(angle + distanceConstant) + 0.5;
  60.     }
  61.     angle = angle + distanceConstant;
  62.     if(numberOfPlayers > 9){
  63.         xJ = radius * Math_cos(angle + distanceConstant) + 0.5;
  64.         zJ = radius * Math_sin(angle + distanceConstant) + 0.5;
  65.     }
  66.     angle = angle + distanceConstant;
  67.     if(numberOfPlayers > 10){
  68.         xK = radius * Math_cos(angle + distanceConstant) + 0.5;
  69.         zK = radius * Math_sin(angle + distanceConstant) + 0.5;
  70.     }
  71.     angle = angle + distanceConstant;
  72.     if(numberOfPlayers > 11){
  73.         xL = radius * Math_cos(angle + distanceConstant) + 0.5;
  74.         zL = radius * Math_sin(angle + distanceConstant) + 0.5;
  75.     }
  76.    
  77.     //Set Player Location
  78.     if(setPlayerLocation){
  79.          if(numberOfPlayers > 0){   rmSetPlayerLocation(1, xA, zA); }
  80.          if(numberOfPlayers > 1){   rmSetPlayerLocation(2, xB, zB); }
  81.          if(numberOfPlayers > 2){   rmSetPlayerLocation(3, xC, zC); }
  82.          if(numberOfPlayers > 3){   rmSetPlayerLocation(4, xD, zD); }
  83.          if(numberOfPlayers > 4){   rmSetPlayerLocation(5, xE, zE); }
  84.          if(numberOfPlayers > 5){   rmSetPlayerLocation(6, xF, zF); }
  85.          if(numberOfPlayers > 6){   rmSetPlayerLocation(7, xG, zG); }
  86.          if(numberOfPlayers > 7){   rmSetPlayerLocation(8, xH, zH); }
  87.          if(numberOfPlayers > 8){   rmSetPlayerLocation(9, xI, zI); }
  88.          if(numberOfPlayers > 9){   rmSetPlayerLocation(10, xJ, zJ);}
  89.          if(numberOfPlayers > 10){  rmSetPlayerLocation(11, xK, zK);}
  90.          if(numberOfPlayers > 11){  rmSetPlayerLocation(12, xL, zL);}
  91.     }
  92. }
  93.  
  94. //Don't need else since it will exit upon true conditions - and now it aligns :D
  95. float rmGetPlayerXLoc(int player = 1){
  96.     if(player == 1){    return(xA);}
  97.     if(player == 2){    return(xB);}
  98.     if(player == 3){    return(xC);}
  99.     if(player == 4){    return(xD);}
  100.     if(player == 5){    return(xE);}
  101.     if(player == 6){    return(xF);}
  102.     if(player == 7){    return(xG);}
  103.     if(player == 8){    return(xH);}
  104.     if(player == 9){    return(xI);}
  105.     if(player == 10){   return(xJ);}
  106.     if(player == 11){   return(xK);}
  107.     if(player == 12){   return(xL);}
  108. }
  109.  
  110. float rmGetPlayerZLoc(int player = 1){
  111.     if(player == 1){    return(zA);}
  112.     if(player == 2){    return(zB);}
  113.     if(player == 3){    return(zC);}
  114.     if(player == 4){    return(zD);}
  115.     if(player == 5){    return(zE);}
  116.     if(player == 6){    return(zF);}
  117.     if(player == 7){    return(zG);}
  118.     if(player == 8){    return(zH);}
  119.     if(player == 9){    return(zI);}
  120.     if(player == 10){   return(zJ);}
  121.     if(player == 11){   return(zK);}
  122.     if(player == 12){   return(zL);}
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement