Reorganize a tiny bit, add Z-City health integration for ragdolls

This commit is contained in:
toasterpanic 2026-05-25 12:33:03 -04:00
parent 9511bf3a82
commit 89c31dec61
8 changed files with 101 additions and 126 deletions

View file

@ -2,13 +2,15 @@
I made this in an angry fugue after desperately trying to improve my frames by creating a more optimized euphoria ragdoll mod. Now that I'm done with that I figured out how tio actually fix my frames, and it was not this addon. However, I have another issue: NPCs with Z-City suck. Like they tank hits like crazy. You could unload a mag on someone's leg and there would be a non-zero chance they would still be perfectly fine. I'd like to turn my optimized Fedhoria mod into a base for a Z-City NPC improvement mod. I made this in an angry fugue after desperately trying to improve my frames by creating a more optimized euphoria ragdoll mod. Now that I'm done with that I figured out how tio actually fix my frames, and it was not this addon. However, I have another issue: NPCs with Z-City suck. Like they tank hits like crazy. You could unload a mag on someone's leg and there would be a non-zero chance they would still be perfectly fine. I'd like to turn my optimized Fedhoria mod into a base for a Z-City NPC improvement mod.
Here are the current features:
- NPCs are now integrated with Z-City's health system. They wriggle when conscious, and don't when they aren't.
Some ideas: Some ideas:
- If an enemy breaks a leg, slow them down. - Generally, enemies need to be closer to players in terms of fleshiness. Extreme pain, broken limbs, etc. currently knock over players, but not NPCs. This is something I'd like to fix.
- If an enemy breaks an arm, make their aim worse.
- Break both legs? Hope you like writhing on the ground for the rest of your life!
- Generally, enemies need to be closer to players in terms of fleshiness. Like a shot to the arm should knock them over, that shit hurts yknow.
- Enemies should target downed enemies of hostile factions. - Enemies should target downed enemies of hostile factions.
- Enemies should be able to get back up from being ragdolled if they're in good enough shape.
Since theoretically the NPCs use the same health system that players use, these shouldn't be too hard to implement. Since theoretically the NPCs use the same health system that players use, these shouldn't be too hard to implement.
@ -17,3 +19,7 @@ More optimistic ideas:
- NPCs will back out of combat when injured. - NPCs will back out of combat when injured.
- Friendly NPCs can heal each other. - Friendly NPCs can heal each other.
- NPCs can heal themselves to a limited degree. - NPCs can heal themselves to a limited degree.
## Incompatibilities
- Any mod that modifies the behavior of death ragdolls (Reagdoll, Artagdoll, Fedhoria)

View file

