Compare commits

..

No commits in common. "a9ae5bccd4420de920a183bf6f85abdbf28c169c" and "02557dacd1b94f351211b7428fa4f0c6463c5ea5" have entirely different histories.

9 changed files with 488 additions and 53 deletions

View file

@ -17,7 +17,8 @@ This addon is based off of Kazarei's Euphoria, which in turn is a fork of Fedhor
## Known issues
- Bandages, tourniquets, etc. that are on the ragdoll or NPC body will not be there when they get back up. Don't know how to fix this right now, though if anyone experienced with Z-City's codebase would know how to I would appreciate knowing.
- The NPC getting up animation is a little ugly. However, creating that animation was an adventure on levels that I would personally dislike re-experiencing.
- The NPC getting up animation is quite ridiculous and a little ugly. Honestly, getting it to work that much was a struggle in itself and I'm terrified of trying to do anything more than that. If anyone else would like to do that, however, feel free to create a discussion and I can send you the source code link.
- Occasionally the game thinks that all damage is bullet damage? God knows why. I'll figure it out eventually.
## Compatibility
@ -37,6 +38,7 @@ MUST BE DONE BEFORE RELEASE:
- Fire / falling / pain reaction (more rapid flailing)
- NPCs should not unfake if being grabbed
- Fix combine targeting players when ai_ignoreplayers = 1. This is caused by an npc_bullseye that is always on the player. I don't know why it's always there but I don't like it. Will probably override it with my own npc_ragdoll_target entity.
Stuff to do:

View file

@ -6,6 +6,9 @@ local function PopulateAISBXToolMenu(pnl)
pnl:ControlHelp("Should NPCs target the player's head? This can result in more effective targeting.")
pnl:CheckBox("NPCs shouldn't target unconscious NPCs", "zcnpci_no_unconscious_targeting")
pnl:CheckBox("NPCs shouldn't target unconscious players", "zcnpci_no_unconscious_targeting_players")
pnl:ControlHelp("This may or may not work.")
end
local function PopulateCustomNPCSBXToolMenu(pnl)
@ -51,13 +54,7 @@ local function PopulateRagdollSBXToolMenu(pnl)
pnl:ControlHelp("How long the ragdoll should hold its wound.")
pnl:NumSlider("Writhing strength", "zcnpci_writhing_strength", 0, 5, 3)
pnl:ControlHelp("How hard should the ragdoll wriggle/writhe.")
pnl:NumSlider("Flailing speed multiplier", "zcnpci_flailing_playback_rate", 0, 12, 3)
pnl:ControlHelp("How fast or slow should the NPC flail by default.")
pnl:NumSlider("Flailing speed multiplier when panicking", "zcnpci_flailing_playback_rate", 0, 12, 3)
pnl:ControlHelp("How fast or slow should the NPC flail when panicking (on fire, falling, etc.).")
pnl:ControlHelp("How hard should the ragdoll wriggle/writhe. 1 is default.")
pnl:NumSlider("Death timer", "zcnpci_death_timer", -1, 600, 3)
pnl:ControlHelp("After an NPC is ragdolled for longer than this timer, they will die instantly. Set to -1 to disable.")

View file

@ -46,7 +46,7 @@ end
function ENT:Think()
if CLIENT then
--hook.Add("physics")
hook.Add("physics")
local old_ragdoll = self:GetNWEntity("parent")
local old_npc = self:GetNWEntity("parent_npc")
if IsValid(old_ragdoll) and IsValid(old_npc) then

92
lua/entities/v1.old Normal file
View file

