Code base code base

This commit is contained in:
toasterpanic 2026-05-25 00:56:02 -04:00
parent af0c52bda5
commit eff80ee215
7 changed files with 94 additions and 45 deletions

View file

@ -0,0 +1,19 @@
# 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.
Some ideas:
- 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.
Since theoretically the NPCs use the same health system that players use, these shouldn't be too hard to implement.
More optimistic ideas:
- NPCs will back out of combat when injured.
- Friendly NPCs can heal each other.
- NPCs can heal themselves to a limited degree.

View file

@ -1,11 +0,0 @@
"AddonInfo"
{
"name" "Optimoria - Optimized Euphoria Ragdolls"
"version" "1.0"
"up_date" "5th August 2015"
"author_name" "MOTDgd.com"
"author_email" "paul.l@motdgd.com"
"author_url" "motdgd.com"
"info" "MOTDgd.com"
"override" "0"
}

View file

@ -8,17 +8,30 @@ local function PopulateSBXToolMenu(pnl)
pnl:CheckBox("NPCs", "fedhoria_npcs")
pnl:ControlHelp("Enable or disable effect for NPCs.")
pnl:Help(" ")
pnl:NumSlider("Stumble time", "fedhoria_stumble_time", 0, 10, 3)
pnl:ControlHelp("How long the ragdoll should stumble for.")
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", "fedhoria_woundgrab_time", 0, 10, 3)
pnl:ControlHelp("How long the ragdoll should hold its wound.")
pnl:Help(" ")
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", "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

View file

@ -1,15 +1,50 @@
include("fedhoria/modules.lua")
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 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", "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
if last_attacker[ent] and last_attacker[ent]:IsPlayer() then active_by_default = true end
end
if !active_by_default then
local entity_position = ragdoll:GetPos()
local in_range = false
local players = player.GetAll()
for i, loop_player in pairs(players) do
local player_position = loop_player:GetPos()
local distance = entity_position:Distance(player_position)
if distance <= active_range:GetFloat() then
in_range = true
break
end
end
if !in_range then return end
end
print(dmgpos)
local phys_bone, lpos
if dmgpos then
@ -33,8 +68,22 @@ hook.Add("EntityTakeDamage", "Fedhoria", function(ent, dmginfo)
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", "Fedhoria", function(npc, hitgroup, dmginfo)
if not IsValid(npc) then return end
last_hitgroup[npc] = hitgroup
print(last_hitgroup[npc] == HITGROUP_HEAD)
end)
--[[hook.Add("OnNPCKilled", "Fedhoria", function(ent, attacker, inflictor)
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()
end)]]
local once = true
--RagMod/TTT support

View file

@ -70,6 +70,7 @@ local cv_anim_roll_playback_rate = CreateConVar("fedhoria_falling_anim_roll_play
-- Время жизни объекта после остановки
local die_time = CreateConVar("fedhoria_dietime", 5, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local die_time_variation = CreateConVar("fedhoria_dietime_variation", 3, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
--[[-------------------------------------------------------------------------
Функция дергания
@ -149,7 +150,7 @@ function MODULE:StartAnimationRoll()
return
end
self.StartDie = nil
--self.StartDie = nil
end
function MODULE:Init()
@ -228,7 +229,7 @@ function MODULE:PhysicsSimulate(phys, dt)
-- проверка на активную анимацию
if cur_time < self.AnimationRollEndTime then
self.StartDie = nil -- сбрасываем таймер "смерти"
--self.StartDie = nil -- сбрасываем таймер "смерти"
return true -- используем стандартную физику
end
@ -242,7 +243,7 @@ function MODULE:PhysicsSimulate(phys, dt)
if ragmod and ragmod:IsRagmodRagdoll(target) then
local owner = target:GetOwningPlayer()
f = (IsValid(owner) and owner:Alive()) and 1 or 0
self.StartDie = nil
--self.StartDie = nil
if f <= 0 then self.AnimationRollEndTime = 0 end
end
@ -290,7 +291,7 @@ function MODULE:PhysicsSimulate(phys, dt)
if (offset_sqr < (10*10 * dt*dt) and not (ragmod and ragmod:IsRagmodRagdoll(target))) then
self.StartDie = self.StartDie or cur_time
else
self.StartDie = nil
--self.StartDie = nil
end
-- коррекция физики после столкновения

View file

@ -37,6 +37,7 @@ local cv_anim_roll_impact_threshold = CreateConVar("fedhoria_falling_anim_roll_i
local cv_anim_roll_playback_rate = CreateConVar("fedhoria_falling_anim_roll_playback_rate", "3.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Скорость воспроизведения анимации 'idleonfire'")
local die_time = CreateConVar("fedhoria_dietime", 5, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local die_time_variation = CreateConVar("fedhoria_dietime_variation", 3, {FCVAR_ARCHIVE, FCVAR_REPLICATED})
-- адно дергание
@ -176,7 +177,7 @@ function MODULE:PhysicsSimulate(phys, dt)
-- проверка на физику
if cur_time < self.AnimationRollEndTime then
-- print("[Fedhoria Sim] In Animation Roll. Time left:", self.AnimationRollEndTime - cur_time) -- Debug
self.StartDie = nil -- Сбрасываем таймер смерти
-- self.StartDie = nil -- Сбрасываем таймер смерти
return true -- стандартная физика пошла нахуй, у меня по ней 2
-- return false -- если физика нахуй идет
@ -190,6 +191,8 @@ function MODULE:PhysicsSimulate(phys, dt)
f = math_Clamp(1 - (cur_time - self.StartDie) / die_time:GetFloat(), 0, 1)
end
print(f)
-- ебаная логика для regmod
if ragmod and ragmod:IsRagmodRagdoll(target) then
local owner = target:GetOwningPlayer()
@ -245,7 +248,7 @@ function MODULE:PhysicsSimulate(phys, dt)
self.StartDie = self.StartDie or cur_time -- идите нахуй
-- print("[Fedhoria Sim] Torso seems stationary. StartDie:", self.StartDie) -- Debug
else
self.StartDie = nil -- нахуй таймер
-- self.StartDie = nil -- нахуй таймер
-- print("[Fedhoria Sim] Torso moved. Resetting StartDie.") -- Debug
end

View file

@ -1,25 +0,0 @@
-- [[
-- ЭТОТ КОД — КАК "ALBERTO BALSALM":
-- КРИВОЙ, НО РАБОЧИЙ. НЕ ТРОГАТЬ.
-- © BRAT, [26.04.2025]
https://open.spotify.com/track/7o2AeQZzfCERsRmOM86EcB?si=e0c85a15f7b34bf6
--[[ BRAT WAS HERE ]]
if true then
print("\n\n>>> ЭТОТ КОД — АРТ-ИНСТАЛЛЯЦИЯ 'XTAL_DEBUG' <<<")
print(">>> ВКЛЮЧИ ОРИГИНАЛ НА SPOTIFY И НЕ ТРОГАЙ КОД\n\n")
return -
end
hook.Add("Think", "BRAT_ART_MODE", function()
if math.random(1, 10000) == 42 then
PrintMessage(HUD_PRINTCENTER, ">> СЛУШАЙ 'XTAL' И НЕ ПАРЬСЯ <<")
end
end)
-- [[
-- Официальный саундтрек этого кода:
-- https://open.spotify.com/track/702AeQZzfCERsRmOM86EcB?si=e0c85a15f7b34bf6
-- Запусти его при чтении, чтобы понять *глубину* багов.
-- ]]