WIP: Race Mode: "AI" (More LUA Animation)

Working on a new map? Have a new mod out for swbf2?! Post an announcement of the up-coming release here.

Moderator: Moderators

Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

Before reading, please tell me that no one has yet been able to convince the SWBF2 AI to consistently ride a vehicle around a looping race course without crashing into something....
Summary at Bottom, if you can't stand my narrative. :sleep:
*EDIT* Clarified summary, added my Java script under the photo.
Anyway, you may have read a few months back about my method for animating objects (and Vehicles/players[sorta]) using LUA script. (basically A Frame-long looping timer and SetEntityMatrix.) It was all well and good in that it made it a bit easier for some types of movement to be animated, and overcame the limited number of key frames in the traditional ZE animator.
CUT But I had other plans. You may be familiar with my age old project Acezuraize. (commenced 2006, releases in: 2007, lost to busted HD :2008, HD decides that it does get along with its replacement control board after all: 2009...) It was originally intended as a race map, but I added every other mode there was, including Zerted's custom modes, at points, and an extensive Conquest+Objectives+CoolStuff Campaign. Now it is mostly a semi-ugly, code-mod-a-copia map. I managed to get the Race mode functional with scripting based off of Maveritchel's work, but its a little boring without opponents. So I programmed some. Sort of.

THE CHASE SCENE

That LUA animation work I did this winter met up with a work-around that allowed you to perform math on Matrixes. When you get a Matrix in LUA, you can't do anything with it but store it and use it for SetEntityMatrix or CreateMatrix. So, I grabbed the matrixes before hand, so to speak. I laid out a way to store data for position in LUA:

Code: Select all

LUALocationPoints = {}
    PointOne = {}          -- create the matrix
    for i=1,100	do --100 rows of lua point
      LUALocationPoints[i] = {}     -- create a new row
      for j=1,6 do --six columns (to represent x y z x rotation y rotation z rotation 
        LUALocationPoints[i][j] = 0
      end
    end

--This six numbers represent values 2-7 in the CreateMatrix Function, Special Radian Rotation and the Reference matrix are absent

--Point 1: 
LUALocationPoints[1][1] = 0.000000 
LUALocationPoints[1][2] = 0.000000
LUALocationPoints[1][3] = 0.000000 
LUALocationPoints[1][4] = 283.022247  
LUALocationPoints[1][5] = 0.000001 
LUALocationPoints[1][6] = 457.61010 
and apply it to an object, using create matrix and an GetEntityMatrix(OBjectAt0,0,0) as the starting point matrix.

Code: Select all

CreateMatrix(0,LUALocationPoints[1][1], LUALocationPoints[1][2], LUALocationPoints[1][3], LUALocationPoints[1][4], LUALocationPoints[1][5], LUALocationPoints[1][6],  GetEntityMatrix("ZeroPoint"))
So, now that I had the position data in the LUA script, I could do math, like place an object at the mid point between two Objects, or 1%/99% point through to %99/1% and the points themselves: I could animate an object between two points.
This meant I could enter a whole tonne of points to create a virtual path for my Racer 'AI' to follow, and use math.rand to make it so they do it at different speeds on slightly different, and even randomly branching paths.
But I've hit some snags.
One I managed to fix. That is the fact that it is a PAIN IN THE :cpu: to copy and paste 6 individual numbers from (NumberOfNodes x2) lines in a .pth file. So I wrote a Java app to do it for me. And I hadn't programmed in ages so even this simple thing was a minor headache.
Hidden/Spoiler:
Image
[code]

package pthmatrixparser;
import java.io.*;
/**
*
* @author Ace Asz
*/
public class PthMatrixParser {
static String filelines[] = new String [1500];
static String PositionData [] = new String [1500];//line 10
static String RotationData [] = new String [1500];//line 10
static String fileName, line, tempString1, tempString2;
static String xrot, yrot, zrot, x, y, z;
static BufferedReader input;
static int a = 0;
static int b = 0;
static int c = 0;//line 15
static int d = 0;
static int e = -1;

static int point = 1;
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
fileName = "C:\\ACE_racepath.PTH";
line = "";
//name of file to be opened
//declare buffered reader - it allows us to read text files
input = new BufferedReader (new FileReader (fileName));
while (line != null) //as long as the line has a word
{
line = input.readLine (); //read the line
filelines [a] = line; //store the line in the element 'a' in the array
//if (line.length > 0)//prevents java from taking the index of a null line
if (line != null)
{
if (line.indexOf("Position") > -1)//if the line contains "object"
{
PositionData [d] = line;//then add it to the array "objects"
d++;
c++;
}
if (line.indexOf("Rotation") > -1)//if the line contains "object"
{
RotationData [d] = line;//then add it to the array "objects"
d++;
c++;
}
}
a++; //increase a by 1 (prevents overwriting elements)
}
input.close (); //close the text file IMPORTANT!!!!

//re-set value of variable IMPORTANT

/*System.out.println("Original File");
for (b = 0; b < (a-1); b++)
{
System.out.println (filelines );

}*/
d = 0;
//System.out.println ("Lines with Position Data and Rotation Data in them:");
//for (d = 0; d < c; d++)
//{
// if (e == -1)
// {
// System.out.println (PositionData [d]);
// e = e*-1;
// }
// else
// {
// System.out.println (RotationData [d]);
// e = e*-1;
// }
//}
e = -1;
System.out.println ("");
System.out.println ("Coordinates:");
System.out.println ();
for (d = 0; d < c; d++)
{

if (e == -1)
{

x = (PositionData [d].substring((PositionData [d].indexOf ("(")+1),(PositionData [d].indexOf (",")-1)) + " ");
tempString1 = (PositionData [d].substring((PositionData [d].indexOf (",")+2),(PositionData [d].indexOf (";") -1)) + " ");
y = (tempString1.substring(0,tempString1.indexOf (",")) + " ");
tempString1 = (PositionData [d].substring((PositionData [d].indexOf (",")+2),(PositionData [d].indexOf (";") -1)) + " ");
z = (tempString1.substring((tempString1.indexOf (",")+2)) + " ");
e = e*-1;

}
else
{
tempString1 = (RotationData [d].substring((RotationData [d].indexOf (",")+2),(RotationData [d].indexOf (";") -1)) + " ");
xrot = (tempString1.substring(0,tempString1.indexOf (",")) + " ");


tempString2 = (tempString1.substring(tempString1.indexOf (",")+2));
yrot = (tempString2.substring(0, tempString2.indexOf (",")));
zrot = (tempString2.substring(tempString2.indexOf (",")+2));
System.out.println("--Point " + point + ": ");
System.out.println ("LUALocationPoints[" + point + "][1] = " + xrot);
System.out.println ("LUALocationPoints[" + point + "][2] = " + yrot);
System.out.println ("LUALocationPoints[" + point + "][3] = " + zrot);
System.out.println ("LUALocationPoints[" + point + "][4] = " + x);
System.out.println ("LUALocationPoints[" + point + "][5] = " + y);
System.out.println ("LUALocationPoints[" + point + "][6] = " + z);
System.out.println ("");
point++;
e = e*-1;
}


}
System.out.println ("");

}

}
[/code]

(Don't worry, I haven't invested TOO much time in this...)

Anyway, here's the part where I explain why I am making a WIP thread for this, besides that it is awesome. (If you don't believe me, then :maulsaber: ) It turns out that this little experiment has largely been a surprising success. Except for this:
Hidden/Spoiler:
Image