@ -0,0 +1,92 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.AutomaticFrameAdvance = true
local bones_to_animate = {
"ValveBiped.Bip01_Pelvis",
"ValveBiped.Bip01_Spine2",
"ValveBiped.Bip01_Head1",
"ValveBiped.Bip01_R_Thigh",
"ValveBiped.Bip01_L_Thigh",
"ValveBiped.Bip01_L_Calf",
"ValveBiped.Bip01_R_Calf",
"ValveBiped.Bip01_R_Foot",
"ValveBiped.Bip01_L_Foot",
"ValveBiped.Bip01_R_Upperarm",
"ValveBiped.Bip01_L_Upperarm",
"ValveBiped.Bip01_R_Forearm",
"ValveBiped.Bip01_L_Forearm",
"ValveBiped.Bip01_R_Hand",
"ValveBiped.Bip01_L_Hand",
}
function ENT:Initialize()
if SERVER then
print("I AM SERVERSIDE")
self:SetModel("models/dav0r/hoverball.mdl")
end
if CLIENT then
print("I AM CLIENTSIDE")
timer.Simple(0.2, function()
end)
end
end
function ENT:Draw()
if CLIENT then
local old_ragdoll = self:GetNWEntity("parent")
if IsValid(old_ragdoll) then
if !self.ready_to_unfake then
self:SetModel(old_ragdoll:GetModel())
self.bone_list = {}
self:SetupBones()
for i,name in pairs(bones_to_animate) do
local bone_index = old_ragdoll:LookupBone(name)
self.bone_list[name] = old_ragdoll:GetBoneMatrix(bone_index)
end
print("BONES:"..self:GetBoneCount())
self.ready_to_unfake = true
end
self:SetPos(old_ragdoll:GetPos())
for name,matrix in pairs(self.bone_list) do
local bone_index = self:LookupBone(name)
if bone_index == -1 then
print(name.." does not exist, skipping...")
continue
end
print(name)
--local bone_matrix = old_ragdoll:GetBoneMatrix(bone_index)
self:SetBoneMatrix(bone_index, matrix)
end
end
end
self:DrawModel()
end
function ENT:Think()
return true
end
function ENT:OnRemove()
if CLIENT then
if self.anim_ragdoll then
self.anim_ragdoll:Remove()
end
end
end

99
lua/entities/v2.old Normal file
View file

@ -0,0 +1,99 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.AutomaticFrameAdvance = true
local bones_to_animate = {
"ValveBiped.Bip01_Pelvis",
"ValveBiped.Bip01_Spine2",
"ValveBiped.Bip01_Head1",
"ValveBiped.Bip01_R_Thigh",
"ValveBiped.Bip01_L_Thigh",
"ValveBiped.Bip01_L_Calf",
"ValveBiped.Bip01_R_Calf",
"ValveBiped.Bip01_R_Foot",
"ValveBiped.Bip01_L_Foot",
"ValveBiped.Bip01_R_Upperarm",
"ValveBiped.Bip01_L_Upperarm",
"ValveBiped.Bip01_R_Forearm",
"ValveBiped.Bip01_L_Forearm",
"ValveBiped.Bip01_R_Hand",
"ValveBiped.Bip01_L_Hand",
}
function ENT:Initialize()
if SERVER then
print("I AM SERVERSIDE")
self:SetModel("models/dav0r/hoverball.mdl")
end
if CLIENT then
print("I AM CLIENTSIDE")
timer.Simple(0.2, function()
end)
end
end
function ENT:Draw()
if CLIENT then
local old_ragdoll = self:GetNWEntity("parent")
if IsValid(old_ragdoll) then
if !self.ready_to_unfake then
self:SetModel(old_ragdoll:GetModel())
self.bone_list = {}
self.bone_original_positions = {}
self:SetupBones()
for i,name in pairs(bones_to_animate) do
local bone_index = old_ragdoll:LookupBone(name)
self.bone_list[name] = old_ragdoll:GetBoneMatrix(bone_index)
self.bone_original_positions[name] = self:GetBoneMatrix(bone_index)
end
print("BONES:"..self:GetBoneCount())
self.ready_to_unfake = true
end
self:SetPos(old_ragdoll:GetPos())
for name,matrix in pairs(self.bone_list) do
local bone_index = self:LookupBone(name)
if bone_index == -1 then
print(name.." does not exist, skipping...")
continue
end
print(name)
--local bone_matrix = old_ragdoll:GetBoneMatrix(bone_index)
local original_position = self.bone_original_positions[name]:GetTranslation()
local goal_position = matrix:GetTranslation()
print((original_position - goal_position))
self:ManipulateBonePosition(bone_index, Vector(0, 0, 16))
end
end
end
self:DrawModel()
end
function ENT:Think()
return true
end
function ENT:OnRemove()
if CLIENT then
if self.anim_ragdoll then
self.anim_ragdoll:Remove()
end
end
end

