Compare commits
No commits in common. "bd83f1db26e1c7bc7d190fc3e7f1dce1a8983df1" and "9511bf3a8293d66567345d2f11e7503bf2e283d7" have entirely different histories.
bd83f1db26
...
9511bf3a82
8 changed files with 137 additions and 174 deletions
20
README.md
20
README.md
|
|
@ -1,20 +1,18 @@
|
|||
# Z-City NPC Integration
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
- 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.
|
||||
Some ideas:
|
||||
|
||||
This plugin is based off of Kazarei's Euphoria, which in turn is a fork of Fedhoria by Rama.
|
||||
- If an enemy breaks a leg, slow them down.
|
||||
- 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.
|
||||
|
||||
## Incompatibilities
|
||||
Since theoretically the NPCs use the same health system that players use, these shouldn't be too hard to implement.
|
||||
|
||||
- Any mod that modifies the behavior of death ragdolls (Reagdoll, Artagdoll, Fedhoria)
|
||||
|
||||
## Future plans
|
||||
|
||||
No guarantees any of this will become real.
|
||||
More optimistic ideas:
|
||||
|
||||
- NPCs will back out of combat when injured.
|
||||
- Friendly NPCs can heal each other.
|
||||
|
|
|
|||
|
|
@ -1,39 +1,48 @@
|
|||
local function PopulateRagdollSBXToolMenu(pnl)
|
||||
pnl:CheckBox("Enabled", "zcnpci_enabled")
|
||||
local function PopulateSBXToolMenu(pnl)
|
||||
pnl:CheckBox("Enabled", "fedhoria_enabled")
|
||||
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:NumSlider("Stumble time", "zcnpci_stumble_time", 0, 10, 3)
|
||||
pnl:ControlHelp("How long the ragdoll should try to stumble for.")
|
||||
pnl:NumSlider("Stumble time", "fedhoria_stumble_time", 0, 10, 3)
|
||||
pnl:ControlHelp("How long the ragdoll should stumble for.")
|
||||
|
||||
pnl:NumSlider("Wound grab chance", "zcnpci_woundgrab_chance", 0, 1, 3)
|
||||
pnl:NumSlider("Die time", "fedhoria_dietime", 0, 10, 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:NumSlider("Wound grab time", "zcnpci_woundgrab_time", 0, 10, 3)
|
||||
pnl:NumSlider("Wound grab time", "fedhoria_woundgrab_time", 0, 10, 3)
|
||||
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:NumSlider("Activation range", "zcnpci_active_range", 0, 5000, 0)
|
||||
pnl:NumSlider("Activation range", "fedhoria_active_range", 0, 5000, 0)
|
||||
pnl:ControlHelp("How close the ragdoll has to be to a player to have euphoria physics")
|
||||
|
||||
pnl:CheckBox("Always activate on player kill", "zcnpci_always_active_on_player_kill")
|
||||
pnl:CheckBox("Always activate on player kill", "fedhoria_always_active_on_player_kill")
|
||||
pnl:ControlHelp("If on, all player-killed ragdolls will be activated regardless of other factors.")
|
||||
end
|
||||
|
||||
if engine.ActiveGamemode() == "sandbox" then
|
||||
hook.Add("AddToolMenuCategories", "ZCNPCICategory", function()
|
||||
spawnmenu.AddToolCategory("Utilities", "zcnpci", "Z-City NPCi")
|
||||
hook.Add("AddToolMenuCategories", "FedhoriaCategory", function()
|
||||
spawnmenu.AddToolCategory("Utilities", "Fedhoria", "Fedhoria")
|
||||
end)
|
||||
|
||||
hook.Add("PopulateToolMenu", "ZCNPCIMenuSettings", function()
|
||||
spawnmenu.AddToolMenuOption("Utilities", "zcnpci", "RagdollSettings", "Ragdoll", "", "", function(pnl)
|
||||
hook.Add("PopulateToolMenu", "FedhoriaMenuSettings", function()
|
||||
spawnmenu.AddToolMenuOption("Utilities", "Fedhoria", "FedhoriaSettings", "Settings", "", "", function(pnl)
|
||||
pnl:ClearControls()
|
||||
PopulateRagdollSBXToolMenu(pnl)
|
||||
PopulateSBXToolMenu(pnl)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
|
@ -1,19 +1,21 @@
|
|||
include("zcnpci/modules.lua")
|
||||
include("fedhoria/modules.lua")
|
||||
|
||||
local enabled = CreateConVar("zcnpci_enabled", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
|
||||
local active_range = CreateConVar("zcnpci_active_range", 300, 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 enabled = CreateConVar("fedhoria_enabled", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
|
||||
local players = CreateConVar("fedhoria_players", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
|
||||
local npcs = CreateConVar("fedhoria_npcs", 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_hitgroup = {}
|
||||
local last_attacker = {}
|
||||
|
||||
hook.Add("CreateEntityRagdoll", "zcnpci", function(ent, ragdoll)
|
||||
if !ent.organism then return end
|
||||
|
||||
if !enabled:GetBool() then return end
|
||||
hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll)
|
||||
if (!enabled:GetBool() or !npcs:GetBool()) then return end
|
||||
local dmgpos = last_dmgpos[ent]
|
||||
|
||||
if last_hitgroup[ent] == HITGROUP_HEAD then return end
|
||||
|
||||
local active_by_default = false
|
||||
|
||||
if always_active_on_player_kill:GetBool() then
|
||||
|
|
@ -39,6 +41,10 @@ hook.Add("CreateEntityRagdoll", "zcnpci", function(ent, ragdoll)
|
|||
if !in_range then return end
|
||||
end
|
||||
|
||||
|
||||
|
||||
print(dmgpos)
|
||||
|
||||
local phys_bone, lpos
|
||||
|
||||
if dmgpos then
|
||||
|
|
@ -49,54 +55,26 @@ hook.Add("CreateEntityRagdoll", "zcnpci", function(ent, ragdoll)
|
|||
end
|
||||
end
|
||||
|
||||
ragdoll.class_in_previous_life = ent:GetClass()
|
||||
|
||||
timer.Simple(0, function()
|
||||
ragdoll.organism.alive = true
|
||||
|
||||
if !IsValid(ragdoll) then return end
|
||||
|
||||
zcnpci.StartModule(ragdoll, "stumble_legs", phys_bone, lpos)
|
||||
fedhoria.StartModule(ragdoll, "stumble_legs", phys_bone, lpos)
|
||||
last_dmgpos[ent] = nil
|
||||
end)
|
||||
end)
|
||||
|
||||
hook.Add("EntityTakeDamage", "zcnpci", function(ent, dmginfo)
|
||||
if !enabled:GetBool() then return end
|
||||
hook.Add("EntityTakeDamage", "Fedhoria", function(ent, dmginfo)
|
||||
if (!enabled:GetBool() or !npcs:GetBool()) then return end
|
||||
if (!ent:IsNPC() or dmginfo:GetDamage() < ent:Health()) then return end
|
||||
|
||||
last_dmgpos[ent] = dmginfo:GetDamagePosition()
|
||||
last_attacker[ent] = dmginfo:GetAttacker()
|
||||
end)
|
||||
|
||||
hook.Add("ScaleNPCDamage", "zcnpci", function(npc, hitgroup, dmginfo)
|
||||
hook.Add("ScaleNPCDamage", "Fedhoria", function(npc, hitgroup, dmginfo)
|
||||
if not IsValid(npc) then return end
|
||||
last_hitgroup[npc] = hitgroup
|
||||
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
|
||||
print(last_hitgroup[npc] == HITGROUP_HEAD)
|
||||
end)
|
||||
|
||||
--[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor)
|
||||
|
|
@ -109,7 +87,7 @@ end)]]
|
|||
local once = true
|
||||
|
||||
--RagMod/TTT support
|
||||
--[[hook.Add("OnEntityCreated", "Fedhoria", function(ent)
|
||||
hook.Add("OnEntityCreated", "Fedhoria", function(ent)
|
||||
--If RagMod isn't installed remove this hook
|
||||
if once then
|
||||
once = nil
|
||||
|
|
@ -145,7 +123,7 @@ local once = true
|
|||
end
|
||||
end
|
||||
end)
|
||||
end)]]
|
||||
end)
|
||||
|
||||
local PLAYER = FindMetaTable("Player")
|
||||
|
||||
|
|
@ -190,13 +168,11 @@ local function GetRagdollEntity(self)
|
|||
return dolls[self] or NULL
|
||||
end
|
||||
|
||||
--[[
|
||||
if enabled:GetBool() then
|
||||
PLAYER.CreateRagdoll = CreateRagdoll
|
||||
PLAYER.GetRagdollEntity = GetRagdollEntity
|
||||
end]]
|
||||
end
|
||||
|
||||
--[[
|
||||
cvars.AddChangeCallback("fedhoria_enabled", function(name, old, new)
|
||||
if (new == "1") then
|
||||
if players:GetBool() then
|
||||
|
|
@ -221,4 +197,23 @@ cvars.AddChangeCallback("fedhoria_players", function(name, old, new)
|
|||
PLAYER.CreateRagdoll = oldCreateRagdoll
|
||||
PLAYER.GetRagdollEntity = oldGetRagdollEntity
|
||||
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 @@
|
|||
zcnpci = {}
|
||||
fedhoria = {}
|
||||
|
||||
local modules = {}
|
||||
|
||||
function zcnpci.GetModule(name)
|
||||
function fedhoria.GetModule(name)
|
||||
if modules[name] then
|
||||
return modules[name]
|
||||
end
|
||||
local path = "zcnpci/modules/"..name..".lua"
|
||||
local path = "fedhoria/modules/"..name..".lua"
|
||||
if !file.Exists(path, "LUA") then
|
||||
print("zcnpci.GetModule failed, couldn't find module '"..name.."'")
|
||||
print("fedhoria.GetModule failed, couldn't find module '"..name.."'")
|
||||
return
|
||||
end
|
||||
local MODULE_old = MODULE
|
||||
|
|
@ -20,12 +20,12 @@ function zcnpci.GetModule(name)
|
|||
return modules[name]
|
||||
end
|
||||
|
||||
function zcnpci.GetModuleList()
|
||||
function fedhoria.GetModuleList()
|
||||
return modules
|
||||
end
|
||||
|
||||
function zcnpci.StartModule(ent, name, ...)
|
||||
if (!modules[name] and !zcnpci.GetModule(name)) then
|
||||
function fedhoria.StartModule(ent, name, ...)
|
||||
if (!modules[name] and !fedhoria.GetModule(name)) then
|
||||
return false
|
||||
end
|
||||
local contr = ents.Create("active_ragdoll_controller")
|
||||
|
|
@ -38,8 +38,8 @@ function zcnpci.StartModule(ent, name, ...)
|
|||
end
|
||||
|
||||
--preload modules
|
||||
for _, file_name in pairs(file.Find("zcnpci/modules/*.lua", "LUA")) do
|
||||
zcnpci.GetModule(file_name:sub(1, -5))
|
||||
for _, file_name in pairs(file.Find("fedhoria/modules/*.lua", "LUA")) do
|
||||
fedhoria.GetModule(file_name:sub(1, -5))
|
||||
end
|
||||
|
||||
local ENTITY = FindMetaTable("Entity")
|
||||
|
|
@ -55,21 +55,22 @@ local VectorRand = VectorRand
|
|||
Convars (Settings)
|
||||
---------------------------------------------------------------------------]]
|
||||
-- Twitching
|
||||
local cv_twitch_enabled = CreateConVar("zcnpci_falling_twitch_enabled", "1", {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("zcnpci_falling_twitch_interval_max", "6", {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("zcnpci_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
|
||||
local cv_twitch_enabled = CreateConVar("fedhoria_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_max = CreateConVar("fedhoria_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_max = CreateConVar("fedhoria_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
|
||||
|
||||
-- Roll
|
||||
local cv_anim_roll_enabled = CreateConVar("zcnpci_falling_anim_roll_enabled", "1", {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("zcnpci_falling_anim_roll_duration", "3.5", {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("zcnpci_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации")
|
||||
local cv_anim_roll_enabled = CreateConVar("fedhoria_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_duration = CreateConVar("fedhoria_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_playback_rate = CreateConVar("fedhoria_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации")
|
||||
|
||||
-- Down time
|
||||
local minimum_down_time = CreateConVar("zcnpci_down_time", "5", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Down time!!!!!!!!!")
|
||||
-- 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
|
||||
|
|
@ -160,7 +161,6 @@ function MODULE:Init()
|
|||
self.LastGroundCollideTime = 0
|
||||
self.StartDie = nil
|
||||
self.AnimationRollEndTime = 0
|
||||
self.StopProcessing = false
|
||||
|
||||
-- Add damping to all bones.
|
||||
local phys = self:GetPhysicsObject()
|
||||
|
|
@ -223,14 +223,10 @@ end
|
|||
Physics Simulation Hook (FIXED)
|
||||
---------------------------------------------------------------------------]]
|
||||
function MODULE:PhysicsSimulate(phys, dt)
|
||||
if self.StopProcessing then return false end
|
||||
|
||||
local cur_time = CurTime()
|
||||
local target = self:GetTarget()
|
||||
if not IsValid(target) then self:Remove(); return false end
|
||||
|
||||
if !self.StartDie then self.StartDie = cur_time end
|
||||
|
||||
-- Check for active animation
|
||||
if cur_time < self.AnimationRollEndTime then
|
||||
--self.StartDie = nil -- Resetting the "death" timer
|
||||
|
|
@ -239,56 +235,22 @@ function MODULE:PhysicsSimulate(phys, dt)
|
|||
|
||||
-- Logic for the disappearance timer
|
||||
local f = 1 -- Force multiplier (default: 1)
|
||||
|
||||
local minimum_down_timer = 0
|
||||
if self.StartDie then
|
||||
minimum_down_timer = math_Clamp((cur_time - self.StartDie) / minimum_down_time:GetFloat(), 0, 1)
|
||||
f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1)
|
||||
end
|
||||
|
||||
if !target.organism then
|
||||
self:Remove()
|
||||
return false -- Cut the bullshit
|
||||
-- Support for RagMod
|
||||
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
|
||||
|
||||
if (!target.organism.alive) then
|
||||
-- If the NPC is dead, they probably aren't coming back; don't bother bringing them back to life
|
||||
-- Deletion if the time-to-live has expired
|
||||
if (f <= 0) then
|
||||
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
|
||||
end
|
||||
|
||||
|
|
@ -21,22 +21,25 @@ local table_HasValue = table.HasValue
|
|||
|
||||
local hand_offset = Vector(2, 0, 0)
|
||||
|
||||
-- Twitching
|
||||
local cv_twitch_enabled = CreateConVar("zcnpci_falling_twitch_enabled", "1", {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("zcnpci_falling_twitch_interval_max", "6", {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("zcnpci_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
|
||||
-- Twitch
|
||||
local cv_twitch_enabled = CreateConVar("fedhoria_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_max = CreateConVar("fedhoria_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_max = CreateConVar("fedhoria_falling_twitch_max", "250", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Макс. угловая скорость для дергания")
|
||||
local ignore_bone_indices_twitch = {0} -- игнор нахуй
|
||||
|
||||
-- Roll
|
||||
local cv_anim_roll_enabled = CreateConVar("zcnpci_falling_anim_roll_enabled", "1", {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("zcnpci_falling_anim_roll_duration", "3.5", {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("zcnpci_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации")
|
||||
local cv_anim_roll_enabled = CreateConVar("fedhoria_falling_anim_roll_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Включить анимацию 'idleonfire' при ударе о землю")
|
||||
local cv_anim_roll_min_delay = CreateConVar("fedhoria_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_impact_threshold = CreateConVar("fedhoria_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'")
|
||||
|
||||
-- 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!
|
||||
function MODULE:DoTwitch()
|
||||
|
|
@ -185,9 +188,11 @@ function MODULE:PhysicsSimulate(phys, dt)
|
|||
|
||||
-- логика для таймера
|
||||
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)
|
||||
end]]
|
||||
end
|
||||
|
||||
print(f)
|
||||
|
||||
-- ебаная логика для regmod
|
||||
if ragmod and ragmod:IsRagmodRagdoll(target) then
|
||||
|
|
@ -199,17 +204,11 @@ function MODULE:PhysicsSimulate(phys, dt)
|
|||
if f <= 0 then self.AnimationRollEndTime = 0 end
|
||||
end
|
||||
|
||||
if !target or !target.organism then
|
||||
--
|
||||
if (f <= 0) then
|
||||
-- print("[Fedhoria Sim] Removing entity (f <= 0)") -- Debug
|
||||
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
|
||||
|
||||
local phys_bone_id = phys:GetID() -- айди кости
|
||||
|
|
@ -18,9 +18,9 @@ MODULE.BoneList =
|
|||
"ValveBiped.Bip01_L_Foot"
|
||||
}
|
||||
|
||||
local stumble_time = CreateConVar("zcnpci_stumble_time", 2, 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("zcnpci_woundgrab_time", 5, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
|
||||
local stumble_time = CreateConVar("fedhoria_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_time = CreateConVar("fedhoria_woundgrab_time", 5, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
|
||||
|
||||
local math_atan2 = math.atan2
|
||||
local math_pi = math.pi
|
||||
|
|
@ -223,8 +223,8 @@ function MODULE:Init(phys_bone, lpos)
|
|||
end
|
||||
|
||||
local function DoFallingAnim(ent)
|
||||
local mod1 = zcnpci.StartModule(ent, "falling_legs")
|
||||
local mod2 = zcnpci.StartModule(ent, "falling_torso")
|
||||
local mod1 = fedhoria.StartModule(ent, "falling_legs")
|
||||
local mod2 = fedhoria.StartModule(ent, "falling_torso")
|
||||
end
|
||||
|
||||
function MODULE:OnRemove()
|
||||
Loading…
Reference in a new issue