local loot_fade_time = 15500 --time until loot will disappear if not picked up (set to 0 for it to stay always) rerolls = 1 --if a loot doesnt drop then it will try again (higher number = more tries) loot = {} itemis = {} drop_chance = {} loot_type = {} pressed = 0 loot_entity_number = {} max_loot_items = 0 timer = {} local count = 0 local first_run_item = {} function loot_for_enemies_init_name(e,name) itemis[e] = tostring(name) loot[e] = 1 Hide(e) count = count + 1 max_loot_items = count loot_entity_number[count] = e --set chance to drop here (% based) --lower number = less chance --if all chances are low then there is a high chance of no item dropping at all --if you don't set a drop chance for an item it will assume 100% (but it still might not drop if another item drops instead) --& set the loot type here so script knows what action to take later if itemis[e] == "QuasarGun (ammo)" then drop_chance[e] = 101 loot_type[e] = "ammo" elseif itemis[e] == "Typhoon (ammo)" then drop_chance[e] = 70 loot_type[e] = "ammo" elseif itemis[e] == "QuasarGun" then drop_chance[e] = 15 loot_type[e] = "weapon" elseif itemis[e] == "Medbox" then drop_chance[e] = 30 loot_type[e] = "health" elseif itemis[e] == "Key" then drop_chance[e] = 100 loot_type[e] = "collect" end end function loot_for_enemies_main(e) if first_run_item[e] == nil then first_run_item[e] = 1 return end if loot[e] == 1 then Hide(e) StartTimer(e) timer[e] = GetTimer(e) + loot_fade_time else Show(e) --adjusts when prompt will appear on screen if PlayerLooking(e,110,20) == 1 then Prompt("Collect the "..itemis[e].."?") if g_KeyPressE == 1 and pressed == 0 then PromptDuration("Collected "..itemis[e],3000) loot[e] = 1 PlaySoundIfSilent(e,0) PlaySoundIfSilent(e,1) pressed = 1 --what happens when player picks up the item (based on it's "type" defined earlier) if loot_type[e] == "ammo" then AddPlayerAmmo(e) elseif loot_type[e] == "weapon" then AddPlayerWeapon(e) elseif loot_type[e] == "health" then AddPlayerHealth(e) elseif loot_type[e] == "collect" then Collected(e) end end end --resets the loot so it can be dropped again later if loot_fade_time > 0 and GetTimer(e) > timer[e] then Hide(e) loot[e] = 1 end end if g_KeyPressE == 0 then pressed = 0 end end function PlayerLooking(e,dis,v) if g_Entity[e] ~= nil then if dis == nil then dis = 3000 end if v == nil then v = 0.5 end if GetPlayerDistance(e) <= dis then local destx = g_Entity[e]['x'] - g_PlayerPosX local destz = g_Entity[e]['z'] - g_PlayerPosZ local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle <= 0 then angle = 360 + angle elseif angle > 360 then angle = angle - 360 end while g_PlayerAngY < 0 or g_PlayerAngY > 360 do if g_PlayerAngY <= 0 then g_PlayerAngY = 360 + g_PlayerAngY elseif g_PlayerAngY > 360 then g_PlayerAngY = g_PlayerAngY - 360 end end local L = angle - v local R = angle + v if L <= 0 then L = 360 + L elseif L > 360 then L = L - 360 end if R <= 0 then R = 360 + R elseif R > 360 then R = R - 360 end if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then return 1 elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then return 1 else return 0 end else return 0 end end end