Anyway LUA can extend the space between joints. For example, normally left elbow is like 1mm from left shoulder. Anyway to make that 1 metre or something?
set_joint_position(integer player_index, integer joint_index, number x, number y, number z) -- Experimental
- Args: player_index (0 for RED, 1 for BLUE), joint_index (from JOINTS.<blah>)
X:
wtfX = fX - (((400 + (2*fY*wtfY) + (2*fZ*wtfZ) - (fY^2) - (wtfY^2) - (fZ^2) - (wtfZ^2))^.5)*sign1)
Y:
wtfY = (((400 + (2*fX*wtfX) + (2*fZ*wtfZ) - (fX^2) - (wtfX^2) - (fZ^2) - (wtfZ^2))^.5)*sign1) + fY
Z:
wtfZ = (((400 + (2*fY*wtfY) + (2*fX*wtfX) - (fY^2) - (wtfY^2) - (fX^2) - (wtfX^2))^.5)*sign1) + fZ
sign1 is plus or minus 1 fX,fY,fZ = get_joint_pos(0,6)
eX,eY,eZ = get_joint_pos(0,10)
aimX = fX-eX
aimY = fY-eY
aimZ = eZ-eZ
aimX = aimX * -30
aimY = aimY * -30
aimZ = aimZ * -30
drawLine({x=fX, y=fY, z=fZ}, {x=aimX, y=aimY, z=aimZ})
?
local function keydown(key)
if(key == blah) then
if(drawline == 1) then drawline = 0 else drawline = 1 end
end
Then just doif(drawline ==1) then drawLine({x=fX, y=fY, z=fZ}, {x=aimX, y=aimY, z=aimZ}) end
--Original Credits
--Cobbled together by TrueBoVinE
--Thank you to Suomynona, SSJokker, and Newbluck for making the original scripts
--
-- NewbLuck's useful function...
--New Credits
--Thanks to all the above and my math teacher for finding a formula
--Edited by Nuyashaki
function get_distance(x1,y1,z1,x2,y2,z2)
local dist = math.abs( math.sqrt( (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 ) )
return dist
end
function explode(player, body, force, radius)
chestpos = get_body_info(player,body).pos
player1 = player
xvec = 0
yvec = 0
zvec = 0
if(player1 == 1) then
player2 = 0
else
player2 = 1
end
for b=0,20 do
if (b ~= body) then
pos = get_body_info(player1,b).pos
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,pos.x,pos.y,pos.z)
if(dist < radius) then
xforce = ((pos.x - chestpos.x) * (1 / dist)) * force
yforce = ((pos.y - chestpos.y) * (1 / dist)) * force
zforce = ((pos.z - chestpos.z) * (1 / dist)) * force
set_body_force(player1,b,xforce,yforce,zforce)
xvec = xvec - xforce
yvec = yvec - yforce
zvec = zvec - zforce
end
end
end
for b=0,20 do
pos = get_body_info(player2,b).pos
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,pos.x,pos.y,pos.z)
if(dist < radius) then
xforce = ((pos.x - chestpos.x) * (1 / dist)) * force
yforce = ((pos.y - chestpos.y) * (1 / dist)) * force
zforce = ((pos.z - chestpos.z) * (1 / dist)) * force
set_body_force(player2,b,xforce,yforce,zforce)
xvec = xvec - xforce
yvec = yvec - yforce
zvec = zvec - zforce
end
end
for p=0,1 do
for j=0,19 do
x,y,z = get_joint_pos(p,j)
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,x,y,z)
if(dist < (radius / 3)) then
rnd = math.random(0,3)
if(rnd > 0) and (rnd < 3) then
fracture_joint(p,j)
elseif(rnd == 3) then
dismember_joint(p,j)
end
end
if(dist < (radius / 9)) then
dismember_joint(p,j)
end
end
end
set_body_force(player,body,xvec / force,yvec / force,zvec / force)
end
function onkey(key)
if(key == string.byte("y")) then
exploded = 1
explode(0,11,6,10)
end
end
hackfoo = 10 --hacky way to fix
hackbar = {} -- having to wait one frame
shot3 = {11}
shot = {10} -- table containing joints connected to the bodyparts to be shot for easy modding
shot2 = {6} -- table containing joints that precede the shot parts for aim calculation
keys = {"q"} -- table containing keys to bind to the bodyparts that are shot
shot['number'] = 3
function init()
add_hook("key_down","shotgun",keydown)
end
function keydown(key)
--run_cmd("echo key pressed: "..key)
--run_cmd("echo key should be pressed: "..keys[1])
for i = 1, shot['number'] do
if ((key == string.byte(keys[i]))) then
--run_cmd("echo should be fired")
bodypart_shoot(shot[i],shot2[i], shot3[i]);
end
end
end
function bodypart_shoot(body,body2, body3)
--run_cmd("echo starting firing")
posX,posY,posZ = get_joint_pos(0,body)
posX2,posY2,posZ2 = get_joint_pos(0,body2)
aimX = posX-posX2
aimY = posY-posY2
aimZ = posZ-posZ2
aimX = aimX * 100
aimY = aimY * 100
aimZ = aimZ * 100
dismember_joint(0,body)
hackfoo = body3
hackbar.x = aimX
hackbar.y = aimY
hackbar.z = aimZ
frame = 0
add_hook("enter_frame","shotgun",shoot)
end
function shoot()
if frame == 1 then
set_body_force(0,hackfoo,hackbar.x,hackbar.y,hackbar.z)
--run_cmd("echo fired")
remove_hook("enter_frame","shotgun")
end
if frame == 2 then
frame = 1
end
if frame == 0 then
frame = 2
end
end
function drawLine(p1, p2, step, thickness)
if(step == nil) then step = .2 end
if(thickness == nil) then thickness = 3 end
local dx, dy, dz = p2.x - p1.x, p2.y - p1.y, p2.z - p1.z
local mag = math.sqrt(dx*dx + dy*dy + dz*dz)
dx, dy, dz = dx/mag, dy/mag, dz/mag
for i=0, mag/step do
local x, y = get_screen_pos(p1.x + dx*step*i, p1.y + dy*step*i, p1.z + dz*step*i)
local setName = "drawLine"..x..","..y
add_hook("draw2d", setName,
function()
draw_quad(x, y, thickness, thickness)
remove_hook("draw2d", setName)
end)
end
end
function drawSomeLines()
fX,fY,fZ = get_joint_pos(0,6)
eX,eY,eZ = get_joint_pos(0,10)
aAa = fX * 8 - eX * 8
bBb = fY * 8 - eY * 8
cCc = fZ * 8 - eZ * 8
aimA = eX - aAa
aimB = eY - bBb
aimC = eZ - cCc
drawLine({x=fX, y=fY, z=fZ}, {x=aimA, y=aimB, z=aimC})
end
add_hook("draw3d", "asdf", drawSomeLines)
init()
add_hook("key_down","grenade",onkey)
add_hook("new_game","grenade",init)
I made the line dotted so that it woulden't obstruct the view as much. It is pretty accurate before you fire, after that, it may lag.--Original Credits
--Cobbled together by TrueBoVinE
--Thank you to Suomynona, SSJokker, and Newbluck for making the original scripts
--
-- NewbLuck's useful function...
--New Credits
--Thanks to all the above and my math teacher for finding a formula
--Edited by Nuyashaki
adrawline = 0
function get_distance(x1,y1,z1,x2,y2,z2)
local dist = math.abs( math.sqrt( (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 ) )
return dist
end
function explode(player, body, force, radius)
chestpos = get_body_info(player,body).pos
player1 = player
xvec = 0
yvec = 0
zvec = 0
if(player1 == 1) then
player2 = 0
else
player2 = 1
end
for b=0,20 do
if (b ~= body) then
pos = get_body_info(player1,b).pos
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,pos.x,pos.y,pos.z)
if(dist < radius) then
xforce = ((pos.x - chestpos.x) * (1 / dist)) * force
yforce = ((pos.y - chestpos.y) * (1 / dist)) * force
zforce = ((pos.z - chestpos.z) * (1 / dist)) * force
set_body_force(player1,b,xforce,yforce,zforce)
xvec = xvec - xforce
yvec = yvec - yforce
zvec = zvec - zforce
end
end
end
for b=0,20 do
pos = get_body_info(player2,b).pos
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,pos.x,pos.y,pos.z)
if(dist < radius) then
xforce = ((pos.x - chestpos.x) * (1 / dist)) * force
yforce = ((pos.y - chestpos.y) * (1 / dist)) * force
zforce = ((pos.z - chestpos.z) * (1 / dist)) * force
set_body_force(player2,b,xforce,yforce,zforce)
xvec = xvec - xforce
yvec = yvec - yforce
zvec = zvec - zforce
end
end
for p=0,1 do
for j=0,19 do
x,y,z = get_joint_pos(p,j)
dist = get_distance(chestpos.x,chestpos.y,chestpos.z,x,y,z)
if(dist < (radius / 3)) then
rnd = math.random(0,3)
if(rnd > 0) and (rnd < 3) then
fracture_joint(p,j)
elseif(rnd == 3) then
dismember_joint(p,j)
end
end
if(dist < (radius / 9)) then
dismember_joint(p,j)
end
end
end
set_body_force(player,body,xvec / force,yvec / force,zvec / force)
end
function onkey(key)
if(key == string.byte("y")) then
exploded = 1
explode(0,11,6,10)
end
if(key == string.byte("o")) then
if(adrawline == 1) then adrawline = 0 else adrawline = 1 end
end
end
hackfoo = 10 --hacky way to fix
hackbar = {} -- having to wait one frame
shot3 = {11}
shot = {10} -- table containing joints connected to the bodyparts to be shot for easy modding
shot2 = {6} -- table containing joints that precede the shot parts for aim calculation
keys = {"q"} -- table containing keys to bind to the bodyparts that are shot
shot['number'] = 3
function init()
add_hook("key_down","shotgun",keydown)
end
function keydown(key)
--run_cmd("echo key pressed: "..key)
--run_cmd("echo key should be pressed: "..keys[1])
for i = 1, shot['number'] do
if ((key == string.byte(keys[i]))) then
--run_cmd("echo should be fired")
bodypart_shoot(shot[i],shot2[i], shot3[i]);
end
end
end
function bodypart_shoot(body,body2, body3)
--run_cmd("echo starting firing")
posX,posY,posZ = get_joint_pos(0,body)
posX2,posY2,posZ2 = get_joint_pos(0,body2)
adrawline = 0
aimX = posX-posX2
aimY = posY-posY2
aimZ = posZ-posZ2
aimX = aimX * 100
aimY = aimY * 100
aimZ = aimZ * 100
dismember_joint(0,body)
hackfoo = body3
hackbar.x = aimX
hackbar.y = aimY
hackbar.z = aimZ
frame = 0
add_hook("enter_frame","shotgun",shoot)
end
function shoot()
if frame == 1 then
set_body_force(0,hackfoo,hackbar.x,hackbar.y,hackbar.z)
--run_cmd("echo fired")
remove_hook("enter_frame","shotgun")
end
if frame == 2 then
frame = 1
end
if frame == 0 then
frame = 2
end
end
function drawLine(p1, p2, step, thickness)
if(step == nil) then step = .2 end
if(thickness == nil) then thickness = 3 end
local dx, dy, dz = p2.x - p1.x, p2.y - p1.y, p2.z - p1.z
local mag = math.sqrt(dx*dx + dy*dy + dz*dz)
dx, dy, dz = dx/mag, dy/mag, dz/mag
for i=0, mag/step do
local x, y = get_screen_pos(p1.x + dx*step*i, p1.y + dy*step*i, p1.z + dz*step*i)
local setName = "drawLine"..x..","..y
add_hook("draw2d", setName,
function()
set_color(1,0,0,1)
draw_quad(x, y, thickness, thickness)
remove_hook("draw2d", setName)
end)
end
end
function drawSomeLines()
fX,fY,fZ = get_joint_pos(0,6)
eX,eY,eZ = get_joint_pos(0,10)
aAa = fX * 30 - eX * 30
bBb = fY * 30 - eY * 30
cCc = fZ * 30 - eZ * 30
aimA = eX - aAa
aimB = eY - bBb
aimC = eZ - cCc
if(adrawline == 1) then drawLine({x=fX, y=fY, z=fZ}, {x=aimA, y=aimB, z=aimC}) end
end
add_hook("draw3d", "asdf", drawSomeLines)
init()
add_hook("key_down","grenade",onkey)
add_hook("new_game","grenade",init)
function draw_bezier(A,v1,v2,D,thickness,quality,r,g,b,a)
local B = { }
local C = { }
B.x = A.x + v1.x
B.y = A.y + v1.y
C.x = D.x + v2.x
C.y = D.y + v2.y
local dx, dy = D.x - A.x, D.y - A.y
local mag = math.sqrt(dx*dx + dy*dy)
for i=0, mag/0.01 do
a = i
b = 1 - i
x = A.x + dx*0.01*i
y = ((A.y*b)^2) + (3*B.y*b^2*a) + ((3*C.y)*b*a^2) + (D.y*a^3)
set_color(r,g,b,a)
draw_disk(x, y, 0, thickness/2, quality, 2, 0, 360, 0)
end
end
local function draw2d()
draw_bezier({x = 150, y = 170},{x = 100, y = 200},{x = 200, y = 400},{x = 180, y = 250},3,80,1,0,0,1)
end
add_hook("draw2d","moo",draw2d)
This code may be completely wrong as i suck at maths :3