goroman

Untitled

Feb 15th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.46 KB | None | 0 0
  1. AddCSLuaFile('autorun/client/ragdoll_death_expression_menu.lua')
  2. AddCSLuaFile('autorun/client/fedh_menu.lua')
  3. include("fedhoria/modules.lua")
  4. --include("firstperson_death.lua")
  5. local enabled = CreateConVar("fedhoria_enabled", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
  6. local players = CreateConVar("fedhoria_players", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
  7. local npcs = CreateConVar("fedhoria_npcs", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
  8. local noc = CreateConVar("fedhoria_ragdoll_nocollide", 1, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
  9. local Removetime=CreateConVar("sv_playerragdoll_remove","20",{FCVAR_REPLICATED, FCVAR_ARCHIVE}, "RAG REMOVE")
  10. local RagdollsCollideWithPlayers = CreateConVar("sv_playerragdolls_collide_players", "0", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Whether player corpses should collide with players or not.")
  11. local RagdollComplex=CreateConVar("sv_playerragdolls_complex", "1", {FCVAR_REPLICATED, FCVAR_ARCHIVE}, "Corpses more than 1")
  12. local RagdollBloodPool=CreateConVar("sv_playerragdolls_bloodpool", "0", {FCVAR_REPLICATED, FCVAR_ARCHIVE}, "Corpses Blood Pool")
  13. local RagdollUrine=CreateConVar("sv_playerragdolls_urine", "0", {FCVAR_REPLICATED, FCVAR_ARCHIVE}, "Corpses Urine")
  14. local fd_firstperson= CreateClientConVar("fd_firstperson", "0", true, false, "Enter the ragdolls point of view when dead")
  15. local Death_FOV=CreateConVar("fed_fov","50",{FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Fedhoria death FOV")
  16. local Death_FOV_duration=CreateConVar("fed_fov_duration","2",{FCVAR_REPLICATED, FCVAR_ARCHIVE}, "Fedhoria_death FOV time")
  17. local Death_cam=CreateConVar("special_cam","1",bit.bor(FCVAR_REPLICATED, FCVAR_ARCHIVE), "Fedhoria_death Cam Type")
  18. local AllowBloodVar = CreateConVar("fd_blood", "0", FCVAR_ARCHIVE,"")
  19. local BloodThresholdVar = CreateConVar("fd_blood_threshold", "500", FCVAR_ARCHIVE,"")
  20. util.AddNetworkString("Fedhoria_Ragdoll")
  21. util.AddNetworkString("ragdeath_client")
  22. local function OnPlyRagdollCollide(collider, colData )
  23. if AllowBloodVar:GetBool() then
  24. if colData.Speed < BloodThresholdVar:GetFloat() then return end
  25. local pos = colData.HitPos
  26. local norm = colData.OurOldVelocity:GetNormalized()
  27. util.Decal("Blood",pos,pos + colData.HitNormal * 20)
  28. end
  29. end
  30. local function SetAllNpcHealth(cls,h)
  31. local npcs = list.GetForEdit( "NPC")
  32. for k, v in pairs( npcs ) do
  33. if v["Class"] == cls then
  34. if h>0 then
  35. if not v["OldHealth"] then
  36. v["OldHealth"]=v["Health"] or ""
  37. --print(v["OldHealth"])
  38. end
  39. v["Health"]=""..h
  40. else
  41. --if v["OldHealth"] then
  42. if v["OldHealth"]=="" then
  43. v["Health"]= nil
  44. else
  45. v["Health"]= v["OldHealth"]
  46. end
  47.  
  48. --end
  49. end
  50. end
  51. end
  52. end
  53.  
  54. local lockhealth = CreateConVar("fedhoria_citizen_health", 0, bit.bor(FCVAR_ARCHIVE, FCVAR_REPLICATED))
  55.  
  56. cvars.AddChangeCallback("fedhoria_citizen_health", function(_, _, new)
  57. SetAllNpcHealth("npc_citizen",lockhealth:GetFloat())
  58. end)
  59.  
  60. timer.Simple( 1, function() SetAllNpcHealth("npc_citizen",lockhealth:GetFloat()) end )
  61.  
  62. function printnpctype(mdlpath)
  63. local npcs = list.GetForEdit( "NPC")
  64.  
  65. for k, v in pairs( npcs ) do
  66. if v["Class"]=="npc_citizen" and v["Model"]==mdlpath then print(k) end
  67. end
  68. end
  69.  
  70.  
  71. hook.Add("OnEntityCreated", "Fedhoria", function(ent)
  72. if(IsValid(ent) and ent:IsNPC()) then
  73. for k, v in ipairs( ents.FindByClass("dummy_info_target") ) do
  74. if IsValid(v)then
  75. ent:AddEntityRelationship(v,D_NU,0)
  76. end
  77. end
  78. end
  79. end
  80. )
  81.  
  82.  
  83. local last_dmgpos = {}
  84.  
  85. hook.Add("CreateEntityRagdoll", "Fedhoria", function(ent, ragdoll)
  86. if (!enabled:GetBool() or !npcs:GetBool()) then return end
  87.  
  88. local class = ent:GetClass()
  89. if(class=="npc_citizen") then
  90. ragdoll.citizen = 1
  91. --printnpctype(ent:GetModel())
  92. end
  93. if(class=="npc_metropolice") then ragdoll.combine = 1 end
  94. if(class=="npc_combine_s") then ragdoll.combine = 1 end
  95.  
  96. ragdoll.hatelist = {}
  97. for k, v in ipairs( ents.FindByClass("npc_*") ) do
  98. if v:IsNPC() and v:Disposition(ent)==D_HT then
  99. table.insert(ragdoll.hatelist, v)
  100. end
  101. end
  102.  
  103. --print(ent:GetBloodColor())
  104.  
  105. if ent:GetBloodColor()==0 then
  106. --printnpctype(ent:GetModel())
  107. ragdoll.UsesRealisticBlood = true
  108. ent.UsesRealisticBlood = true
  109. end
  110. local dmgpos = last_dmgpos[ent]
  111.  
  112. --print("dmgpos",dmgpos)
  113.  
  114. local phys_bone, lpos
  115.  
  116. if dmgpos then
  117. phys_bone = ragdoll:GetClosestPhysBone(dmgpos)
  118. if phys_bone then
  119. local phys = ragdoll:GetPhysicsObjectNum(phys_bone)
  120. lpos = phys:WorldToLocal(dmgpos)
  121. end
  122. end
  123.  
  124. if noc:GetBool() then
  125. ragdoll:SetCollisionGroup(COLLISION_GROUP_DEBRIS_TRIGGER)
  126. end
  127. //finger
  128.  
  129. for ii= 0 , ragdoll:GetBoneCount() do
  130. if ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger0' then
  131. ragdoll:ManipulateBoneAngles(ii,Angle(0,3-math.Rand(0,3),0))
  132. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger0' then
  133. ragdoll:ManipulateBoneAngles(ii,Angle(0,10-math.Rand(0,2),0))
  134. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger01' then
  135. ragdoll:ManipulateBoneAngles(ii,Angle(0,20-math.Rand(0,2),0))
  136. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger02' then
  137. ragdoll:ManipulateBoneAngles(ii,Angle(0,25-math.Rand(0,3),0))
  138. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger1' then
  139. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  140. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger11' then
  141. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  142. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger12' then
  143. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  144. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger2' then
  145. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-26-math.Rand(0,4),0))
  146. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger21' then
  147. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,40),0))
  148. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger22' then
  149. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,40),0))
  150. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger3' then
  151. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  152. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger31' then
  153. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,40),0))
  154. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger32' then
  155. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,40),0))
  156. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger4' then
  157. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,30),0))
  158. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger41' then
  159. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,20),0))
  160. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger42' then
  161. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,3),0))
  162.  
  163. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger0' then
  164. ragdoll:ManipulateBoneAngles(ii,Angle(0,3-math.Rand(0,2),0))
  165. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger01' then
  166. ragdoll:ManipulateBoneAngles(ii,Angle(0,10-math.Rand(0,3),0))
  167. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger02' then
  168. ragdoll:ManipulateBoneAngles(ii,Angle(0,20-math.Rand(0,3),0))
  169. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger1' then
  170. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  171. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger11' then
  172. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  173. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger12' then
  174. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  175. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger2' then
  176. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-27-math.Rand(0,4),0))
  177. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger21' then
  178. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  179. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger22' then
  180. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  181. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger3' then
  182. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  183. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger31' then
  184. ragdoll:ManipulateBoneAngles(ii,Angle(0,-32-math.Rand(0,4),0))
  185. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger32' then
  186. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,40),0))
  187. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger4' then
  188. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-20-math.Rand(0,30),0))
  189. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger41' then
  190. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,20),0))
  191. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger42' then
  192. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,3),0))
  193. end
  194.  
  195. end
  196. -- //hentai
  197. -- if RagdollUrine:GetInt()== 765493316 then
  198. -- boneid2=ragdoll:LookupBone( 'ValveBiped.Bip01_L_Thigh' )
  199. -- boneid3=ragdoll:LookupBone( 'ValveBiped.Bip01_R_Thigh' )
  200. -- pos3=(ragdoll:GetBonePosition(boneid2)+ragdoll:GetBonePosition(boneid3))
  201. -- timer.Simple(5,function()
  202. -- boneid1=ragdoll:LookupBone('ValveBiped.Bip01_Pelvis')
  203. -- CreateUrineForRagdoll(ragdoll, boneid1, boneid2,boneid3,BLOOD_COLOR_YELLOW, 1)
  204. -- end)
  205. -- end
  206. --print(ent.bloodpool_lastdmgbone)
  207. if ent.bloodpool_lastdmgbone then
  208. --print(ragdoll:GetBoneName(ent.bloodpool_lastdmgbone))
  209. if ragdoll:GetBoneName(ent.bloodpool_lastdmgbone)=='ValveBiped.Bip01_Head1' then //判定是否死于爆头击杀
  210. --print(114)
  211. ragdoll.HeadShotToDeath=1
  212. end
  213. end
  214. timer.Simple(0, function()
  215. if !IsValid(ragdoll) then return end
  216. fedhoria.StartModule(ragdoll, "stumble_legs", phys_bone, lpos)
  217. last_dmgpos[ent] = nil
  218. end)
  219. end)
  220.  
  221. hook.Add("EntityTakeDamage", "Fedhoria", function(ent, dmginfo)
  222. if (ent:IsNPC() or ent:IsPlayer()) and ent:GetBloodColor()==0 then
  223. ent.UsesRealisticBlood = true
  224. end
  225. if (!enabled:GetBool() or !npcs:GetBool()) then return end
  226. if (ent:IsRagdoll() and ent.infotarget) then
  227.  
  228. if ent.overkilled then ent.overkilled=ent.overkilled+1 end
  229.  
  230. if !IsValid(ent.infotarget) then
  231. --ent.infotarget = nil
  232. ent.overkilled = ent.overkilled or 1
  233. elseif dmginfo:IsBulletDamage() then
  234. local dmginfo1= DamageInfo()
  235. dmginfo1:SetDamage(1)
  236. ent.infotarget:TakeDamageInfo(dmginfo1)
  237. if ent.infotarget:Health()<=0 then
  238. --ent.infotarget = nil
  239. ent.overkilled = ent.overkilled or 1
  240. end
  241. end
  242. end
  243. --print(dmginfo:GetDamagePosition())
  244. if ((ent:IsNPC() or ent:IsPlayer()) and dmginfo:GetDamage() >= ent:Health()) then
  245. --print("recorded dmg pos",ent,dmginfo:GetDamagePosition())
  246. last_dmgpos[ent] = dmginfo:GetDamagePosition()
  247. end
  248. --print(1)
  249. if ent:IsRagdoll() and ent.player==1 and ent.bleeding!=1 then //为玩家的尸体添加血液效果
  250.  
  251. if ent.bloodpool_lastdmgbone and RagdollBloodPool:GetBool() then
  252.  
  253. local bone = ent.bloodpool_lastdmgbone
  254.  
  255. local lpos = ent.bloodpool_lastdmglpos
  256. local lang = ent.bloodstream_lastdmglang
  257. ent.bleeding=1
  258. --theres proably a better way to do this D:
  259. local meme = ents.Create("prop_dynamic")
  260. meme:SetModel("models/error.mdl")
  261. meme:Spawn()
  262. meme:SetModelScale(0)
  263. meme:SetNotSolid(true)
  264. meme:DrawShadow(false)
  265. --print(1)
  266.  
  267.  
  268. meme:FollowBone(ent, bone)
  269.  
  270. meme:SetLocalPos(lpos)
  271.  
  272. meme:SetLocalAngles(Angle(lpos)-lang*(-4))
  273. PrecacheParticleSystem("blood_fluid_UBTM_bleeding1")
  274. ParticleEffectAttach("blood_fluid_UBTM_bleeding1", PATTACH_ABSORIGIN_FOLLOW, meme, 0)
  275. -- local effectdata = EffectData()
  276. -- effectdata:SetEntity(meme)
  277. -- effectdata:SetFlags(0)
  278. -- util.Effect("bloodstreameffectzippy", effectdata)
  279. if dmginfo:GetDamage()>=70 then
  280. --print(dmginfo:GetDamage())
  281. CreateBloodPoolForRagdoll(ent, bone ,BLOOD_COLOR_RED,0)
  282. end
  283. ent.bloodpool_lastdmgbone = nil
  284. timer.Simple(5,function()
  285. ent.bleeding=0
  286. end)
  287. end
  288. end
  289. end)
  290.  
  291. local once = true
  292.  
  293. --RagMod/TTT support
  294. hook.Add("OnEntityCreated", "Fedhoria", function(ent)
  295. --If RagMod isn't installed remove this hook
  296. if once then
  297. once = nil
  298. if (!RMA_Ragdolize and !CORPSE) then
  299. hook.Remove("OnEntityCreated", "Fedhoria")
  300. return
  301. end
  302. --these hooks fucks shit up
  303. if RMA_Ragdolize then
  304. hook.Remove( "PlayerDeath", "RM_PlayerDies")
  305. hook.Add( "PostPlayerDeath", "RemoveRagdoll", function(ply)
  306. if IsValid(ply.RM_Ragdoll) then
  307. SafeRemoveEntity(ply:GetRagdollEntity())
  308. ply:SpectateEntity(ply.RM_Ragdoll)
  309. end
  310. end)
  311. end
  312. end
  313. if (!enabled:GetBool() or !players:GetBool() or !ent:IsRagdoll()) then return end
  314.  
  315. timer.Simple(0, function()
  316. if !IsValid(ent) then return end
  317. if CORPSE then
  318. local ply = ent:GetDTEntity(CORPSE.dti.ENT_PLAYER)
  319. if (IsValid(ply) and ply:IsPlayer()) then
  320.  
  321. local dmgpos = last_dmgpos[ply]
  322. local phys_bone, lpos
  323.  
  324. if dmgpos then
  325. phys_bone = ent:GetClosestPhysBone(dmgpos)
  326. if phys_bone then
  327. local phys = ent:GetPhysicsObjectNum(phys_bone)
  328. lpos = phys:WorldToLocal(dmgpos)
  329. end
  330. end
  331.  
  332. ent.hatelist = {}
  333. for k, v in ipairs( ents.FindByClass("npc_*") ) do
  334. if v:IsNPC() and v:Disposition(ply)==D_HT then
  335. table.insert(ent.hatelist, v)
  336. end
  337. end
  338.  
  339. --print("aaa1",dmgpos,phys_bone, lpos)
  340. fedhoria.StartModule(ent, "stumble_legs", phys_bone, lpos)
  341. return
  342. end
  343. end
  344. for _, ply in ipairs(player.GetAll()) do
  345. if (ply.RM_IsRagdoll and ply.RM_Ragdoll == ent) then
  346.  
  347. local dmgpos = last_dmgpos[ply]
  348. local phys_bone, lpos
  349.  
  350. if dmgpos then
  351. phys_bone = ent:GetClosestPhysBone(dmgpos)
  352. if phys_bone then
  353. local phys = ent:GetPhysicsObjectNum(phys_bone)
  354. lpos = phys:WorldToLocal(dmgpos)
  355. end
  356. end
  357.  
  358. ent.hatelist = {}
  359. for k, v in ipairs( ents.FindByClass("npc_*") ) do
  360. if v:IsNPC() and v:Disposition(ply)==D_HT then
  361. table.insert(ent.hatelist, v)
  362. end
  363. end
  364. --print("aaa2",dmgpos,phys_bone, lpos)
  365.  
  366. fedhoria.StartModule(ent, "stumble_legs", phys_bone, lpos)
  367. return
  368. end
  369. end
  370. end)
  371. end)
  372.  
  373. local PLAYER = FindMetaTable("Player")
  374.  
  375. --local oldCreateRagdoll = PLAYER.CreateRagdoll
  376.  
  377. local dolls = {}
  378. local pps = {}
  379. local countt= 1
  380. local function CreateEntityRagdoll(self,ragdoll)
  381. if type(self)!="Player" or (!enabled:GetBool())then return end
  382. if not RagdollComplex:GetBool() then //如果设定玩家布娃娃可以多于一个,则不会去删掉存在的玩家布娃娃。
  383. SafeRemoveEntity(dolls[self])
  384. end
  385.  
  386. SafeRemoveEntity(pps[self])
  387. self.UsesRealisticBlood = true
  388.  
  389. ragdoll = ents.Create("prop_ragdoll")
  390. plycolor=self:GetPlayerColor()
  391. --ragdoll:SetColor4Part(plycolor.r,plycolor.g,plycolor.b)
  392. ragdoll.player=1
  393. if not RagdollBloodPool:GetBool() then
  394. ragdoll.UsesRealisticBlood = true
  395. end
  396. self.UsesRealisticBlood = true
  397. self:SetBloodColor(0)
  398. --print(self:GetBloodColor())
  399. ragdoll:SetModel(self:GetModel())
  400. --print(self:GetModel())
  401. ragdoll:SetPos(self:GetPos())
  402. -- if own.ZippyGoreMod3_LastDMGINFO then
  403. -- rag:ZippyGoreMod3_DamageRagdoll( own.ZippyGoreMod3_LastDMGINFO )
  404. -- end
  405. --ragdoll.ZippyGoreMod3_Ragdoll= true
  406. --ragdoll.ZippyGoreMod3_PhysBoneHPs = true
  407. ragdoll:SetAngles(self:GetAngles())
  408. ragdoll:Spawn()
  409. ragdoll:SetOwner(self)
  410. ragdoll:SetSkin(self:GetSkin())
  411. ragdoll:SetName(self:GetName().."'s ragdoll") --
  412. ragdoll.Fedindex="Fed_player_corpse"
  413. ragdoll.CanConstrain = true
  414. ragdoll.GravGunPunt = true
  415. ragdoll.PhysgunDisabled = false
  416. ragdoll.countnum=ragdoll:EntIndex()
  417. --print(ragdoll:GetName())
  418. --print(ragdoll:GetBoneName(self.bloodpool_lastdmgbone))
  419. if self.bloodpool_lastdmgbone then
  420. if ragdoll:GetBoneName(self.bloodpool_lastdmgbone)=='ValveBiped.Bip01_Head1' then //判定是否死于爆头击杀
  421. ragdoll.HeadShotToDeath=1
  422.  
  423. end
  424. end
  425. local pp=ents.Create("prop_dynamic")
  426. pp:SetModel("models/hunter/plates/plate.mdl")
  427. pp:SetRenderMode(10)
  428. pp:SetCollisionGroup(1)
  429. pp:SetMoveType(MOVETYPE_NONE)
  430. pp:SetNotSolid(true)
  431. pp:SetParent(ragdoll,-1)
  432.  
  433. pp:SetPos(self:GetPos()*Vector(1,1,1)+Vector(0,0,30))
  434. --pp:Fire("setparentattachmentmaintainoffset", "head", 1)
  435. --pp:SetAngles(self:GetAngles()*0.2)
  436. --pp:CreateBoneFollowers(ragdoll)
  437. --pp:UpdateBoneFollowers()
  438. pp:Spawn()
  439. pps[self]=pp
  440. for i = 0, self:GetNumBodyGroups() - 1 do
  441. ragdoll:SetBodygroup(i, self:GetBodygroup(i))
  442. end
  443.  
  444. for i = 0, ragdoll:GetPhysicsObjectCount()-1 do
  445. local phys = ragdoll:GetPhysicsObjectNum(i)
  446. local bone = ragdoll:TranslatePhysBoneToBone(i)
  447. local matrix = self:GetBoneMatrix(bone)
  448. local pos, ang = matrix:GetTranslation(), matrix:GetAngles()--self:GetBonePosition(bone)
  449. phys:SetPos(pos)
  450. phys:SetAngles(ang)
  451. phys:SetVelocity(self:GetVelocity())
  452. end
  453. --ragdoll.FOV=45
  454. if not GetConVar("fd_firstperson"):GetBool() then
  455. if not Death_cam:GetBool() then
  456. self:SpectateEntity(ragdoll)
  457. self:SetFOV(Death_FOV:GetFloat(),Death_FOV_duration:GetFloat(),pp)
  458. self:Spectate(5)
  459. pp:Remove()
  460. else
  461. --self:SpectateEntity(ragdoll)
  462. --self:Spectate(5)
  463. pp:Remove()
  464. end
  465. else
  466. --self:SpectateEntity(ragdoll)
  467. --self:Spectate(5)
  468. pp:Remove()
  469. --self:Spectate(0)
  470.  
  471. end
  472. if (Removetime:GetInt()>0 && ragdoll:IsValid()) then
  473. timer.Simple(Removetime:GetInt(),function()
  474. if ragdoll:IsValid() then
  475. ragdoll:Remove()
  476. end
  477. end)
  478. end
  479. if not RagdollsCollideWithPlayers:GetBool() then
  480. ragdoll:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  481. end
  482. -- timer.Simple(0.05, function()
  483. -- if not IsValid(ragdoll) then return end
  484. -- local boneid = 0
  485.  
  486.  
  487.  
  488. -- if RagdollBloodPool:GetBool() then
  489. -- if self.bloodpool_lastdmgbone then
  490. -- --print(self:GetBloodColor())
  491. -- CreateBloodPoolForRagdoll(ragdoll, self.bloodpool_lastdmgbone, self.bloodpool_lastdmglpos, 0)
  492. -- end
  493. -- end
  494. -- if RagdollUrine:GetBool() then
  495.  
  496. -- CreateUrineForRagdoll(ragdoll, boneid1, pos3,BLOOD_COLOR_YELLOW, 1)
  497. -- end
  498. -- end)
  499. //blood trail & bloodpool
  500. if self.bloodpool_lastdmgbone and RagdollBloodPool:GetBool() then
  501.  
  502. local bone = self.bloodpool_lastdmgbone
  503.  
  504. local lpos = self.bloodpool_lastdmglpos
  505. local lang = self.bloodstream_lastdmglang
  506.  
  507. --theres proably a better way to do this D:
  508. local meme = ents.Create("prop_dynamic")
  509. meme:SetModel("models/error.mdl")
  510. meme:Spawn()
  511. meme:SetModelScale(0)
  512. meme:SetNotSolid(true)
  513. meme:DrawShadow(false)
  514. --print(1)
  515.  
  516.  
  517. meme:FollowBone(ragdoll, bone)
  518.  
  519. meme:SetLocalPos(lpos)
  520.  
  521. meme:SetLocalAngles(Angle(lpos)-lang*(-4))
  522. PrecacheParticleSystem("blood_fluid_UBTM_bleeding1")
  523. ParticleEffectAttach("blood_fluid_UBTM_bleeding1", PATTACH_ABSORIGIN_FOLLOW, meme, 0)
  524. -- local effectdata = EffectData()
  525. -- effectdata:SetEntity(meme)
  526. -- effectdata:SetFlags(0)
  527. -- util.Effect("bloodstreameffectzippy", effectdata)
  528. CreateBloodPoolForRagdoll(ragdoll, self.bloodpool_lastdmgbone ,BLOOD_COLOR_RED,0)
  529. SafeRemoveEntityDelayed(meme, 30)
  530. self.bloodpool_lastdmgbone=nil
  531. end
  532. //hentai
  533.  
  534. if RagdollUrine:GetString()=='765493316' then
  535. --print(RagdollUrine:GetInt())
  536. -- boneid2=ragdoll:LookupBone( 'ValveBiped.Bip01_L_Thigh' )
  537. -- boneid3=ragdoll:LookupBone( 'ValveBiped.Bip01_R_Thigh' )
  538. -- pos3=(ragdoll:GetBonePosition(boneid2)+ragdoll:GetBonePosition(boneid3))
  539. -- timer.Simple(5,function()
  540. -- boneid1=ragdoll:LookupBone( 'ValveBiped.Bip01_Pelvis' )
  541. -- CreateUrineForRagdoll(ragdoll, boneid1, boneid2,boneid3,BLOOD_COLOR_YELLOW, 1)
  542. -- end)
  543.  
  544. local lpos = Vector(-5,3,0)
  545. local lang = Angle(0,-25,0)
  546.  
  547.  
  548. --ParticleEffectAttach("AntlionGibTrails_air", PATTACH_ABSORIGIN_FOLLOW, meme, 0)
  549.  
  550. timer.Simple(math.Rand(6,8),function()
  551. --print(114)
  552. local memeu = ents.Create("prop_dynamic")
  553. memeu:SetModel("models/error.mdl")
  554. memeu:Spawn()
  555. memeu:SetModelScale(0)
  556. memeu:SetNotSolid(true)
  557. memeu:DrawShadow(false)
  558.  
  559. SafeRemoveEntityDelayed(memeu, 30)
  560.  
  561. memeu:SetParent(ragdoll)
  562.  
  563. memeu:SetLocalAngles(lang)
  564. memeu:SetLocalPos(lpos - lang:Forward()*-8)
  565.  
  566. ParticleEffectAttach("AntlionGibTrails_air", PATTACH_ABSORIGIN_FOLLOW, meme, 0)
  567. if IsValid(memeu) then
  568. local effectdatau = EffectData()
  569. effectdatau:SetEntity(memeu)
  570. effectdatau:SetFlags(0)
  571. util.Effect("urinestreameffectzippymod", effectdatau)
  572. end
  573. end)
  574. end
  575. //finger
  576. for ii= 0 , ragdoll:GetBoneCount() do
  577. if ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger0' then
  578. ragdoll:ManipulateBoneAngles(ii,Angle(0,3-math.Rand(0,3),0))
  579. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger0' then
  580. ragdoll:ManipulateBoneAngles(ii,Angle(0,10-math.Rand(0,2),0))
  581. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger01' then
  582. ragdoll:ManipulateBoneAngles(ii,Angle(0,20-math.Rand(0,2),0))
  583. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger02' then
  584. ragdoll:ManipulateBoneAngles(ii,Angle(0,25-math.Rand(0,3),0))
  585. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger1' then
  586. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  587. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger11' then
  588. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  589. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger12' then
  590. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  591. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger2' then
  592. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-26-math.Rand(0,4),0))
  593. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger21' then
  594. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,40),0))
  595. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger22' then
  596. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,40),0))
  597. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger3' then
  598. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  599. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger31' then
  600. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,40),0))
  601. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger32' then
  602. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,40),0))
  603. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger4' then
  604. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,30),0))
  605. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger41' then
  606. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,20),0))
  607. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_L_Finger42' then
  608. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,3),0))
  609.  
  610. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger0' then
  611. ragdoll:ManipulateBoneAngles(ii,Angle(0,3-math.Rand(0,2),0))
  612. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger01' then
  613. ragdoll:ManipulateBoneAngles(ii,Angle(0,10-math.Rand(0,3),0))
  614. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger02' then
  615. ragdoll:ManipulateBoneAngles(ii,Angle(0,20-math.Rand(0,3),0))
  616. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger1' then
  617. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  618. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger11' then
  619. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  620. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger12' then
  621. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  622. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger2' then
  623. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-27-math.Rand(0,4),0))
  624. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger21' then
  625. ragdoll:ManipulateBoneAngles(ii,Angle(0,-35-math.Rand(0,4),0))
  626. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger22' then
  627. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,4),0))
  628. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger3' then
  629. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-25-math.Rand(0,4),0))
  630. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger31' then
  631. ragdoll:ManipulateBoneAngles(ii,Angle(0,-32-math.Rand(0,4),0))
  632. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger32' then
  633. ragdoll:ManipulateBoneAngles(ii,Angle(0,-20-math.Rand(0,40),0))
  634. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger4' then
  635. ragdoll:ManipulateBoneAngles(ii,Angle(math.Rand(-5,5),-20-math.Rand(0,30),0))
  636. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger41' then
  637. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,20),0))
  638. elseif ragdoll:GetBoneName(ii)=='ValveBiped.Bip01_R_Finger42' then
  639. ragdoll:ManipulateBoneAngles(ii,Angle(0,-25-math.Rand(0,3),0))
  640. end
  641.  
  642. end
  643. dolls[self] = ragdoll
  644. --LocalRagdoll = ragdoll
  645. --rag=ragdoll
  646. --ragdoll:AddCallback( "PhysicsCollide", OnPlyRagdollCollide)
  647.  
  648.  
  649. net.Start("Fedhoria_Ragdoll")
  650. net.WriteInt(ragdoll:EntIndex(),32)
  651. net.WriteEntity(ragdoll:GetOwner())
  652. --print(ragdoll:EntIndex())
  653. net.Broadcast()
  654. net.Start("ragdeath_client")
  655. net.WriteInt(ragdoll:EntIndex(),32)
  656. --net.WriteInt(rag:GetOwner():EntIndex(),32)
  657. net.Broadcast()
  658. timer.Simple(1,function()
  659. ragdoll:SetOwner(NULL)
  660. end)
  661. --countt=countt+1;
  662. --rag:RealisticBlood_Setup()
  663. --local dmgapply=ragdoll.ZippyGoreMod3_LastDMGINFO
  664.  
  665. -- timer.Simple(0.5, function()
  666. -- local dmgnn=DamageInfo()
  667. -- local pos1, ang1 = ragdoll:GetBonePosition(self.bloodpool_lastdmgbone)
  668. -- dmgnn:SetDamage(1)
  669. -- dmgnn:SetDamageType(268435456)
  670. -- --dmgnn:SetAttacker(dmgapply:GetAttacker())
  671.  
  672. -- dmgnn:SetDamagePosition(pos1)
  673. -- --print(self.bloodpool_physicbone)
  674. -- ragdoll:GetPhysicsObjectNum(2):TakeDamage(1)
  675. -- end)
  676.  
  677. end
  678. hook.Add("EntityTakeDamage", "BloodPool_&Gib_TakeDamage", function(self, dmginfo)
  679. if ((self:IsPlayer() or self:IsNPC()) and RagdollBloodPool:GetBool()) or self.player==1 then
  680. -- print(1)
  681. local phys_bone = dmginfo:GetHitPhysBone_FDP(self)
  682. --print(phys_bone)
  683. if phys_bone then
  684. local bone = self:TranslatePhysBoneToBone(phys_bone)
  685. self.ZippyGoreMod3_LastDMGINFO = dmginfo
  686. self.bloodpool_lastdmgbone = bone
  687. self.bloodpool_physicbone = phys_bone
  688. self.bloodpool_lastdmglpos,self.bloodstream_lastdmglang = WorldToLocal(dmginfo:GetDamagePosition(), angle_zero, self:GetBonePosition(bone))
  689. --`print(self:GetBoneName(self.bloodpool_lastdmgbone))
  690. end
  691.  
  692. end
  693. end)
  694. local DMGINFO = FindMetaTable("CTakeDamageInfo")//from GibSplat
  695.  
  696. local COLL_CACHE = {}
  697.  
  698. local vec_max = Vector(1, 1, 1)
  699. local vec_min = -vec_max
  700.  
  701. function DMGINFO:GetHitPhysBone_FDP(ent)
  702. local mdl = ent:GetModel()
  703.  
  704. local colls = COLL_CACHE[mdl]
  705. if !colls then
  706. colls = CreatePhysCollidesFromModel(mdl)
  707. COLL_CACHE[mdl] = colls
  708. end
  709. --print(colls)
  710. local dmgpos = self:GetDamagePosition()
  711.  
  712. local dmgdir = self:GetDamageForce()
  713. dmgdir:Normalize()
  714.  
  715. local ray_start = dmgpos - dmgdir * 50
  716. local ray_end = dmgpos + dmgdir * 50
  717. if colls then
  718. for phys_bone, coll in pairs(colls) do
  719. phys_bone = phys_bone - 1
  720. local bone = ent:TranslatePhysBoneToBone(phys_bone)
  721. local pos, ang = ent:GetBonePosition(bone)
  722. if pos && ang && coll && IsValid(coll)then
  723. --print(1)
  724. if coll:TraceBox(pos, ang, ray_start, ray_end, vec_min, vec_max) then
  725. return phys_bone
  726. end
  727. end
  728. end
  729. end
  730. end
  731.  
  732. local ppas={}
  733. hook.Add("PlayerSpawn", "FPDM_Spawn", function(ply)
  734. self=ply
  735. SafeRemoveEntity(pps[self])
  736. ply:SetViewEntity(ply)
  737. -- ply:SetShouldServerRagdoll(enabled:GetBool())
  738.  
  739. end)
  740.  
  741.  
  742. local oldGetRagdollEntity = PLAYER.GetRagdollEntity
  743.  
  744. local function GetRagdollEntity(self)
  745. return dolls[self] or NULL
  746. end
  747.  
  748. if enabled:GetBool() then
  749. PLAYER.CreateRagdoll = CreateEntityRagdoll
  750. PLAYER.GetRagdollEntity = GetRagdollEntity
  751. end
  752.  
  753. cvars.AddChangeCallback("fedhoria_enabled", function(name, old, new)
  754. if (new == "1") then
  755. if players:GetBool() then
  756.  
  757. PLAYER.CreateRagdoll = CreateEntityRagdoll
  758. PLAYER.GetRagdollEntity = GetRagdollEntity
  759. end
  760. else
  761. --PLAYER.CreateRagdoll = oldCreateRagdoll
  762. --PLAYER.GetRagdollEntity = oldGetRagdollEntity
  763. end
  764. end)
  765.  
  766. cvars.AddChangeCallback("fedhoria_players", function(name, old, new)
  767. if (new == "1") then
  768. if enabled:GetBool() then
  769. if (debug.getinfo(PLAYER.CreateRagdoll).short_src == "[C]") then
  770. PLAYER.CreateRagdoll = CreateEntityRagdoll
  771. PLAYER.GetRagdollEntity = GetRagdollEntity
  772. end
  773. end
  774. else
  775. --PLAYER.CreateRagdoll = oldCreateRagdoll
  776. --PLAYER.GetRagdollEntity = oldGetRagdollEntity
  777. end
  778. end)
  779. local Feddmginfo={}
  780.  
  781. hook.Add("PostPlayerDeath", "Fedhoria", function(ply)
  782. if (!enabled:GetBool() or !players:GetBool()) then return end
  783.  
  784.  
  785.  
  786.  
  787. timer.Simple(0, function()
  788. if !IsValid(ply) then return end
  789. local ragdoll = ply:GetRagdollEntity()
  790. if (IsValid(ragdoll) and ragdoll:IsRagdoll()) then
  791.  
  792. local dmgpos = last_dmgpos[ply]
  793. local phys_bone, lpos
  794.  
  795. if dmgpos then
  796. phys_bone = ragdoll:GetClosestPhysBone(dmgpos)
  797. if phys_bone then
  798. local phys = ragdoll:GetPhysicsObjectNum(phys_bone)
  799. lpos = phys:WorldToLocal(dmgpos)
  800. end
  801. end
  802.  
  803. ragdoll.hatelist = {}
  804. for k, v in ipairs( ents.FindByClass("npc_*") ) do
  805. if v:IsNPC() and v:Disposition(ply)==D_HT then
  806. table.insert(ragdoll.hatelist, v)
  807. end
  808. end
  809.  
  810. --print("aaa3",dmgpos,phys_bone, lpos)
  811. fedhoria.StartModule(ragdoll, "stumble_legs", phys_bone, lpos)
  812.  
  813. end
  814. end)
  815. end)
  816.  
  817.  
  818.  
  819.  
  820. -- hook.Add("CreateEntityRagdoll","RagDeath_Ragdoll",function(owner, rag)
  821. -- --print(owner)
  822. -- if type(owner) != "Player" then return end
  823. -- -- Send the ragdolls entity index to its owner player
  824. -- local index = rag:EntIndex()
  825. -- net.Start("ragdeath_client")
  826. -- net.WriteInt(rag:EntIndex(),32)
  827. -- net.WriteInt(owner:EntIndex(),32)
  828. -- net.Broadcast()
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836. -- -- Remove owner (Otherwise owning player won't collide with the ragdoll)
  837. -- rag:SetOwner(NULL )
  838.  
  839. -- -- Enable tool interactions
  840. -- rag.CanConstrain = true
  841. -- rag.GravGunPunt = true
  842. -- rag.PhysgunDisabled = false
  843.  
  844. -- -- Add callback for blood decals
  845. -- rag:AddCallback( "PhysicsCollide", OnRagdollCollide)
  846.  
  847. -- end)
  848. local NPC =
  849. {
  850. Name = "Npc Info Target",
  851. Class = "npc_info_target",
  852. Health = "10",
  853. KeyValues = { citizentype = 4 },
  854. Model = "",
  855. Category = "Dummy"
  856. }
  857. list.Set( "NPC", "npc_info_target", NPC )
  858.  
  859. local NPC =
  860. {
  861. Name = "Npc Info Target",
  862. Class = "npc_info_target",
  863. Health = "10",
  864. KeyValues = { citizentype = 4 },
  865. Model = "",
  866. Category = "Dummy"
  867. }
  868. list.Set( "NPC", "dummy_info_target", NPC )
  869.  
  870. local NPC =
  871. {
  872. Name = "Npc Info Target Enemy",
  873. Class = "npc_info_target_e",
  874. Health = "10",
  875. Model = "",
  876. KeyValues = { citizentype = 4 },
  877. Category = "Dummy"
  878. }
  879. list.Set( "NPC", "npc_info_target_e", NPC )
  880.  
  881.  
  882.  
  883.  
Add Comment
Please, Sign In to add comment