hook.Add("InitPostEntityMap", "Worm'sReplacements", function() -- We will replace now all prop_dynamic to prop_physics to make them usable. -- prop_dynamic shouldn't be used at all except on some zombie escapes. -- If you wish to use a whitelist/blacklist in case it breaks on some maps, toggle the mode. local whitelist = false -- Whitelist all maps in the mapList. local blacklist = false -- Blacklist all maps in the mapList. local debugger = false -- Debug mode if GAMEMODE.WRUseWhitelist then whitelist = true else blacklist = true end if GAMEMODE.WRDebug then debugger = true end local activeMap = game.GetMap() local ntd = 9999 -- What number should display when object is nailed. Don't worry, it won't be destructible. if (blacklist and GAMEMODE.WRMapList[activeMap]) or (whitelist and not GAMEMODE.WRMapList[activeMap]) then if debugger then print("Worm's Replacements: This map should not be affected. Aborting.") end return end -- Do not change if a map does not meet the conditions. timer.Simple(1, function() -- To prevent possible issues, call it on the next frame of InitPostEntityMap. for _, ent in pairs(ents.FindByClass("prop_dynamic")) do if not self.ZombieEscape then local prop = ents.Create("prop_physics") if prop:IsValid() then prop:SetModel(ent:GetModel()) prop:SetMaterial(ent:GetMaterial()) prop:SetPos(ent:GetPos()) prop:SetAngles(ent:GetAngles()) prop:Spawn() local oldphys = ent:GetPhysicsObject() local shouldMove = true if oldphys:IsValid() and not oldphys:IsMoveable() then shouldMove = false end if not shouldMove then -- The prop should not move. Set it to be an immortal one. if debugger then print("Worm's Replacements: "..tostring(prop).." is now a Map Object.") end prop:SetMaxHealth(ntd) prop:SetMaxBarricadeHealth(ntd) prop:SetHealth(ntd) prop:SetBarricadeHealth(ntd) prop:SetNWBool("MapObject", true) prop.IsNotPhasable = true end local phys = prop:GetPhysicsObject() if phys:IsValid() and not shouldMove then phys:EnableMotion(false) prop:SetNWBool("MapObject", true) end end end if self.ZombieEscape then return end if debugger then print("Worm's Replacements: Converted "..prop:GetModel().." ("..tostring(prop)..").") end ent:Remove() end end) end)