Skip to content

Commit

Permalink
Fixed bodies with ammo not showing marker
Browse files Browse the repository at this point in the history
  • Loading branch information
rodikh committed Dec 7, 2021
1 parent a93e339 commit 1371026
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down
19 changes: 13 additions & 6 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -269,13 +277,12 @@ 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
end
return nil
end


return BetterLootMarkers:new()

0 comments on commit 1371026

Please sign in to comment.