Very nice script!
I also like Fatesights idea for DQ detection
It would be nice if it was possible to set an opener for Uke and consider own dismemberments and fractures in the fitness ranking. That would turn this script into a counter-move finder! Yeah, that would be cool!
PS: some functions I wrote that may be helpfull for you too:
matrix = {
E = function(d)
d = d or 4
local m = {}
for i=1,d do
m[i]={}
for j=1,d do
if i==j then
m[i][j]=1
else
m[i][j]=0
end
end
end
return m
end,
fromR = function(rot)
local m = {{},{},{},{}}
m[1][1]=rot.r0
m[1][2]=rot.r1
m[1][3]=rot.r2
m[1][4]=rot.r3
m[2][1]=rot.r4
m[2][2]=rot.r5
m[2][3]=rot.r6
m[2][4]=rot.r7
m[3][1]=rot.r8
m[3][2]=rot.r9
m[3][3]=rot.r10
m[3][4]=rot.r11
m[4][1]=rot.r12
m[4][2]=rot.r13
m[4][3]=rot.r14
m[4][4]=rot.r15
return m
end,
dup = function(n)
local m = {}
for i=1,#n do
m[i] = {}
for j=1,#n[1] do
m[i][j]=n[i][j] or 0
end
end
return m
end,
trans = function(n)
local m = {}
for i=1,#n do
m[i] = {}
for j=1,#n[1] do
m[i][j]=n[j][i]
end
end
return m
end,
add = function(m,n)
local a = {}
for i=1,#n do
a[i] = {}
for j=1,#n[1] do
a[i][j] = m[i][j]+n[i][j]
end
end
return a
end,
smul = function(m,n)
local a = {}
for i=1,#m do
a[i] = {}
for j=1,#m[1] do
a[i][j] = m[i][j]*n
end
end
return a
end,
mmul = function(m,n)
local a = {}
for i=1,#n do
a[i] = {}
for j=1,#n[1] do
a[i][j] = m[i][1]*n[1][j] +m[i][2]*n[2][j] +m[i][3]*n[3][j] +m[i][4]*n[4][j]
end
end
return a
end,
inv = function(mat)
local m = matrix.dup(mat)
local e = matrix.E(#m)
local function chRow(r1,r2)
local t=0
for j=1,#m do
t=m[r1][j]
m[r1][j]=m[r2][j]
m[r2][j]=t
t=e[r1][j]
e[r1][j]=e[r2][j]
e[r2][j]=t
end
end
local function mulRow(r)
local f = m[r][r]
for j=1,#m do
m[r][j]=m[r][j]/f
e[r][j]=e[r][j]/f
end
end
local function calcRow(rT,rS)
local f = m[rT][rS]
for j=1,#m do
m[rT][j]=m[rT][j] - f*m[rS][j]
e[rT][j]=e[rT][j] - f*e[rS][j]
end
end
--==
for i=1,#m do
if m[i][i]==0 then
for j=i+1,#m do
if m[j][i]~=0 then
chRow(i,j)
break
end
end
end
mulRow(i)
for j=i+1,#m do
calcRow(j,i)
end
end
for i=1,#m-1 do
for j=i+1,#m do
calcRow(i,j)
end
end
return e
end,
}
local jc = {
NECK ={0,1},
CHEST ={1,2},
LUMBAR ={2,3},
ABS ={3,4},
R_PECS ={1,5},
R_SHOULDER ={5,6},
R_ELBOW ={6,7},
L_PECS ={1,8},
L_SHOULDER ={8,9},
L_ELBOW ={9,10},
R_WRIST ={7,11},
L_WRIST ={10,12},
R_GLUTE ={4,13},
L_GLUTE ={4,14},
R_HIP ={13,15},
L_HIP ={14,16},
R_KNEE ={15,18},
L_KNEE ={16,17},
R_ANKLE ={18,19},
L_ANKLE ={17,20},
}
local function get_stance(player)
if (player<0) then
return
end
local tbl = {}
for d,n in pairs(JOINTS) do
if not get_joint_dismember(player,n) then
local rb1 = matrix.fromR(get_body_info(player,jc[d][1]).rot)
local rb2 = matrix.fromR(get_body_info(player,jc[d][2]).rot)
local rd = matrix.mmul(matrix.inv(rb1),rb2)
tbl[d]=math.round(math.asin(rd[3][2])/math.pi*12)
+math.round(math.asin(rd[1][3])/math.pi*12)
+math.round(math.asin(rd[2][1])/math.pi*12)
end
end
return tbl
end
local function get_lobody(pl)
local lo = 100000
for i=0,10 do
local bi = get_body_info(pl,i)
lo = math.min(lo, bi.pos.z-bi.sides.z)
end
for i=13,18 do
local bi = get_body_info(pl,i)
lo = math.min(lo, bi.pos.z-bi.sides.z)
end
for i=0,17 do
local jx,jy,jz = get_joint_pos(pl,i)
lo = math.min(lo, jz-get_joint_radius(pl,i))
end
return lo
end
the matrix table contains functions for matrix calculations
get_stance(player) returns a table with the joint positions (the angle in 15А steps)
get_lobody(player) returns the height of the lowest bodypart, that can dq
(maybe the weighted diff of the 2 lobodys in the fitness ranking can lead to good results for no dq moves)