@ -1,48 +1,36 @@
local function PopulateSBXToolMenu(pnl) local function PopulateRagdollSBXToolMenu(pnl)
pnl:CheckBox("Enabled", "fedhoria_enabled") pnl:CheckBox("Enabled", "zcnpci_enabled")
pnl:ControlHelp("Enable or disable the addon.") pnl:ControlHelp("Enable or disable the addon.")
pnl:CheckBox("Players", "fedhoria_players")
pnl:ControlHelp("Enable or disable effect for players.")
pnl:CheckBox("NPCs", "fedhoria_npcs")
pnl:ControlHelp("Enable or disable effect for NPCs.")
pnl:Help(" ") pnl:Help(" ")
pnl:NumSlider("Stumble time", "fedhoria_stumble_time", 0, 10, 3) pnl:NumSlider("Stumble time", "zcnpci_stumble_time", 0, 10, 3)
pnl:ControlHelp("How long the ragdoll should stumble for.") pnl:ControlHelp("How long the ragdoll should stumble for.")
pnl:NumSlider("Die time", "fedhoria_dietime", 0, 10, 3) pnl:NumSlider("Wound grab chance", "zcnpci_woundgrab_chance", 0, 1, 3)
pnl:ControlHelp("How long before the ragdoll dies after drowning/being still for too long.")
pnl:NumSlider("Die time variation", "fedhoria_dietime_variation", 0, 10, 2)
pnl:ControlHelp("A random number between 0 and the value you choose here will be added to the die timer.")
pnl:NumSlider("Wound grab chance", "fedhoria_woundgrab_chance", 0, 1, 3)
pnl:ControlHelp("The chance the ragdoll will grab it's wound when shot.") pnl:ControlHelp("The chance the ragdoll will grab it's wound when shot.")
pnl:NumSlider("Wound grab time", "fedhoria_woundgrab_time", 0, 10, 3) pnl:NumSlider("Wound grab time", "zcnpci_woundgrab_time", 0, 10, 3)
pnl:ControlHelp("How long the ragdoll should hold its wound.") pnl:ControlHelp("How long the ragdoll should hold its wound.")
pnl:Help(" ") pnl:Help(" ")
pnl:NumSlider("Activation range", "fedhoria_active_range", 0, 5000, 0) pnl:NumSlider("Activation range", "zcnpci_active_range", 0, 5000, 0)
pnl:ControlHelp("How close the ragdoll has to be to a player to have euphoria physics") pnl:ControlHelp("How close the ragdoll has to be to a player to have euphoria physics")
pnl:CheckBox("Always activate on player kill", "fedhoria_always_active_on_player_kill") pnl:CheckBox("Always activate on player kill", "zcnpci_always_active_on_player_kill")
pnl:ControlHelp("If on, all player-killed ragdolls will be activated regardless of other factors.") pnl:ControlHelp("If on, all player-killed ragdolls will be activated regardless of other factors.")
end end
if engine.ActiveGamemode() == "sandbox" then if engine.ActiveGamemode() == "sandbox" then
hook.Add("AddToolMenuCategories", "FedhoriaCategory", function() hook.Add("AddToolMenuCategories", "ZCNPCICategory", function()
spawnmenu.AddToolCategory("Utilities", "Fedhoria", "Fedhoria") spawnmenu.AddToolCategory("Utilities", "zcnpci", "Z-City NPCi")
end) end)
hook.Add("PopulateToolMenu", "FedhoriaMenuSettings", function() hook.Add("PopulateToolMenu", "ZCNPCIMenuSettings", function()
spawnmenu.AddToolMenuOption("Utilities", "Fedhoria", "FedhoriaSettings", "Settings", "", "", function(pnl) spawnmenu.AddToolMenuOption("Utilities", "zcnpci", "RagdollSettings", "Ragdoll", "", "", function(pnl)
pnl:ClearControls() pnl:ClearControls()
PopulateSBXToolMenu(pnl) PopulateRagdollSBXToolMenu(pnl)
end) end)
end) end)
end end

View file

