ZioPao / The-Only-Cure

Amputation mod for Project Zomboid
GNU General Public License v3.0
11 stars 7 forks source link

Zombie Amputations - cant get it to work even with 0 damage threshold and 100 chance #110

Closed m-hynek closed 2 months ago

m-hynek commented 2 months ago

Tried various sandbox setting configurations, I was unable to proc amputation on zombies

Logs Nothing useful in log (no debug print)

Additional context I am using better sort, maybe it makes categories different, so condition wont ever be true? if not (weaponCategories:contains("Axe") or weaponCategories:contains("LongBlade")) then return end

Or is OnWeaponHitCharacter right event when there is OnHitZombie ?

Idea Some weapons can be sharp, even if its blunt (spiked bat for example). Comma-separated sandbox field for additional weapons that should be considered for this feature would be awesome. Patch is fine too, up to you

ZioPao commented 2 months ago

I'll double check it as soon as I can. I might have fucked up something before pushing the update. I don't think BetterSort has anything to do with it. Also, thanks for the tidy issue, it's always helpful :)

m-hynek commented 2 months ago

Forgot to specify that I was testing it on dedicated MP server

m-hynek commented 2 months ago

Ok the issue is in sandbox variable, its false no matter the settings in config.

if not SandboxVars.TOC.EnableZombieAmputations then return end

TOC = {
        -- Minimum=1 Maximum=10 Default=1
        CicatrizationSpeed = 1,
        -- Minimum=0 Maximum=5 Default=1
        WoundDirtynessMultiplier = 1,
        -- Minimum=1 Maximum=3 Default=2
        SurgeonAbilityImportance = 2,
        EnableZombieAmputations = true,
        -- Minimum=0 Maximum=10 Default=4
        ZombieAmputationDamageThreshold = 4,
        -- Minimum=0 Maximum=100 Default=25
        ZombieAmputationDamageChance = 25,
    },

but TOC_DEBUG.print("EnableZombieAmputations value: " .. tostring(SandboxVars.TOC.EnableZombieAmputations)) prints [DEBUG_TheOnlyCure] [TOC][ZombiesAmputation] EnableZombieAmputations value: false

ZioPao commented 2 months ago

Should be fixed in #113. Keep in mind that this feature is still experimental and I haven't tested it thoroughly

m-hynek commented 2 months ago

I enabled that feature with patch yesterday and no issues so far other than left hand is always cut first. I added ugly rand condition to solve that. Also I want to implement amputations for shotgun and high caliber guns, because its so much fun. Are you interested in feature PR or nah?

Anyway thanks for the updates. And the mod ofc!

ZioPao commented 2 months ago

I enabled that feature with patch yesterday and no issues so far other than left hand is always cut first. I added ugly rand condition to solve that. Also I want to implement amputations for shotgun and high caliber guns, because its so much fun. Are you interested in feature PR or nah?

Anyway thanks for the updates. And the mod ofc!

I'm always open for PR! About the bug, that's not something I ever noticed, it should be completely random.

m-hynek commented 2 months ago

it always checks if left is free to amputate (if i understand correctly)

 -- Check left or right
        if not zombieInv:containsEval(PredicateAmputationItemLeft) then
            SpawnAmputation(zombie, "L")
        elseif not zombieInv:containsEval(PredicateAmputationItemRight) then
            SpawnAmputation(zombie, "R")
        end

my ugly tweak (i couldnt get dynamic method name call to work)

if ZombRand(0, 2) == 0 then
            if not zombieInv:containsEval(PredicateAmputationItemLeft) then
                SpawnAmputation(zombie, "L")
            elseif not zombieInv:containsEval(PredicateAmputationItemRight) then
                SpawnAmputation(zombie, "R")
            else
                return
            end
        else
            if not zombieInv:containsEval(PredicateAmputationItemRight) then
                SpawnAmputation(zombie, "R")
            elseif not zombieInv:containsEval(PredicateAmputationItemLeft) then
                SpawnAmputation(zombie, "L")
            else
                return
            end
        end

and added return in case both codition fails so we dont spawn timer with bloodsplat

ZioPao commented 2 months ago

You're completely right, I didn't notice it at all. I'll push a tweak in a minute

m-hynek commented 2 months ago

no rush, not critical

ZioPao commented 2 months ago

Not critical but you never know when you have some free time to mess around with stuff like this. I've pushed it right now, it's just a simple if else after all.

About the guns, it should be fairly easy to implement, just to give you a heads up. In theory, you'd just need to tweak the acceptable weapon categories in line 78

ZioPao commented 2 months ago

I'll open another issue to keep track of the enhancements. #118