ITADN

Invisible bots

#153Opendufft-angrygermantryhard 创建于 2026-03-01
bug
Hi, I had some issues stopping bots from turning invisible on my server and eventually realized this seemed to be an ongoing issue (seemed to still be marked as TODO within supervisor.lua). I mostly managed to solve this (models may still bug out, but atleast they dont turn invisible anymore) Is there a chance this could be the actual fix? Is there maybe more that needs to be done than I first realized? This so far seems to have worked fine for me. Main differences were the use of SetTransmitWithParent, checking for potential invalid alpha levels, and trying to use different render mode. At the same time, i tried giving the application of the status in gamemode/init.lua a quick timer application (timer.simple with 0.1 delay) because i feel like it couldve been a race condition? Within gamemode/init.lua (at local overridemodel = pl:GetZombieClassTable().OverrideModel): ``` local overridemodel = pl:GetZombieClassTable().OverrideModel if overridemodel then timer.Simple(0.1, function() if not IsValid(pl) or not pl:Alive() then return end local current = pl:GiveStatus("overridemodel") if current and current:IsValid() then current:SetModel(overridemodel) current:SetOwner(pl) -- Ensure owner is explicitly set to attempt to fix the problem current:ResetBones() pl:CallZombieFunction1("ManipulateOverrideModel", current) end end) else pl:RemoveStatus("overridemodel", false, true) end ``` Within zombiesurvival/entities/entities/status_overridemodel.lua: ``` AddCSLuaFile() ENT.Type = "anim" ENT.Base = "status__base" ENT.RenderGroup = RENDERGROUP_TRANSLUCENT function ENT:Initialize() self:SetSolid(SOLID_NONE) self:SetMoveType(MOVETYPE_NONE) self:SetTransmitWithParent(true) -- attempt at fixing the issue with invisibility, as parents seem to break on ModelOverride self:AddEffects(bit.bor(EF_BONEMERGE, EF_BONEMERGE_FASTCULL, EF_PARENT_ANIMATES)) --self:SetRenderMode(RENDERMODE_TRANSALPHA) local pPlayer = self:GetOwner() if pPlayer:IsValid() then pPlayer.status_overridemodel = self if SERVER and (pPlayer:Team() ~= TEAM_UNDEAD or not pPlayer:GetZombieClassTable().NoHideMainModel) then -- more attempts at a fix by using different render mode --pPlayer:SetRenderMode(RENDERMODE_NONE) -- should hopefully fix issue (i dont think this worked lol) pPlayer:SetRenderMode(RENDERMODE_TRANSLAPHA) pPlayer:SetColor(Color(255,255,255,0)) end end end function ENT:PlayerSet(pPlayer, bExists) if SERVER and pPlayer:Team() ~= TEAM_UNDEAD or not pPlayer:GetZombieClassTable().NoHideMainModel then -- more attempts at a fix by using different render mode --pPlayer:SetRenderMode(RENDERMODE_NONE) -- should hopefully fix issue (i dont think this worked lol) pPlayer:SetRenderMode(RENDERMODE_TRANSALPHA) pPlayer:SetColor(Color(255,255,255,0)) end end function ENT:OnRemove() local pPlayer = self:GetOwner() if SERVER and pPlayer:IsValid() then pPlayer:SetRenderMode(RENDERMODE_NORMAL) end end function ENT:Think() end if CLIENT then function ENT:Draw() local owner = self:GetOwner() if owner:IsValid() and (not owner:IsPlayer() or owner:Alive()) then local pcolor = owner:GetColor() or Color(255,255,255,255) -- failsafe attempt -- Attempt at a fix; trying to failsafe the alpha levels if pcolor.a <= 0 and (not owner.SpawnProtection) then pcolor.a = 255 end if owner.SpawnProtection then pcolor.a = (0.02 + (CurTime() + self:EntIndex() * 0.2) % 0.05) * 255 pcolor.r = 0 pcolor.b = 0 pcolor.g = 255 render.SuppressEngineLighting(true) end self:SetColor(pcolor) -- trying to force the game to realize if theres some issues if not (owner.SpawnProtection and owner:GetZombieClassTable().NoHideMainModel) then if not owner:CallZombieFunction1("PrePlayerDrawOverrideModel", self) then self:DrawModel() owner:CallZombieFunction1("PostPlayerDrawOverrideModel", self) end end if owner.SpawnProtection then render.SuppressEngineLighting(false) end end end ENT.DrawTranslucent = ENT.Draw end ```
2 条评论