Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This resource has been created by qaisjp
- Find more epic resources at www.code.google.com/p/mta-freeroamplus
- Please give me credit!
- ]]
- local function iif(a,b,c) if a then return b else return c end return nil end
- local me, ufo, realufo = getLocalPlayer(), getElementByID("ufo"), getElementByID("realufo")
- local data = {mapShown=false}
- local sW, sH = guiGetScreenSize()
- local mapSize = iif((sH - 100)>=600, 600, sH - 100)
- local mapX = (sW / 2) - (mapSize / 2)
- local mapY = (sH / 2) - (mapSize / 2)
- function tse(st,...)
- local args = {...}
- triggerServerEvent(st, root, unpack(args))
- end
- function createEvent(str, hand, func)
- addEvent(str, true)
- addEventHandler(str, hand, func)
- end
- --[[
- addEventHandler("onClientGUIClick", button_fun, toggleFunWindow, false) opens the fun stuff. we will have a gridlist attch to btn
- addEventHandler("onClientGUIClick", button_map, mapUfoInit, false) warp to map
- triggerServerEvent("ufo:dirHeight", root,tonumber(theHeight))
- addEventHandler("onClientGUIClick", button_quickmap_go,
- function()
- pointX = tonumber( guiGetText(edit_coord) )
- pointY = tonumber( guiGetText(edit_coord_2))
- speed = guiGetText(edit_speed)
- superSpeed = speed * 1000
- z = "nothing"
- if speed and pointX then
- tse("ufo:moveEvent", tonumber(pointX), tonumber(pointY), z, true, tonumber(superSpeed))
- end
- end
- , false)
- bla bla notes here bla bla bla bla
- height_up, function() triggerServerEvent("ufoHeight", root, 3) end, false)
- height_down, function() triggerServerEvent("ufoHeight", root, -3) end, false)
- movement_stop, function() triggerServerEvent("ufoStop", root) end, false)
- LS, function() triggerServerEvent("ufo:move2Loc", root, 835.6, -2086, 500) end, false)
- SF, function() triggerServerEvent("ufo:move2Loc", root, -1357.7, 532.4, 500) end, false)
- LV, function() triggerServerEvent("ufo:move2Loc", root, 2415, 507, 500) end, false)
- nw, function() triggerServerEvent("ufo:moveEvent", root, -160, 160, 0) end, false)
- n, function() triggerServerEvent("ufo:moveEvent", root, 0, 160, 0) end, false)
- ne, function() triggerServerEvent("ufo:moveEvent", root, 160, 160, 0) end, false)
- e, function() triggerServerEvent("ufo:moveEvent", root, 160, 0, 0) end, false)
- se, function() triggerServerEvent("ufo:moveEvent", root, 160, -160, 0) end, false)
- s, function() triggerServerEvent("ufo:moveEvent", root, 0, -160, 0) end, false)
- sw, function() triggerServerEvent("ufo:moveEvent", root, -160, -160, 0) end, false)
- w, function() triggerServerEvent("ufo:moveEvent", root, -160, 0, 0) end, false)
- rot_45nw, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, 45) end, false)
- rot_45ne, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, -45) end, false)
- rot_90ne, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, -90) end, false)
- rot_90nw, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, 90) end, false)]]
- local guiContainer = {}
- local extraOptions = {scrolling=true}
- function getControl(child)
- return guiContainer[child]
- end
- function mouseToggle()
- showCursor(not isCursorShowing())
- end
- function bool2col(bool)
- if bool then
- return 0,255,0
- end
- return 255,0,0
- end
- -------------------
- --///////////////--
- -------------------
- local function handleScroll(type)
- if not extraOptions.scrolling then return end
- type = type:gsub("mouse_wheel_", "")
- if (not getKeyState("lshift") and not getKeyState("lalt")) then -- if both keys pressed or none
- type = type=="up" and 1 or -1
- elseif getKeyState("lshift") and not getKeyState("lalt") then
- type = type=="up" and 1.5 or -1.5
- elseif getKeyState("lalt") and not getKeyState("lshift") then
- type = type=="up" and 0.5 or -0.5
- end
- local x,y,z = getElementPosition(ufo)
- setElementPosition(ufo, x,y,z+type)
- end
- local function doSlidingExtras(btn,st)
- if btn ~= "left" and st ~= "down" then return end
- st = getElementData(source, "shown")
- guiSetText(source, ((st and "Show") or "Hide").." Extras")
- if st then
- -- do the sliding off
- guiSetVisible(getControl("extragrid"), false)
- ---
- guiSetPosition(getControl("mapaccess"), 0.7825, 0.21, true)
- guiSetPosition(getControl("pref"), 0.7825, 0.285, true)
- else
- -- do the sliding in
- guiSetVisible(getControl("extragrid"), true)
- --
- guiSetPosition(getControl("mapaccess"), 0.7825, 0.54, true)
- guiSetPosition(getControl("pref"), 0.7825, 0.6133, true)
- end
- setElementData(source, "shown", not st)
- end
- function extrasSelection()
- local row = guiGridListGetSelectedItem(getControl("extragrid"))
- if row==-1 then return end
- local text = guiGridListGetItemText(getControl("extragrid"), row, 1)
- if text == "Scroll Movement" then
- extraOptions.scrolling = not extraOptions.scrolling
- guiGridListSetItemColor(getControl("extragrid"), 2, 1, bool2col(extraOptions.scrolling))
- elseif text == "Nuke!" then
- tse("zapUFO")
- end
- end
- function installExtras()
- --[[local features = {"World Collide", "Scroll Movement", "Nuke!", "Classic Controller", "Height", "Coordinates", "Follow"}
- for i,v in ipairs(features) do
- guiGridListSetItemText(getControl("extragrid"), i, 1, v, false, false)
- end]]-- More optimised, but i should build this with performance not in mind and jst get the stff working. then optimise
- --[[ Colour codes:
- -RED/GREEN = Boolean.
- -CYAN = Action.
- -YELLOW = Window.
- --]]
- guiGridListSetItemText(getControl("extragrid"), 1, 1, "World Collide", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 1, 1, bool2col(false))
- guiGridListSetItemText(getControl("extragrid"), 2, 1, "Scroll Movement", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 2, 1, bool2col(true))
- guiGridListSetItemText(getControl("extragrid"), 3, 1, "Nuke!", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 3, 1, 0,255,255)
- guiGridListSetItemText(getControl("extragrid"), 4, 1, "Classic Controller", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 4, 1, 255,255,0)
- guiGridListSetItemText(getControl("extragrid"), 5, 1, "Height", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 5, 1, 255,255,0)
- guiGridListSetItemText(getControl("extragrid"), 6, 1, "Coordinates", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 6, 1, 255,255,0)
- guiGridListSetItemText(getControl("extragrid"), 7, 1, "Follow", false, false)
- guiGridListSetItemColor(getControl("extragrid"), 7, 1, 255,255,0)
- addEventHandler("onClientGUIClick", getControl("showextras"), doSlidingExtras)
- addEventHandler("onClientGUIDoubleClick", getControl("extragrid"), extrasSelection)
- end
- function initUfoWnd(btn,st)
- if btn~="left" and st~="down" then return end
- if data.mapShown == false then
- addEventHandler("onClientRender", root, drawUfoMap)
- data.mapShown = true
- setTimer(
- function()
- addEventHandler("onClientClick", root, ufoSpawn)
- end
- , 1000, 1)
- else
- removeEventHandler("onClientRender", root, drawUfoMap)
- removeEventHandler("onClientClick", root, ufoSpawn)
- data.mapShown = false
- end
- end
- -------------------
- --///////////////--
- -------------------
- function showMenu()
- if data.enabled then return end
- toggleControl("enter_exit", false)
- bindKey("f", "down", mouseToggle)
- bindKey("mouse_wheel_up", "both", handleScroll)
- bindKey("mouse_wheel_down", "both", handleScroll)
- showCursor(true)
- local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"}
- for i,v in ipairs(additions) do
- local gui = getControl(v)
- guiSetVisible(gui, true)
- end
- data.enabled = true
- end
- addCommandHandler("ufo", showMenu)
- function hideMenu()
- data.enabled = false
- local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"}
- for i,v in ipairs(additions) do
- local gui = getControl(v)
- guiSetVisible(gui, false)
- end
- showCursor(false)
- toggleControl("enter_exit", true)
- unbindKey("f", "down", mouseToggle)
- unbindKey("mouse_wheel_up", "both", handleScroll)
- unbindKey("mouse_wheel_down", "both", handleScroll)
- setCameraTarget(me)
- end
- -------------------
- --///////////////--: Create the main screen objects
- -------------------
- -- Leave movement mode
- guiContainer["stopedit"] = guiCreateButton(0.7825,0.0583,0.205,0.0617,"Stop Editing",true)
- addEventHandler("onClientGUIClick", getControl("stopedit"), hideMenu)
- -- Create the extras menu, to do is sliding the extras gridlist up and down to toggle showing, also moving the btns below it.
- guiContainer["showextras"] = guiCreateButton(0.7825,0.135,0.205,0.0617,"Hide Extras",true)
- guiSetProperty(getControl("showextras"),"AlwaysOnTop","True")
- setElementData(getControl("showextras"), "shown", true)
- guiContainer["extragrid"] = guiCreateGridList(0.7825,0.155,0.205,0.37,true)
- guiGridListSetSelectionMode(getControl("extragrid"),2)
- guiSetProperty(getControl("extragrid"),"ZOrderChangeEnabled","False")
- guiGridListAddColumn(getControl("extragrid"),"",1)
- guiSetVisible(getControl("extragrid"), false)
- setTimer(installExtras, 75, 1) -- This installs the "extras" gridlist+button for interactive use.
- --
- guiContainer["mapaccess"] = guiCreateButton(0.7825,0.54,0.205,0.0617,"Quick Map",true)
- addEventHandler("onClientGUIClick", getControl("mapaccess"), initUfoWnd)
- guiContainer["pref"] = guiCreateButton(0.7825,0.6133,0.205,0.0617,"Preferences",true)
- for i = 0, 7 do
- guiGridListAddRow(getControl("extragrid"))
- end
- -------------------
- --///////////////--
- -------------------
- for i,v in pairs(guiContainer) do
- guiSetVisible(v, false)
- end
- -------------------
- --///////////////--
- -------------------
- --[[do -- This contains content from the freecam resource and has been editied by karlis, so thanks to him.
- TO DO LIST:
- When moving forward, the ufo will move forward. Only forward is supported (W)
- Cursor look-at direction changes the rotation of the ufo.
- So when moving the ufo will always move forward, but in the camera lookat direction
- local zoom=100 --how far is camera target from elem
- local rotX, rotY = 0,0
- local ratio = 3 --how many times distance from camera to player is smaller then distance from player to camera target
- local width, height = guiGetScreenSize()
- local hit
- --heavily modified freecam resource's core
- function freecamFrame()
- local cameraAngleX = rotX
- local cameraAngleY = rotY
- local freeModeAngleZ = math.sin(cameraAngleY)
- local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX)
- local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX)
- local camPosX, camPosY, camPosZ = getElementPosition(ufo)
- -- calculate a target based on the current position and an offset based on the angle
- local camTargetX = camPosX + freeModeAngleX * zoom
- local camTargetY = camPosY + freeModeAngleY * zoom
- local camTargetZ = camPosZ + freeModeAngleZ * zoom
- local camPosX = camPosX - ( camTargetX - camPosX ) / ratio
- local camPosY = camPosY - ( camTargetY - camPosY ) / ratio
- local camPosZ = camPosZ - ( camTargetZ - camPosZ ) / ratio
- if not isLineOfSightClear(camPosX,camPosY,camPosZ,camPosX,camPosY,camPosZ,true,true,true,true,false,true,false,me) then
- _,camPosX,camPosY,camPosZ=processLineOfSight(camTempPosX,camTempPosY,camPosZ,camPosX,camPosY,camPosZ,true,true,true,true,false,true,false,false,localPlayer)
- camPosX,camPosY,camPosZ=camPosX-(camTempPosX-camPosX)*0.1,camPosY-(camTempPosY-camPosY)*0.1,camPosZ-(camTempPosZ-camPosZ)*0.1
- end
- -- Set the new camera position and target
- setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ )
- end
- end]]
- -- state variables
- local speed = 0
- local strafespeed = 0
- local rotX, rotY = 0,0
- local velocityX, velocityY, velocityZ
- -- configurable parameters
- local options = {
- invertMouseLook = false,
- normalMaxSpeed = 1,
- slowMaxSpeed = 0.2,
- fastMaxSpeed = 9,
- smoothMovement = true,
- acceleration = 0.3,
- decceleration = 0.15,
- mouseSensitivity = 0.3,
- maxYAngle = 188,
- key_fastMove = "lshift",
- key_slowMove = "lalt",
- key_forward = "w",
- zoom = 100,
- ratio = 3, --how many times distance from camera to player is smaller then distance from player to camera target
- }
- local mouseFrameDelay = 0
- local getKeyState = getKeyState
- do
- local mta_getKeyState = getKeyState
- function getKeyState(key)
- if isMTAWindowActive() or isCursorShowing()then
- return false
- else
- return mta_getKeyState(key)
- end
- end
- end
- -- PRIVATE
- local function freecamFrame ()
- if not data.enabled then return end
- if getKeyState(options.key_fastMove) then
- options.mouseSensitivity = 0.7
- elseif getKeyState(options.key_slowMove) then
- options.mouseSensitivity = 0.1
- else
- options.mouseSensitivity = 0.3
- end
- do
- local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"}
- for i,v in ipairs(additions) do
- local gui, show = getControl(v), isCursorShowing()
- guiSetAlpha(gui, show and 1 or 0.9)
- guiSetEnabled(gui, show)
- end
- end
- setElementPosition(getPedOccupiedVehicle(me) or me, getElementPosition(ufo))
- -- work out an angle in radians based on the number of pixels the cursor has moved (ever)
- local cameraAngleX = rotX
- local cameraAngleY = rotY
- local freeModeAngleZ = math.sin(cameraAngleY)
- local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX)
- local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX)
- local camPosX, camPosY, camPosZ = getElementPosition(realufo)--getCameraMatrix()
- camPosZ = camPosZ-8 -- This is to not interfere with the offsets of the attach.
- -- calculate a target based on the current position and an offset based on the angle
- local camTargetX = camPosX + freeModeAngleX * options.zoom
- local camTargetY = camPosY + freeModeAngleY * options.zoom
- local camTargetZ = camPosZ + freeModeAngleZ * options.zoom
- -- Calculate what the maximum speed that the camera should be able to move at.
- local mspeed = options.normalMaxSpeed
- if getKeyState(options.key_fastMove) then
- mspeed = options.fastMaxSpeed
- elseif getKeyState(options.key_slowMove) then
- mspeed = options.slowMaxSpeed
- end
- if options.smoothMovement then
- local acceleration = options.acceleration
- local decceleration = options.decceleration
- -- Check to see if the forwards/backwards keys are pressed
- local speedKeyPressed = false
- if getKeyState ( options.key_forward ) then
- speed = speed + acceleration
- speedKeyPressed = true
- end
- -- Check to see if the strafe keys are pressed
- -- If no forwards/backwards keys were pressed, then gradually slow down the movement towards 0
- if speedKeyPressed ~= true then
- if speed > 0 then
- speed = speed - decceleration
- elseif speed < 0 then
- speed = speed + decceleration
- end
- end
- -- Check the ranges of values - set the speed to 0 if its very close to 0 (stops jittering), and limit to the maximum speed
- if speed > -decceleration and speed < decceleration then
- speed = 0
- elseif speed > mspeed then
- speed = mspeed
- elseif speed < -mspeed then
- speed = -mspeed
- end
- if strafespeed > -(acceleration / 2) and strafespeed < (acceleration / 2) then
- strafespeed = 0
- elseif strafespeed > mspeed then
- strafespeed = mspeed
- elseif strafespeed < -mspeed then
- strafespeed = -mspeed
- end
- else
- speed = 0
- strafespeed = 0
- if getKeyState ( options.key_forward ) then speed = mspeed end
- end
- -- Work out the distance between the target and the camera (should be 100 units)
- local camAngleX = camPosX - camTargetX
- local camAngleY = camPosY - camTargetY
- local camAngleZ = 0 -- we ignore this otherwise our vertical angle affects how fast you can strafe
- -- Calulcate the length of the vector
- local angleLength = math.sqrt(camAngleX*camAngleX+camAngleY*camAngleY+camAngleZ*camAngleZ)
- -- Normalize the vector, ignoring the Z axis, as the camera is stuck to the XY plane (it can't roll)
- local camNormalizedAngleX = camAngleX / angleLength
- local camNormalizedAngleY = camAngleY / angleLength
- local camNormalizedAngleZ = 0
- -- We use this as our rotation vector
- local normalAngleX = 0
- local normalAngleY = 0
- local normalAngleZ = 1
- -- Perform a cross product with the rotation vector and the normalzied angle
- local normalX = (camNormalizedAngleY * normalAngleZ - camNormalizedAngleZ * normalAngleY)
- local normalY = (camNormalizedAngleZ * normalAngleX - camNormalizedAngleX * normalAngleZ)
- local normalZ = (camNormalizedAngleX * normalAngleY - camNormalizedAngleY * normalAngleX)
- -- Update the camera position based on the forwards/backwards speed
- camPosX = camPosX + freeModeAngleX * speed
- camPosY = camPosY + freeModeAngleY * speed
- -- Update the camera position based on the strafe speed
- camPosX = camPosX + normalX * strafespeed
- camPosY = camPosY + normalY * strafespeed
- --local cameraPosX = camPosX - ( camTargetX - camPosX ) / ratio
- --local cameraPosY = camPosY - ( camTargetY - camPosY ) / ratio
- local cameraPosZ = (camPosZ+8) - ( camTargetZ - (camPosZ+8) ) / options.ratio
- --Store the velocity
- velocityX = (freeModeAngleX * speed) + (normalX * strafespeed)
- velocityY = (freeModeAngleY * speed) + (normalY * strafespeed)
- velocityZ = (freeModeAngleZ * speed) + (normalZ * strafespeed)
- -- Update the target based on the new camera position (again, otherwise the camera kind of sways as the target is out by a frame)
- camTargetX = camPosX + freeModeAngleX * 100
- camTargetY = camPosY + freeModeAngleY * 100
- camTargetZ = camPosZ + freeModeAngleZ * 100
- -- Set the new camera position and target
- local _,_,ufoZ = getElementPosition(ufo)
- setCameraMatrix ( camPosX, camPosY, cameraPosZ, camTargetX, camTargetY, camTargetZ )
- setElementPosition(ufo, camPosX, camPosY, ufoZ)
- setElementRotation(ufo, 0,0, math.deg(-rotX))
- end
- local function freecamMouse (cX,cY,aX,aY)
- --ignore mouse movement if the cursor or MTA window is on
- --and do not resume it until at least 5 frames after it is toggled off
- --(prevents cursor mousemove data from reaching this handler)
- if not data.enabled then return end
- if isCursorShowing() or isMTAWindowActive() then
- mouseFrameDelay = 5
- return
- elseif mouseFrameDelay > 0 then
- mouseFrameDelay = mouseFrameDelay - 1
- return
- end
- -- how far have we moved the mouse from the screen center?
- local width, height = guiGetScreenSize()
- aX = aX - width / 2
- aY = aY - height / 2
- --invert the mouse look if specified
- if options.invertMouseLook then
- aY = -aY
- end
- rotX = rotX + aX * options.mouseSensitivity * 0.01745
- rotY = rotY - aY * options.mouseSensitivity * 0.01745
- local PI = math.pi
- if rotX > PI then
- rotX = rotX - 2 * PI
- elseif rotX < -PI then
- rotX = rotX + 2 * PI
- end
- if rotY > PI then
- rotY = rotY - 2 * PI
- elseif rotY < -PI then
- rotY = rotY + 2 * PI
- end
- -- limit the camera to stop it going too far up or down - PI/2 is the limit, but we can't let it quite reach that or it will lock up
- -- and strafeing will break entirely as the camera loses any concept of what is 'up'
- if rotY < -PI / 2.05 then
- rotY = -PI / 2.05
- elseif rotY > PI / 2.05 then
- rotY = PI / 2.05
- end
- end
- addEventHandler("onClientRender", root, freecamFrame)
- addEventHandler("onClientCursorMove", root, freecamMouse)
- -------------------
- ----- UFO MAP -----
- -------------------
- function drawUfoMap()
- data.mapShown = true
- dxDrawRectangle((sW / 2) - ((mapSize / 2) + 4), (sH / 2) - ((mapSize / 2) + 4), (mapSize + 8), (mapSize + 8), tocolor(0, 0, 0, 128), false)
- -- Draw the map.
- dxDrawImage(mapX, mapY, mapSize, mapSize, "map.jpg", 0, 0, 0, tocolor(255, 255, 255, 255), true)
- dxDrawText("Click on a location", 2, 12, sW, dxGetFontHeight(1, "bankgothic"), tocolor(0, 0, 0, 128), 1, "bankgothic", "center", "top", false, false, true)
- dxDrawText("Click on a location", 0, 10, sW - 2, dxGetFontHeight(1, "bankgothic"), tocolor(255, 255, 255, 255), 1, "bankgothic", "center", "top", false, false, true)
- local px, py, wx, wy, wz = getCursorPosition()
- px = math.floor(px * sW)
- py = math.floor(py * sH)
- if (px >= mapX and py >= mapY and px <= (mapX + mapSize) and py <= (mapY + mapSize)) then
- px = px - mapX
- py = py - mapY
- px = (6000 / mapSize) * px
- py = (6000 / mapSize) * py
- px = px - 3000
- py = 3000 - py
- local zoneName = getZoneName(px, py, 0, false)
- dxDrawText(zoneName, 2, sH - 40, sW, dxGetFontHeight(1, "bankgothic"), tocolor(0, 0, 0, 128), 1, "bankgothic", "center", "top", false, false, true)
- dxDrawText(zoneName, 0, sH - 42, sW - 2, dxGetFontHeight(1, "bankgothic"), tocolor(255, 255, 255, 255), 1, "bankgothic", "center", "top", false, false, true)
- end
- end
- function ufoSpawn(button, state, px, py)
- if data.mapShown then
- removeEventHandler("onClientRender", root, drawUfoMap)
- removeEventHandler("onClientClick", root, ufoSpawn)
- data.mapShown = false
- if (px >= mapX and py >= mapY and px <= (mapX + mapSize) and py <= (mapY + mapSize)) then
- px = px - mapX
- py = py - mapY
- px = (6000 / mapSize) * px
- py = (6000 / mapSize) * py
- px = px - 3000
- py = 3000 - py
- --guiSetText(edit_coord, tostring(px))
- --guiSetText(edit_coord_2, tostring(py))
- outputChatBox("x: "..px.." y: "..py)
- end
- end
- end
- --///////////////////////////////////////--
- --// Super weapons - Nuke - By Ransom ///--
- --///////////////////////////////////////--
- local N_loops = 0
- local N_cloudRotationAngle = 0
- local NFlashDelay = 0
- local stopNFlash = false
- function FireN ( x, y, z )
- NBeaconX = x --these are for the render function
- NBeaconY = y
- NBeaconZ = z
- N_Cloud = NBeaconZ
- setTimer ( function() setTimer ( NExplosion, 170, 35 ) end, 2700, 1 ) -- wait 2700 seconds then 35 loops @ 170ms
- setTimer ( NShot, 500, 1 )
- end
- createEvent("ufo:ClientFireN", root, FireN)
- function NShot ()
- NukeObjectA = createObject ( 16340, NBeaconX, NBeaconY, NBeaconZ - 0.5 )
- NukeObjectB = createObject ( 3865, NBeaconX + 0.072265, NBeaconY + 0.013731, NBeaconZ + 196.153122 )
- NukeObjectC = createObject ( 1243, NBeaconX + 0.060547, NBeaconY - 0.017578, NBeaconZ + 189.075554 )
- setElementRotation ( NukeObjectA, math.deg(3.150001), math.deg(0), math.deg(0.245437) )
- setElementRotation ( NukeObjectB, math.deg(-1.575), math.deg(0), math.deg(1.938950) )
- setElementRotation ( NukeObjectC, math.deg(0), math.deg(0), math.deg(-1.767145) )
- shotpath = NBeaconZ - 200
- moveObject ( NukeObjectA, 5000, NBeaconX, NBeaconY, shotpath, 0, 0, 259.9 )
- moveObject ( NukeObjectB, 5000, NBeaconX + 0.072265, NBeaconY + 0.013731, shotpath - 3.846878, 0, 0, 259.9 )
- moveObject ( NukeObjectC, 5000, NBeaconX + 0.060547, NBeaconY - 0.017578, shotpath - 10.924446, 0, 0, 259.9 )
- end
- function NExplosion ()
- N_loops = N_loops + 1
- r = math.random(1.5, 4.5)
- angleup = math.random(0, 35999)/100
- explosionXCoord = r*math.cos(angleup) + NBeaconX
- ExplosionYCoord = r*math.sin(angleup) + NBeaconY
- if N_loops == 1 then
- N_Cloud = NBeaconZ
- createExplosion ( explosionXCoord, ExplosionYCoord, N_Cloud, 7 )
- killXPosRadius = NBeaconX + 35
- killXNegRadius = NBeaconX - 35
- killYPosRadius = NBeaconY + 35
- killYNegRadius = NBeaconY - 35 --+/- 35 x/y
- killZPosRadius = NBeaconZ + 28-- +28
- killZNegRadius = NBeaconZ - 28-- -28
- local x, y, z = getElementPosition ( me )
- if ( x < killXPosRadius ) and ( x > killXNegRadius ) and ( y < killYPosRadius ) and ( y > killYNegRadius ) and
- ( z < killZPosRadius ) and ( z > killZNegRadius ) then
- triggerServerEvent ( "ufo:serverKillNukedPlayer", me )
- end
- elseif N_loops == 2 then
- N_Cloud = NBeaconZ + 4
- createExplosion ( explosionXCoord, ExplosionYCoord, N_Cloud, 7 )
- destroyElement ( NukeObjectA ) --Exploded, get rid of objects
- destroyElement ( NukeObjectB )
- destroyElement ( NukeObjectC )
- elseif N_loops > 20 then
- N_cloudRotationAngle = N_cloudRotationAngle + 22.5
- if N_explosionLimiter == false then
- N_cloudRadius = 7
- explosionXCoord = N_cloudRadius*math.cos(N_cloudRotationAngle) + NBeaconX --recalculate
- ExplosionYCoord = N_cloudRadius*math.sin(N_cloudRotationAngle) + NBeaconY --recalculate
- createExplosion ( explosionXCoord, ExplosionYCoord, N_Cloud, 7 )
- N_explosionLimiter = true
- elseif N_explosionLimiter == true then
- N_explosionLimiter = false
- end
- N_cloudRadius2 = 16
- explosionXCoord2 = N_cloudRadius2*math.cos(N_cloudRotationAngle) + NBeaconX
- ExplosionYCoord2 = N_cloudRadius2*math.sin(N_cloudRotationAngle) + NBeaconY
- createExplosion ( explosionXCoord2, ExplosionYCoord2, N_Cloud, 7 )
- else
- N_Cloud = N_Cloud + 4
- createExplosion ( explosionXCoord, ExplosionYCoord, N_Cloud, 7 )
- end
- if N_loops == 1 then
- NExplosionFlash = createMarker ( NBeaconX, NBeaconY, NBeaconZ, "corona", 0, 255, 255, 255, 255 )
- N_FlashSize = 1
- addEventHandler ( "onClientRender", root, NFlash )
- elseif N_loops == 35 then
- stopNFlash = true
- end
- end
- function NFlash() --Corona "flare". Grows after cp marker B grows a little
- if ( stopNFlash == false ) then
- if N_FlashSize > 60 then --beginning flash must grow fast, then delayed
- if NFlashDelay == 2 then
- N_FlashSize = N_FlashSize + 1
- NFlashDelay = 0
- else
- NFlashDelay = NFlashDelay + 1
- end
- else
- N_FlashSize = N_FlashSize + 1
- end
- else
- N_FlashSize = N_FlashSize - 1
- end
- setMarkerSize ( NExplosionFlash, N_FlashSize )
- if N_FlashSize == 0 then
- removeEventHandler ( "onClientRender", root, NFlash )
- destroyElement ( NExplosionFlash )
- N_loops = 0 --reset stuff
- N_cloudRotationAngle = 0 --reset stuff
- stopNFlash = false --reset stuff
- NFlashDelay = 0 --reset stuff
- tse("ufo:serverNukeFinished")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement