diff --git a/README.md b/README.md index 7e696da..0b39234 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a Cyberpunk 2077 mod that adds detailed loot markers on looting containe If a container contains items of different types (armor, weapon, eddies), an icon for each category will show instead of the default loot marker, with different colored icons to represent the highest quality loot in each category. ## Installation -This mod requires [Cyber Engine Tweaks](https://github.com/yamashi/CyberEngineTweaks) (also on [Nexus](https://www.nexusmods.com/cyberpunk2077/mods/107)) to be installed. +This mod requires [Cyber Engine Tweaks](https://github.com/yamashi/CyberEngineTweaks) Version 1.18+ (also on [Nexus](https://www.nexusmods.com/cyberpunk2077/mods/107)) to be installed. Extract the entire repository into `Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\` and run the game. @@ -19,7 +19,6 @@ Tested to work on Cyberpunk version 1.31 Feel free to open an issue if you encounter a bug or suggest a pull request. - Currently (Cyberpunk 1.31), Cyberpunk's default loot markers are buggy even without this mod, and the mod relies on the loot marker's default behaviour to show the new custom icons. BetterLootMarkers may not show up if the default marker is not handled properly by the game. -- Known issue: ammo loot markers are sometimes missing ## Planned Features diff --git a/init.lua b/init.lua index dc580e6..3ebd27d 100644 --- a/init.lua +++ b/init.lua @@ -15,6 +15,12 @@ function BetterLootMarkers:new() registerForEvent("onInit", function() BetterLootMarkers.ItemTypes = require("Modules/Types.lua") + Override("ScriptedPuppet", "HasLootableItems;ScriptedPuppet", function(self) + -- This fixes a bug where bodies with only ammo loot will not show markers in the vanilla game. HasLootableItems is coded to ignore ammo. + local _, itemList = Game.GetTransactionSystem():GetItemList(self) + return table.getn(itemList) > 0 + end) + Observe("GameplayRoleComponent", "ShowSingleMappin;Int32", function(self, index) if not BetterLootMarkers.IsLootMappin(self.mappins[index + 1]) then return @@ -185,11 +191,12 @@ function BetterLootMarkers.ResolveHighestQualityByCategory(itemList) if not Utils.HasKey(categories, category) then categories[category] = newItem else - qualityForCompare = quality + local qualityForCompare = quality if newItem.isIconic then qualityForCompare = BetterLootMarkers.ItemTypes.Qualities.Iconic end - if BetterLootMarkers.ItemTypes.Qualities[qualityForCompare.value] > BetterLootMarkers.ItemTypes.Qualities[categories[category].quality.value] then + if BetterLootMarkers.ItemTypes.Qualities[qualityForCompare.value] > + BetterLootMarkers.ItemTypes.Qualities[categories[category].quality.value] then categories[category] = newItem end end @@ -231,7 +238,8 @@ function BetterLootMarkers.IsLootableRole(role) end function BetterLootMarkers.IsLootMappin(mappin) - return mappin ~= nil and (mappin.mappinVariant == gamedataMappinVariant.LootVariant or mappin.gameplayRole == EGameplayRole.Loot) + return mappin ~= nil and + (mappin.mappinVariant == gamedataMappinVariant.LootVariant or mappin.gameplayRole == EGameplayRole.Loot) end function BetterLootMarkers.FindLootMappinId(gameplayRoleComponent) @@ -259,7 +267,7 @@ end function BetterLootMarkers.RemoveMappedObjectByTarget(object) local objectId = Utils.GetObjectId(object) - for i,v in ipairs(BetterLootMarkers.mappedObjects) do + for i, v in ipairs(BetterLootMarkers.mappedObjects) do if objectId == Utils.GetObjectId(v.target) then table.remove(BetterLootMarkers.mappedObjects, i) return @@ -269,7 +277,7 @@ end function BetterLootMarkers.FindMappedObjectByTarget(object) local objectId = Utils.GetObjectId(object) - for _,v in ipairs(BetterLootMarkers.mappedObjects) do + for _, v in ipairs(BetterLootMarkers.mappedObjects) do if objectId == Utils.GetObjectId(v.target) then return v end @@ -277,5 +285,4 @@ function BetterLootMarkers.FindMappedObjectByTarget(object) return nil end - return BetterLootMarkers:new()