Garry's Mod

Garry's Mod

NPC (Ragdoll) Falling
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 4:34
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
最后由 󠀡𝅵󠀡𝅷 编辑于; 2023 年 11 月 5 日 上午 4:35
< >
正在显示第 1 - 10 条,共 10 条留言
rabies baby  [开发者] 2023 年 11 月 5 日 上午 4:47 
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.
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 4:51 
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
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 5:00 
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
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 5:05 
now I'll try to make it an option to add/remove npcs
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 5:23 
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
rabies baby  [开发者] 2023 年 11 月 5 日 上午 5:51 
Alright I'll test it out and update it soon. Thanks again. Do you want to be added as a contributor?
󠀡𝅵󠀡𝅷 2023 年 11 月 5 日 上午 5:54 
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 2023 年 11 月 5 日 下午 6:55 
引用自 󠀡𝅵󠀡𝅷
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.
最后由 John Tech-Head 编辑于; 2023 年 11 月 5 日 下午 6:55
depa360 2023 年 11 月 9 日 下午 12:46 
not everyone has enough free time or a way to use convars correctly
Awakened NPC. 2023 年 11 月 10 日 下午 6:11 
引用自 depa360
not everyone has enough free time or a way to use convars correctly
We know, but the creator responded so all is well
< >
正在显示第 1 - 10 条,共 10 条留言
每页显示数: 1530 50