Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // concatenation of CombatHexGridNameTextField.text + X Num + Y Num
- // X Num and Y Num change depending on if we're filling the node name or
- //connectingNodeNW
- //connectingNodeNN
- //connectingNodeNE
- //connectingNodeSW
- //connectingNodeSS
- //connectingNodeSE
- //xPosTextField.text and yPosTextField.text
- //CombatHexGridNameTextField.text
- //x = 1
- //connectingNodeNW = -1;
- //connectingNodeSW = -1;
- //x = xPosTextField.text
- //connectingNodeNE = -1;
- //connectingNodeSE = -1;
- //y = 1
- //connectingNodeNN = -1;
- //y = 1 and x = odd number
- //connectingNodeNW = -1;
- //connectingNodeNN = -1;
- //connectingNodeNE = -1;
- //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
- //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
- //WARNING: THE XGRIDPOS IS THE YWORLDPOSITION AND VICE VERSA.
- function BeginHexCreation(%xPosition, %yPosition, %zPosition)
- {
- //We iterate on these in two (nested) for loops
- %xGridPos = 1;
- %yGridPos = 1;
- //These define the width and depth/height of the hex grid.
- %xGridMaxPos = xPosTextField.getValue();
- %yGridMaxPos = yPosTextField.getValue();
- //This setting defines if the hex column is connected above or below the last column
- %hexOffsetValue = 0;
- %combatNodeXWorldPos = %xPosition;
- %combatNodeYWorldPos = %yPosition;
- %variableCombatNodeYWorldPos = %combatNodeYWorldPos;
- %combatNodeZWorldPos = %zPosition+0.1;
- %combatNodePosition = %combatNodeXWorldPos SPC %CombatNodeYWorldPos SPC %combatNodeZWorldPos;
- %exampleTriggerPosition = (%combatNodeXWorldPos-4) SPC %CombatNodeYWorldPos SPC %combatNodeZWorldPos;
- %combatCameraPosition = %combatNodeXWorldPos SPC %CombatNodeYWorldPos SPC (%combatNodeZWorldPos + 20);
- //THE LINE BELOW IS DUE TO BE CHANGED
- %player1StartPosition = CombatHexGridNameTextField.getValue() @ "X" @ %xGridPos @ "Y" @ %yGridPos;
- //NB Here we should be setting up arrays for player character start positions
- //NB Here we should be setting up arrays for enemy start positions as a enemyName, NodeName combination
- %triggerYPos = ((%xGridMaxPos -1) * 3)+4;
- %triggerYSize = 4;
- %triggerXPos = (%yGridMaxPos * 4)+2;
- %cameraAim = %combatNodeXWorldPos + (%triggerYPos/2) SPC %combatNodeYWorldPos - (%triggerXPos/2) SPC %combatNodeZWorldPos;
- %cameraPosition = %combatNodeXWorldPos - (%triggerYPos+4) SPC %combatNodeYWorldPos - ((%triggerXPos/2)) SPC (%combatNodeZWorldPos + 16);
- %simGroupName = CombatHexGridNameTextField.getValue();
- %obj = new SimGroup(%simGroupName)
- {
- canSave = "1";
- canSaveDynamicFields = "1";
- cameraPosition = %cameraPosition;
- cameraFacing = %cameraAim;
- playerStartNode = %player1StartPosition;
- enemiesList = "Enemy1Name Enemy1StartNode Enemy2Name Enemy2StartNode etc";
- };
- MissionGroup.add(%obj);
- %triggerName = CombatHexGridNameTextField.getValue() @ "Trigger";
- %combatManagerReference = "startHexBattle(" @ %simGroupName @ ");";
- new Trigger(%triggerName) {
- // 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";
- // position position position width u u u length u u u height
- polyhedron = "-2 2 0" SPC %triggerYSize SPC "0 0 0" SPC -%triggerXPos SPC "0 0 0 4"; //triggerXPos is actually size, btw
- enterCommand = %combatManagerReference;
- dataBlock = "DefaultTrigger";
- parentGroup = %simGroupName;
- position = %exampleTriggerPosition;
- rotation = "1 0 0 0";
- scale = "1 1 1";
- canSave = "1";
- canSaveDynamicFields = "1";
- };
- //%simGroupName.cameraFacing = %triggerName.position;
- %hexOffset = true;
- %ORIGINcombatNodeXWorldPos = %combatNodeXWorldPos;
- while(%yGridPos<=%yGridMaxPos)
- {
- %hexOffset = true;
- %combatNodeXWorldPos = %ORIGINcombatNodeXWorldPos;
- while(%xGridPos<=%xGridMaxPos)
- {
- %newCombatNodeName = CombatHexGridNameTextField.getValue() @ "X" @ %xGridPos @ "Y" @ %yGridPos;
- //Turns out the connecting node names are different depending on if %xGridPos is odd or even
- if(!((%xGridPos /2)==1))
- {
- %connectingNodeNWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos-1;
- %connectingNodeNNName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos-1;
- %connectingNodeNEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos-1;
- %connectingNodeSWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos;
- %connectingNodeSSName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos+1;
- %connectingNodeSEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos;
- }
- else
- {
- %connectingNodeNWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos;
- %connectingNodeNNName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos-1;
- %connectingNodeNEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos;
- %connectingNodeSWName = CombatHexGridNameTextField.text @ "X" @ %xGridPos-1 @ "Y" @ %yGridPos+1;
- %connectingNodeSSName = CombatHexGridNameTextField.text @ "X" @ %xGridPos @ "Y" @ %yGridPos+1;
- %connectingNodeSEName = CombatHexGridNameTextField.text @ "X" @ %xGridPos+1 @ "Y" @ %yGridPos+1;
- }
- //The next section of code sets connecting node references that go 'off grid' to be -1
- //It also catches a problem with not assigning the offset in the first column
- if(%xGridPos==1) //This if prevents the offset triggering when it shouldn't be due to odd numbered width
- {
- %hexOffsetValue = 0;
- //We also want the positions that go 'off grid' to be assigned -1
- %connectingNodeNWName = "-1";
- %connectingNodeSWName = "-1";
- }
- if(%xGridPos == %xGridMaxPos)
- {
- %connectingNodeNEName = "-1";
- %connectingNodeSEName = "-1";
- }
- if(%yGridPos==1)
- {
- %connectingNodeNNName = "-1";
- }
- if((%yGridPos==1)&&((%xGridPos % 2)==1))
- {
- %connectingNodeNWName = "-1";
- %connectingNodeNEName = "-1";
- }
- if(%yGridPos==%yGridMaxPos)
- {
- %connectingNodeSSName = "-1";
- }
- if((%yGridPos==%yGridMaxPos)&&((%xGridPos % 2)==0))
- {
- %connectingNodeSWName = "-1";
- %connectingNodeSEName = "-1";
- }
- //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.
- //the position is then adjusted during the loop iterations, including whether next node needs to be offset.
- %variableCombatNodeYWorldPos = %combatNodeYWorldPos + %hexOffsetValue;
- %combatNodePosition = %combatNodeXWorldPos SPC %variableCombatNodeYWorldPos SPC %combatNodeZWorldPos;
- new TSStatic(%newCombatNodeName) {
- shapeName = "art/shapes/Hexagon.dae";
- parentGroup = %simGroupName;
- position = %combatNodePosition;
- rotation = "1 0 0 0";
- scale = "1 1 1";
- canSave = "1";
- collisionType = "Visible Mesh";
- decalType = "Collision Mesh";
- allowPlayerStep = "1";
- canSaveDynamicFields = "1";
- connectingNodeNW = %connectingNodeNWName;
- connectingNodeNN = %connectingNodeNNName;
- connectingNodeNE = %connectingNodeNEName;
- connectingNodeSW = %connectingNodeSWName;
- connectingNodeSS = %connectingNodeSSName;
- connectingNodeSE = %connectingNodeSEName;
- occupant = "None";
- };
- echo("Created " @ %newCombatNodeName @ " at X: " @ %combatNodeXWorldPos @ " Y: " @ %variableCombatNodeYWorldPos);
- if(%hexOffset$=true)
- {
- %hexOffset = false;
- %hexOffsetValue = -2;
- }
- else
- {
- %hexOffset = true;
- %hexOffsetValue = 0;
- }
- %combatNodeXWorldPos = %combatNodeXWorldPos + 3;
- %xGridPos = %xGridPos +1;
- }
- %combatNodeYWorldPos = %combatNodeYWorldPos -4;
- %xGridPos = 1;
- %yGridPos = %yGridPos +1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment