G'day fellas
Im working on a acf weapon. Im making a Designator Relay and reciever Via wire radio control. No further comment is needed but you can imagine what it will be used for
The trouble is I Dont have a snowflakes chance in hell at correctly mathing the angle formula to aim the gun precisely at the correct trajectory taken into effect the guns shell velocity, weight, distance, elevation and any other factors that will effect the guns necessary trajectory.
The code is below if you want to try and finish it. While I just try my tactic of senseless trial and error.
There is a code for a holo artillery trajectory display by the gmodism. but it doesn't not actually adjust guns angle
I will be certain to give you the majority of credits if you get this to accurately-enough work and any other codes or persons that assisted.
Bonus points go to precision and lag/Ops-friendly.
NOTE: It does not matter whether the angle output is done in Angle(degrees) or the gimbal(Z) calculation, i can attempt to convert it back and fourth
This code needs to be for all gun calibres hence why i asked for the shell weight to be taken into mind.
Cheers
This is the code
Code:
[CODE]@name ACF Auto trajector
@inputs Gun:entity [GPS,Gun1,Gimbal,Radio]:wirelink Fire On
@outputs DistanceX DistanceY DistanceZ Distance OUT
@persist Shellspeed ShellWeight CaliberS:string Caliber
@persist Online RequestFire PosX PosY PosZ Channel X Y Z
@persist ShellPhys Angle
runOnTick(1)
if (dupefinished())
{reset()}
"Connect to the radios channel"
Channel=155
"Set correct Coordinates to Radio Values"
X=Radio["1",normal]
Y=Radio["2",normal]
Z=Radio["3",normal]
Online=Radio["4",normal]
RequestFire=Radio["5",normal]
"X=1(Radio)"
"Y=2(Radio)"
"Z=3(Radio)"
"Online Relay=4(Radio)"
"Fire request=5(Radio)"
"--------------Setup Finished-----------------------"
Radio["Channel",normal]=Channel
PosX=GPS["X",normal]
PosY=GPS["Y",normal]
PosZ=GPS["Z",normal]
if (first())
{
Shellspeed = Gun1["Muzzle Velocity",normal]
ShellWeight = Gun1["Muzzle Weight",normal]
CaliberS = Gun:acfNameShort():matchFirst("^%d+")
Caliber = CaliberS:toNumber()
print("Caliber:" + Caliber + " Shellspeed:" + Shellspeed)
}
if (On& Online)
{
Gimbal["On",normal]=1
Gun1["Fire",normal]=RequestFire|Fire
Gimbal["X",normal]=X
Gimbal["Y",normal]=Y
DistanceY=abs(PosX-X)
DistanceZ=abs(PosZ-Z)
DistanceX=abs(PosY-Y)
"Trial and error take at calculating angle"
"Setup Variables"
Distance=sqrt((DistanceY*DistanceY)+(DistanceZ*DistanceZ)+(DistanceX*DistanceX))
"---------This is where im lost---------"
#"This is just to set distance to metres"
Dist=Distance/75
ShellPhys=(Shellspeed+(ShellWeight"*?"))"*?"
Angle=Z"The angle formula"
Gimbal["Z",normal]=Angle
}
[/CODE]
Sorry, you need to Log In to post a reply to this thread.