Edit defaults, take burning into account, don't delete player corpses

This commit is contained in:
toasterpanic 2026-05-26 19:12:52 -04:00
parent a17730107a
commit 8da450edb3
3 changed files with 17 additions and 7 deletions

View file

@ -5,8 +5,14 @@ Adds better NPC integration for the Garry's Mod addon Z-City. While Z-City has a
- NPCs can now be alive while ragdolled, and can move around in that state. - NPCs can now be alive while ragdolled, and can move around in that state.
- NPCs can collapse due to unconsciousness or pain. - NPCs can collapse due to unconsciousness or pain.
- NPCs can get back up after being ragdolled. - NPCs can get back up after being ragdolled.
- Various performance settings are included, with the biggest one being automatic corpse removal.
This plugin is based off of Kazarei's Euphoria, which in turn is a fork of Fedhoria by Rama. This plugin is based off of Kazarei's Euphoria, which in turn is a fork of Fedhoria by Rama. Credits to them for making the cool thing.
## Known issues
- Kicking NPCs does not knock them down. This is not something I can easily fix -- I would have to override code in Z-City, which I would rather not do.
- NPCs currently instantly get up, with no animation. I plan on remedying this in the future.
## Incompatibilities ## Incompatibilities
@ -18,4 +24,4 @@ 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.
- NPCs can heal themselves to a limited degree. - NPCs can heal themselves.

View file

@ -6,8 +6,8 @@ local always_active_on_player_kill = CreateConVar("zcnpci_always_active_on_play
local remove_corpses = CreateConVar("zcnpci_enable_corpse_removal", 0, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local remove_corpses = CreateConVar("zcnpci_enable_corpse_removal", 0, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local max_corpses = CreateConVar("zcnpci_max_corpses", 8, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local max_corpses = CreateConVar("zcnpci_max_corpses", 8, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local max_corpse_time = CreateConVar("zcnpci_max_corpse_time", 30, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local max_corpse_time = CreateConVar("zcnpci_max_corpse_time", 120, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local max_corpse_distance = CreateConVar("zcnpci_max_corpse_distance", 3000, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local max_corpse_distance = CreateConVar("zcnpci_max_corpse_distance", 2500, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local no_corpse_removal_near_player = CreateConVar("zcnpci_disable_corpse_removal_near_player", 0, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED)) local no_corpse_removal_near_player = CreateConVar("zcnpci_disable_corpse_removal_near_player", 0, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
local last_dmgpos = {} local last_dmgpos = {}
@ -108,7 +108,8 @@ hook.Add("Think", "zcnpci", function()
ent.organism.llegamputated or ent.organism.llegamputated or
ent.organism.rlegamputated or ent.organism.rlegamputated or
(ent.organism.consciousness <= 0.3) or (ent.organism.consciousness <= 0.3) or
(ent.organism.pain > 90) (ent.organism.pain > 90) or
ent:IsOnFire()
) then ) then
local damage_info = DamageInfo() local damage_info = DamageInfo()
damage_info:SetDamage(ent:Health()) damage_info:SetDamage(ent:Health())
@ -118,7 +119,7 @@ hook.Add("Think", "zcnpci", function()
ent:TakeDamageInfo(damage_info) ent:TakeDamageInfo(damage_info)
end end
elseif !ent.organism.alive and remove_corpses then elseif !ent.organism.alive and remove_corpses and ent.is_npc_corpse then
-- Add to corpse list if not there already -- Add to corpse list if not there already
if !table.HasValue(corpses, ent) then if !table.HasValue(corpses, ent) then
table.insert(corpses, ent) table.insert(corpses, ent)

View file

@ -244,6 +244,8 @@ function MODULE:PhysicsSimulate(phys, dt)
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
target.is_npc_corpse = true
if !self.StartDie then self.StartDie = cur_time end if !self.StartDie then self.StartDie = cur_time end
@ -281,7 +283,8 @@ function MODULE:PhysicsSimulate(phys, dt)
(minimum_down_timer >= 1.0) and (minimum_down_timer >= 1.0) and
(target.class_in_previous_life != nil) 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.llegamputated or target.organism.rlegamputated or target.organism.larmamputated or target.organism.rarmamputated) and
(target.organism.pain <= 80) (target.organism.pain <= 80) and
!target:IsOnFire()
) then ) then
local ent = ents.Create(target.class_in_previous_life) local ent = ents.Create(target.class_in_previous_life)
ent:SetPos(target:GetPos()) ent:SetPos(target:GetPos())