sthalik Posted July 18, 2017 Share Posted July 18, 2017 Hey, I've made a rudimentary mod that changes permanent infection to hypochondriac-like infection. There's a question -- can one define the length of the fake infection or reset its duration to the beginning? Also, I just couldn't get the list of body parts to work. Enumerating them is a real PITA in the present code. Looked like the enumerator didn't work without further explanation, hence hand-unrolled version. Can you see anything else dubious in the code? local function do_part(dmg, part, acc) local part = dmg:getBodyPart(part) if part:IsInfected() then part:SetInfected(false) part:SetFakeInfected(true) return true end return acc end local function maybe_clear_infected(dmg) local ret = false ret = do_part(dmg, BodyPartType.Foot_L, ret) ret = do_part(dmg, BodyPartType.Foot_R, ret) ret = do_part(dmg, BodyPartType.ForeArm_L, ret) ret = do_part(dmg, BodyPartType.ForeArm_R, ret) ret = do_part(dmg, BodyPartType.Groin, ret) ret = do_part(dmg, BodyPartType.Hand_L, ret) ret = do_part(dmg, BodyPartType.Hand_R, ret) ret = do_part(dmg, BodyPartType.Head, ret) ret = do_part(dmg, BodyPartType.LowerLeg_L, ret) ret = do_part(dmg, BodyPartType.LowerLeg_R, ret) ret = do_part(dmg, BodyPartType.Neck, ret) ret = do_part(dmg, BodyPartType.Torso_Lower, ret) ret = do_part(dmg, BodyPartType.Torso_Upper, ret) ret = do_part(dmg, BodyPartType.UpperArm_L, ret) ret = do_part(dmg, BodyPartType.UpperArm_R, ret) ret = do_part(dmg, BodyPartType.UpperLeg_L, ret) ret = do_part(dmg, BodyPartType.UpperLeg_R, ret) return ret end local function check_player_infected(player) local dmg = player:getBodyDamage() local inf_level = dmg:getInfectionLevel() if inf_level > 0. and maybe_clear_infected(dmg) then local fake_inf_level = dmg:getFakeInfectionLevel() dmg:setInfectionLevel(0) dmg:setFakeInfectionLevel(fake_inf_level + inf_level) dmg:setInf(false) dmg:setIsFakeInfected(true) end end Events.OnPlayerUpdate.Add(check_player_infected) Link to comment Share on other sites More sharing options...
Morry Posted August 15, 2017 Share Posted August 15, 2017 You are using the update function, so this is being called 30/60 times each second. You might want to put it on EveryTenMinutes instead and do these actions for each player there. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now