Compare commits
3 commits
9511bf3a82
...
bd83f1db26
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd83f1db26 | ||
|
|
439e152b19 | ||
|
|
89c31dec61 |
8 changed files with 176 additions and 139 deletions
20
README.md
20
README.md
|
|
@ -1,18 +1,20 @@
|
||||||
# Z-City NPC Integration
|
# Z-City NPC Integration
|
||||||
|
|
||||||
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.
|
Adds better NPC integration for the Garry's Mod addon Z-City. While Z-City has a convar that enables the custom health system on NPCs, it really isn't the best or most advanced thing in the world. This has irritated me since I first started using Z-City. Therefore, I've decided to take care of the problem myself with my own plugin.
|
||||||
|
|
||||||
Some ideas:
|
- NPCs can now be alive while ragdolled, and can move around in that state.
|
||||||
|
- NPCs can collapse due to unconsciousness or pain.
|
||||||
|
- NPCs can get back up after being ragdolled.
|
||||||
|
|
||||||
- If an enemy breaks a leg, slow them down.
|
This plugin is based off of Kazarei's Euphoria, which in turn is a fork of Fedhoria by Rama.
|
||||||
- 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.
|
|
||||||
|
|
||||||
Since theoretically the NPCs use the same health system that players use, these shouldn't be too hard to implement.
|
## Incompatibilities
|
||||||
|
|
||||||
More optimistic ideas:
|
- Any mod that modifies the behavior of death ragdolls (Reagdoll, Artagdoll, Fedhoria)
|
||||||
|
|
||||||
|
## Future plans
|
||||||
|
|
||||||
|
No guarantees any of this will become real.
|
||||||
|
|
||||||
- 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.
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,39 @@
|
||||||
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 try to 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:NumSlider("Minimum down time", "zcnpci_down_time", 0, 20, 3)
|
||||||
|
pnl:ControlHelp("The minimum amount of time the ragdoll should be down before trying to get back up.")
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -55,26 +49,54 @@ hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ragdoll.class_in_previous_life = ent:GetClass()
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
hook.Add("Think", "zcnpci", function()
|
||||||
|
for i, ent in pairs(ents.GetAll()) do
|
||||||
|
if !IsValid(ent) then continue end
|
||||||
|
if !ent:IsNPC() then continue end
|
||||||
|
if !ent.organism then continue end
|
||||||
|
|
||||||
|
-- Knock them down if something is off
|
||||||
|
if (
|
||||||
|
((ent.organism.lleg >= 1) and (ent.organism.rleg >= 1)) or
|
||||||
|
ent.organism.llegamputated or
|
||||||
|
ent.organism.rlegamputated or
|
||||||
|
(ent.organism.consciousness <= 0.3) or
|
||||||
|
(ent.organism.pain > 90)
|
||||||
|
) then
|
||||||
|
local damage_info = DamageInfo()
|
||||||
|
damage_info:SetDamage(ent:Health())
|
||||||
|
damage_info:SetAttacker(ent)
|
||||||
|
damage_info:SetDamageType( DMG_DIRECT )
|
||||||
|
damage_info:SetDamageForce(Vector(0, 0, 0))
|
||||||
|
|
||||||
|
ent:TakeDamageInfo(damage_info)
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor)
|
--[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor)
|
||||||
|
|
@ -87,7 +109,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 +145,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 +190,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 +221,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)
|
|
||||||
|
|
@ -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")
|
||||||
|
|
@ -55,22 +55,21 @@ 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
|
-- Down time
|
||||||
local die_time = CreateConVar("fedhoria_dietime", 5, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
|
local minimum_down_time = CreateConVar("zcnpci_down_time", "5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Down time!!!!!!!!!")
|
||||||
local die_time_variation = CreateConVar("fedhoria_dietime_variation", 3, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
|
|
||||||
|
|
||||||
--[[-------------------------------------------------------------------------
|
--[[-------------------------------------------------------------------------
|
||||||
Tug function
|
Tug function
|
||||||
|
|
@ -161,6 +160,7 @@ function MODULE:Init()
|
||||||
self.LastGroundCollideTime = 0
|
self.LastGroundCollideTime = 0
|
||||||
self.StartDie = nil
|
self.StartDie = nil
|
||||||
self.AnimationRollEndTime = 0
|
self.AnimationRollEndTime = 0
|
||||||
|
self.StopProcessing = false
|
||||||
|
|
||||||
-- Add damping to all bones.
|
-- Add damping to all bones.
|
||||||
local phys = self:GetPhysicsObject()
|
local phys = self:GetPhysicsObject()
|
||||||
|
|
@ -223,10 +223,14 @@ end
|
||||||
Physics Simulation Hook (FIXED)
|
Physics Simulation Hook (FIXED)
|
||||||
---------------------------------------------------------------------------]]
|
---------------------------------------------------------------------------]]
|
||||||
function MODULE:PhysicsSimulate(phys, dt)
|
function MODULE:PhysicsSimulate(phys, dt)
|
||||||
|
if self.StopProcessing then return false end
|
||||||
|
|
||||||
local cur_time = CurTime()
|
local cur_time = CurTime()
|
||||||
local target = self:GetTarget()
|
local target = self:GetTarget()
|
||||||
if not IsValid(target) then self:Remove(); return false end
|
if not IsValid(target) then self:Remove(); return false end
|
||||||
|
|
||||||
|
if !self.StartDie then self.StartDie = cur_time end
|
||||||
|
|
||||||
-- Check for active animation
|
-- Check for active animation
|
||||||
if cur_time < self.AnimationRollEndTime then
|
if cur_time < self.AnimationRollEndTime then
|
||||||
--self.StartDie = nil -- Resetting the "death" timer
|
--self.StartDie = nil -- Resetting the "death" timer
|
||||||
|
|
@ -235,22 +239,56 @@ 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)
|
||||||
|
|
||||||
|
local minimum_down_timer = 0
|
||||||
if self.StartDie then
|
if self.StartDie then
|
||||||
f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1)
|
minimum_down_timer = math_Clamp((cur_time - self.StartDie) / minimum_down_time:GetFloat(), 0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Support for RagMod
|
if !target.organism then
|
||||||
if ragmod and ragmod:IsRagmodRagdoll(target) then
|
|
||||||
local owner = target:GetOwningPlayer()
|
|
||||||
f = (IsValid(owner) and owner:Alive()) and 1 or 0
|
|
||||||
--self.StartDie = nil
|
|
||||||
|
|
||||||
if f <= 0 then self.AnimationRollEndTime = 0 end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Deletion if the time-to-live has expired
|
|
||||||
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) or ((target.organism.lleg >= 1) and (target.organism.rleg >= 1)) then
|
||||||
|
self.StartDie = cur_time
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Getting up
|
||||||
|
-- Don't need to check for consciousness and the like because we've done it already above
|
||||||
|
if (
|
||||||
|
(minimum_down_timer >= 1.0) and
|
||||||
|
(target.class_in_previous_life != nil) and
|
||||||
|
!(target.organism.llegamputated or target.organism.rlegamputated or target.organism.larmamputated or target.organism.rarmamputated) and
|
||||||
|
(target.organism.pain <= 80)
|
||||||
|
) then
|
||||||
|
local ent = ents.Create(target.class_in_previous_life)
|
||||||
|
ent:SetPos(target:GetPos())
|
||||||
|
ent:SetModel(target:GetModel())
|
||||||
|
|
||||||
|
if target:GetNumBodyGroups() > 0 then
|
||||||
|
local i = 1
|
||||||
|
while (i <= target:GetNumBodyGroups()) do
|
||||||
|
ent:SetBodygroup(i, target:GetBodygroup(i))
|
||||||
|
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ent:Spawn()
|
||||||
|
|
||||||
|
ent.organism = table.Copy(target.organism)
|
||||||
|
ent.organism.owner = ent
|
||||||
|
|
||||||
|
self.StopProcessing = true
|
||||||
|
|
||||||
|
self:Remove()
|
||||||
|
target:Remove()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -21,25 +21,22 @@ 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})
|
|
||||||
|
|
||||||
|
-- Down time
|
||||||
|
local minimum_down_time = CreateConVar("zcnpci_down_time", "5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Down time!!!!!!!!!")
|
||||||
|
|
||||||
-- Do it!
|
-- Do it!
|
||||||
function MODULE:DoTwitch()
|
function MODULE:DoTwitch()
|
||||||
|
|
@ -188,11 +185,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 +199,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() -- айди кости
|
||||||
|
|
@ -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()
|
||||||
Loading…
Reference in a new issue