diff --git a/README.md b/README.md index 9e00b22..5dc3d25 100644 --- a/README.md +++ b/README.md @@ -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 collapse due to unconsciousness or pain. - 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 @@ -18,4 +24,4 @@ No guarantees any of this will become real. - NPCs will back out of combat when injured. - Friendly NPCs can heal each other. -- NPCs can heal themselves to a limited degree. \ No newline at end of file +- NPCs can heal themselves. \ No newline at end of file diff --git a/lua/zcnpci.lua b/lua/zcnpci.lua index 121b3bc..273c4a7 100644 --- a/lua/zcnpci.lua +++ b/lua/zcnpci.lua @@ -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 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_distance = CreateConVar("zcnpci_max_corpse_distance", 3000, 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", 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 last_dmgpos = {} @@ -108,7 +108,8 @@ hook.Add("Think", "zcnpci", function() ent.organism.llegamputated or ent.organism.rlegamputated or (ent.organism.consciousness <= 0.3) or - (ent.organism.pain > 90) + (ent.organism.pain > 90) or + ent:IsOnFire() ) then local damage_info = DamageInfo() damage_info:SetDamage(ent:Health()) @@ -118,7 +119,7 @@ hook.Add("Think", "zcnpci", function() ent:TakeDamageInfo(damage_info) 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 if !table.HasValue(corpses, ent) then table.insert(corpses, ent) diff --git a/lua/zcnpci/modules/falling_legs.lua b/lua/zcnpci/modules/falling_legs.lua index c172a08..d09d0fe 100644 --- a/lua/zcnpci/modules/falling_legs.lua +++ b/lua/zcnpci/modules/falling_legs.lua @@ -244,6 +244,8 @@ function MODULE:PhysicsSimulate(phys, dt) local cur_time = CurTime() local target = self:GetTarget() if not IsValid(target) then self:Remove(); return false end + + target.is_npc_corpse = true if !self.StartDie then self.StartDie = cur_time end @@ -281,7 +283,8 @@ function MODULE:PhysicsSimulate(phys, dt) (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) + (target.organism.pain <= 80) and + !target:IsOnFire() ) then local ent = ents.Create(target.class_in_previous_life) ent:SetPos(target:GetPos())