@ -1,20 +1,18 @@
include("fedhoria/modules.lua") include("zcnpci/modules.lua")
local enabled = CreateConVar("fedhoria_enabled", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local enabled = CreateConVar("zcnpci_enabled", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local players = CreateConVar("fedhoria_players", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local active_range = CreateConVar("zcnpci_active_range", 300, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local npcs = CreateConVar("fedhoria_npcs", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local always_active_on_player_kill = CreateConVar("zcnpci_always_active_on_player_kill", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local active_range = CreateConVar("fedhoria_active_range", 300, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local always_active_on_player_kill = CreateConVar("fedhoria_always_active_on_player_kill", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local last_dmgpos = {} local last_dmgpos = {}
local last_hitgroup = {} local last_hitgroup = {}
local last_attacker = {} local last_attacker = {}
hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll) hook.Add("CreateEntityRagdoll", "zcnpci", function(ent, ragdoll)
if (!enabled:GetBool() or !npcs:GetBool()) then return end if !ent.organism then return end
local dmgpos = last_dmgpos[ent]
if last_hitgroup[ent] == HITGROUP_HEAD then return end if !enabled:GetBool() then return end
local dmgpos = last_dmgpos[ent]
local active_by_default = false local active_by_default = false
@ -41,10 +39,6 @@ hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll)
if !in_range then return end if !in_range then return end
end end
print(dmgpos)
local phys_bone, lpos local phys_bone, lpos
if dmgpos then if dmgpos then
@ -56,25 +50,26 @@ hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll)
end end
timer.Simple(0, function() timer.Simple(0, function()
ragdoll.organism.alive = true
if !IsValid(ragdoll) then return end if !IsValid(ragdoll) then return end
fedhoria.StartModule(ragdoll, "stumble_legs", phys_bone, lpos) zcnpci.StartModule(ragdoll, "stumble_legs", phys_bone, lpos)
last_dmgpos[ent] = nil last_dmgpos[ent] = nil
end) end)
end) end)
hook.Add("EntityTakeDamage", "Fedhoria", function(ent, dmginfo) hook.Add("EntityTakeDamage", "zcnpci", function(ent, dmginfo)
if (!enabled:GetBool() or !npcs:GetBool()) then return end if !enabled:GetBool() then return end
if (!ent:IsNPC() or dmginfo:GetDamage() < ent:Health()) then return end if (!ent:IsNPC() or dmginfo:GetDamage() < ent:Health()) then return end
last_dmgpos[ent] = dmginfo:GetDamagePosition() last_dmgpos[ent] = dmginfo:GetDamagePosition()
last_attacker[ent] = dmginfo:GetAttacker() last_attacker[ent] = dmginfo:GetAttacker()
end) end)
hook.Add("ScaleNPCDamage", "Fedhoria", function(npc, hitgroup, dmginfo) hook.Add("ScaleNPCDamage", "zcnpci", function(npc, hitgroup, dmginfo)
if not IsValid(npc) then return end if not IsValid(npc) then return end
last_hitgroup[npc] = hitgroup last_hitgroup[npc] = hitgroup
print(last_hitgroup[npc] == HITGROUP_HEAD)
end) end)
--[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor) --[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor)
@ -87,7 +82,7 @@ end)]]
local once = true local once = true
--RagMod/TTT support --RagMod/TTT support
hook.Add("OnEntityCreated", "Fedhoria", function(ent) --[[hook.Add("OnEntityCreated", "Fedhoria", function(ent)
--If RagMod isn't installed remove this hook --If RagMod isn't installed remove this hook
if once then if once then
once = nil once = nil
@ -123,7 +118,7 @@ hook.Add("OnEntityCreated", "Fedhoria", function(ent)
end end
end end
end) end)
end) end)]]
local PLAYER = FindMetaTable("Player") local PLAYER = FindMetaTable("Player")
@ -168,11 +163,13 @@ local function GetRagdollEntity(self)
return dolls[self] or NULL return dolls[self] or NULL
end end
--[[
if enabled:GetBool() then if enabled:GetBool() then
PLAYER.CreateRagdoll = CreateRagdoll PLAYER.CreateRagdoll = CreateRagdoll
PLAYER.GetRagdollEntity = GetRagdollEntity PLAYER.GetRagdollEntity = GetRagdollEntity
end end]]
--[[
cvars.AddChangeCallback("fedhoria_enabled", function(name, old, new) cvars.AddChangeCallback("fedhoria_enabled", function(name, old, new)
if (new == "1") then if (new == "1") then
if players:GetBool() then if players:GetBool() then
@ -197,23 +194,4 @@ cvars.AddChangeCallback("fedhoria_players", function(name, old, new)
PLAYER.CreateRagdoll = oldCreateRagdoll PLAYER.CreateRagdoll = oldCreateRagdoll
PLAYER.GetRagdollEntity = oldGetRagdollEntity PLAYER.GetRagdollEntity = oldGetRagdollEntity
end end
end) end)]]
hook.Add("PostPlayerDeath", "Fedhoria", function(ply)
if (!enabled:GetBool() or !players:GetBool()) then return end
timer.Simple(0, function()
if !IsValid(ply) then return end
local ragdoll = ply:GetRagdollEntity()
if (IsValid(ragdoll) and ragdoll:IsRagdoll()) then
fedhoria.StartModule(ragdoll, "stumble_legs")
end
end)
end)
--RagMod Reworked support
hook.Add("RM_RagdollReady", "Fedhoria", function(ragdoll)
if IsValid(ragdoll) then
fedhoria.StartModule(ragdoll, "stumble_legs")
end
end)

View file

@ -1,14 +1,14 @@
fedhoria = {} zcnpci = {}
local modules = {} local modules = {}
function fedhoria.GetModule(name) function zcnpci.GetModule(name)
if modules[name] then if modules[name] then
return modules[name] return modules[name]
end end
local path = "fedhoria/modules/"..name..".lua" local path = "zcnpci/modules/"..name..".lua"
if !file.Exists(path, "LUA") then if !file.Exists(path, "LUA") then
print("fedhoria.GetModule failed, couldn't find module '"..name.."'") print("zcnpci.GetModule failed, couldn't find module '"..name.."'")
return return
end end
local MODULE_old = MODULE local MODULE_old = MODULE
@ -20,12 +20,12 @@ function fedhoria.GetModule(name)
return modules[name] return modules[name]
end end
function fedhoria.GetModuleList() function zcnpci.GetModuleList()
return modules return modules
end end
function fedhoria.StartModule(ent, name, ...) function zcnpci.StartModule(ent, name, ...)
if (!modules[name] and !fedhoria.GetModule(name)) then if (!modules[name] and !zcnpci.GetModule(name)) then
return false return false
end end
local contr = ents.Create("active_ragdoll_controller") local contr = ents.Create("active_ragdoll_controller")
@ -38,8 +38,8 @@ function fedhoria.StartModule(ent, name, ...)
end end
--preload modules --preload modules
for _, file_name in pairs(file.Find("fedhoria/modules/*.lua", "LUA")) do for _, file_name in pairs(file.Find("zcnpci/modules/*.lua", "LUA")) do
fedhoria.GetModule(file_name:sub(1, -5)) zcnpci.GetModule(file_name:sub(1, -5))
end end
local ENTITY = FindMetaTable("Entity") local ENTITY = FindMetaTable("Entity")

View file

@ -55,22 +55,18 @@ local VectorRand = VectorRand
Convars (Settings) Convars (Settings)
---------------------------------------------------------------------------]] ---------------------------------------------------------------------------]]
-- Twitching -- Twitching
local cv_twitch_enabled = CreateConVar("fedhoria_falling_twitch_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить дергание для падающих ног") local cv_twitch_enabled = CreateConVar("zcnpci_falling_twitch_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить дергание для падающих ног")
local cv_twitch_interval_min = CreateConVar("fedhoria_falling_twitch_interval_min", "3", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Минимальный интервал между дерганиями (сек)") local cv_twitch_interval_min = CreateConVar("zcnpci_falling_twitch_interval_min", "3", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Минимальный интервал между дерганиями (сек)")
local cv_twitch_interval_max = CreateConVar("fedhoria_falling_twitch_interval_max", "6", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Максимальный интервал между дерганиями (сек)") local cv_twitch_interval_max = CreateConVar("zcnpci_falling_twitch_interval_max", "6", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Максимальный интервал между дерганиями (сек)")
local cv_twitch_force_min = CreateConVar("fedhoria_falling_twitch_min", "100", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. угловая скорость для дергания") local cv_twitch_force_min = CreateConVar("zcnpci_falling_twitch_min", "100", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. угловая скорость для дергания")
local cv_twitch_force_max = CreateConVar("fedhoria_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания") local cv_twitch_force_max = CreateConVar("zcnpci_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
-- Roll -- Roll
local cv_anim_roll_enabled = CreateConVar("fedhoria_falling_anim_roll_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить анимацию при ударе о землю") local cv_anim_roll_enabled = CreateConVar("zcnpci_falling_anim_roll_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить анимацию при ударе о землю")
local cv_anim_roll_min_delay = CreateConVar("fedhoria_falling_anim_roll_min_delay", "0.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. задержка перед возможной анимацией после удара (сек)") local cv_anim_roll_min_delay = CreateConVar("zcnpci_falling_anim_roll_min_delay", "0.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. задержка перед возможной анимацией после удара (сек)")
local cv_anim_roll_duration = CreateConVar("fedhoria_falling_anim_roll_duration", "3.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Продолжительность принудительной анимации (сек)") local cv_anim_roll_duration = CreateConVar("zcnpci_falling_anim_roll_duration", "3.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Продолжительность принудительной анимации (сек)")
local cv_anim_roll_impact_threshold = CreateConVar("fedhoria_falling_anim_roll_impact_threshold", "300", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. скорость удара для запуска анимации") local cv_anim_roll_impact_threshold = CreateConVar("zcnpci_falling_anim_roll_impact_threshold", "300", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. скорость удара для запуска анимации")
local cv_anim_roll_playback_rate = CreateConVar("fedhoria_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации") local cv_anim_roll_playback_rate = CreateConVar("zcnpci_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации")
-- Death timer
local die_time = CreateConVar("fedhoria_dietime", 5, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local die_time_variation = CreateConVar("fedhoria_dietime_variation", 3, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
--[[------------------------------------------------------------------------- --[[-------------------------------------------------------------------------
Tug function Tug function
@ -235,9 +231,9 @@ function MODULE:PhysicsSimulate(phys, dt)
-- Logic for the disappearance timer -- Logic for the disappearance timer
local f = 1 -- Force multiplier (default: 1) local f = 1 -- Force multiplier (default: 1)
if self.StartDie then --[[if self.StartDie then
f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1) f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1)
end end]]
-- Support for RagMod -- Support for RagMod
if ragmod and ragmod:IsRagmodRagdoll(target) then if ragmod and ragmod:IsRagmodRagdoll(target) then
@ -248,9 +244,16 @@ function MODULE:PhysicsSimulate(phys, dt)
if f <= 0 then self.AnimationRollEndTime = 0 end if f <= 0 then self.AnimationRollEndTime = 0 end
end end
-- Deletion if the time-to-live has expired if !target or !target.organism then
if (f <= 0) then
self:Remove() self:Remove()
return false -- Cut the bullshit
end
if (!target.organism.alive) then
-- If the NPC is dead, they probably aren't coming back; don't bother bringing them back to life
self:Remove()
return false -- Cut the bullshit
elseif (target.organism.consciousness <= 0.3) then
return false return false
end end

View file

@ -21,24 +21,20 @@ local table_HasValue = table.HasValue
local hand_offset = Vector(2, 0, 0) local hand_offset = Vector(2, 0, 0)
-- Twitch -- Twitching
local cv_twitch_enabled = CreateConVar("fedhoria_falling_twitch_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить дергание для падающих торсов") local cv_twitch_enabled = CreateConVar("zcnpci_falling_twitch_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить дергание для падающих ног")
local cv_twitch_interval_min = CreateConVar("fedhoria_falling_twitch_interval_min", "3", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Минимальный интервал между дерганиями (сек)") local cv_twitch_interval_min = CreateConVar("zcnpci_falling_twitch_interval_min", "3", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Минимальный интервал между дерганиями (сек)")
local cv_twitch_interval_max = CreateConVar("fedhoria_falling_twitch_interval_max", "6", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Максимальный интервал между дерганиями (сек)") local cv_twitch_interval_max = CreateConVar("zcnpci_falling_twitch_interval_max", "6", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Максимальный интервал между дерганиями (сек)")
local cv_twitch_force_min = CreateConVar("fedhoria_falling_twitch_min", "100", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. угловая скорость для дергания") local cv_twitch_force_min = CreateConVar("zcnpci_falling_twitch_min", "100", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. угловая скорость для дергания")
local cv_twitch_force_max = CreateConVar("fedhoria_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания") local cv_twitch_force_max = CreateConVar("zcnpci_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
local ignore_bone_indices_twitch = {0} -- игнор нахуй
-- Roll -- Roll
local cv_anim_roll_enabled = CreateConVar("fedhoria_falling_anim_roll_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить анимацию 'idleonfire' при ударе о землю") local cv_anim_roll_enabled = CreateConVar("zcnpci_falling_anim_roll_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить анимацию при ударе о землю")
local cv_anim_roll_min_delay = CreateConVar("fedhoria_falling_anim_roll_min_delay", "0.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. задержка перед возможной анимацией после удара (сек)") local cv_anim_roll_min_delay = CreateConVar("zcnpci_falling_anim_roll_min_delay", "0.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. задержка перед возможной анимацией после удара (сек)")
local cv_anim_roll_duration = CreateConVar("fedhoria_falling_anim_roll_duration", "3.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Продолжительность принудительной анимации 'idleonfire' (сек)") local cv_anim_roll_duration = CreateConVar("zcnpci_falling_anim_roll_duration", "3.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Продолжительность принудительной анимации (сек)")
local cv_anim_roll_impact_threshold = CreateConVar("fedhoria_falling_anim_roll_impact_threshold", "300", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. скорость удара для запуска анимации") local cv_anim_roll_impact_threshold = CreateConVar("zcnpci_falling_anim_roll_impact_threshold", "300", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Мин. скорость удара для запуска анимации")
local cv_anim_roll_playback_rate = CreateConVar("fedhoria_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации 'idleonfire'") local cv_anim_roll_playback_rate = CreateConVar("zcnpci_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации")
-- Death timer
local die_time = CreateConVar("fedhoria_dietime", 5, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local die_time_variation = CreateConVar("fedhoria_dietime_variation", 3, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
-- Do it! -- Do it!
@ -188,11 +184,9 @@ function MODULE:PhysicsSimulate(phys, dt)
-- логика для таймера -- логика для таймера
local f = 1 -- сила есть ума не надо (по умолчанию 1) local f = 1 -- сила есть ума не надо (по умолчанию 1)
if self.StartDie then --[[if self.StartDie then
f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1) f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1)
end end]]
print(f)
-- ебаная логика для regmod -- ебаная логика для regmod
if ragmod and ragmod:IsRagmodRagdoll(target) then if ragmod and ragmod:IsRagmodRagdoll(target) then
@ -204,11 +198,17 @@ function MODULE:PhysicsSimulate(phys, dt)
if f <= 0 then self.AnimationRollEndTime = 0 end if f <= 0 then self.AnimationRollEndTime = 0 end
end end
-- if !target or !target.organism then
if (f <= 0) then
-- print("[Fedhoria Sim] Removing entity (f <= 0)") -- Debug
self:Remove() self:Remove()
return false -- Прекращаем хуйню return false -- Cut the bullshit
end
if (!target.organism.alive) then
-- If the NPC is dead, they probably aren't coming back; don't bother bringing them back to life
self:Remove()
return false -- Cut the bullshit
elseif (target.organism.consciousness <= 0.3) then
return false
end end
local phys_bone_id = phys:GetID() -- айди кости local phys_bone_id = phys:GetID() -- айди кости

View file

@ -18,9 +18,9 @@ MODULE.BoneList =
"ValveBiped.Bip01_L_Foot" "ValveBiped.Bip01_L_Foot"
} }
local stumble_time = CreateConVar("fedhoria_stumble_time", 2, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local stumble_time = CreateConVar("zcnpci_stumble_time", 2, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local grab_chance = CreateConVar("fedhoria_woundgrab_chance", 0.9, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local grab_chance = CreateConVar("zcnpci_woundgrab_chance", 0.9, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local grab_time = CreateConVar("fedhoria_woundgrab_time", 5, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local grab_time = CreateConVar("zcnpci_woundgrab_time", 5, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local math_atan2 = math.atan2 local math_atan2 = math.atan2
local math_pi = math.pi local math_pi = math.pi
@ -223,8 +223,8 @@ function MODULE:Init(phys_bone, lpos)
end end
local function DoFallingAnim(ent) local function DoFallingAnim(ent)
local mod1 = fedhoria.StartModule(ent, "falling_legs") local mod1 = zcnpci.StartModule(ent, "falling_legs")
local mod2 = fedhoria.StartModule(ent, "falling_torso") local mod2 = zcnpci.StartModule(ent, "falling_torso")
end end
function MODULE:OnRemove() function MODULE:OnRemove()