94
lua/entities/v3.old Normal file
View file

@ -0,0 +1,94 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.AutomaticFrameAdvance = true
local bones_to_animate = {
"ValveBiped.Bip01_Pelvis",
"ValveBiped.Bip01_Spine2",
"ValveBiped.Bip01_Head1",
"ValveBiped.Bip01_R_Thigh",
"ValveBiped.Bip01_L_Thigh",
"ValveBiped.Bip01_L_Calf",
"ValveBiped.Bip01_R_Calf",
"ValveBiped.Bip01_R_Foot",
"ValveBiped.Bip01_L_Foot",
"ValveBiped.Bip01_R_Upperarm",
"ValveBiped.Bip01_L_Upperarm",
"ValveBiped.Bip01_R_Forearm",
"ValveBiped.Bip01_L_Forearm",
"ValveBiped.Bip01_R_Hand",
"ValveBiped.Bip01_L_Hand",
}
function ENT:Initialize()
if SERVER then
print("I AM SERVERSIDE")
self:SetModel("models/dav0r/hoverball.mdl")
end
if CLIENT then
print("I AM CLIENTSIDE")
timer.Simple(0.2, function()
end)
end
end
function ENT:Draw()
if CLIENT then
local old_ragdoll = self:GetNWEntity("parent")
if IsValid(old_ragdoll) then
if !self.ready_to_unfake then
self.ragdoll = ClientsideModel(old_ragdoll:GetModel())
self.ragdoll:SetModel(old_ragdoll:GetModel())
self.bone_list = {}
self.ragdoll:SetupBones()
for i,name in pairs(bones_to_animate) do
local bone_index = old_ragdoll:LookupBone(name)
self.bone_list[name] = old_ragdoll:GetBoneMatrix(bone_index)
end
print("BONES:"..self.ragdoll:GetBoneCount())
self.ready_to_unfake = true
end
self.ragdoll:SetPos(old_ragdoll:GetPos())
for name,matrix in pairs(self.bone_list) do
local bone_index = self.ragdoll:LookupBone(name)
if bone_index == -1 then
print(name.." does not exist, skipping...")
continue
end
print(name)
--local bone_matrix = old_ragdoll:GetBoneMatrix(bone_index)
self.ragdoll:SetBoneMatrix(bone_index, matrix)
end
end
end
self:DrawModel()
self.ragdoll:DrawModel()
end
function ENT:Think()
return true
end
function ENT:OnRemove()
if CLIENT then
if self.anim_ragdoll then
self.anim_ragdoll:Remove()
end
end
end

191
lua/entities/v4.old Normal file
View file