The virtual path isn't oriented correctly, or worse, its not being followed in the correct order. Observe the Bespin tower vs the path points. I'd like help in the form of fresh minds to take a look at (probably run) my code to see why.
Image
Hidden/Spoiler:
[code]
LUALocationPoints = {}
PointOne = {} -- create the matrix
for i=1,100 do --100 rows of lua point
LUALocationPoints = {} -- create a new row
for j=1,6 do --six columns (to represent x y z x rotation y rotation z rotation
LUALocationPoints[j] = 0
end
end

--This six numbers represent values 2-7 in the CreateMatrix Function, Special Radian Rotation and the Reference matrix are absent

--Point 1:
LUALocationPoints[1][1] = 0.000000
LUALocationPoints[1][2] = 0.000000
LUALocationPoints[1][3] = 0.000000
LUALocationPoints[1][4] = 283.022247
LUALocationPoints[1][5] = 0.000001
LUALocationPoints[1][6] = 457.61010

--Point 2:
LUALocationPoints[2][1] = 0.000000
LUALocationPoints[2][2] = 0.000000
LUALocationPoints[2][3] = 0.000000
LUALocationPoints[2][4] = 376.578217
LUALocationPoints[2][5] = 0.000000
LUALocationPoints[2][6] = 465.88913

--Point 3:
LUALocationPoints[3][1] = 0.000000
LUALocationPoints[3][2] = 0.000000
LUALocationPoints[3][3] = 0.000000
LUALocationPoints[3][4] = 413.593018
LUALocationPoints[3][5] = 0.000000
LUALocationPoints[3][6] = 449.83267

--Point 4:
LUALocationPoints[4][1] = 0.000000
LUALocationPoints[4][2] = 0.000000
LUALocationPoints[4][3] = 0.000000
LUALocationPoints[4][4] = 419.836304
LUALocationPoints[4][5] = 0.000000
LUALocationPoints[4][6] = 395.38201

--Point 5:
LUALocationPoints[5][1] = 0.000000
LUALocationPoints[5][2] = 0.000000
LUALocationPoints[5][3] = 0.000000
LUALocationPoints[5][4] = 442.031769
LUALocationPoints[5][5] = 0.000000
LUALocationPoints[5][6] = 333.53460

--Point 6:
LUALocationPoints[6][1] = 0.000000
LUALocationPoints[6][2] = 0.000000
LUALocationPoints[6][3] = 0.000000
LUALocationPoints[6][4] = 438.327515
LUALocationPoints[6][5] = 0.000000
LUALocationPoints[6][6] = 248.15860

--Point 7:
LUALocationPoints[7][1] = 0.000000
LUALocationPoints[7][2] = 0.000000
LUALocationPoints[7][3] = 0.000000
LUALocationPoints[7][4] = 434.212341
LUALocationPoints[7][5] = 0.000000
LUALocationPoints[7][6] = 184.95797

--Point 8:
LUALocationPoints[8][1] = 0.000000
LUALocationPoints[8][2] = 0.000000
LUALocationPoints[8][3] = 0.000000
LUALocationPoints[8][4] = 353.462677
LUALocationPoints[8][5] = 0.000000
LUALocationPoints[8][6] = 100.65515

--Point 9:
LUALocationPoints[9][1] = 0.000000
LUALocationPoints[9][2] = 0.000000
LUALocationPoints[9][3] = 0.000000
LUALocationPoints[9][4] = 336.273041
LUALocationPoints[9][5] = 1.409971
LUALocationPoints[9][6] = -20.35596

--Point 10:
LUALocationPoints[10][1] = 0.000000
LUALocationPoints[10][2] = 0.000000
LUALocationPoints[10][3] = 0.000000
LUALocationPoints[10][4] = 323.874939
LUALocationPoints[10][5] = -0.321567
LUALocationPoints[10][6] = -57.42618

--Point 11:
LUALocationPoints[11][1] = 0.000000
LUALocationPoints[11][2] = 0.000000
LUALocationPoints[11][3] = 0.000000
LUALocationPoints[11][4] = 319.148499
LUALocationPoints[11][5] = 1.322924
LUALocationPoints[11][6] = -167.04922

--Point 12:
LUALocationPoints[12][1] = 0.000000
LUALocationPoints[12][2] = 0.000000
LUALocationPoints[12][3] = 0.000000
LUALocationPoints[12][4] = 276.732117
LUALocationPoints[12][5] = 0.024262
LUALocationPoints[12][6] = -288.07141

--Point 13:
LUALocationPoints[13][1] = 0.000000
LUALocationPoints[13][2] = 0.000000
LUALocationPoints[13][3] = 0.000000
LUALocationPoints[13][4] = 187.228851
LUALocationPoints[13][5] = 2.692170
LUALocationPoints[13][6] = -329.97863

--Point 14:
LUALocationPoints[14][1] = 0.000000
LUALocationPoints[14][2] = 0.000000
LUALocationPoints[14][3] = 0.000000
LUALocationPoints[14][4] = 100.159424
LUALocationPoints[14][5] = 1.089711
LUALocationPoints[14][6] = -292.01306

--Point 15:
LUALocationPoints[15][1] = 0.000000
LUALocationPoints[15][2] = 0.000000
LUALocationPoints[15][3] = 0.000000
LUALocationPoints[15][4] = 78.195084
LUALocationPoints[15][5] = 1.288867
LUALocationPoints[15][6] = -201.24499

--Point 16:
LUALocationPoints[16][1] = 0.000000
LUALocationPoints[16][2] = 0.000000
LUALocationPoints[16][3] = 0.000000
LUALocationPoints[16][4] = 59.354065
LUALocationPoints[16][5] = 0.963373
LUALocationPoints[16][6] = -84.64901

--Point 17:
LUALocationPoints[17][1] = 0.000000
LUALocationPoints[17][2] = 0.000000
LUALocationPoints[17][3] = 0.000000
LUALocationPoints[17][4] = 96.523758
LUALocationPoints[17][5] = 0.553417
LUALocationPoints[17][6] = -40.15289

--Point 18:
LUALocationPoints[18][1] = 0.000000
LUALocationPoints[18][2] = 0.000000
LUALocationPoints[18][3] = 0.000000
LUALocationPoints[18][4] = 77.537888
LUALocationPoints[18][5] = 1.613748
LUALocationPoints[18][6] = -16.15483

--Point 19:
LUALocationPoints[19][1] = 0.000000
LUALocationPoints[19][2] = 0.000000
LUALocationPoints[19][3] = 0.000000
LUALocationPoints[19][4] = 61.186287
LUALocationPoints[19][5] = 0.950061
LUALocationPoints[19][6] = 76.62510

--Point 20:
LUALocationPoints[20][1] = 0.000000
LUALocationPoints[20][2] = 0.000000
LUALocationPoints[20][3] = 0.000000
LUALocationPoints[20][4] = -4.762239
LUALocationPoints[20][5] = 0.495810
LUALocationPoints[20][6] = 145.29576

--Point 21:
LUALocationPoints[21][1] = 0.000000
LUALocationPoints[21][2] = 0.000000
LUALocationPoints[21][3] = 0.000000
LUALocationPoints[21][4] = -102.713394
LUALocationPoints[21][5] = 0.359543
LUALocationPoints[21][6] = 195.42596

--Point 22:
LUALocationPoints[22][1] = 0.000000
LUALocationPoints[22][2] = 0.000000
LUALocationPoints[22][3] = 0.000000
LUALocationPoints[22][4] = -226.234192
LUALocationPoints[22][5] = 5.404127
LUALocationPoints[22][6] = 139.74130

--Point 23:
LUALocationPoints[23][1] = 0.000000
LUALocationPoints[23][2] = 0.000000
LUALocationPoints[23][3] = 0.000000
LUALocationPoints[23][4] = -306.583679
LUALocationPoints[23][5] = 0.000000
LUALocationPoints[23][6] = -5.22055

--Point 24:
LUALocationPoints[24][1] = 0.000000
LUALocationPoints[24][2] = 0.000000
LUALocationPoints[24][3] = 0.000000
LUALocationPoints[24][4] = -317.754272
LUALocationPoints[24][5] = 0.000000
LUALocationPoints[24][6] = -150.54983

--Point 25:
LUALocationPoints[25][1] = 0.000000
LUALocationPoints[25][2] = 0.000000
LUALocationPoints[25][3] = 0.000000
LUALocationPoints[25][4] = -285.086914
LUALocationPoints[25][5] = -10.385271
LUALocationPoints[25][6] = -236.32872

--Point 26:
LUALocationPoints[26][1] = 0.000000
LUALocationPoints[26][2] = 0.000000
LUALocationPoints[26][3] = 0.000000
LUALocationPoints[26][4] = -235.945923
LUALocationPoints[26][5] = -24.219515
LUALocationPoints[26][6] = -259.76470

--Point 27:
LUALocationPoints[27][1] = 0.000000
LUALocationPoints[27][2] = 0.000000
LUALocationPoints[27][3] = 0.000000
LUALocationPoints[27][4] = -173.810028
LUALocationPoints[27][5] = -34.216011
LUALocationPoints[27][6] = -261.73443

--Point 28:
LUALocationPoints[28][1] = 0.000000
LUALocationPoints[28][2] = 0.000000
LUALocationPoints[28][3] = 0.000000
LUALocationPoints[28][4] = -111.097649
LUALocationPoints[28][5] = -25.086514
LUALocationPoints[28][6] = -251.08120

--Point 29:
LUALocationPoints[29][1] = 0.000000
LUALocationPoints[29][2] = 0.000000
LUALocationPoints[29][3] = 0.000000
LUALocationPoints[29][4] = -91.585938
LUALocationPoints[29][5] = -23.635384
LUALocationPoints[29][6] = -220.77482

--Point 30:
LUALocationPoints[30][1] = 0.000000
LUALocationPoints[30][2] = 0.000000
LUALocationPoints[30][3] = 0.000000
LUALocationPoints[30][4] = -39.106453
LUALocationPoints[30][5] = -15.395015
LUALocationPoints[30][6] = -199.21777

--Point 31:
LUALocationPoints[31][1] = 0.000000
LUALocationPoints[31][2] = 0.000000
LUALocationPoints[31][3] = 0.000000
LUALocationPoints[31][4] = 14.801650
LUALocationPoints[31][5] = -10.134123
LUALocationPoints[31][6] = -209.58587

--Point 32:
LUALocationPoints[32][1] = 0.000000
LUALocationPoints[32][2] = 0.000000
LUALocationPoints[32][3] = 0.000000
LUALocationPoints[32][4] = 17.853550
LUALocationPoints[32][5] = -7.535734
LUALocationPoints[32][6] = -250.99517

--Point 33:
LUALocationPoints[33][1] = 0.000000
LUALocationPoints[33][2] = 0.000000
LUALocationPoints[33][3] = 0.000000
LUALocationPoints[33][4] = -6.410461
LUALocationPoints[33][5] = -6.568787
LUALocationPoints[33][6] = -276.56121

--Point 34:
LUALocationPoints[34][1] = 0.000000
LUALocationPoints[34][2] = 0.000000
LUALocationPoints[34][3] = 0.000000
LUALocationPoints[34][4] = -59.709972
LUALocationPoints[34][5] = -8.196197
LUALocationPoints[34][6] = -298.83361

--Point 35:
LUALocationPoints[35][1] = 0.000000
LUALocationPoints[35][2] = 0.000000
LUALocationPoints[35][3] = 0.000000
LUALocationPoints[35][4] = -61.723091
LUALocationPoints[35][5] = 0.867523
LUALocationPoints[35][6] = -349.68512

--Point 36:
LUALocationPoints[36][1] = 0.000000
LUALocationPoints[36][2] = 0.000000
LUALocationPoints[36][3] = 0.000000
LUALocationPoints[36][4] = -66.493866
LUALocationPoints[36][5] = 13.559672
LUALocationPoints[36][6] = -429.31488

--Point 37:
LUALocationPoints[37][1] = 0.000000
LUALocationPoints[37][2] = 0.000000
LUALocationPoints[37][3] = 0.000000
LUALocationPoints[37][4] = -178.703094
LUALocationPoints[37][5] = 0.036946
LUALocationPoints[37][6] = -437.53692

--Point 38:
LUALocationPoints[38][1] = 0.000000
LUALocationPoints[38][2] = 0.000000
LUALocationPoints[38][3] = 0.000000
LUALocationPoints[38][4] = -204.057816
LUALocationPoints[38][5] = 2.281365
LUALocationPoints[38][6] = -441.55969

--Point 39:
LUALocationPoints[39][1] = 0.000000
LUALocationPoints[39][2] = 0.000000
LUALocationPoints[39][3] = 0.000000
LUALocationPoints[39][4] = -250.108566
LUALocationPoints[39][5] = 5.559190
LUALocationPoints[39][6] = -419.34185

--Point 40:
LUALocationPoints[40][1] = 0.000000
LUALocationPoints[40][2] = 0.000000
LUALocationPoints[40][3] = 0.000000
LUALocationPoints[40][4] = -324.732513
LUALocationPoints[40][5] = 66.889847
LUALocationPoints[40][6] = -301.78430

--Point 41:
LUALocationPoints[41][1] = 0.000000
LUALocationPoints[41][2] = 0.000000
LUALocationPoints[41][3] = 0.000000
LUALocationPoints[41][4] = -367.067657
LUALocationPoints[41][5] = 63.316341
LUALocationPoints[41][6] = -254.73806

--Point 42:
LUALocationPoints[42][1] = 0.000000
LUALocationPoints[42][2] = 0.000000
LUALocationPoints[42][3] = 0.000000
LUALocationPoints[42][4] = -392.205505
LUALocationPoints[42][5] = 69.368683
LUALocationPoints[42][6] = -207.03448

--Point 43:
LUALocationPoints[43][1] = 0.000000
LUALocationPoints[43][2] = 0.000000
LUALocationPoints[43][3] = 0.000000
LUALocationPoints[43][4] = -419.608978
LUALocationPoints[43][5] = 68.107071
LUALocationPoints[43][6] = -140.76886

--Point 44:
LUALocationPoints[44][1] = 0.000000
LUALocationPoints[44][2] = 0.000000
LUALocationPoints[44][3] = 0.000000
LUALocationPoints[44][4] = -444.548950
LUALocationPoints[44][5] = 67.964058
LUALocationPoints[44][6] = -59.66763

--Point 45:
LUALocationPoints[45][1] = 0.000000
LUALocationPoints[45][2] = 0.000000
LUALocationPoints[45][3] = 0.000000
LUALocationPoints[45][4] = -435.159668
LUALocationPoints[45][5] = 9.191442
LUALocationPoints[45][6] = 92.35434

--Point 46:
LUALocationPoints[46][1] = 0.000000
LUALocationPoints[46][2] = 0.000000
LUALocationPoints[46][3] = 0.000000
LUALocationPoints[46][4] = -402.012695
LUALocationPoints[46][5] = 8.062954
LUALocationPoints[46][6] = 172.60788

--Point 47:
LUALocationPoints[47][1] = 0.000000
LUALocationPoints[47][2] = 0.000000
LUALocationPoints[47][3] = 0.000000
LUALocationPoints[47][4] = -373.794342
LUALocationPoints[47][5] = 2.340534
LUALocationPoints[47][6] = 244.65789

--Point 48:
LUALocationPoints[48][1] = 0.000000
LUALocationPoints[48][2] = 0.000000
LUALocationPoints[48][3] = 0.000000
LUALocationPoints[48][4] = -337.347168
LUALocationPoints[48][5] = 2.247941
LUALocationPoints[48][6] = 298.06622

--Point 49:
LUALocationPoints[49][1] = 0.000000
LUALocationPoints[49][2] = 0.000000
LUALocationPoints[49][3] = 0.000000
LUALocationPoints[49][4] = -327.886475
LUALocationPoints[49][5] = 0.549346
LUALocationPoints[49][6] = 346.03906

--Point 50:
LUALocationPoints[50][1] = 0.000000
LUALocationPoints[50][2] = 0.000000
LUALocationPoints[50][3] = 0.000000
LUALocationPoints[50][4] = -250.923492
LUALocationPoints[50][5] = 2.394804
LUALocationPoints[50][6] = 355.86688

--Point 51:
LUALocationPoints[51][1] = 0.000000
LUALocationPoints[51][2] = 0.000000
LUALocationPoints[51][3] = 0.000000
LUALocationPoints[51][4] = -196.850769
LUALocationPoints[51][5] = 0.000000
LUALocationPoints[51][6] = 368.27041

--Point 52:
LUALocationPoints[52][1] = 0.000000
LUALocationPoints[52][2] = 0.000000
LUALocationPoints[52][3] = 0.000000
LUALocationPoints[52][4] = -177.322510
LUALocationPoints[52][5] = 1.618879
LUALocationPoints[52][6] = 389.79577

--Point 53:
LUALocationPoints[53][1] = 0.000000
LUALocationPoints[53][2] = 0.000000
LUALocationPoints[53][3] = 0.000000
LUALocationPoints[53][4] = -124.961655
LUALocationPoints[53][5] = 3.489887
LUALocationPoints[53][6] = 373.56451

--Point 54:
LUALocationPoints[54][1] = 0.000000
LUALocationPoints[54][2] = 0.000000
LUALocationPoints[54][3] = 0.000000
LUALocationPoints[54][4] = -52.341270
LUALocationPoints[54][5] = 0.018566
LUALocationPoints[54][6] = 375.34301

--Point 55:
LUALocationPoints[55][1] = 0.000000
LUALocationPoints[55][2] = 0.000000
LUALocationPoints[55][3] = 0.000000
LUALocationPoints[55][4] = -30.424145
LUALocationPoints[55][5] = 0.563761
LUALocationPoints[55][6] = 343.43853

--Point 56:
LUALocationPoints[56][1] = 0.000000
LUALocationPoints[56][2] = 0.000000
LUALocationPoints[56][3] = 0.000000
LUALocationPoints[56][4] = 30.764595
LUALocationPoints[56][5] = 0.000000
LUALocationPoints[56][6] = 364.37811

--Point 57:
LUALocationPoints[57][1] = 0.000000
LUALocationPoints[57][2] = 0.000000
LUALocationPoints[57][3] = 0.000000
LUALocationPoints[57][4] = 90.792587
LUALocationPoints[57][5] = 0.000000
LUALocationPoints[57][6] = 384.92620

--Point 58:
LUALocationPoints[58][1] = 0.000000
LUALocationPoints[58][2] = 0.000000
LUALocationPoints[58][3] = 0.000000
LUALocationPoints[58][4] = 186.591537
LUALocationPoints[58][5] = 0.000000
LUALocationPoints[58][6] = 386.04748

--Point 59:
LUALocationPoints[59][1] = 0.000000
LUALocationPoints[59][2] = 0.000000
LUALocationPoints[59][3] = 0.000000
LUALocationPoints[59][4] = 230.878021
LUALocationPoints[59][5] = 0.429876
LUALocationPoints[59][6] = 349.09527

--Point 60:
LUALocationPoints[60][1] = 0.000000
LUALocationPoints[60][2] = 0.000000
LUALocationPoints[60][3] = 0.000000
LUALocationPoints[60][4] = 282.328247
LUALocationPoints[60][5] = 0.368921
LUALocationPoints[60][6] = 293.90274

--Point 61:
LUALocationPoints[61][1] = 0.000000
LUALocationPoints[61][2] = 0.000000
LUALocationPoints[61][3] = 0.000000
LUALocationPoints[61][4] = 335.146576
LUALocationPoints[61][5] = 0.000000
LUALocationPoints[61][6] = 183.56851

--Point 62:
LUALocationPoints[62][1] = 0.000000
LUALocationPoints[62][2] = 0.000000
LUALocationPoints[62][3] = 0.000000
LUALocationPoints[62][4] = 420.524933
LUALocationPoints[62][5] = 9.221782
LUALocationPoints[62][6] = 129.94102

--Point 63:
LUALocationPoints[63][1] = 0.000000
LUALocationPoints[63][2] = 0.000000
LUALocationPoints[63][3] = 0.000000
LUALocationPoints[63][4] = 425.136780
LUALocationPoints[63][5] = 35.930534
LUALocationPoints[63][6] = 61.92621

--Point 64:
LUALocationPoints[64][1] = 0.000000
LUALocationPoints[64][2] = 0.000000
LUALocationPoints[64][3] = 0.000000
LUALocationPoints[64][4] = 422.350861
LUALocationPoints[64][5] = 52.645359
LUALocationPoints[64][6] = 18.46855

--Point 65:
LUALocationPoints[65][1] = 0.000000
LUALocationPoints[65][2] = 0.000000
LUALocationPoints[65][3] = 0.000000
LUALocationPoints[65][4] = 367.035675
LUALocationPoints[65][5] = 56.584049
LUALocationPoints[65][6] = -24.03871

--Point 66:
LUALocationPoints[66][1] = 0.000000
LUALocationPoints[66][2] = 0.000000
LUALocationPoints[66][3] = 0.000000
LUALocationPoints[66][4] = 345.486481
LUALocationPoints[66][5] = 56.998985
LUALocationPoints[66][6] = -79.71548

--Point 67:
LUALocationPoints[67][1] = 0.000000
LUALocationPoints[67][2] = 0.000000
LUALocationPoints[67][3] = 0.000000
LUALocationPoints[67][4] = 375.124756
LUALocationPoints[67][5] = 58.026245
LUALocationPoints[67][6] = -128.63613

--Point 68:
LUALocationPoints[68][1] = 0.000000
LUALocationPoints[68][2] = 0.000000
LUALocationPoints[68][3] = 0.000000
LUALocationPoints[68][4] = 357.256805
LUALocationPoints[68][5] = 57.384277
LUALocationPoints[68][6] = -191.06051

--Point 69:
LUALocationPoints[69][1] = 0.000000
LUALocationPoints[69][2] = 0.000000
LUALocationPoints[69][3] = 0.000000
LUALocationPoints[69][4] = 344.397095
LUALocationPoints[69][5] = 54.788452
LUALocationPoints[69][6] = -239.11734

--Point 70:
LUALocationPoints[70][1] = 0.000000
LUALocationPoints[70][2] = 0.000000
LUALocationPoints[70][3] = 0.000000
LUALocationPoints[70][4] = 347.473938
LUALocationPoints[70][5] = 61.968491
LUALocationPoints[70][6] = -256.69207

--Point 71:
LUALocationPoints[71][1] = 0.000000
LUALocationPoints[71][2] = 0.000000
LUALocationPoints[71][3] = 0.000000
LUALocationPoints[71][4] = 348.971985
LUALocationPoints[71][5] = 62.504784
LUALocationPoints[71][6] = -273.05038

--Point 72:
LUALocationPoints[72][1] = 0.000000
LUALocationPoints[72][2] = 0.000000
LUALocationPoints[72][3] = 0.000000
LUALocationPoints[72][4] = 331.752380
LUALocationPoints[72][5] = 56.392105
LUALocationPoints[72][6] = -294.16131

--Point 73:
LUALocationPoints[73][1] = 0.000000
LUALocationPoints[73][2] = 0.000000
LUALocationPoints[73][3] = 0.000000
LUALocationPoints[73][4] = 132.173615
LUALocationPoints[73][5] = 57.286842
LUALocationPoints[73][6] = -287.37457

--Point 74:
LUALocationPoints[74][1] = 0.000000
LUALocationPoints[74][2] = 0.000000
LUALocationPoints[74][3] = 0.000000
LUALocationPoints[74][4] = 74.612587
LUALocationPoints[74][5] = 55.515602
LUALocationPoints[74][6] = -177.32600

--Point 75:
LUALocationPoints[75][1] = 0.000000
LUALocationPoints[75][2] = 0.000000
LUALocationPoints[75][3] = 0.000000
LUALocationPoints[75][4] = 70.094971
LUALocationPoints[75][5] = 58.202667
LUALocationPoints[75][6] = -96.01835

--Point 76:
LUALocationPoints[76][1] = 0.000000
LUALocationPoints[76][2] = 0.000000
LUALocationPoints[76][3] = 0.000000
LUALocationPoints[76][4] = 27.387470
LUALocationPoints[76][5] = 63.494934
LUALocationPoints[76][6] = -71.13843

--Point 77:
LUALocationPoints[77][1] = 0.000000
LUALocationPoints[77][2] = 0.000000
LUALocationPoints[77][3] = 0.000000
LUALocationPoints[77][4] = -24.898558
LUALocationPoints[77][5] = 74.569138
LUALocationPoints[77][6] = -390.66601

--Point 78:
LUALocationPoints[78][1] = 0.000000
LUALocationPoints[78][2] = 0.000000
LUALocationPoints[78][3] = 0.000000
LUALocationPoints[78][4] = -48.402004
LUALocationPoints[78][5] = 76.605301
LUALocationPoints[78][6] = -416.21347

--Point 79:
LUALocationPoints[79][1] = 0.000000
LUALocationPoints[79][2] = 0.000000
LUALocationPoints[79][3] = 0.000000
LUALocationPoints[79][4] = -60.292660
LUALocationPoints[79][5] = 91.715317
LUALocationPoints[79][6] = -429.96484

--Point 80:
LUALocationPoints[80][1] = 0.000000
LUALocationPoints[80][2] = 0.000000
LUALocationPoints[80][3] = 0.000000
LUALocationPoints[80][4] = -82.444397
LUALocationPoints[80][5] = 89.253624
LUALocationPoints[80][6] = -479.43203

--Point 81:
LUALocationPoints[81][1] = 0.000000
LUALocationPoints[81][2] = 0.000000
LUALocationPoints[81][3] = 0.000000
LUALocationPoints[81][4] = -141.395386
LUALocationPoints[81][5] = 81.549232
LUALocationPoints[81][6] = -503.77108

--Point 82:
LUALocationPoints[82][1] = 0.000000
LUALocationPoints[82][2] = 0.000000
LUALocationPoints[82][3] = 0.000000
LUALocationPoints[82][4] = -277.430450
LUALocationPoints[82][5] = 80.711731
LUALocationPoints[82][6] = -524.19744

--Point 83:
LUALocationPoints[83][1] = 0.000000
LUALocationPoints[83][2] = 0.000000
LUALocationPoints[83][3] = 0.000000
LUALocationPoints[83][4] = -371.525879
LUALocationPoints[83][5] = 81.392197
LUALocationPoints[83][6] = -490.98352

--Point 84:
LUALocationPoints[84][1] = 0.000000
LUALocationPoints[84][2] = 0.000000
LUALocationPoints[84][3] = 0.000000
LUALocationPoints[84][4] = -448.692963
LUALocationPoints[84][5] = 80.614647
LUALocationPoints[84][6] = -307.19604

--Point 85:
LUALocationPoints[85][1] = 0.000000
LUALocationPoints[85][2] = 0.000000
LUALocationPoints[85][3] = 0.000000
LUALocationPoints[85][4] = -409.539185
LUALocationPoints[85][5] = 85.353790
LUALocationPoints[85][6] = -276.40155

--Point 86:
LUALocationPoints[86][1] = 0.000000
LUALocationPoints[86][2] = 0.000000
LUALocationPoints[86][3] = 0.000000
LUALocationPoints[86][4] = -386.189636
LUALocationPoints[86][5] = 64.380066
LUALocationPoints[86][6] = -251.48703

--Point 87:
LUALocationPoints[87][1] = 5.000005
LUALocationPoints[87][2] = 4.000004
LUALocationPoints[87][3] = 3.000003
LUALocationPoints[87][4] = -390.396301
LUALocationPoints[87][5] = 68.379745
LUALocationPoints[87][6] = -212.80773

--Testing Purposes: 'Draw 'ghosts' of object' at all keyframes
print("Deploying Test Markers")
numba = 1
while numba > 88 do
ObjectName = "Ghost"..numba
CreateEntity("bes2_bldg_large_tower", CreateMatrix(0,LUALocationPoints[numba][1], LUALocationPoints[numba][2], LUALocationPoints[numba][3], LUALocationPoints[numba][4], LUALocationPoints[numba][5], LUALocationPoints[numba][6], GetEntityMatrix("ZeroPoint")), ObjectName)
end
print("Markers Deployed")
--rate = 0.001
rate = 0.05
a = rate
Keyframe = 1
NextKeyframe = 2

function MatrixTween(Matrix1, Matrix2) --TO DO: when objects matrix equals matrix 2, set matrix 2 as matrix one, get a new matrix 2
MatTwResult = {}
MatTwResult[1] = (Matrix2[1] - Matrix1[1])*a
MatTwResult[2] = (Matrix2[2] - Matrix1[2])*a
MatTwResult[3] = (Matrix2[3] - Matrix1[3])*a
MatTwResult[4] = (Matrix2[4] - Matrix1[4])*a
MatTwResult[5] = (Matrix2[5] - Matrix1[5])*a
MatTwResult[6] = (Matrix2[6] - Matrix1[6])*a
print(" ")
print("Matrix Subtraction Result")
print(" "..MatTwResult[1].." "..MatTwResult[2].." "..MatTwResult[3].." "..MatTwResult[4].." "..MatTwResult[5].." "..MatTwResult[6].." ")
print(" ")

--animation speed, determine distance between points (points are basically position vectors)
Distance = ((Matrix2[1] - Matrix1[1])^2 + (Matrix2[2] - Matrix1[2])^2 + (Matrix2[3] - Matrix1[3])^2 + (Matrix2[4] - Matrix1[4])^2 + (Matrix2[5] - Matrix1[5])^2 + (Matrix2[6] - Matrix1[6])^2)^(-0.5)
--Speed = Distance/Time
--TravelTime = Speed/Distance Time is in 60th of seconds, to mark value of A*100?
end





CreateTimer("FrameRate")
SetTimerValue("FrameRate", 0.016666666666666667)
--SetTimerValue("FrameRate", 0.5)



OnTimerElapse(
function(timer)
--SetTimerValue("FrameRate", 0.5)
SetTimerValue("FrameRate", 0.016666666666666667)
if a <= 1 then
print("a is <1")
a = a + rate -- initial value and this value are equal (0.001) and the smaller they are, the smoother the animation and more tweens
else
print("a is 1 or bigger")
Keyframe = Keyframe + 1
NextKeyframe = NextKeyframe + 1 --(should also = KeyFrame + 1)
print("Moved to next keyframe. Keyframe ="..Keyframe..", nextkeyframe ="..NextKeyframe..".")
Origin = nil
Origin = CreateMatrix(0,LUALocationPoints[Keyframe][1], LUALocationPoints[Keyframe][2], LUALocationPoints[Keyframe][3], LUALocationPoints[Keyframe][4], LUALocationPoints[Keyframe][5], LUALocationPoints[Keyframe][6], GetEntityMatrix("ZeroPoint"))

print("Origin Set")
a = 0
--if Keyframe == 2 then
--rate = 0.001
--end
end
StartTimer("FrameRate")
--Calculate AI tween positions and move
MatrixTween(LUALocationPoints[Keyframe],LUALocationPoints[NextKeyframe])
SetEntityMatrix("GiantChessPiece", CreateMatrix(0,MatTwResult[1], MatTwResult[2], MatTwResult[3], MatTwResult[4], MatTwResult[5], MatTwResult[6], Origin)) -- Will need one of these sets of lines (setentitymatrix and MatrixTween) per AI, currently set to player vehicle as test
MatTwResult = nil

end,
"FrameRate"
)
[/code]


Thread Summary:
LUA Code and the Java program which helps write it designed to get Objects to follow a ZeroEditor Path and other points around a map. Code runs, but Object moves along erratic or mirrored/inverted path. WIP.
Last edited by Ace_Azzameen_5 on Sat May 22, 2010 11:37 am, edited 2 times in total.
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by Anakin »

looks great what is this for a program language??
it looks a bit like Java
Ace_Azzameen_5 wrote: [...]
Hidden/Spoiler:
Image
[...]
501st_commander
Master Bounty Hunter
Master Bounty Hunter
Posts: 1570
Joined: Wed Dec 10, 2008 7:48 pm

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by 501st_commander »

Anakin wrote:looks great what is this for a program language??
it looks a bit like Java
Ace_Azzameen_5 wrote: [...]
Hidden/Spoiler:
Image
[...]
because it is java.
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by DarthD.U.C.K. »

Hidden/Spoiler:
Image
sorry.. i couldnt resist
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by Anakin »

501st_commander wrote:because it is java.
:shock: :shock:
???????you can use java for battlefront??????
!!!how i can do?? this is simpler than the other i think!!!
User avatar
DarthD.U.C.K.
Master of the Force
Master of the Force
Posts: 6027
Joined: Wed Sep 27, 2006 11:05 am
Location: Duckburg, Germany

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by DarthD.U.C.K. »

Ace_Azzameen_5 wrote:One I managed to fix. That is the fact that it is a PAIN IN THE :cpu: to copy and paste 6 individual numbers from (NumberOfNodes x2) lines in a .pth file. So I wrote a Java app to do it for me. And I hadn't programmed in ages so even this simple thing was a minor headache.
501st_commander
Master Bounty Hunter
Master Bounty Hunter
Posts: 1570
Joined: Wed Dec 10, 2008 7:48 pm

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by 501st_commander »

lol @D.U.C.K

Ace, nice work, i'll keep my self updated on this.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP/Help: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

I got it working (I guess X coordinate was negative of what it should be, how it took this long to fix I don't know), more info to come!

Now I'm working on getting the object to travel at a custom speed. I'm at a place where I think it should work, but now the object is jumping (NOT teleporting) around. :P
Edit: Constant speed now maintained. Here is the updated code. It includes branching paths. If you'd like, supply the correctly named "GiantChessPiece" object on a blank map and watch it circle infinitely. Maybe turn up the speed factor. Uncomment the "test Markers" code and supply the right odf (once object using it needs to be placed in the map or otherwise loaded) and see a representation of the points on the course.

Code: Select all

--Point 1: 
LUALocationPoints[1][1] = 0.000000 
LUALocationPoints[1][2] = 0.000000
LUALocationPoints[1][3] = 0.000000 
LUALocationPoints[1][4] = -457.61010 
LUALocationPoints[1][5] = 0.000001 
LUALocationPoints[1][6] = 283.022247  

--Point 2: 
LUALocationPoints[2][1] = 0.000000 
LUALocationPoints[2][2] = 0.000000
LUALocationPoints[2][3] = 0.000000 
LUALocationPoints[2][4] = -465.88913 
LUALocationPoints[2][5] = 0.000000 
LUALocationPoints[2][6] = 376.578217  

--Point 3: 
LUALocationPoints[3][1] = 0.000000 
LUALocationPoints[3][2] = 0.000000
LUALocationPoints[3][3] = 0.000000 
LUALocationPoints[3][4] = -449.83267 
LUALocationPoints[3][5] = 0.000000 
LUALocationPoints[3][6] = 413.593018  

--Point 4: 
LUALocationPoints[4][1] = 0.000000 
LUALocationPoints[4][2] = 0.000000
LUALocationPoints[4][3] = 0.000000 
LUALocationPoints[4][4] = -395.38201 
LUALocationPoints[4][5] = 0.000000 
LUALocationPoints[4][6] = 419.836304  

--Point 5: 
LUALocationPoints[5][1] = 0.000000 
LUALocationPoints[5][2] = 0.000000
LUALocationPoints[5][3] = 0.000000 
LUALocationPoints[5][4] = -333.53460 
LUALocationPoints[5][5] = 0.000000 
LUALocationPoints[5][6] = 442.031769  

--Point 6: 
LUALocationPoints[6][1] = 0.000000 
LUALocationPoints[6][2] = 0.000000
LUALocationPoints[6][3] = 0.000000 
LUALocationPoints[6][4] = -248.15860 
LUALocationPoints[6][5] = 0.000000 
LUALocationPoints[6][6] = 438.327515  

--Point 7: 
LUALocationPoints[7][1] = 0.000000 
LUALocationPoints[7][2] = 0.000000
LUALocationPoints[7][3] = 0.000000 
LUALocationPoints[7][4] = -184.95797 
LUALocationPoints[7][5] = 0.000000 
LUALocationPoints[7][6] = 434.212341  

--Point 8: 
LUALocationPoints[8][1] = 0.000000 
LUALocationPoints[8][2] = 0.000000
LUALocationPoints[8][3] = 0.000000 
LUALocationPoints[8][4] = -100.65515 
LUALocationPoints[8][5] = 0.000000 
LUALocationPoints[8][6] = 353.462677  

--Point 9: 
LUALocationPoints[9][1] = 0.000000 
LUALocationPoints[9][2] = 0.000000
LUALocationPoints[9][3] = 0.000000 
LUALocationPoints[9][4] = 20.35596 
LUALocationPoints[9][5] = 1.409971 
LUALocationPoints[9][6] = 336.273041  

--Point 10: 
LUALocationPoints[10][1] = 0.000000 
LUALocationPoints[10][2] = 0.000000
LUALocationPoints[10][3] = 0.000000 
LUALocationPoints[10][4] = 57.42618 
LUALocationPoints[10][5] = -0.321567 
LUALocationPoints[10][6] = 323.874939  

--Point 11: 
LUALocationPoints[11][1] = 0.000000 
LUALocationPoints[11][2] = 0.000000
LUALocationPoints[11][3] = 0.000000 
LUALocationPoints[11][4] = 167.04922 
LUALocationPoints[11][5] = 1.322924 
LUALocationPoints[11][6] = 319.148499  

--Point 12: 
LUALocationPoints[12][1] = 0.000000 
LUALocationPoints[12][2] = 0.000000
LUALocationPoints[12][3] = 0.000000 
LUALocationPoints[12][4] = 288.07141 
LUALocationPoints[12][5] = 0.024262 
LUALocationPoints[12][6] = 276.732117  

--Point 13: 
LUALocationPoints[13][1] = 0.000000 
LUALocationPoints[13][2] = 0.000000
LUALocationPoints[13][3] = 0.000000 
LUALocationPoints[13][4] = 329.97863 
LUALocationPoints[13][5] = 2.692170 
LUALocationPoints[13][6] = 187.228851  

--Point 14: 
LUALocationPoints[14][1] = 0.000000 
LUALocationPoints[14][2] = 0.000000
LUALocationPoints[14][3] = 0.000000 
LUALocationPoints[14][4] = 292.01306 
LUALocationPoints[14][5] = 1.089711 
LUALocationPoints[14][6] = 100.159424  

--Point 15: 
LUALocationPoints[15][1] = 0.000000 
LUALocationPoints[15][2] = 0.000000
LUALocationPoints[15][3] = 0.000000 
LUALocationPoints[15][4] = 201.24499 
LUALocationPoints[15][5] = 1.288867 
LUALocationPoints[15][6] = 78.195084  

--Point 16: 
LUALocationPoints[16][1] = 0.000000 
LUALocationPoints[16][2] = 0.000000
LUALocationPoints[16][3] = 0.000000 
LUALocationPoints[16][4] = 84.64901 
LUALocationPoints[16][5] = 0.963373 
LUALocationPoints[16][6] = 59.354065  

--Point 17: 
LUALocationPoints[17][1] = 0.000000 
LUALocationPoints[17][2] = 0.000000
LUALocationPoints[17][3] = 0.000000 
LUALocationPoints[17][4] = 40.15289 
LUALocationPoints[17][5] = 0.553417 
LUALocationPoints[17][6] = 96.523758  

--Point 18: 
LUALocationPoints[18][1] = 0.000000 
LUALocationPoints[18][2] = 0.000000
LUALocationPoints[18][3] = 0.000000 
LUALocationPoints[18][4] = 16.15483 
LUALocationPoints[18][5] = 1.613748 
LUALocationPoints[18][6] = 77.537888  

--Point 19: 
LUALocationPoints[19][1] = 0.000000 
LUALocationPoints[19][2] = 0.000000
LUALocationPoints[19][3] = 0.000000 
LUALocationPoints[19][4] = -76.62510 
LUALocationPoints[19][5] = 0.950061 
LUALocationPoints[19][6] = 61.186287  

--Point 20: 
LUALocationPoints[20][1] = 0.000000 
LUALocationPoints[20][2] = 0.000000
LUALocationPoints[20][3] = 0.000000 
LUALocationPoints[20][4] = -145.29576 
LUALocationPoints[20][5] = 0.495810 
LUALocationPoints[20][6] = -4.762239  

--Point 21: 
LUALocationPoints[21][1] = 0.000000 
LUALocationPoints[21][2] = 0.000000
LUALocationPoints[21][3] = 0.000000 
LUALocationPoints[21][4] = -195.42596 
LUALocationPoints[21][5] = 0.359543 
LUALocationPoints[21][6] = -102.713394  

--Point 22: 
LUALocationPoints[22][1] = 0.000000 
LUALocationPoints[22][2] = 0.000000
LUALocationPoints[22][3] = 0.000000 
LUALocationPoints[22][4] = -139.74130 
LUALocationPoints[22][5] = 5.404127 
LUALocationPoints[22][6] = -226.234192  

--Point 23: 
LUALocationPoints[23][1] = 0.000000 
LUALocationPoints[23][2] = 0.000000
LUALocationPoints[23][3] = 0.000000 
LUALocationPoints[23][4] = 5.22055 
LUALocationPoints[23][5] = 0.000000 
LUALocationPoints[23][6] = -306.583679  

--Point 24: 
LUALocationPoints[24][1] = 0.000000 
LUALocationPoints[24][2] = 0.000000
LUALocationPoints[24][3] = 0.000000 
LUALocationPoints[24][4] = 150.54983 
LUALocationPoints[24][5] = 0.000000 
LUALocationPoints[24][6] = -317.754272  

--Point 25: 
LUALocationPoints[25][1] = 0.000000 
LUALocationPoints[25][2] = 0.000000
LUALocationPoints[25][3] = 0.000000 
LUALocationPoints[25][4] = 236.32872 
LUALocationPoints[25][5] = -10.385271 
LUALocationPoints[25][6] = -285.086914  

--Point 26: 
LUALocationPoints[26][1] = 0.000000 
LUALocationPoints[26][2] = 0.000000
LUALocationPoints[26][3] = 0.000000 
LUALocationPoints[26][4] = 259.76470 
LUALocationPoints[26][5] = -24.219515 
LUALocationPoints[26][6] = -235.945923  

--Point 27: 
LUALocationPoints[27][1] = 0.000000 
LUALocationPoints[27][2] = 0.000000
LUALocationPoints[27][3] = 0.000000 
LUALocationPoints[27][4] = 261.73443 
LUALocationPoints[27][5] = -34.216011 
LUALocationPoints[27][6] = -173.810028  

--Point 28: 
LUALocationPoints[28][1] = 0.000000 
LUALocationPoints[28][2] = 0.000000
LUALocationPoints[28][3] = 0.000000 
LUALocationPoints[28][4] = 251.08120 
LUALocationPoints[28][5] = -25.086514 
LUALocationPoints[28][6] = -111.097649  

--Point 29: 
LUALocationPoints[29][1] = 0.000000 
LUALocationPoints[29][2] = 0.000000
LUALocationPoints[29][3] = 0.000000 
LUALocationPoints[29][4] = 220.77482 
LUALocationPoints[29][5] = -23.635384 
LUALocationPoints[29][6] = -91.585938  

--Point 30: 
LUALocationPoints[30][1] = 0.000000 
LUALocationPoints[30][2] = 0.000000
LUALocationPoints[30][3] = 0.000000 
LUALocationPoints[30][4] = 199.21777 
LUALocationPoints[30][5] = -15.395015 
LUALocationPoints[30][6] = -39.106453  

--Point 31: 
LUALocationPoints[31][1] = 0.000000 
LUALocationPoints[31][2] = 0.000000
LUALocationPoints[31][3] = 0.000000 
LUALocationPoints[31][4] = 209.58587 
LUALocationPoints[31][5] = -10.134123 
LUALocationPoints[31][6] = 14.801650  

--Point 32: 
LUALocationPoints[32][1] = 0.000000 
LUALocationPoints[32][2] = 0.000000
LUALocationPoints[32][3] = 0.000000 
LUALocationPoints[32][4] = 250.99517 
LUALocationPoints[32][5] = -7.535734 
LUALocationPoints[32][6] = 17.853550  

--Point 33: 
LUALocationPoints[33][1] = 0.000000 
LUALocationPoints[33][2] = 0.000000
LUALocationPoints[33][3] = 0.000000 
LUALocationPoints[33][4] = 276.56121 
LUALocationPoints[33][5] = -6.568787 
LUALocationPoints[33][6] = -6.410461  

--Point 34: 
LUALocationPoints[34][1] = 0.000000 
LUALocationPoints[34][2] = 0.000000
LUALocationPoints[34][3] = 0.000000 
LUALocationPoints[34][4] = 298.83361 
LUALocationPoints[34][5] = -8.196197 
LUALocationPoints[34][6] = -59.709972  

--Point 35: 
LUALocationPoints[35][1] = 0.000000 
LUALocationPoints[35][2] = 0.000000
LUALocationPoints[35][3] = 0.000000 
LUALocationPoints[35][4] = 349.68512 
LUALocationPoints[35][5] = 0.867523 
LUALocationPoints[35][6] = -61.723091  

--Point 36: 
LUALocationPoints[36][1] = 0.000000 
LUALocationPoints[36][2] = 0.000000
LUALocationPoints[36][3] = 0.000000 
LUALocationPoints[36][4] = 429.31488 
LUALocationPoints[36][5] = 13.559672 
LUALocationPoints[36][6] = -66.493866  

--Point 37: 
LUALocationPoints[37][1] = 0.000000 
LUALocationPoints[37][2] = 0.000000
LUALocationPoints[37][3] = 0.000000 
LUALocationPoints[37][4] = 437.53692 
LUALocationPoints[37][5] = 0.036946 
LUALocationPoints[37][6] = -178.703094  

--Point 38: 
LUALocationPoints[38][1] = 0.000000 
LUALocationPoints[38][2] = 0.000000
LUALocationPoints[38][3] = 0.000000 
LUALocationPoints[38][4] = 441.55969 
LUALocationPoints[38][5] = 2.281365 
LUALocationPoints[38][6] = -204.057816  

--Point 39: 
LUALocationPoints[39][1] = 0.000000 
LUALocationPoints[39][2] = 0.000000
LUALocationPoints[39][3] = 0.000000 
LUALocationPoints[39][4] = 419.34185 
LUALocationPoints[39][5] = 5.559190 
LUALocationPoints[39][6] = -250.108566  

--Point 40: 
LUALocationPoints[40][1] = 0.000000 
LUALocationPoints[40][2] = 0.000000
LUALocationPoints[40][3] = 0.000000 
LUALocationPoints[40][4] = 301.78430 
LUALocationPoints[40][5] = 66.889847 
LUALocationPoints[40][6] = -324.732513  

--Point 41: 
LUALocationPoints[41][1] = 0.000000 
LUALocationPoints[41][2] = 0.000000
LUALocationPoints[41][3] = 0.000000 
LUALocationPoints[41][4] = 254.73806 
LUALocationPoints[41][5] = 63.316341 
LUALocationPoints[41][6] = -367.067657  

--Point 42: 
LUALocationPoints[42][1] = 0.000000 
LUALocationPoints[42][2] = 0.000000
LUALocationPoints[42][3] = 0.000000 
LUALocationPoints[42][4] = 207.03448 
LUALocationPoints[42][5] = 69.368683 
LUALocationPoints[42][6] = -392.205505  

--Point 43: 
LUALocationPoints[43][1] = 0.000000 
LUALocationPoints[43][2] = 0.000000
LUALocationPoints[43][3] = 0.000000 
LUALocationPoints[43][4] = 140.76886 
LUALocationPoints[43][5] = 68.107071 
LUALocationPoints[43][6] = -419.608978  

--Point 44: 
LUALocationPoints[44][1] = 0.000000 
LUALocationPoints[44][2] = 0.000000
LUALocationPoints[44][3] = 0.000000 
LUALocationPoints[44][4] = 59.66763 
LUALocationPoints[44][5] = 67.964058 
LUALocationPoints[44][6] = -444.548950  

--Point 45: 
LUALocationPoints[45][1] = 0.000000 
LUALocationPoints[45][2] = 0.000000
LUALocationPoints[45][3] = 0.000000 
LUALocationPoints[45][4] = -92.35434 
LUALocationPoints[45][5] = 9.191442 
LUALocationPoints[45][6] = -435.159668  

--Point 46: 
LUALocationPoints[46][1] = 0.000000 
LUALocationPoints[46][2] = 0.000000
LUALocationPoints[46][3] = 0.000000 
LUALocationPoints[46][4] = -172.60788 
LUALocationPoints[46][5] = 8.062954 
LUALocationPoints[46][6] = -402.012695  

--Point 47: 
LUALocationPoints[47][1] = 0.000000 
LUALocationPoints[47][2] = 0.000000
LUALocationPoints[47][3] = 0.000000 
LUALocationPoints[47][4] = -244.65789 
LUALocationPoints[47][5] = 2.340534 
LUALocationPoints[47][6] = -373.794342  

--Point 48: 
LUALocationPoints[48][1] = 0.000000 
LUALocationPoints[48][2] = 0.000000
LUALocationPoints[48][3] = 0.000000 
LUALocationPoints[48][4] = -298.06622 
LUALocationPoints[48][5] = 2.247941 
LUALocationPoints[48][6] = -337.347168  

--Point 49: 
LUALocationPoints[49][1] = 0.000000 
LUALocationPoints[49][2] = 0.000000
LUALocationPoints[49][3] = 0.000000 
LUALocationPoints[49][4] = -346.03906 
LUALocationPoints[49][5] = 0.549346 
LUALocationPoints[49][6] = -327.886475  

--Point 50: 
LUALocationPoints[50][1] = 0.000000 
LUALocationPoints[50][2] = 0.000000
LUALocationPoints[50][3] = 0.000000 
LUALocationPoints[50][4] = -355.86688 
LUALocationPoints[50][5] = 2.394804 
LUALocationPoints[50][6] = -250.923492  

--Point 51: 
LUALocationPoints[51][1] = 0.000000 
LUALocationPoints[51][2] = 0.000000
LUALocationPoints[51][3] = 0.000000 
LUALocationPoints[51][4] = -368.27041 
LUALocationPoints[51][5] = 0.000000 
LUALocationPoints[51][6] = -196.850769  

--Point 52: 
LUALocationPoints[52][1] = 0.000000 
LUALocationPoints[52][2] = 0.000000
LUALocationPoints[52][3] = 0.000000 
LUALocationPoints[52][4] = -389.79577 
LUALocationPoints[52][5] = 1.618879 
LUALocationPoints[52][6] = -177.322510  

--Point 53: 
LUALocationPoints[53][1] = 0.000000 
LUALocationPoints[53][2] = 0.000000
LUALocationPoints[53][3] = 0.000000 
LUALocationPoints[53][4] = -373.56451 
LUALocationPoints[53][5] = 3.489887 
LUALocationPoints[53][6] = -124.961655  

--Point 54: 
LUALocationPoints[54][1] = 0.000000 
LUALocationPoints[54][2] = 0.000000
LUALocationPoints[54][3] = 0.000000 
LUALocationPoints[54][4] = -375.34301 
LUALocationPoints[54][5] = 0.018566 
LUALocationPoints[54][6] = -52.341270  

--Point 55: 
LUALocationPoints[55][1] = 0.000000 
LUALocationPoints[55][2] = 0.000000
LUALocationPoints[55][3] = 0.000000 
LUALocationPoints[55][4] = -343.43853 
LUALocationPoints[55][5] = 0.563761 
LUALocationPoints[55][6] = -30.424145  

--Point 56: 
LUALocationPoints[56][1] = 0.000000 
LUALocationPoints[56][2] = 0.000000
LUALocationPoints[56][3] = 0.000000 
LUALocationPoints[56][4] = -364.37811 
LUALocationPoints[56][5] = 0.000000 
LUALocationPoints[56][6] = 30.764595  

--Point 57: 
LUALocationPoints[57][1] = 0.000000 
LUALocationPoints[57][2] = 0.000000
LUALocationPoints[57][3] = 0.000000 
LUALocationPoints[57][4] = -384.92620 
LUALocationPoints[57][5] = 0.000000 
LUALocationPoints[57][6] = 90.792587  

--Point 58: 
LUALocationPoints[58][1] = 0.000000 
LUALocationPoints[58][2] = 0.000000
LUALocationPoints[58][3] = 0.000000 
LUALocationPoints[58][4] = -386.04748 
LUALocationPoints[58][5] = 0.000000 
LUALocationPoints[58][6] = 186.591537  

--Point 59: 
LUALocationPoints[59][1] = 0.000000 
LUALocationPoints[59][2] = 0.000000
LUALocationPoints[59][3] = 0.000000 
LUALocationPoints[59][4] = -349.09527 
LUALocationPoints[59][5] = 0.429876 
LUALocationPoints[59][6] = 230.878021  

--Point 60: 
LUALocationPoints[60][1] = 0.000000 
LUALocationPoints[60][2] = 0.000000
LUALocationPoints[60][3] = 0.000000 
LUALocationPoints[60][4] = -293.90274 
LUALocationPoints[60][5] = 0.368921 
LUALocationPoints[60][6] = 282.328247  

--Point 61: 
LUALocationPoints[61][1] = 0.000000 
LUALocationPoints[61][2] = 0.000000
LUALocationPoints[61][3] = 0.000000 
LUALocationPoints[61][4] = -183.56851 
LUALocationPoints[61][5] = 0.000000 
LUALocationPoints[61][6] = 335.146576  

--Point 62: 
LUALocationPoints[62][1] = 0.000000 
LUALocationPoints[62][2] = 0.000000
LUALocationPoints[62][3] = 0.000000 
LUALocationPoints[62][4] = -129.94102 
LUALocationPoints[62][5] = 9.221782 
LUALocationPoints[62][6] = 420.524933  

--Point 63: 
LUALocationPoints[63][1] = 0.000000 
LUALocationPoints[63][2] = 0.000000
LUALocationPoints[63][3] = 0.000000 
LUALocationPoints[63][4] = -61.92621 
LUALocationPoints[63][5] = 35.930534 
LUALocationPoints[63][6] = 425.136780  

--Point 64: 
LUALocationPoints[64][1] = 0.000000 
LUALocationPoints[64][2] = 0.000000
LUALocationPoints[64][3] = 0.000000 
LUALocationPoints[64][4] = -18.46855 
LUALocationPoints[64][5] = 52.645359 
LUALocationPoints[64][6] = 422.350861  

--Point 65: 
LUALocationPoints[65][1] = 0.000000 
LUALocationPoints[65][2] = 0.000000
LUALocationPoints[65][3] = 0.000000 
LUALocationPoints[65][4] = 24.03871 
LUALocationPoints[65][5] = 56.584049 
LUALocationPoints[65][6] = 367.035675  

--Point 66: 
LUALocationPoints[66][1] = 0.000000 
LUALocationPoints[66][2] = 0.000000
LUALocationPoints[66][3] = 0.000000 
LUALocationPoints[66][4] = 79.71548 
LUALocationPoints[66][5] = 56.998985 
LUALocationPoints[66][6] = 345.486481  

--Point 67: 
LUALocationPoints[67][1] = 0.000000 
LUALocationPoints[67][2] = 0.000000
LUALocationPoints[67][3] = 0.000000 
LUALocationPoints[67][4] = 128.63613 
LUALocationPoints[67][5] = 58.026245 
LUALocationPoints[67][6] = 375.124756  

--Point 68: 
LUALocationPoints[68][1] = 0.000000 
LUALocationPoints[68][2] = 0.000000
LUALocationPoints[68][3] = 0.000000 
LUALocationPoints[68][4] = 191.06051 
LUALocationPoints[68][5] = 57.384277 
LUALocationPoints[68][6] = 357.256805  

--Point 69: 
LUALocationPoints[69][1] = 0.000000 
LUALocationPoints[69][2] = 0.000000
LUALocationPoints[69][3] = 0.000000 
LUALocationPoints[69][4] = 239.11734 
LUALocationPoints[69][5] = 54.788452 
LUALocationPoints[69][6] = 344.397095  

--Point 70: 
LUALocationPoints[70][1] = 0.000000 
LUALocationPoints[70][2] = 0.000000
LUALocationPoints[70][3] = 0.000000 
LUALocationPoints[70][4] = 256.69207 
LUALocationPoints[70][5] = 61.968491 
LUALocationPoints[70][6] = 347.473938  

--Point 71: 
LUALocationPoints[71][1] = 0.000000 
LUALocationPoints[71][2] = 0.000000
LUALocationPoints[71][3] = 0.000000 
LUALocationPoints[71][4] = 273.05038 
LUALocationPoints[71][5] = 62.504784 
LUALocationPoints[71][6] = 348.971985  

--Point 72: 
LUALocationPoints[72][1] = 0.000000 
LUALocationPoints[72][2] = 0.000000
LUALocationPoints[72][3] = 0.000000 
LUALocationPoints[72][4] = 294.16131 
LUALocationPoints[72][5] = 56.392105 
LUALocationPoints[72][6] = 331.752380  

--Point 73: 
LUALocationPoints[73][1] = 0.000000 
LUALocationPoints[73][2] = 0.000000
LUALocationPoints[73][3] = 0.000000 
LUALocationPoints[73][4] = 287.37457 
LUALocationPoints[73][5] = 57.286842 
LUALocationPoints[73][6] = 132.173615  

--Point 74: 
LUALocationPoints[74][1] = 0.000000 
LUALocationPoints[74][2] = 0.000000
LUALocationPoints[74][3] = 0.000000 
LUALocationPoints[74][4] = 177.32600 
LUALocationPoints[74][5] = 55.515602 
LUALocationPoints[74][6] = 74.612587  

--Point 75: 
LUALocationPoints[75][1] = 0.000000 
LUALocationPoints[75][2] = 0.000000
LUALocationPoints[75][3] = 0.000000 
LUALocationPoints[75][4] = 96.01835 
LUALocationPoints[75][5] = 58.202667 
LUALocationPoints[75][6] = 70.094971  

--Point 76: 
LUALocationPoints[76][1] = 0.000000 
LUALocationPoints[76][2] = 0.000000
LUALocationPoints[76][3] = 0.000000 
LUALocationPoints[76][4] = 71.13843 
LUALocationPoints[76][5] = 63.494934 
LUALocationPoints[76][6] = 27.387470  

--Point 77: 
LUALocationPoints[77][1] = 0.000000 
LUALocationPoints[77][2] = 0.000000
LUALocationPoints[77][3] = 0.000000 
LUALocationPoints[77][4] = 390.66601 
LUALocationPoints[77][5] = 74.569138 
LUALocationPoints[77][6] = -24.898558  

--Point 78: 
LUALocationPoints[78][1] = 0.000000 
LUALocationPoints[78][2] = 0.000000
LUALocationPoints[78][3] = 0.000000 
LUALocationPoints[78][4] = 416.21347 
LUALocationPoints[78][5] = 76.605301 
LUALocationPoints[78][6] = -48.402004  

--Point 79: 
LUALocationPoints[79][1] = 0.000000 
LUALocationPoints[79][2] = 0.000000
LUALocationPoints[79][3] = 0.000000 
LUALocationPoints[79][4] = 429.96484 
LUALocationPoints[79][5] = 91.715317 
LUALocationPoints[79][6] = -60.292660  

--Point 80: 
LUALocationPoints[80][1] = 0.000000 
LUALocationPoints[80][2] = 0.000000
LUALocationPoints[80][3] = 0.000000 
LUALocationPoints[80][4] = 479.43203 
LUALocationPoints[80][5] = 89.253624 
LUALocationPoints[80][6] = -82.444397  

--Point 81: 
LUALocationPoints[81][1] = 0.000000 
LUALocationPoints[81][2] = 0.000000
LUALocationPoints[81][3] = 0.000000 
LUALocationPoints[81][4] = 503.77108 
LUALocationPoints[81][5] = 81.549232 
LUALocationPoints[81][6] = -141.395386  

--Point 82: 
LUALocationPoints[82][1] = 0.000000 
LUALocationPoints[82][2] = 0.000000
LUALocationPoints[82][3] = 0.000000 
LUALocationPoints[82][4] = 524.19744 
LUALocationPoints[82][5] = 80.711731 
LUALocationPoints[82][6] = -277.430450  

--Point 83: 
LUALocationPoints[83][1] = 0.000000 
LUALocationPoints[83][2] = 0.000000
LUALocationPoints[83][3] = 0.000000 
LUALocationPoints[83][4] = 490.98352 
LUALocationPoints[83][5] = 81.392197 
LUALocationPoints[83][6] = -371.525879  

--Point 84: 
LUALocationPoints[84][1] = 0.000000 
LUALocationPoints[84][2] = 0.000000
LUALocationPoints[84][3] = 0.000000 
LUALocationPoints[84][4] = 307.19604 
LUALocationPoints[84][5] = 80.614647 
LUALocationPoints[84][6] = -448.692963  

--Point 85: 
LUALocationPoints[85][1] = 0.000000 
LUALocationPoints[85][2] = 0.000000
LUALocationPoints[85][3] = 0.000000 
LUALocationPoints[85][4] = 276.40155 
LUALocationPoints[85][5] = 85.353790 
LUALocationPoints[85][6] = -409.539185  

--Point 86: 
LUALocationPoints[86][1] = 0.000000 
LUALocationPoints[86][2] = 0.000000
LUALocationPoints[86][3] = 0.000000 
LUALocationPoints[86][4] = 251.48703 
LUALocationPoints[86][5] = 64.380066 
LUALocationPoints[86][6] = -386.189636  

--Point 87: 
LUALocationPoints[87][1] = 5.000005 
LUALocationPoints[87][2] = 4.000004
LUALocationPoints[87][3] = 3.000003 
LUALocationPoints[87][4] = 212.80773 
LUALocationPoints[87][5] = 68.379745 
LUALocationPoints[87][6] = -390.396301  



--Testing Purposes: 'Draw 'ghosts' of object' at all keyframes
--print("Deploying Test Markers")
--numba = 1
--while numba <= NumPoints do
--ObjectName = "Ghost"..numba
--CreateEntity("bes2_bldg_large_tower", CreateMatrix(0,LUALocationPoints[numba][1], LUALocationPoints[numba][2], LUALocationPoints[numba][3], LUALocationPoints[numba][4], LUALocationPoints[numba][5], LUALocationPoints[numba][6], GetEntityMatrix("ZeroPoint")), ObjectName)
--end
--print("Markers Deployed")
--rate = 0.001
SpeedFactor = 0.8
rate = SpeedFactor
a = rate
Keyframe = 1
NextKeyframe = 2
NumPoints = 87
AnimLap = 1
function MatrixTween(Matrix1, Matrix2) --TO DO: when objects matrix equals matrix 2, set matrix 2 as matrix one, get a new matrix 2
MatTwResult = {}
MatTwResult[1] = (Matrix2[1] - Matrix1[1])*a
MatTwResult[2] = (Matrix2[2] - Matrix1[2])*a
MatTwResult[3] = (Matrix2[3] - Matrix1[3])*a
MatTwResult[4] = (Matrix2[4] - Matrix1[4])*a
MatTwResult[5] = (Matrix2[5] - Matrix1[5])*a
MatTwResult[6] = (Matrix2[6] - Matrix1[6])*a
print(" ")
print("Matrix Subtraction Result")
print(" "..MatTwResult[1].." "..MatTwResult[2].." "..MatTwResult[3].." "..MatTwResult[4].." "..MatTwResult[5].." "..MatTwResult[6].." ")
print(" ")

end   

function MatrixDistanceSpeed(Matrix1, Matrix2)
--animation speed, determine distance between points (points are basically position vectors)
Distance = ((Matrix2[4] - Matrix1[4])^2 + (Matrix2[5] - Matrix1[5])^2 + (Matrix2[6] - Matrix1[6])^2)^0.5
print("Distance: "..Distance)
--Speed = Distance/Time
--TravelTime = Speed/Distance  Time is in 60th of seconds, to mark value of A*100? a is in effect frames per node to node jump or well its inverse or something
a = SpeedFactor/Distance
rate = a 
end



CreateTimer("FrameRate")
SetTimerValue("FrameRate", 0.016666666666666667)
--SetTimerValue("FrameRate", 0.5)


--StartTimer("FrameRate")
OnTimerElapse(
function(timer)
--SetTimerValue("FrameRate", 0.5)
SetTimerValue("FrameRate", 0.016666666666666667)
	if a <= 1 then
	print("a is <1")
	a = a + rate -- initial value and this value are equal (0.001) and the smaller they are, the smoother the animation and more tweens
	else
	print("a is 1 or bigger")

   
		if NextKeyframe == NumPoints then
		NextKeyframe = 42
		print("After NextKeyframe 42"..AnimLap)
		elseif NextKeyframe == 61 and AnimLap == 1 then
		Nextkeyframe = 8
		else
		NextKeyframe = NextKeyframe + 1 --(should also = KeyFrame + 1)
		end
   
		if Keyframe == NumPoints then
		Keyframe = 42
		AnimLap = AnimLap * -1 
		print("After Keyframe 42"..AnimLap)
		elseif Keyframe == 61 and AnimLap == 1 then 
		Keyframe = 8
		else
		Keyframe = Keyframe + 1
		end 
			
	
   print("Moved to next keyframe. Keyframe = "..Keyframe..", nextkeyframe = "..NextKeyframe..".")
   Origin = nil
   Origin = CreateMatrix(0,LUALocationPoints[Keyframe][1], LUALocationPoints[Keyframe][2], LUALocationPoints[Keyframe][3], LUALocationPoints[Keyframe][4], (LUALocationPoints[Keyframe][5]), LUALocationPoints[Keyframe][6],  GetEntityMatrix("ZeroPoint"))
   
   print("Origin Set")
   a = 0
   MatrixDistanceSpeed(LUALocationPoints[Keyframe], LUALocationPoints[NextKeyframe])
      --if Keyframe == 2 then
      --rate = 0.001      
      --end
   end
StartTimer("FrameRate")
--Calculate AI tween positions and move
MatrixTween(LUALocationPoints[Keyframe],LUALocationPoints[NextKeyframe])
SetEntityMatrix("GiantChessPiece", CreateMatrix(0,MatTwResult[1], MatTwResult[2], MatTwResult[3], MatTwResult[4], MatTwResult[5], MatTwResult[6], Origin)) -- Will need one of these sets of lines (setentitymatrix and MatrixTween) per AI, currently set to player vehicle as test
   MatTwResult = nil   
   
end,
"FrameRate"
)   
One thing remains and I will have a good base system, then I can work on supporting multiple entities at once. I need to make the cornering look natural with object rotation, which probably just involves opening Zeroeditor and rotating the path points to match the course.

EDIT
BRB, learning about splines and trying to remember high school math classes.
I want to see if I can make an object follow a ZE path (on their default Hermite setting) not just travel linearly between points. So I can adjust this to make more robust animation code and learn stuff...
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by RepSharpshooter »

I gotta say, this is brilliant work!
Ace_Azzameen_5 wrote:BRB, learning about splines and trying to remember high school math classes.
I want to see if I can make an object follow a ZE path (on their default Hermite setting) not just travel linearly between points. So I can adjust this to make more robust animation code and learn stuff...
That'd be the next step, I've always wanted to learn about splines, bezier curves, etc, but never had the time or reason to. I suppose you could define a parametric curve in 3-space, and run the AI along it. Although you would need to do a arc length parametrization in order for the guy to run along at the same speed everywhere.

Good luck with this! I've taken Calc 3 so let me know if you need any help in this area (curves in 3 dimensions, etc).
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

Well, I found a website that explained it as such, however it makes assumptions about precise meanings of things etc, and I wrote this code

Code: Select all

T1 = {}
T2 = {}
function HermiteTween(P1, P2, protoT1, protoT2)

T1[4] = P1[4] - protoT1[4]
T1[5] = P1[5] - protoT1[5]
T1[6] = P1[6] - protoT1[6]

T2[4] = P1[4] - protoT2[4]
T2[5] = P1[5] - protoT2[5]
T2[6] = P1[6] - protoT2[6]

h1X =  (2*P1[4])^3 - (3*P1[4])^2 + (1*P1[4])          
h2X = (-2*P2[4])^3 + (3*P2[4])^2         
h3X =   T1[4]^3 - (2*T1[4])^2 + T1[4]        
h4X =   T2[4]^3 -  T2[4]^2   

h1Y =  2*P1[5]^3 - 3*P1[5]^2 + 1*P1[5]          
h2Y = -2*P2[5]^3 + 3*P2[5]^2         
h3Y =   T1[5]^3 - 2*T1[5]^2 + T1[5]        
h4Y =   T2[5]^3 -  T2[5]^2   

h1Z =  2*P1[6]^3 - 3*P1[6]^2 + 1*P1[6]          
h2Z = -2*P2[6]^3 + 3*P2[6]^2         
h3Z =   T1[6]^3 - 2*T1[6]^2 + T1[6]        
h4Z =   T2[6]^3 -  T2[6]^2   

HermiteVectorX = h1X*P1[4] + h2X*P2[4] + h3X*T1[4] + h4X*T2[4]
HermiteVectorY = h1Y*P1[5] + h2Y*P2[5] + h3Y*T1[5] + h4Y*T2[5]
HermiteVectorZ = h1Z*P1[6] + h2Z*P2[6] + h3Z*T1[6] + h4Z*T2[6]

end
which spat out numbers like this for the first point: Hermite Point-108983549952, 9.9999609287638e-013, -6505042944, compared to the linear code's number 14.033395767212 -1.5000000530563e-007 , 1.2418533563614.

For the first run through of the function,
P1 is
--Point 1:
LUALocationPoints[1][1] = 0.000000
LUALocationPoints[1][2] = 0.000000
LUALocationPoints[1][3] = 0.000000
LUALocationPoints[1][4] = 283.022247
LUALocationPoints[1][5] = 0.000001
LUALocationPoints[1][6] = 457.61010

P2 is
--Point 2:
LUALocationPoints[2][1] = 0.000000
LUALocationPoints[2][2] = 0.000000
LUALocationPoints[2][3] = 0.000000
LUALocationPoints[2][4] = 376.578217
LUALocationPoints[2][5] = 0.000000
LUALocationPoints[2][6] = 465.88913

ProtoT1 (tangent) is
Point 0 (= P1, so there is no affect?)
LUALocationPoints[1][1] = 0.000000
LUALocationPoints[1][2] = 0.000000
LUALocationPoints[1][3] = 0.000000
LUALocationPoints[1][4] = 283.022247
LUALocationPoints[1][5] = 0.000001
LUALocationPoints[1][6] = 457.61010

and ProtoT2 is

--Point 3:
LUALocationPoints[3][1] = 0.000000
LUALocationPoints[3][2] = 0.000000
LUALocationPoints[3][3] = 0.000000
LUALocationPoints[3][4] = 413.593018
LUALocationPoints[3][5] = 0.000000
LUALocationPoints[3][6] = 449.83267
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by RepSharpshooter »

Ace_Azzameen_5 wrote:which spat out numbers like this for the first point: Hermite Point-108983549952, 9.9999609287638e-013, -6505042944, compared to the linear code's number 14.033395767212 -1.5000000530563e-007 , 1.2418533563614.
Aren't those too far off? 108 billion? Even a nonlinear interpolation should be within the ballpark of the linear, not within the next solar system.
Cardinal Splines Tangent Definition wrote:Ti = a * ( Pi+1 - Pi-1 )
I'm assuming these are tangent definitions wrote: T1[4] = P1[4] - protoT1[4]
T1[5] = P1[5] - protoT1[5]
T1[6] = P1[6] - protoT1[6]

T2[4] = P1[4] - protoT2[4]
T2[5] = P1[5] - protoT2[5]
T2[6] = P1[6] - protoT2[6]
Just checking the above formula, each should be:
T1 = Point2 - Point0
T2 = Point3 - Point1

If I understand correctly
ProtoT1 = point0
P1 = point1
P2 = point2
protoT2 = point3

So:

T1 = P2 - ProtoT1
T2 = protoT2 - P1

Hidden/Spoiler:
All this stuff can be expessed with some vector and matrix algebra. I think the matrix-form is much easier to understand.

Vector S: The interpolation-point and it's powers up to 3:
Vector C: The parameters of our hermite curve:
Matrix h: The matrix form of the 4 hermite polynomials:


[code] | s^3 | | P1 | | 2 -2 1 1 |
S = | s^2 | C = | P2 | h = | -3 3 -2 -1 |
| s^1 | | T1 | | 0 0 1 0 |
| 1 | | T2 | | 1 0 0 0 |[/code]
To calculate a point on the curve you build the Vector S, multiply it with the matrix h and then multiply with C.
P = S * h * C
h1X = (2*P1[4])^3 - (3*P1[4])^2 + (1*P1[4])
h2X = (-2*P2[4])^3 + (3*P2[4])^2
h3X = T1[4]^3 - (2*T1[4])^2 + T1[4]
h4X = T2[4]^3 - T2[4]^2
According to the site, the basis functions should all be calculated based on the interpolation parameter S. It seems here you flip flop between using P and T? Where is your parameter for the interpolation point?

I can't really say much more because I'm not entirely sure of what you're doing or what the hermites are doing. But hopefully you get this working because it'd be really cool.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

XD
You I know, right, the numbers are way off.
Yeah it said something about vector s. It says "build" vector S. That's not exactly mathematical language and I have no idea where S is supposed to come from.

Maybe you could help by doing what the page says, for a single 2d point (or 3d with z = 0) without worrying about those matrices/tables (blah[5]) and then maybe I could adapt it.

So, you're telling me what the website says it 'should be' or are you using exterior knowledge? Just don't trust anything I do (higher-math) mathematically to be correct.
I think that if I ever want programming to be more than a hobby I need to take a few math courses. :)
I'm not so great at math, that is to say, in my education, math was incredibly easy until the last few years of high school when I tried to learn/they taught too much too quickly without enough of my time spent studying...

*EDIT* When I was trying to establish the tangents, I looked at ZE and though that they might actually be the direct line from the previous point to the current and the second current point to the one after that. (maybe that's what you said) Note: If you and I get this pegged down and produce a successful animation, but it doesn't look right, maybe it will be because Pandemic's hermite is a bit different.
RepSharpshooter
Gametoast Staff
Gametoast Staff
Posts: 1351
Joined: Tue Jul 10, 2007 4:10 pm

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by RepSharpshooter »

Ace_Azzameen_5 wrote:So, you're telling me what the website says it 'should be' or are you using exterior knowledge?
I was just going off of the what the website said. Although the site uses concepts that I do already know, such as vectors, matrix multiplication, etc.
Ace_Azzameen_5 wrote:Maybe you could help by doing what the page says, for a single 2d point (or 3d with z = 0) without worrying about those matrices/tables (blah[5]) and then maybe I could adapt it.
I'm interested in the subject, so I might be able to write a C++ program to generate a hermite curve. I've recently found some sourcecode to easily write bitmaps, so I can make a graphical print out.

Have you made any progress since then?
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

No, my interest has waned for now and I have real life things to take care of as well. I'll probably get around to it.
If you make your C program that would make a nice guideline for me to write LUA. You could also web-search for a pre-existing open source Hermite, I might too.
Jaspo
Command Sergeant Major
Command Sergeant Major
Posts: 282
Joined: Sun Mar 01, 2009 4:34 am
Projects :: AotC DoW+++Boonta Eve Classic
Games I'm Playing :: WoT MBWBVC Robocraft
xbox live or psn: No gamertag set
Contact:

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Jaspo »

As you may or may not know, I'm working on the Boonta Eve Classic (podracing). I think that aside from varying the speed of the ai, pretty much everything can be done with basic spline following code in the vehicle's odf file...of course, splines only work with flyers, not sure if that's a problem for you. But anyway, I think I learned all I needed to know about spline following in the basic modtools documentation- there's a property for disabling evasive manuvers, and for various other useful things to keep the racers from crashing into things that are near the spline. My great theory that I still have to put to the test is creating and destroying cps to serve as checkpoints along the track.
Also, to get realistic flight, I set the minflyheight to I think 8 and max to 15 or 20 or something...only problem is that it easily triggers the leaving map message, which I relocalized to say "outside repulsorlift parameters", but is there a way to disable it altogether? Along with the death timer? That would be very nifty.
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Anakin »

i don't understand a word form all this with lua :runaway:

a question howmany percents of the map are finished??

and is this a fight or a race or both??
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

. . .
115%

Mostly did this a fun project. The further work I do, to get hermite splines, will also produce a better way to animate (which you can do to player vehicles.)
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Anakin »

115% finished?? :shock:
how did this work??
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Ace_Azzameen_5 »

I was being sarcastic. Don't demand progress reports its against the forum rules I think. I have no idea how to quantify how much work has been done vs how much has to be done...


Oh and by the way, this could be better than splines. Can splines do random deviations and paths?

That's the other thing I've been working on is support for multiple object tracking and animating.
Still, I've sort have phased out of work on this do to life, but I might crack it open sooner or later.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: WIP: Race Mode: "AI" (More LUA Animation)

Post by Maveritchell »

Ace_Azzameen_5 wrote:Oh and by the way, this could be better than splines. Can splines do random deviations and paths?
Splines are paths, you can make them very tight or very loose, by default flyer splines are pretty loose. You can set weights to branched paths, so if you wanted a strictly random split you can just do even weights.
Post Reply