Larington

Untitled

Jan 17th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.24 KB | None | 0 0
  1.  
  2. // concatenation of CombatHexGridNameTextField.text + X Num + Y Num
  3. // X Num and Y Num change depending on if we're filling the node name or
  4. //connectingNodeNW
  5. //connectingNodeNN
  6. //connectingNodeNE
  7. //connectingNodeSW
  8. //connectingNodeSS
  9. //connectingNodeSE
  10.  
  11.  
  12. //xPosTextField.text and yPosTextField.text
  13. //CombatHexGridNameTextField.text
  14.  
  15. //x = 1
  16. //connectingNodeNW = -1;
  17. //connectingNodeSW = -1;
  18.  
  19. //x = xPosTextField.text
  20. //connectingNodeNE = -1;
  21. //connectingNodeSE = -1;
  22.  
  23. //y = 1
  24. //connectingNodeNN = -1;
  25.  
  26. //y = 1 and x = odd number
  27. //connectingNodeNW = -1;
  28. //connectingNodeNN = -1;
  29. //connectingNodeNE = -1;
  30.  
  31. //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
  32. //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
  33. //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
  34.  
  35. function BeginHexCreation(%xPosition, %yPosition, %zPosition)
  36. {
  37. //We iterate on these in two (nested) for loops
  38. %xGridPos = 1;
  39. %yGridPos = 1;
  40.  
  41. //These define the width and depth/height of the hex grid.
  42. %xGridMaxPos = xPosTextField.getValue();
  43. %yGridMaxPos = yPosTextField.getValue();
  44.  
  45. //This setting defines if the hex column is connected above or below the last column
  46. %hexOffsetValue = 0;
  47.  
  48. %combatNodeXWorldPos = %xPosition;
  49. %combatNodeYWorldPos = %yPosition;
  50. %variableCombatNodeYWorldPos = %combatNodeYWorldPos;
  51. %combatNodeZWorldPos = %zPosition+0.1;
  52. %combatNodePosition = %combatNodeXWorldPos SPC %CombatNodeYWorldPos SPC %combatNodeZWorldPos;
  53.  
  54. %exampleTriggerPosition = (%combatNodeXWorldPos-4) SPC %CombatNodeYWorldPos SPC %combatNodeZWorldPos;
  55.  
  56. %combatCameraPosition = %combatNodeXWorldPos SPC %CombatNodeYWorldPos SPC (%combatNodeZWorldPos + 20);
  57.  
  58. //THE LINE BELOW IS DUE TO BE CHANGED
  59. %player1StartPosition = CombatHexGridNameTextField.getValue() @ "X" @ %xGridPos @ "Y" @ %yGridPos;
  60.  
  61. //NB Here we should be setting up arrays for player character start positions
  62. //NB Here we should be setting up arrays for enemy start positions as a enemyName, NodeName combination
  63.  
  64. %triggerYPos = ((%xGridMaxPos -1) * 3)+4;
  65. %triggerYSize = 4;
  66. %triggerXPos = (%yGridMaxPos * 4)+2;
  67.  
  68. %cameraAim = %combatNodeXWorldPos + (%triggerYPos/2) SPC %combatNodeYWorldPos - (%triggerXPos/2) SPC %combatNodeZWorldPos;
  69. %cameraPosition = %combatNodeXWorldPos - (%triggerYPos+4) SPC %combatNodeYWorldPos - ((%triggerXPos/2)) SPC (%combatNodeZWorldPos + 16);
  70.  
  71. %simGroupName = CombatHexGridNameTextField.getValue();
  72. %obj = new SimGroup(%simGroupName)
  73. {
  74. canSave = "1";
  75. canSaveDynamicFields = "1";
  76.  
  77. cameraPosition = %cameraPosition;
  78. cameraFacing = %cameraAim;
  79. playerStartNode = %player1StartPosition;
  80. enemiesList = "Enemy1Name Enemy1StartNode Enemy2Name Enemy2StartNode etc";
  81. };
  82. MissionGroup.add(%obj);
  83.  
  84. %triggerName = CombatHexGridNameTextField.getValue() @ "Trigger";
  85. %combatManagerReference = "startHexBattle(" @ %simGroupName @ ");";
  86. new Trigger(%triggerName) {
  87. // polyhedron = "-2.000000 2.000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 4.0000000";
  88. // position position position width u u u length u u u height
  89. polyhedron = "-2 2 0" SPC %triggerYSize SPC "0 0 0" SPC -%triggerXPos SPC "0 0 0 4"; //triggerXPos is actually size, btw
  90. enterCommand = %combatManagerReference;
  91. dataBlock = "DefaultTrigger";
  92. parentGroup = %simGroupName;
  93. position = %exampleTriggerPosition;
  94. rotation = "1 0 0 0";
  95. scale = "1 1 1";
  96. canSave = "1";
  97. canSaveDynamicFields = "1";
  98. };
  99.  
  100. //%simGroupName.cameraFacing = %triggerName.position;
  101.  
  102. %hexOffset = true;
  103.  
  104. %ORIGINcombatNodeXWorldPos = %combatNodeXWorldPos;
  105.  
  106.  
  107.  
  108. while(%yGridPos<=%yGridMaxPos)
  109. {
  110. %hexOffset = true;
  111. %combatNodeXWorldPos = %ORIGINcombatNodeXWorldPos;
  112.  
  113.  
  114. while(%xGridPos<=%xGridMaxPos)
  115. {
  116.  
  117. %newCombatNodeName = CombatHexGridNameTextField.getValue() @ "X" @ %xGridPos @ "Y" @ %yGridPos;
  118.  
  119. //Turns out the connecting node names are different depending on if %xGridPos is odd or even
  120. if(!((%xGridPos /2)==1))
  121. {
  122. %connectingNodeNWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos-1;
  123. %connectingNodeNNName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos-1;
  124. %connectingNodeNEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos-1;
  125. %connectingNodeSWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos;
  126. %connectingNodeSSName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos+1;
  127. %connectingNodeSEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos;
  128. }
  129. else
  130. {
  131. %connectingNodeNWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos;
  132. %connectingNodeNNName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos-1;
  133. %connectingNodeNEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos;
  134. %connectingNodeSWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos+1;
  135. %connectingNodeSSName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos+1;
  136. %connectingNodeSEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos+1;
  137. }
  138.  
  139. //The next section of code sets connecting node references that go 'off grid' to be -1
  140. //It also catches a problem with not assigning the offset in the first column
  141.  
  142. if(%xGridPos==1) //This if prevents the offset triggering when it shouldn't be due to odd numbered width
  143. {
  144. %hexOffsetValue = 0;
  145. //We also want the positions that go 'off grid' to be assigned -1
  146. %connectingNodeNWName = "-1";
  147. %connectingNodeSWName = "-1";
  148. }
  149. if(%xGridPos == %xGridMaxPos)
  150. {
  151. %connectingNodeNEName = "-1";
  152. %connectingNodeSEName = "-1";
  153. }
  154. if(%yGridPos==1)
  155. {
  156. %connectingNodeNNName = "-1";
  157. }
  158. if((%yGridPos==1)&&((%xGridPos % 2)==1))
  159. {
  160. %connectingNodeNWName = "-1";
  161. %connectingNodeNEName = "-1";
  162. }
  163. if(%yGridPos==%yGridMaxPos)
  164. {
  165. %connectingNodeSSName = "-1";
  166. }
  167. if((%yGridPos==%yGridMaxPos)&&((%xGridPos % 2)==0))
  168. {
  169. %connectingNodeSWName = "-1";
  170. %connectingNodeSEName = "-1";
  171. }
  172.  
  173. //Assignment of node position in world, we apply an offset which is either 0 or -2 depending on which column of grid is being created.
  174. //the position is then adjusted during the loop iterations, including whether next node needs to be offset.
  175. %variableCombatNodeYWorldPos = %combatNodeYWorldPos + %hexOffsetValue;
  176. %combatNodePosition = %combatNodeXWorldPos SPC %variableCombatNodeYWorldPos SPC %combatNodeZWorldPos;
  177.  
  178.  
  179. new TSStatic(%newCombatNodeName) {
  180. shapeName = "art/shapes/Hexagon.dae";
  181. parentGroup = %simGroupName;
  182. position = %combatNodePosition;
  183. rotation = "1 0 0 0";
  184. scale = "1 1 1";
  185. canSave = "1";
  186. collisionType = "Visible Mesh";
  187. decalType = "Collision Mesh";
  188. allowPlayerStep = "1";
  189. canSaveDynamicFields = "1";
  190. connectingNodeNW = %connectingNodeNWName;
  191. connectingNodeNN = %connectingNodeNNName;
  192. connectingNodeNE = %connectingNodeNEName;
  193. connectingNodeSW = %connectingNodeSWName;
  194. connectingNodeSS = %connectingNodeSSName;
  195. connectingNodeSE = %connectingNodeSEName;
  196. occupant = "None";
  197. };
  198. echo("Created " @ %newCombatNodeName @ " at X: " @ %combatNodeXWorldPos @ " Y: " @ %variableCombatNodeYWorldPos);
  199.  
  200. if(%hexOffset$=true)
  201. {
  202. %hexOffset = false;
  203. %hexOffsetValue = -2;
  204. }
  205. else
  206. {
  207. %hexOffset = true;
  208. %hexOffsetValue = 0;
  209. }
  210.  
  211. %combatNodeXWorldPos = %combatNodeXWorldPos + 3;
  212. %xGridPos = %xGridPos +1;
  213.  
  214. }
  215. %combatNodeYWorldPos = %combatNodeYWorldPos -4;
  216.  
  217. %xGridPos = 1;
  218. %yGridPos = %yGridPos +1;
  219.  
  220. }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment