Garry's Mod

Garry's Mod

NPC (Ragdoll) Falling
Exclude headcrabs, antlions, and fast zombies from the main function
local function Think() for _, v in ipairs(ents.GetAll()) do if IsValid(v) and v:IsNPC() then if -- NPC class checker v:GetClass() ~= "npc_fastzombie" and v:GetClass() ~= "npc_headcrab" and v:GetClass() ~= "npc_headcrab_black" and v:GetClass() ~= "npc_headcrab_fast" and v:GetClass() ~= "npc_antlion" and v:GetClass() ~= "npc_antlion_worker" then if not v:IsOnGround() then v.m_fLastFallVelocity = v:GetVelocity().z if (v.m_fLastFallVelocity or 0) < NPC_FALL_MINIMUM_HEIGHT then local info = DamageInfo() info:SetDamageType(DMG_FALL) info:SetDamage(GetConVarNumber("npc_custom_fall_damage")) info:SetDamagePosition(v:GetPos()) info:SetAttacker(v) if info:GetDamage() > 0 then v:TakeDamageInfo(info) end v.m_fLastFallVelocity = 0 hear_sound = true end end end end end end
Last edited by 󠀡𝅵󠀡𝅷; 5 Nov, 2023 @ 4:35am
< >
Showing 1-10 of 10 comments
havin a melty?  [developer] 5 Nov, 2023 @ 4:47am 
Can it be made into an option? I know beggars can't be choosers, but there is some appeal to tricking headcrabs and whatever into accidentally launching themselves off a cliff to their deaths.
󠀡𝅵󠀡𝅷 5 Nov, 2023 @ 4:51am 
Originally posted by 168 IQ (inquire about anything):
Can it be made into an option? I know beggars can't be choosers, but there is some appeal to tricking headcrabs and whatever into accidentally launching themselves off a cliff to their deaths.
np, just need to make a table where u can add and remove NPCs from. Then call the table in ur func
gonna try it
󠀡𝅵󠀡𝅷 5 Nov, 2023 @ 5:00am 
done!

local NPCsBlacklist = { "npc_fastzombie", "npc_headcrab", "npc_headcrab_black", "npc_headcrab_fast", "npc_antlion", "npc_antlion_worker" } -- Think function to handle fall damage logic local function Think() for _, v in ipairs(ents.GetAll()) do if IsValid(v) and v:IsNPC() then if not table.HasValue(NPCsBlacklist, v:GetClass()) then if not v:IsOnGround() then v.m_fLastFallVelocity = v:GetVelocity().z if (v.m_fLastFallVelocity or 0) < NPC_FALL_MINIMUM_HEIGHT then local info = DamageInfo() info:SetDamageType(DMG_FALL) info:SetDamage(GetConVarNumber("npc_custom_fall_damage")) info:SetDamagePosition(v:GetPos()) info:SetAttacker(v) if info:GetDamage() > 0 then v:TakeDamageInfo(info) end v.m_fLastFallVelocity = 0 hear_sound = true end end end end end end

so u can make a concommand to add or remove NPCs from blacklist
and then u can make Q-menu tab where u can add/remove NPCs even easier
󠀡𝅵󠀡𝅷 5 Nov, 2023 @ 5:05am 
now I'll try to make it an option to add/remove npcs
󠀡𝅵󠀡𝅷 5 Nov, 2023 @ 5:23am 
that didn't worked
but toggle option is working

local function ToggleBlacklist() if blacklistEnabled then blacklistEnabled = false print("Blacklist disabled.") else blacklistEnabled = true print("Blacklist enabled.") end end concommand.Add("toggle_npc_falling_blacklist", ToggleBlacklist) local NPCsBlacklist = { "npc_fastzombie", "npc_headcrab", "npc_headcrab_black", "npc_headcrab_fast", "npc_antlion", "npc_antlion_worker" } -- Think function to handle fall damage logic local function Think() for _, v in ipairs(ents.GetAll()) do if IsValid(v) and v:IsNPC() then if not blacklistEnabled or not table.HasValue(NPCsBlacklist, v:GetClass()) then if not v:IsOnGround() then v.m_fLastFallVelocity = v:GetVelocity().z if (v.m_fLastFallVelocity or 0) < NPC_FALL_MINIMUM_HEIGHT then local info = DamageInfo() info:SetDamageType(DMG_FALL) info:SetDamage(GetConVarNumber("npc_custom_fall_damage")) info:SetDamagePosition(v:GetPos()) info:SetAttacker(v) if info:GetDamage() > 0 then v:TakeDamageInfo(info) end v.m_fLastFallVelocity = 0 hear_sound = true end end end end end end
havin a melty?  [developer] 5 Nov, 2023 @ 5:51am 
Alright I'll test it out and update it soon. Thanks again. Do you want to be added as a contributor?
󠀡𝅵󠀡𝅷 5 Nov, 2023 @ 5:54am 
Originally posted by 168 IQ (inquire about anything):
Alright I'll test it out and update it soon. Thanks again. Do you want to be added as a contributor?
yw
nah, u don't have to add me as a contributor
John Tech-Head 5 Nov, 2023 @ 6:55pm 
Originally posted by 󠀡𝅵󠀡𝅷:
that didn't worked
but toggle option is working

local function ToggleBlacklist() if blacklistEnabled then blacklistEnabled = false print("Blacklist disabled.") else blacklistEnabled = true print("Blacklist enabled.") end end concommand.Add("toggle_npc_falling_blacklist", ToggleBlacklist) local NPCsBlacklist = { "npc_fastzombie", "npc_headcrab", "npc_headcrab_black", "npc_headcrab_fast", "npc_antlion", "npc_antlion_worker" } -- Think function to handle fall damage logic local function Think() for _, v in ipairs(ents.GetAll()) do if IsValid(v) and v:IsNPC() then if not blacklistEnabled or not table.HasValue(NPCsBlacklist, v:GetClass()) then if not v:IsOnGround() then v.m_fLastFallVelocity = v:GetVelocity().z if (v.m_fLastFallVelocity or 0) < NPC_FALL_MINIMUM_HEIGHT then local info = DamageInfo() info:SetDamageType(DMG_FALL) info:SetDamage(GetConVarNumber("npc_custom_fall_damage")) info:SetDamagePosition(v:GetPos()) info:SetAttacker(v) if info:GetDamage() > 0 then v:TakeDamageInfo(info) end v.m_fLastFallVelocity = 0 hear_sound = true end end end end end end
Its so cool to see the community to help in petitions they made for an addon to become better, instead of begging and begging and becoming anoying.
Last edited by John Tech-Head; 5 Nov, 2023 @ 6:55pm
depa360 9 Nov, 2023 @ 12:46pm 
not everyone has enough free time or a way to use convars correctly
Awakened NPC. 10 Nov, 2023 @ 6:11pm 
Originally posted by depa360:
not everyone has enough free time or a way to use convars correctly
We know, but the creator responded so all is well
< >
Showing 1-10 of 10 comments
Per page: 1530 50