-- LUA Script - precede every function and global member with lowercase name of script + '_main' local bullet_hit_list = {} local sub = string.sub function helicopter_bullet_hit_init(e) Hide(e) CollisionOff(e) bullet_hit_list[e] = {used = false, s1 = nil, s2 = nil, timer = math.huge} end function bhPos (Ang, x, z) for k, v in pairs(bullet_hit_list) do if not v.used then local bh = bullet_hit_list[k] bh.used = true bh.timer = g_Time + 50 bh.state = 'fp' bh.Ang = math.rad(Ang) bh.x = x bh.z = z break end end end function bhAdd1(e) for k, v in pairs(bullet_hit_list) do if v.s1 == nil then bullet_hit_list[k].s1 = e return true end end return false end function bhAdd2(e) for k, v in pairs(bullet_hit_list) do if v.s2 == nil then bullet_hit_list[k].s2 = e return true end end return false end local function CloseTo(x, z, x2, z2) local dX, dZ = x - x2, z - z2 return (dX*dX + dZ*dZ) < 150 * 150 end local function CanHurtPlayer(x,z) if ZonesPlayerIn ~= nil then local zones = ZonesPlayerIn() -- check if player in safe zone for _,v in pairs(zones) do if sub(v,1,9) == 'Safe Zone' and PointIsInZone(x,z,v) then return false end end -- now check if shot is in safe zone if sub(ZonePointIn(x, z),1,9) == 'Safe Zone' then return false end end return true end function helicopter_bullet_hit_main(e) local bh = bullet_hit_list[e] if bh == nil or not bh.used then return end if g_Time > bh.timer then if bh.state == 'fp' then local x,z = bh.x + math.sin(bh.Ang) * math.random(4800,5200), bh.z + math.cos(bh.Ang) * math.random(4800,5200) local y = GetTerrainHeight(x, z) local Px,Pz = g_PlayerPosX, g_PlayerPosZ if CanHurtPlayer(x,z) then ResetPosition(e, x, y + 40, z) RotateToPlayer(e) Show(e) StartParticleEmitter(e) bh.state = 'lt' bh.timer = g_Time + 400 if bh.s1 ~= nil then ResetPosition(bh.s1, x, y, z) RotateToPlayer(bh.s1) Show(bh.s1) end if bh.s2 ~= nil then ResetPosition(bh.s2, x, y, z) RotateToPlayer(bh.s2) Show(bh.s2) end if CloseTo(x, z, Px, Pz) then HurtPlayer(e, 10) end end for k,_ in pairs(ai_bot_state) do local aiEnt = g_Entity[k] if aiEnt.health > 0 and CloseTo(x, z, aiEnt.x, aiEnt.z) then SetEntityHealth(k, aiEnt.health - 50) end end else Hide(e) bh.used = false StopParticleEmitter(e) if bh.s1 ~= nil then Hide(bh.s1) end if bh.s2 ~= nil then Hide(bh.s2) end end end end