-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Weapon local weapon_name = "Proximity Mine" local mines = 0 local mine_state = {} local timer_running = {} local pressed = 0 local StartTime = {} function proximine_pickup_init(e,name) mine_state[e] = 0 timer_running[e] = 0 StartTime[e] = 0 end function proximine_pickup_main(e) PlayerDist = GetPlayerDistance(e) if PlayerDist < 150 then SourceAngle = g_PlayerAngY while SourceAngle < 0.0 do SourceAngle = SourceAngle + 360.0 end while SourceAngle > 340.0 do SourceAngle = SourceAngle - 360.0 end PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX) PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ) DestAngle = math.atan2( PlayerDZ , PlayerDX ) -- Convert to degrees DestAngle = (DestAngle * 57.2957795) - 90.0 Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle)) if Result > 180 then Result = 0 end if Result < 20.0 then --[[ SourceAngle = g_PlayerAngX while SourceAngle < 0.0 do SourceAngle = SourceAngle + 360.0 end while SourceAngle > 335.0 do SourceAngle = SourceAngle - 360.0 end DestAngle = math.atan2( PlayerDZ , PlayerDY ) -- Convert to degrees DestAngle = (DestAngle * 57.2957795) - 90.0 Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle)) if Result > 180 then Result = 0 end if Result < 25.0 then --]] Prompt ("Press E To pick up the " .. weapon_name) if g_KeyPressE == 1 and pressed == 0 then pressed = 1 PromptDuration("Collected the " .. weapon_name,3000) PlaySound(e,1) mines = mines + 1 mine_state[e] = 1 ResetPosition(e,0,0,0) ActivateIfUsed(e) end --end end end --place mines if mines > 0 then if g_KeyPressE == 1 and pressed == 0 then Prompt("Placing Mine") if timer_running[e] == 0 then StartTime[e] = GetTimer(e) + 1000 timer_running[e] = 1 end if GetTimer(e) > StartTime[e] then ResetPosition(e,g_PlayerPosX,g_PlayerPosY-60,g_PlayerPosZ) mines = mines - 1 Show(e) SwitchScript(e,"proximine2") end end end if g_KeyPressE == 0 then timer_running[e] = 0 StartTimer(e) pressed = 0 end end local minimum_HP = 25 local trigger_dist = 90 local proximine_started={} function proximine_pickup_init(e) proximine_started[e] = 0 end function proximine2_main(e) for a = 1, 2999 do if g_Entity[a] ~= nil then if g_Entity[a]['health'] > 25 then MineDX = g_Entity[a]['x'] - g_Entity[e]['x']; MineDY = g_Entity[a]['y'] - g_Entity[e]['y']; MineDZ = g_Entity[a]['z'] - g_Entity[e]['z']; MineDist = math.sqrt(math.abs(MineDX*MineDX)+math.abs(MineDY*MineDY)+math.abs(MineDZ*MineDZ)); if MineDist < 200 and proximine_started[e] == 0 and GetPlayerDistance(e) > 600 then proximine_started[e] = GetTimer(e)+2500 PlaySound(e,0) end end end end if proximine_started[e]>0 then if GetTimer(e) > proximine_started[e] then SetEntityHealth(e,0) end end end