Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name RDC's Turret Lite V1.2
- @inputs Gun:entity Active Aimpos:vector ElevPos:array Gunlock LaseKey
- @persist Lase TableSlot Distance RTIncrements Rotation Inertia:angle Elevation Depression Yaw RotateSpeed GunAng:angle
- @outputs Latched Distance SElevation TableSlot
- @trigger
- #E2 was made to aim secondary guns like MGs on a tank and thus has no hud or cam links
- #Setup:
- #Link up Gun to the turret's main gun, Active to the the Pod Active,
- #Aimpos to the Came Controller Hitpos, Elevpos to the ballistic table array
- #Gunlock to the key that you want to lock your gun with along with setting up a weldlatch
- #To your baseplate and wiring that to the latch output to lock your gun in place.
- #THE WELD LATCH IS MANDATORY bc it reduces usage a lot and is just good to have, dont complain
- #If the turret doesn't work because you didn't setup a latch. Its also default on.
- #Setup Lasekey if you have Lase set to 1, this will adjust your range whenever you hit a key.
- #Notes: This gun accepts input from a ballistic calculator that does full drag computation
- #This e2 was released at irritation at certain tank e2s using 700 US, talking
- #to you EZ tank turret and Turret Hud Combo, use it over those due to optimization
- interval(100)
- if(duped())
- {
- reset()
- }
- elseif (first()) {
- Lase=0 #Set to 1 if you want to press a key to lase a range, else auto range aquisition
- Elevation = 10 #Gun Elevation
- Depression = 90 #Gun Depression
- Yaw = 180 #Turret ability to rotate around, 180 is a complete circle
- Rotation = 500 #Turret rotation speed, be reasonable please
- #Unless you know what your doing dont edit below here
- Elevation*=-1
- Inertia = shiftL(ang(Gun:inertia()))
- RTIncrements=20*39.37
- function number interpolatearray(Array:array, Dist) {
- TableSlot=Dist/RTIncrements
- TableNum=floor(TableSlot)
- Rat=(Dist-floor(TableSlot))/RTIncrements
- Smaller=Array[TableNum,number]
- Larger=Array[TableNum+1,number]
- return Smaller+(Larger-Smaller)/Rat
- }
- RotateSpeed = Rotation/Gun:mass()*10
- }
- if (~Active) {
- Latched=1
- }
- if( Active ) {
- if(~Gunlock&Gunlock)
- {
- Latched=!Latched
- }
- if(!Latched)
- {
- # Distance=Gun:attachmentPos("muzzle"):setZ(0):distance(Aimpos:setZ(0))+(Aimpos:z()-Gun:attachmentPos("muzzle"):z())
- if(!Lase|~LaseKey&LaseKey)
- {
- Distance=Gun:attachmentPos("muzzle"):distance(Aimpos)
- SElevation = -elevation(vec(0),ang(0),vec(Distance,0,interpolatearray(ElevPos,Distance)))
- }
- GunAng =(Aimpos - Gun:pos()):toAngle()+ang(SElevation,0,0)
- Gun:applyAngForce((Gun:toLocal(entity():toWorld(clamp(entity():toLocal(Gun:toWorld(clamp(Gun:toLocal(GunAng),ang(-RotateSpeed),ang(RotateSpeed)))),ang(Elevation,-Yaw,-1),ang(Depression,Yaw,1)))) * 250 - Gun:angVel() * 30) * Inertia)
- }
- }
Add Comment
Please, Sign In to add comment