@ -0,0 +1,191 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.AutomaticFrameAdvance = true
local bones_to_animate = {
"ValveBiped.Bip01_Pelvis",
"ValveBiped.Bip01_Spine2",
"ValveBiped.Bip01_Head1",
"ValveBiped.Bip01_R_Thigh",
"ValveBiped.Bip01_L_Thigh",
"ValveBiped.Bip01_L_Calf",
"ValveBiped.Bip01_R_Calf",
"ValveBiped.Bip01_R_Foot",
"ValveBiped.Bip01_L_Foot",
"ValveBiped.Bip01_R_Upperarm",
"ValveBiped.Bip01_L_Upperarm",
"ValveBiped.Bip01_R_Forearm",
"ValveBiped.Bip01_L_Forearm",
"ValveBiped.Bip01_R_Hand",
"ValveBiped.Bip01_L_Hand",
}
local function GetBoneLocalOffsetMatrix(ent, bone_index)
local parent = ent:GetBoneParent(bone_index)
local parent_matrix = Matrix(ent:GetBoneMatrix(parent))
parent_matrix:Invert()
parent_matrix:Mul(ent:GetBoneMatrix(bone_index))
return parent_matrix
end
local function GetGlobalMatrixFromLocal(ent, bone_index, local_matrix)
local parent = ent:GetBoneParent(bone_index)
local parent_matrix = Matrix(ent:GetBoneMatrix(parent))
parent_matrix:Mul(local_matrix)
return parent_matrix
end
function ENT:Initialize()
if SERVER then
print("I AM SERVERSIDE")
self:SetModel("models/dav0r/hoverball.mdl")
end
if CLIENT then
print("I AM CLIENTSIDE")
timer.Simple(0.2, function()
end)
end
end
function ENT:Draw()
if CLIENT then
local old_ragdoll = self:GetNWEntity("parent")
local old_npc = self:GetNWEntity("parent_npc")
if IsValid(old_ragdoll) and IsValid(old_npc) then
if !self.ready_to_unfake then
self:SetModel(old_ragdoll:GetModel())
self.bone_list = {}
self.bone_list_end = {}
self.bone_list_end_offset = {}
self:SetupBones()
local i = 0
while i < self:GetBoneCount() do
local name = self:GetBoneName(i)
if name == "__INVALIDBONE__" then
i = i + 1
continue
end
table.insert(bones_to_animate, name)
local matrix = Matrix()
local position, angle = old_ragdoll:GetBonePosition(i)
if position == old_ragdoll:GetPos() then
get_matrix = old_ragdoll:GetBoneMatrix(i)
if get_matrix then
position = get_matrix:GetTranslation()
end
end
matrix:Translate(position)
matrix:Rotate(angle)
self.bone_list[name] = matrix
local matrix = Matrix()
local npc_bone_index = old_npc:LookupBone(name)
local position, angle = old_npc:GetBonePosition(npc_bone_index)
if position == old_npc:GetPos() then
print("DINGUS!!!! "..name)
self.bone_list_end_offset[name] = GetBoneLocalOffsetMatrix(self, npc_bone_index)
get_matrix = old_npc:GetBoneMatrix(npc_bone_index)
if get_matrix then
position = get_matrix:GetTranslation()
end
else
matrix:Translate(position)
matrix:Rotate(angle)
self.bone_list_end[name] = matrix
end
i = i + 1
end
PrintTable(bones_to_animate)
--[[for i,name in pairs(bones_to_animate) do
local bone_index = old_ragdoll:LookupBone(name)
if bone_index == nil then continue end
self.bone_list[name] = Matrix(old_ragdoll:GetBoneMatrix(bone_index))
end]]
print("BONES:"..self:GetBoneCount())
self.ready_to_unfake = true
end
self:SetPos(old_ragdoll:GetPos())
self:SetupBones()
local fake_start = self:GetNWFloat("fake_start")
local fake_end = self:GetNWFloat("fake_end")
local progress = (CurTime() - fake_start) / (fake_end - fake_start)
for name,matrix in pairs(self.bone_list) do
local bone_index = self:LookupBone(name)
if bone_index == -1 then
print(name.." does not exist, skipping...")
continue
end
local matrix_end = self.bone_list_end[name]
if matrix_end == nil then
if (self.bone_list_end_offset[name] == nil) then
print("OH FUCKKKKKKKK! No matrix end for "..name)
continue
end
matrix_end = GetGlobalMatrixFromLocal(self, bone_index, self.bone_list_end_offset[name])
end
local final_matrix = Matrix()
final_matrix:Translate(LerpVector(progress, matrix:GetTranslation(), matrix_end:GetTranslation()))
final_matrix:Rotate(LerpAngle(progress, matrix:GetAngles(), matrix_end:GetAngles()))
--print(name)
--local bone_matrix = old_ragdoll:GetBoneMatrix(bone_index)
if matrix:GetTranslation():DistToSqr(self:GetPos()) == 1 then continue end
self:SetBoneMatrix(bone_index, final_matrix)
end
end
end
self:DrawModel()
end
function ENT:Think()
return true
end
function ENT:OnRemove()
if CLIENT then
--[[if self.anim_ragdoll then
self.anim_ragdoll:Remove()
end]]
end
end

