Senior Member
Join Date: Sep 2015
Location: Location:
|
06-05-2019
, 23:52
Re: [L4D2] cs_ragdoll usage?
|
#9
|
Quote:
Originally Posted by Dragokas
I'm not compeletely sure what do you try to accomplish ... "convert" client sided ragdoll to server-sided?
In L4D1 (not sure about L4d2) ragdoll entity is valid for a very small amount of time: "player_death" with EventHookMode_Pre and no more valid on Post-event.
A trick is to kill it right there and create your own by reproducing original preperties, something like this:
PHP Code:
#pragma semicolon 1 #pragma newdecls required
#include <sourcemod> #include <sdktools> #tryinclude <LMCCore>
public void OnPluginStart() { HookEvent("player_death", player_death, EventHookMode_Pre); }
public Action player_death(Event event, const char [] name, bool dontBroadcast) { static char Tank_Model[PLATFORM_MAX_PATH]; int client = GetClientOfUserId(event.GetInt("userid")); //required checks //if (client && IsClientInGame(client) && IsInfected(client, ZOMBIECLASS_TANK)) { // note: tank_killed event is too late here to retrieve ragdoll entity! int ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll"); // CCSRagdoll if (ragdoll && IsValidEntity(ragdoll)) { AcceptEntityInput(ragdoll, "Kill"); } int r,g,b,a; float vOrigin[3]; char sColor[16]; GetClientAbsOrigin(client, vOrigin); GetEntityRenderColor(client, r,g,b,a); Format(sColor, sizeof(sColor), "%i %i %i", r, g, b); /* int iOverlayModel = -1; #if defined _LMCCore_included if( bLMC_Available ) iOverlayModel = LMC_GetClientOverlayModel(client); #endif */ //GetEntPropString(iOverlayModel < 1 ? client : iOverlayModel, Prop_Data, "m_ModelName", Tank_Model, sizeof(Tank_Model)); GetEntPropString(client, Prop_Data, "m_ModelName", Tank_Model, sizeof(Tank_Model)); CreateTankRagdoll(vOrigin, Tank_Model, sColor); } }
void CreateTankRagdoll(float pos[3], char[] sModel, char[] sColor) { static int body; body = CreateEntityByName("prop_ragdoll"); if (body != -1) { DispatchKeyValue(body, "model", sModel); DispatchKeyValue(body, "RenderColor", sColor); DispatchKeyValue(body, "spawnflags", "4"); DispatchSpawn(body); TeleportEntity(body, pos, NULL_VECTOR, NULL_VECTOR); SetEntityKillTimer(body, 60.0); } }
stock void SetEntityKillTimer(int ent, float time) { char sRemove[64]; Format(sRemove, sizeof(sRemove), "OnUser1 !self:Kill::%f:1", time); SetVariantString(sRemove); AcceptEntityInput(ent, "AddOutput"); AcceptEntityInput(ent, "FireUser1"); }
Apply original velocity and direction is the only required to add to finish what you want.
This sample was for my tank plugin.
|
Basically, what I'm trying to do is make dead survivors create a client ragdoll like in the Restore Ragdolls plugin, while keeping the original death model albeit making it invisible.
Reasons:
* I wanted to try out something (almost) on my own.
* Death models created with CreateEntityByName aren't affected by gravity.
Sorry if what I wanted wasn't all that clear with you.
The problem was that the client ragdolls didn't automatically assume the velocity + bone positions of their owner. So far only velocity from owner itself was finished.
And yes, in L4D2 cs_ragdoll behaves similarly like in L4D1.
Last edited by Shadowysn; 06-06-2019 at 00:01.
|
|