Guest User

ac130 En main.xml

a guest
Aug 16th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.37 KB | None | 0 0
  1. eairstrikeprojectileHandler = {
  2.     shellNum = 1,
  3.     shells = {},
  4.     defaultShell = {active=false}
  5. }
  6.  
  7. function init()
  8.     RegisterTool("eairstrike", "Enhanced Air Strike", "MOD/vox/eairstrike.vox")
  9.     SetBool("game.tool.eairstrike.enabled", true)
  10.     SetFloat("game.tool.eairstrike.ammo", 101)
  11.  
  12.     eaop = GetBool("savegame.mod.eaop")
  13.  
  14.     for i=1, 9999 do
  15.         eairstrikeprojectileHandler.shells[i] = deepcopy(eairstrikeprojectileHandler.defaultShell)
  16.     end
  17.    
  18.     if GetString("savegame.mod.controls.changetype") == "" then
  19.         SetString("savegame.mod.controls.changetype","V")
  20.     end
  21.     salvoSliderKey = GetString("savegame.mod.controls.salvoslider")
  22.    
  23.     if GetString("savegame.mod.controls.changeammo") == "" then
  24.         SetString("savegame.mod.controls.changeammo","C")
  25.     end
  26.     changeammoKey = GetString("savegame.mod.controls.changeammo")
  27.     changetypeKey = GetString("savegame.mod.controls.changetype")
  28.     changespreadKey = GetString("savegame.mod.controls.changespread")
  29.    
  30.     bullet_spread = 0
  31.    
  32.     flycamenabled = false
  33.     eairstrikeenabled = false
  34.     firing = false
  35.     radioactivated = false
  36.    
  37.     damage = 1
  38.     gravity = Vec(0, 0, 0)
  39.     velocity = 1.0
  40.     shotDelay = 0.01
  41.  
  42.     zoomlevel = 6
  43.     maxzoom = 12
  44.     minzoom = 0.5
  45.  
  46.     lightTimer = 0
  47.     equipTimer = 0
  48.  
  49.     selectedshell = 1
  50.     ammoselecter = {}
  51.     ammoselectermax = {}
  52.     ammoselectermax[1] = 2
  53.     ammoselectermax[2] = 1
  54.     ammoselectermax[3] = 1
  55.     ammoselectermax[4] = 1
  56.     ammoselectermax[5] = 1
  57.     ammoselectermax[6] = 1
  58.  
  59.     shoottimers = {}
  60.  
  61.     for i=1, 6 do
  62.         shoottimers[i] = 0
  63.         ammoselecter[i] = 1
  64.     end
  65.  
  66.     shellsprites = {}
  67.     shellsprites[1] = LoadSprite("MOD/img/25mm.png")
  68.     shellsprites[2] = LoadSprite("MOD/img/40mm.png")
  69.     shellsprites[3] = LoadSprite("MOD/img/105mm.png")
  70.     shellsprites[4] = LoadSprite("MOD/img/105mm.png")
  71.     shellsprites[5] = LoadSprite("MOD/img/pixel.png")
  72.     shellsprites[6] = LoadSprite("MOD/img/flame.png")
  73.  
  74.     gunsounds = {}
  75.     gunsounds[1] = LoadLoop("MOD/snd/gun1.ogg")
  76.     gunsounds[2] = LoadSound("MOD/snd/gun2.ogg")
  77.     gunsounds[3] = LoadSound("MOD/snd/gun3.ogg")
  78.     gunsounds[4] = LoadSound("MOD/snd/gun4.ogg")
  79.     gunsounds[5] = LoadSound("MOD/snd/gun5.ogg")
  80.     gunsounds[6] = LoadLoop("MOD/snd/gun6.ogg")
  81.     planesound = LoadLoop("MOD/snd/planeloop.ogg")
  82.  
  83.     explosionsounds = {}
  84.     explosionsounds[1] = LoadSound("explosion/s0.ogg")
  85.     explosionsounds[6] = LoadSound("explosion/s0.ogg")
  86.  
  87.     switchsound = LoadSound("MOD/snd/switch.ogg")
  88.     beepsound = LoadSound("MOD/snd/radiobeep.ogg")
  89.  
  90.     plane = {}
  91.     plane.pos = Vec(0, 0 ,0)
  92.     plane.rot = QuatRotateQuat(Quat(), QuatEuler(-90, -90, 0))
  93.  
  94.     plane.barrel = {}
  95.     plane.barrel.rot = Quat()
  96.  
  97.     plane.pos[2] = 100
  98.     plane.pos[1] = plane.pos[1] + 100
  99. end
  100.  
  101. function clamp(value, mi, ma)
  102.     if value < mi then value = mi end
  103.     if value > ma then value = ma end
  104.     return value
  105. end
  106.  
  107. function deepcopy(orig)
  108.     local orig_type = type(orig)
  109.     local copy
  110.     if orig_type == 'table' then
  111.         copy = {}
  112.         for orig_key, orig_value in next, orig, nil do
  113.             copy[deepcopy(orig_key)] = deepcopy(orig_value)
  114.         end
  115.         setmetatable(copy, deepcopy(getmetatable(orig)))
  116.     else
  117.         copy = orig
  118.     end
  119.     return copy
  120. end
  121.  
  122. function GetAimPos()
  123.     if bullet_spread ~= 0 then
  124.         angle = math.random() * 2 * math.pi
  125.         radius = math.random() * bullet_spread
  126.         spread_x = math.cos(angle) * radius
  127.         spread_y = math.sin(angle) * radius
  128.     else
  129.         spread_x = 0
  130.         spread_y = 0
  131.     end
  132.     local ct = GetCameraTransform()
  133.     local forwardPos = TransformToParentPoint(ct, Vec(spread_x, spread_y, -150))
  134.     local direction = VecSub(forwardPos, ct.pos)
  135.     local distance = VecLength(direction)
  136.     local direction = VecNormalize(direction)
  137.     local hit, hitDistance = QueryRaycast(ct.pos, direction, distance)
  138.     if hit then
  139.         forwardPos = TransformToParentPoint(ct, Vec(spread_x, spread_y, -hitDistance))
  140.         distance = hitDistance
  141.     end
  142.     return forwardPos, hit, distance
  143. end
  144.  
  145. function GetCamLookPos()
  146.     if bullet_spread ~= 0 then
  147.         angle = math.random() * 2 * math.pi
  148.         radius = math.random() * bullet_spread
  149.         spread_x = math.cos(angle) * radius
  150.         spread_y = math.sin(angle) * radius
  151.     else
  152.         spread_x = 0
  153.         spread_y = 0
  154.     end
  155.     local forwardPos = TransformToParentPoint(plane.barrel, Vec(spread_x, spread_y, -150))
  156.     local direction = VecSub(forwardPos, plane.barrel.pos)
  157.     local distance = VecLength(direction)
  158.     local direction = VecNormalize(direction)
  159.     local hit, hitDistance = QueryRaycast(plane.barrel.pos, direction, distance)
  160.     if hit then
  161.         forwardPos = TransformToParentPoint(plane.barrel, Vec(spread_x, spread_y, -hitDistance))
  162.         distance = hitDistance
  163.     end
  164.     return forwardPos, hit, distance
  165. end
  166.  
  167. function GetShootDistance()
  168.     local direction = VecSub(aimpos, plane.barrel.pos)
  169.     local distance = VecLength(direction)
  170.     local direction = VecNormalize(direction)
  171.     local hit, hitDistance = QueryRaycast(plane.barrel.pos, direction, distance)
  172.     if hit then
  173.         forwardPos = TransformToParentPoint(plane.barrel, Vec(0, 0, -hitDistance))
  174.         distance = hitDistance
  175.     end
  176.     return distance
  177. end
  178.  
  179. function FlyCam()
  180.     local mousewheel = InputValue("mousewheel")
  181.     if mousewheel ~= 0 and GetBool("game.input.locktool") == false then
  182.         zoomlevel = clamp(zoomlevel - mousewheel/2, minzoom, maxzoom)
  183.     end
  184.  
  185.     local mx, my, a, d = InputValue("mousedx"), InputValue("mousedy"), InputDown("A"), InputDown("D")
  186.  
  187.     local turn = 0
  188.     if a then turn = 1 elseif d then turn = -1 end
  189.  
  190.     local rotdiv = 200/zoomlevel
  191.     if planevox ~= 0 then rotdiv = rotdiv * 2 end
  192.     plane.barrel.rot = QuatRotateQuat(plane.barrel.rot, QuatEuler(-my/rotdiv, -mx/rotdiv, 0))
  193.     plane.barrel.rot = QuatRotateQuat(plane.barrel.rot, QuatEuler(0, 0, turn))
  194.     local newT = Transform(plane.barrel.pos, plane.barrel.rot)
  195.     SetCameraTransform(newT, zoomlevel*10)
  196.     SetPlayerTransform(GetPlayerTransform())
  197.     PlayLoop(planesound)
  198. end
  199.  
  200. function Shoot()
  201.     if shoottimers[selectedshell] > 0 then
  202.         return
  203.     end
  204.  
  205.     local distance = GetShootDistance()
  206.     local barrelEnd = TransformToParentPoint(plane.barrel, Vec(0, -1, -2))
  207.     local dir = VecSub(aimpos, barrelEnd)
  208.  
  209.     eairstrikeprojectileHandler.shells[eairstrikeprojectileHandler.shellNum] = deepcopy(eairstrikeprojectileHandler.defaultShell)
  210.     loadedShell = eairstrikeprojectileHandler.shells[eairstrikeprojectileHandler.shellNum]
  211.     loadedShell.active = true
  212.     loadedShell.type = type
  213.     loadedShell.pos = barrelEnd
  214.     loadedShell.cannonLoc = plane.barrel
  215.     loadedShell.type = selectedshell
  216.     loadedShell.ammo = ammoselecter[selectedshell]
  217.     loadedShell.predictedBulletVelocity = VecScale(dir, velocity)
  218.     eairstrikeprojectileHandler.shellNum = (eairstrikeprojectileHandler.shellNum%#eairstrikeprojectileHandler.shells) +1
  219.  
  220.     if not eaop then
  221.         --if selectedshell == 1 or selectedshell == 6 then
  222.         if selectedshell == 1 then
  223.             shoottimers[selectedshell] = shotDelay
  224.         elseif selectedshell == 2 or selectedshell == 3 or selectedshell == 4 then
  225.             shoottimers[selectedshell] = shotDelay * (selectedshell * 3.0)
  226.         elseif selectedshell == 5 then
  227.             shoottimers[selectedshell] = 0.25
  228.         elseif selectedshell == 6 then
  229.             shoottimers[selectedshell] = 0.02
  230.         else
  231.         end
  232.     end
  233.  
  234.     if selectedshell ~= 1 and selectedshell ~= 6 then
  235.     local p = GetPlayerPos()
  236.     if selectedshell == 3 then
  237.     PlaySound(gunsounds[selectedshell], plane.barrel.pos, 0.7)
  238.     PlaySound(gunsounds[selectedshell], p, 0.35)
  239.     else
  240.     PlaySound(gunsounds[selectedshell], plane.barrel.pos, 1)
  241.     PlaySound(gunsounds[selectedshell], p, 0.5)
  242.     end
  243.     else
  244.     end
  245.     lightTimer = 0.05
  246. end
  247.  
  248. function ProjectileOperations(projectile, dt)
  249.     local hit, dist, normal, shape = QueryRaycast(position, direction, 500)
  250.     projectile.predictedBulletVelocity = VecAdd(projectile.predictedBulletVelocity,(VecScale(gravity, dt)))
  251.     local point2 = VecAdd(projectile.pos,VecScale(projectile.predictedBulletVelocity,dt))
  252.     local hit, dist1 = QueryRaycast(projectile.pos, VecNormalize(VecSub(point2,projectile.pos)),VecLength(VecSub(point2,projectile.pos)))
  253.     if hit then
  254.         hitPos = VecAdd(projectile.pos, VecScale(VecNormalize(VecSub(point2,projectile.pos)),dist1))
  255.         projectile.active = false
  256.         if projectile.type == 1 then
  257.             if projectile.ammo == 1 then
  258.                 Explosion(hitPos, 0.5)
  259.                 MakeHole(hitPos, 1.25, 1.25, 1.25)
  260.                 SpawnFire(hitPos)
  261.                 SpawnParticle("smoke", hitPos, Vec(0, 1.0+math.random(1,10)*0.1, 0), 1.5, 1.5)
  262.                 PlaySound(explosionsounds[selectedshell], hitPos, 0.5)
  263.             elseif projectile.ammo == 2 then
  264.                 MakeHole(hitPos, 0.55, 0.55, 0.55)
  265.                 MakeHole(hitPos, 0.5, 0.5, 0.5)
  266.                 MakeHole(hitPos, 0.45, 0.45, 0.45)
  267.                 SpawnParticle("smoke", hitPos, Vec(0, 1.0+math.random(1,10)*0.1, 0), 1.5, 1.5)
  268.                 PlaySound(explosionsounds[selectedshell], hitPos, 0.5)
  269.             end
  270.         elseif projectile.type == 2 then
  271.             Explosion(hitPos, 1.5)
  272.             MakeHole(hitPos, 3.75, 3.75, 3.75)
  273.             SpawnFire(hitPos)
  274.         elseif projectile.type == 3 then
  275.             Explosion(hitPos, 4)
  276.             MakeHole(hitPos, 5, 5, 5)
  277.             SpawnFire(hitPos)
  278.         elseif projectile.type == 4 then
  279.             local intervalo4 = 360 / 9
  280.                 for degrees = 1, 360, intervalo4 do
  281.                 local x = hitPos[1] + 5 * math.sin(degrees)
  282.                 local z = hitPos[3] + 5 * math.cos(degrees)
  283.                 local hitPosition4 = Vec(x, hitPos[2],z)               
  284.                 Explosion(hitPosition4, 3.5)
  285.                 end            
  286.             Explosion(VecAdd(hitPos, Vec(0, 5, 0)), 4)
  287.             Explosion(VecAdd(hitPos, Vec(0, -5, 0)), 4)
  288.             Explosion(hitPos, 3.5)
  289.         elseif projectile.type == 5 then
  290.             local intervalo = 360 / 9
  291.             local intervalo2 = 360 / 24
  292.             local intervalo3 = 360 / 48
  293.             ParticleReset()
  294.             ParticleType("fire")
  295.             ParticleColor(0.3, 0.2, 0.1)
  296.             ParticleCollide(0)
  297.             ParticleRadius(10, 5)
  298.                 for degrees = 1, 360, intervalo do
  299.                 local x = hitPos[1] + 9.8 * math.sin(degrees)
  300.                 local z = hitPos[3] + 9.8 * math.cos(degrees)
  301.                 local hitPosition = Vec(x, hitPos[2],z)
  302.                
  303.                 SpawnParticle(hitPosition,Vec(0,20,0), 1, 10)
  304.                
  305.                 Explosion(hitPosition, 4)
  306.                 Explosion(VecAdd(hitPosition, Vec(0, 8, 0)), 4)
  307.                 Explosion(VecAdd(hitPosition, Vec(0, -8, 0)), 4)
  308.                 SpawnFire(hitposition)
  309.                 --DebugPrint(degrees)
  310.                 end
  311.                 for degrees = 1, 360, intervalo2 do
  312.                 local x2 = hitPos[1] + 18 * math.sin(degrees)
  313.                 local z2 = hitPos[3] + 18 * math.cos(degrees)
  314.                 local hitPosition2 = Vec(x2, hitPos[2],z2)
  315.                
  316.                 MakeHole(hitPosition2, 5, 5, 5)
  317.                 MakeHole(VecAdd(hitPosition2, Vec(0, 6, 0)), 5, 5, 5)
  318.                 MakeHole(VecAdd(hitPosition2, Vec(0, -6, 0)), 5, 5, 5)
  319.                 SpawnFire(hitposition2)
  320.                 end            
  321.                 for degrees = 1, 360, intervalo3 do
  322.                 local x3 = hitPos[1] + 25 * math.sin(degrees)
  323.                 local z3 = hitPos[3] + 25 * math.cos(degrees)
  324.                 local hitPosition3 = Vec(x3, hitPos[2],z3)
  325.                
  326.                 MakeHole(hitPosition3, 5, 5, 5)
  327.                 MakeHole(VecAdd(hitPosition3, Vec(0, 6, 0)), 5, 5, 5)
  328.                 MakeHole(VecAdd(hitPosition3, Vec(0, -6, 0)), 5, 5, 5)
  329.                 SpawnFire(hitposition3)
  330.                 end
  331.                
  332.                 Explosion(VecAdd(hitPos, Vec(0, 6, 0)), 4)
  333.                 Explosion(VecAdd(hitPos, Vec(0, -6, 0)), 4)
  334.                 Explosion(hitPos, 4)
  335.                 --ParticleColor(1,0.5,0,1,0.3,0)
  336.                 --ParticleEmissive(3, 0)
  337.                 --ParticleTile(5)
  338.                 ParticleColor(1, 0.2, 0)
  339.                 SpawnParticle(hitPos,Vec(0,20,0), 1, 10)
  340.                 SpawnFire(hitPos)
  341.                 else
  342.                 ParticleReset()
  343.                 ParticleType("smoke")
  344.                 ParticleTile(5)
  345.                 ParticleColor(1, 0.2, 0)
  346.                 ParticleRadius(0.2)
  347.                 ParticleEmissive(5, 4)
  348.                 local intervalo5 = 360 / 6
  349.                 for degrees = 1, 360, intervalo5 do
  350.                 local x = hitPos[1] + 0.3 * math.sin(degrees)
  351.                 local z = hitPos[3] + 0.3 * math.cos(degrees)
  352.                 local hitPosition5 = Vec(x, hitPos[2],z)
  353.                
  354.                 SpawnParticle(hitPosition5, Vec(0, 0, 0), 1.8)
  355.                 SpawnParticle("smoke", hitPosition5, Vec(0,2,0), .75, 4)
  356.                 SpawnFire(VecAdd(hitPosition5, Vec(0, 0.3, 0)))
  357.                 SpawnFire(VecAdd(hitPosition5, Vec(0, -0.3, 0)))
  358.                 --SpawnFire(VecAdd(hitPosition5, Vec(0, 1, 0)))
  359.                 --SpawnFire(VecAdd(hitPosition5, Vec(0, -1, 0)))
  360.                 --SpawnFire(VecAdd(hitPosition5, Vec(0, 1, 0)))
  361.                 --SpawnFire(VecAdd(hitPosition5, Vec(0, -1, 0)))
  362.                 SpawnFire(hitPosition5)
  363.                 end
  364.                 local intervalo6 = 360 / 24
  365.                 for degrees = 1, 360, intervalo6 do
  366.                 local x = hitPos[1] + 1 * math.sin(degrees)
  367.                 local z = hitPos[3] + 1 * math.cos(degrees)
  368.                 local hitPosition6 = Vec(x, hitPos[2],z)
  369.                
  370.                 SpawnParticle(hitPosition6, Vec(0, 0, 0), 1.8)
  371.                 --SpawnParticle("smoke", hitPosition6, Vec(0,2,0), .75, 4)
  372.                 --SpawnFire(VecAdd(hitPosition6, Vec(0, 0.5, 0)))
  373.                 --SpawnFire(VecAdd(hitPosition6, Vec(0, -0.5, 0)))
  374.                 --SpawnFire(VecAdd(hitPosition6, Vec(0, 1, 0)))
  375.                 --SpawnFire(VecAdd(hitPosition6, Vec(0, -1, 0)))
  376.                 --SpawnFire(hitPosition6)
  377.                 end
  378.                 SpawnParticle(hitPos, Vec(0, 0, 0), 1.8, 50)
  379.                 SpawnParticle("smoke", hitPos, Vec(0,2,0), .75, 4)
  380.                 SpawnFire(VecAdd(hitPos, Vec(0, 0.3, 0)))
  381.                 SpawnFire(VecAdd(hitPos, Vec(0, -0.3, 0)))
  382.                 --SpawnFire(VecAdd(hitPos, Vec(0, 1, 0)))
  383.                 --SpawnFire(VecAdd(hitPos, Vec(0, -1, 0)))
  384.                 --SpawnFire(VecAdd(hitPos, Vec(0, 1, 0)))
  385.                 --SpawnFire(VecAdd(hitPos, Vec(0, -1, 0)))
  386.                 SpawnFire(hitPos)
  387.                 MakeHole(hitPos, 0.5, 0.5, 0.5)
  388.                 PlaySound(explosionsounds[selectedshell], hitPos, 0.4)
  389.             end
  390.         end
  391.  
  392.     local width = 0.35
  393.     local length = 1
  394.     local rot = QuatLookAt(projectile.pos, point2)
  395.     local spritepos = TransformToParentPoint(Transform(projectile.pos, rot), Vec(0, 0, -1))
  396.     rot = QuatRotateQuat(rot, QuatEuler(-90, 0, 0))
  397.     local transform = Transform(spritepos, rot)
  398.     if projectile.type == 5 then
  399.     ballVisual = {
  400.     {0,0,0,90,0,0,0.5,0.5,0.1,0.1,0.1},
  401.     {0.25,0.75,0,0,90,0,0.5,1.5,0.1,0.1,0.1},
  402.     {-0.25,0.75,0,0,90,0,0.5,1.5,0.1,0.1,0.1},
  403.     {0,0.75,0.25,0,0,0,0.5,1.5,0.1,0.1,0.1},
  404.     {0,0.75,-0.25,0,0,0,0.5,1.5,0.1,0.1,0.1},
  405.     {0,1.5,0,90,0,0,0.5,0.5,0.1,0.1,0.1},
  406.     {0,1.85,0,0,0,0,0.5,0.3,0.1,0.1,0.1},
  407.     {0,1.85,0,0,90,0,0.5,0.3,0.1,0.1,0.1}
  408.     }
  409.     for i=1, #ballVisual do
  410.         local p = ballVisual[i]
  411.         local t = Transform(Vec(p[1],p[2],p[3]),QuatEuler(p[4],p[5],p[6]))
  412.         t = TransformToParentTransform(missleTransform,t)
  413.         DrawSprite(shellsprites[projectile.type], transform, p[7], p[8], p[9], p[10], p[11], 1, true, false)
  414.     end
  415.     else
  416.     DrawSprite(shellsprites[projectile.type], transform, width, length, 1, 1, 1, 1, true, false)
  417.     end
  418.     projectile.pos = point2
  419. end
  420.  
  421.  
  422. function tick(dt)
  423.     for key, shell in ipairs(eairstrikeprojectileHandler.shells) do
  424.         if shell.active then
  425.             ProjectileOperations(shell, dt)
  426.         end
  427.     end
  428.  
  429.     if flycamenabled then
  430.         SetString("game.player.tool", "eairstrike")
  431.     end
  432.    
  433.     if GetString("game.player.tool") == "eairstrike" and GetPlayerVehicle() == 0 then
  434.         firing = InputDown("lmb")
  435.         eairstrikeenabled = true
  436.         if equipTimer < 1 then
  437.             equipTimer = equipTimer + dt * 2
  438.         end
  439.  
  440.         if firing then
  441.             Shoot()
  442.             local p = GetPlayerPos
  443.             if selectedshell == 1 or selectedshell == 6 then
  444.             if selectedshell == 1 then
  445.             PlayLoop(gunsounds[selectedshell], plane.barrel.pos, 0.7)
  446.             PlayLoop(gunsounds[selectedshell], p, 0.5)
  447.             else
  448.             PlayLoop(gunsounds[selectedshell], plane.barrel.pos, 1)
  449.             PlayLoop(gunsounds[selectedshell], p, 1)
  450.             end    
  451.             end
  452.         end
  453.  
  454.         if InputPressed(changeammoKey) then
  455.             PlaySound(switchsound, GetCameraTransform().pos, 0.4)
  456.             if selectedshell == 6 then selectedshell = 1 else selectedshell = selectedshell + 1 end
  457.         end
  458.        
  459.         if InputPressed(changetypeKey) then
  460.             if ammoselectermax[selectedshell] > 1 then
  461.             PlaySound(switchsound, GetCameraTransform().pos, 0.4)
  462.                 if ammoselecter[selectedshell] == ammoselectermax[selectedshell] then ammoselecter[selectedshell] = 1 else ammoselecter[selectedshell] = ammoselecter[selectedshell] + 1 end
  463.             else
  464.             end
  465.         end
  466.  
  467.         if InputDown(changespreadKey) then        
  468.             SetBool("game.input.locktool", true)
  469.  
  470.             if InputValue("mousewheel") ~= 0 then
  471.                 local offset = 0.5 * InputValue("mousewheel")
  472.                 bullet_spread = clamp(bullet_spread + offset, 0, 10)
  473.             end
  474.         else
  475.             SetBool("game.input.locktool", false)
  476.         end
  477.  
  478.         if InputPressed("rmb") then flycamenabled = not flycamenabled end
  479.         if InputPressed("esc") then flycamenabled = false end
  480.         if flycamenabled then FlyCam() end
  481.  
  482.         aimpos = flycamenabled and GetCamLookPos() or GetAimPos()
  483.  
  484.         local b = GetToolBody()
  485.         if b ~= 0 then
  486.             toolTrans = GetBodyTransform(b)
  487.             toolPos = TransformToParentPoint(toolTrans, Vec(0.35, -0.6, -2.1))
  488.  
  489.             if lightTimer > 0 then
  490.                 PointLight(plane.barrel.pos, 1, 1, 1, 1)
  491.                 lightTimer = lightTimer - dt
  492.             end
  493.  
  494.             if body ~= b then
  495.                 body = b
  496.                 local shapes = GetBodyShapes(b)
  497.                 radioshape = shapes[1]
  498.                 antennashape = shapes[2]
  499.                 planeshape = shapes[3]
  500.                 blinkshape = shapes[4]
  501.                 radiotransformation = GetShapeLocalTransform(radioshape)
  502.                 antennatransformation = GetShapeLocalTransform(antennashape)
  503.                 planetransformation = GetShapeLocalTransform(planeshape)
  504.                 blinktransformation = GetShapeLocalTransform(blinkshape)
  505.             end
  506.            
  507.             if equipTimer > 1 and not radioactivated then
  508.                 PlaySound(beepsound, GetCameraTransform().pos, 0.4)
  509.                 radioactivated = true
  510.             end
  511.  
  512.             if radioactivated then
  513.                 SetShapeEmissiveScale(radioshape, 0.5)
  514.             else
  515.                 SetShapeEmissiveScale(radioshape, 0)
  516.             end
  517.  
  518.             if InputDown("lmb") then
  519.                 SetShapeEmissiveScale(blinkshape, 5)
  520.             else
  521.                 SetShapeEmissiveScale(blinkshape, 0)
  522.             end
  523.  
  524.             rt = TransformCopy(radiotransformation)
  525.             rt.rot = QuatRotateQuat(rt.rot, QuatEuler(0, 0, -15))
  526.             SetShapeLocalTransform(radioshape, rt)
  527.  
  528.             bt = TransformCopy(blinktransformation)
  529.             bt.rot = QuatRotateQuat(bt.rot, QuatEuler(0, 0, -15))
  530.             SetShapeLocalTransform(blinkshape, bt)
  531.  
  532.             at = TransformCopy(antennatransformation)
  533.             at.pos = VecAdd(at.pos, Vec(0, equipTimer*0.4, 0))
  534.             at.rot = QuatRotateQuat(at.rot, QuatEuler(0, 0, -15))
  535.             SetShapeLocalTransform(antennashape, at)
  536.  
  537.             SetShapeLocalTransform(planeshape, TransformToLocalTransform(GetBodyTransform(GetToolBody()), plane))
  538.         end
  539.  
  540.         planefwdpos = TransformToParentPoint(plane, Vec(-0.15, 0, 0))
  541.         planerotation = QuatRotateQuat(plane.rot, QuatEuler(0, 0, 0.1))
  542.         plane.pos = planefwdpos
  543.         plane.rot = planerotation
  544.         plane.barrel.pos = TransformToParentPoint(plane, Vec(2.5, 4.5, 0))
  545.     else
  546.         eairstrikeenabled = false
  547.         radioactivated = false
  548.         equipTimer = 0
  549.     end
  550.  
  551.     for i=1, 6 do
  552.         if shoottimers[i] > 0 then
  553.             shoottimers[i] = shoottimers[i] - dt
  554.         else
  555.             shoottimers[i] = 0
  556.         end
  557.     end
  558. end
  559.    
  560.    
  561.  
  562.  
  563. function draw()
  564.     if flycamenabled and GetPlayerVehicle() == 0 then
  565.         UiPush()
  566.             UiTranslate(UiCenter(), UiMiddle())
  567.             UiColor(1, 1, 1, 0.5)
  568.             UiAlign("center middle")
  569.             UiImage("MOD/img/AC130crosshair"..selectedshell..".png")
  570.         UiPop()
  571.  
  572.         UiPush()
  573.             UiTranslate(UiCenter(), UiMiddle()+UiMiddle()/2+50)
  574.             UiColor(1, 1, 1)
  575.             UiAlign("center")
  576.             UiFont("regular.ttf", 26)
  577.             if selectedshell ~= 3 or shoottimers[selectedshell] == 0 then
  578.                 UiText("Ready")
  579.             else
  580.                 UiText(tostring(math.ceil(shoottimers[selectedshell])))
  581.             end
  582.         UiPop()
  583.     end
  584.     if eairstrikeenabled and GetPlayerVehicle() == 0 then
  585.         UiPush()
  586.             UiTranslate(80, UiMiddle()+UiMiddle()/2)
  587.             UiColor(0.4, 0.4, 0.4)
  588.             UiAlign("left")
  589.             UiFont("regular.ttf", 26)
  590.             UiTextOutline(0,0,0,1,0.2)
  591.  
  592.             UiPush()
  593.                 UiColor(1, 1, 1)
  594.                 UiTranslate(0, -30)
  595.                 UiText("["..changeammoKey.."] Change Ammo")
  596.                 UiTranslate(0, 30)
  597.                 UiText("["..changetypeKey.."] Change Type")
  598.                 UiTranslate(0, 30)
  599.                 UiText("["..changespreadKey.."] + [Mouse Wheel] adjust spread: "..bullet_spread.."m")
  600.                 UiTranslate(0, 30)
  601.                 UiText("Right-Click to Plane-view")
  602.                 UiTranslate(0, 20)
  603.                 UiText("-----------------------------")
  604.             UiPop()
  605.  
  606.             UiTranslate(0, 100)
  607.             UiPush()
  608.                 if selectedshell == 1 then UiColor(1, 1, 1) end
  609.                 UiText("25mm")
  610.                     if selectedshell == 1 then
  611.                         if ammoselecter[selectedshell] == 1 then
  612.                             UiTranslate(70,0)
  613.                             UiColor(1,1,1)
  614.                             UiText("[HE]")
  615.                         elseif ammoselecter[selectedshell] == 2 then
  616.                             UiTranslate(70,0)
  617.                             UiColor(1,1,1)
  618.                             UiText("[FMJ]")
  619.                         end
  620.                     end
  621.             UiPop()
  622.  
  623.             UiTranslate(0, 30)
  624.             UiPush()
  625.                 if selectedshell == 2 then UiColor(1, 1, 1) end
  626.                 UiText("40mm")
  627.             UiPop()
  628.  
  629.             UiTranslate(0, 30)
  630.             UiPush()
  631.                 if selectedshell == 3 then UiColor(1, 1, 1) end
  632.                 UiText("105mm")
  633.             UiPop()
  634.             UiTranslate(0, 30)
  635.             UiPush()
  636.                 if selectedshell == 4 then UiColor(1, 1, 1) end
  637.                 UiText("240mm")
  638.             UiPop()
  639.             UiTranslate(0, 30)
  640.             UiPush()
  641.                 if selectedshell == 5 then UiColor(1, 1, 1) end
  642.                 UiText("Tactical Nuke")
  643.             UiPop()
  644.             UiTranslate(0, 30)
  645.             UiPush()
  646.                 if selectedshell == 6 then UiColor(1, 1, 1) end
  647.                 UiText("Napalm")
  648.             UiPop()
  649.         UiPop()
  650.     end
  651. end
Advertisement
Add Comment
Please, Sign In to add comment