View file

@ -105,14 +105,6 @@ local death_timer = CreateConVar("zcnpci_death_timer", "-1", {FCVAR_ARCHIVE, FCV
-- Targeting
local npc_targeting_enabled = CreateConVar("zcnpci_npc_targeting_enabled", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Should NPCs target downed NPCs")
-- Flailing
local flailing_playback_rate = CreateConVar("zcnpci_flailing_playback_rate", "1.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local flailing_panic_multiplier = CreateConVar("zcnpci_flailing_panic_multiplier", "2.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local flailing_panic_airbone_check_distance = CreateConVar("zcnpci_flailing_panic_airbone_check_distance", "128", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
-- Writhing
local writhing_strength = CreateConVar("zcnpci_writhing_strength", "1.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
--[[-------------------------------------------------------------------------
Tug function
Applies a random impulse to one of the leg bones.
@ -393,7 +385,7 @@ function MODULE:PhysicsSimulate(phys, dt)
end
-- Force multiplier
local f = target.organism.consciousness * writhing_strength:GetFloat()
local f = target.organism.consciousness
local minimum_down_timer = 0
if target.StartDie then
@ -429,17 +421,6 @@ function MODULE:PhysicsSimulate(phys, dt)
target.StartDie = cur_time
end
local distance_check = util.TraceLine({
start = target:GetPos(),
endpos = target:GetPos() + Vector(0, 0, -128),
filter = {target},
mask = MASK_SOLID
}).Hit
if !distance_check then
target.StartDie = cur_time
end
if ((CurTime() - self.LastFakeUpCheck) >= 1.0) and (can_unfake:GetBool()) then
self.LastFakeUpCheck = CurTime()
@ -566,17 +547,7 @@ function MODULE:PhysicsSimulate(phys, dt)
-- Logic for fall animation
local vel = phys:GetVelocity()
local pbr = math_Clamp(vel.z / -600, 0.5, 1.5) * flailing_playback_rate:GetFloat()
target.panicking = (
target:IsOnFire() or
(!distance_check) or
(target.organism.pain > 80)
)
if target.panicking then
pbr = pbr * flailing_panic_multiplier:GetFloat()
end
local pbr = math_Clamp(vel.z / -600, 0.5, 1.5)
if self:GetSequence() ~= self:LookupSequence("Choked_Barnacle") or self:GetPlaybackRate() ~= pbr then
local seq_idle = self:LookupSequence("Choked_Barnacle")

View file

@ -35,12 +35,6 @@ local cv_anim_roll_duration = CreateConVar("zcnpci_falling_anim_roll_duration",
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 flailing_playback_rate = CreateConVar("zcnpci_flailing_playback_rate", "1.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
local flailing_panic_multiplier = CreateConVar("zcnpci_flailing_panic_multiplier", "2.5", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
-- Writhing
local writhing_strength = CreateConVar("zcnpci_writhing_strength", "1.0", {FCVAR_ARCHIVE, FCVAR_REPLICATED})
-- Do it!
function MODULE:DoTwitch()
@ -193,7 +187,7 @@ function MODULE:PhysicsSimulate(phys, dt)
-- --- логика идет нахуй
-- Force multiplier
local f = target.organism.consciousness * writhing_strength:GetFloat()
local f = target.organism.consciousness
-- ебаная логика для regmod
if ragmod and ragmod:IsRagmodRagdoll(target) then
@ -239,12 +233,7 @@ function MODULE:PhysicsSimulate(phys, dt)
-- логика для анимации переката
local vel = phys:GetVelocity()
local pbr = math_Clamp(vel.z / -600, 0.5, 1.5) * flailing_playback_rate:GetFloat()
if target.panicking then
pbr = pbr * flailing_panic_multiplier:GetFloat()
end
local pbr = math_Clamp(vel.z / -600, 0.5, 1.5)
-- падения и ебаная скорость
-- если мы не в.. а впрочем иди нахуй
if self:GetSequence() ~= self:LookupSequence("idleonfire") or self:GetPlaybackRate() ~= pbr then