pkszZomboid / pkszTH

Treasure hunt event
0 stars 1 forks source link

Question about epic generator #1

Open cyberbobjr opened 2 months ago

cyberbobjr commented 2 months ago

Hello, Thanks you for your mod, it's really a great mod !

For the epic item, i'm wondering if you can store the modded value of the item inside the ModData of the item. That's way you can keep the informations of the epic item and display them the next time the game was launched.

What do you think about that ? Do you accept PR ?

pkszZomboid commented 1 month ago

Thank you for issue out. It is possible to add that functionality.

The initial design of this MOD was focused on lightweight, stable operation, and compatibility, so I intentionally avoided using moddata. However, I think the addition of the features you have suggested is necessary not only for epic item tooltips, but also for the extensibility of the Event feature.

But right now I don't have the personal time to deal with it ;)

new features with your hands...

cyberbobjr commented 1 month ago

Hello @pkszZomboid ok i finished the job, it's really really simple to implement. Something like that :

local pkszTooltip = {

}
pkszTooltip.render = ISToolTipInv.render

function ISToolTipInv:render()
    local item = self.item
    local itemModData = item:getModData()
    if item and item:getModData()["pksz"] then
        itemModData = item:getModData()["pksz"]
        local tooltip = ""
        if itemModData["setAimingTime"] then
            tooltip = tooltip .. "AimingTime +" .. itemModData["setAimingTime"] .. "<br>"
        end
        if itemModData["setRecoilDelay"] then
            tooltip = tooltip .. "RecoilDelay -" .. itemModData["setRecoilDelay"] .. "<br>"
        end
        if itemModData["setMaxRange"] then
            tooltip = tooltip .. "MaxRange +" .. itemModData["setMaxRange"] .. "<br>"
        end
        if itemModData["setMaxDamage"] then
            tooltip = tooltip .. "MaxDamage +" .. itemModData["setMaxDamage"] .. "<br>"
        end
        if itemModData["setCapacity"] then
            tooltip = tooltip .. "Capacity +" .. itemModData["setCapacity"] .. "<br>"
        end
        if itemModData["setWeightReduction"] then
            tooltip = tooltip .. "WeightReduction +" .. itemModData["setWeightReduction"] .. "<br>"
        end
        item:setTooltip(tooltip)
    end
    pkszTooltip.render(self)
end

and in the file pkszEpicGen.lua, you can set the modData like that :

    local itemModData = item:getModData()
    if not itemModData["pksz"] then
        itemModData["pksz"] = {}
    end

    ....

    item:setRecoilDelay(modifi.value)
            itemModData["pksz"]["setRecoilDelay"] = modifi.mod

            effectText = effectText .. "<br>RecoilDelay - " .. modifi.mod
            logText = pkszEpicBuildLogText(logText, "-Recoil", modifi.mod)

but i'll prepare a PR ;) (with French translation :p) Food for though : maybe we can delegate the epic generator to this mod (if mod.contains) : https://steamcommunity.com/sharedfiles/filedetails/?id=2932853467

cyberbobjr commented 1 month ago

image

cyberbobjr commented 1 month ago

Done this is the PR : https://github.com/pkszZomboid/pkszTH/pull/2