CreateServerRagdoll
0x00799710 · 3047 bytes · __cdecl
_Z19CreateServerRagdollP14CBaseAnimatingiRK15CTakeDamageInfoib
Decompiled
undefined (5 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CreateServerRagdoll(CBaseAnimating*, int, CTakeDamageInfo const&, int, bool) */
CBaseAnimating *
CreateServerRagdoll(CBaseAnimating *param_1,int param_2,CTakeDamageInfo *param_3,int param_4,
bool param_5)
{
CBaseAnimating CVar1;
ushort uVar2;
CBaseEdict *pCVar3;
code *pcVar4;
char cVar5;
CBaseAnimating *this;
char *pcVar6;
int *piVar7;
int iVar8;
undefined4 *puVar9;
int iVar10;
CStudioHdr *pCVar11;
CStudioHdr *pCVar12;
undefined *puVar13;
char *pcVar14;
matrix3x4_t *pmVar15;
uint uVar16;
int iVar17;
longdouble lVar18;
float fVar19;
float fVar20;
Vector *local_3264;
Vector *local_3260;
matrix3x4_t *local_3258;
float local_3254;
float local_3240;
float local_323c;
float local_3238;
undefined4 local_3234;
undefined4 local_3230;
undefined4 local_322c;
float local_3228;
float local_3224;
float local_3220;
float local_321c;
float local_3218;
float local_3214;
matrix3x4_t local_301c [6144];
matrix3x4_t local_181c [6156];
if ((((byte)param_3[0x48] & 0x11) != 0) &&
(piVar7 = *(int **)(param_1 + 0x238), piVar7 != (int *)0x0)) {
(**(code **)(*piVar7 + 0x11c))(piVar7,(Vector *)local_181c,0);
CBaseEntity::SetAbsOrigin((CBaseEntity *)param_1,(Vector *)local_181c);
}
local_3258 = local_181c;
if (((byte)param_1[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)param_1);
}
this = (CBaseAnimating *)
CBaseEntity::CreateNoSpawn
("prop_ragdoll",(Vector *)(param_1 + 0x2e0),(QAngle *)&vec3_angle,
(CBaseEntity *)0x0);
CBaseAnimating::CopyAnimationDataFrom(this,param_1);
(**(code **)(*(int *)this + 0x50))(this,param_1);
CRagdollProp::InitRagdollAnimation((CRagdollProp *)this);
if (((byte)param_1[0x14f] & 8) != 0) {
*(uint *)(this + 0x14c) = *(uint *)(this + 0x14c) | 0x8000000;
}
uVar16 = *(uint *)(param_3 + 0x30);
if ((((uVar16 == 0xffffffff) ||
(puVar13 = g_pEntityList + (uVar16 & 0xfff) * 0x10, puVar13 == (undefined *)0xfffffffc)) ||
(*(uint *)(puVar13 + 8) != uVar16 >> 0xc)) ||
(piVar7 = *(int **)(puVar13 + 4), piVar7 == (int *)0x0)) {
*(undefined4 *)(this + 0x1eb4) = 0xffffffff;
}
else {
puVar9 = (undefined4 *)(**(code **)(*piVar7 + 0xc))(piVar7);
*(undefined4 *)(this + 0x1eb4) = *puVar9;
}
pcVar6 = "";
if (*(char **)(param_1 + 0x7c) != (char *)0x0) {
pcVar6 = *(char **)(param_1 + 0x7c);
}
pcVar14 = (char *)0x0;
if (*pcVar6 != '\0') {
pcVar14 = pcVar6;
}
*(char **)(this + 0x1ec8) = pcVar14;
uVar2 = *(ushort *)(param_1 + 0x524);
iVar8 = *(int *)(param_1 + 0x494);
*(ushort *)(param_1 + 0x524) = uVar2 | 1;
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
if (pCVar12 == (CStudioHdr *)0x0) {
iVar17 = CBaseEntity::GetModel((CBaseEntity *)param_1);
if (iVar17 == 0) {
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
else {
CBaseAnimating::LockStudioHdr(param_1);
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
pCVar11 = (CStudioHdr *)0x0;
if (pCVar12 != (CStudioHdr *)0x0) goto LAB_0079983b;
}
else {
LAB_0079983b:
pCVar11 = (CStudioHdr *)0x0;
if (*(int *)pCVar12 != 0) {
pCVar11 = pCVar12;
}
}
lVar18 = (longdouble)CBaseAnimating::SequenceDuration(param_1,pCVar11,iVar8);
fVar19 = *(float *)(param_1 + 0x490);
local_3254 = fVar19 * (float)lVar18;
if ((local_3254 <= 0.0) || (0.1 < local_3254)) {
local_3254 = 0.1;
}
fVar20 = fVar19 - local_3254 / (float)lVar18;
if (fVar20 <= 0.0) {
fVar20 = 0.0;
}
if (1.0 <= fVar20) {
fVar20 = 1.0;
}
(**(code **)(*(int *)param_1 + 0x35c))(param_1,local_3258,0x7ff00);
if (fVar20 != *(float *)(param_1 + 0x490)) {
if (param_1[0x6c] == (CBaseAnimating)0x0) {
pCVar3 = *(CBaseEdict **)(param_1 + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar8 + 2) = 0;
}
}
else {
param_1[0x70] = (CBaseAnimating)((byte)param_1[0x70] | 1);
}
*(float *)(param_1 + 0x490) = fVar20;
}
(**(code **)(*(int *)param_1 + 0x35c))(param_1,local_301c,0x7ff00);
if (fVar19 != *(float *)(param_1 + 0x490)) {
if (param_1[0x6c] == (CBaseAnimating)0x0) {
pCVar3 = *(CBaseEdict **)(param_1 + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar8 + 2) = 0;
}
}
else {
param_1[0x70] = (CBaseAnimating)((byte)param_1[0x70] | 1);
}
*(float *)(param_1 + 0x490) = fVar19;
}
*(ushort *)(param_1 + 0x524) = *(ushort *)(param_1 + 0x524) & 0xfffe | uVar2;
if (((byte)param_1[0x14d] & 0x10) != 0) {
CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)param_1);
}
local_3240 = *(float *)(param_1 + 0x274);
local_323c = *(float *)(param_1 + 0x278);
local_3238 = *(float *)(param_1 + 0x27c);
fVar19 = local_3238 * local_3238 + local_323c * local_323c + local_3240 * local_3240;
if ((SQRT(fVar19) == 0.0) && (0.0 < local_3254)) {
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
if (pCVar12 == (CStudioHdr *)0x0) {
iVar8 = CBaseEntity::GetModel((CBaseEntity *)param_1);
if (iVar8 == 0) {
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
else {
CBaseAnimating::LockStudioHdr(param_1);
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
if (pCVar12 != (CStudioHdr *)0x0) goto LAB_007999fc;
}
else {
LAB_007999fc:
if (*(int *)pCVar12 != 0) {
cVar5 = Studio_SeqMovement(pCVar12,*(int *)(param_1 + 0x494),fVar20,
*(float *)(param_1 + 0x490),(float *)(param_1 + 0x498),
(Vector *)&local_3228,(QAngle *)&local_321c);
if (cVar5 != '\0') {
if (((byte)param_1[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)param_1);
}
VectorRotate(&local_3228,(matrix3x4_t *)(param_1 + 0x28c),&local_3240);
fVar19 = 1.0 / local_3254;
local_3240 = local_3240 * fVar19;
local_323c = local_323c * fVar19;
local_3238 = fVar19 * local_3238;
}
fVar19 = local_3240 * local_3240 + local_323c * local_323c + local_3238 * local_3238;
goto LAB_00799af8;
}
}
fVar19 = local_3240 * local_3240 + local_323c * local_323c + local_3238 * local_3238;
}
LAB_00799af8:
local_3260 = (Vector *)&local_321c;
local_3264 = (Vector *)&local_3228;
if (0.0 < fVar19) {
piVar7 = *(int **)(param_1 + 0x13e0);
if (piVar7 == (int *)0x0) {
iVar8 = CBaseEntity::GetModel((CBaseEntity *)param_1);
if (iVar8 == 0) {
piVar7 = *(int **)(param_1 + 0x13e0);
}
else {
CBaseAnimating::LockStudioHdr(param_1);
piVar7 = *(int **)(param_1 + 0x13e0);
}
}
if ((piVar7 == (int *)0x0) || (iVar8 = *piVar7, *piVar7 == 0)) {
iVar8 = _DAT_00000000;
}
iVar8 = *(int *)(iVar8 + 0x9c);
local_3240 = local_3240 * local_3254;
local_323c = local_323c * local_3254;
local_3238 = local_3238 * local_3254;
if (0 < iVar8) {
iVar17 = 0;
pmVar15 = local_301c;
do {
iVar17 = iVar17 + 1;
MatrixGetColumn(pmVar15,3,local_3260);
local_321c = local_321c - local_3240;
local_3218 = local_3218 - local_323c;
local_3214 = local_3214 - local_3238;
MatrixSetColumn(local_3260,3,pmVar15);
pmVar15 = pmVar15 + 0x30;
} while (iVar17 != iVar8);
}
}
if ((((byte)param_3[0x48] & 0x10) == 0) || (iVar8 = CBaseEntity::MyNPCPointer(), iVar8 == 0)) {
local_321c = *(float *)(param_3 + 0xc);
local_3218 = *(float *)(param_3 + 0x10);
local_3214 = *(float *)(param_3 + 0x14);
local_3228 = *(float *)param_3;
local_3224 = *(float *)(param_3 + 4);
local_3220 = *(float *)(param_3 + 8);
CRagdollProp::InitRagdoll
((CRagdollProp *)this,local_3264,param_2,local_3260,local_301c,local_3258,local_3254,
param_4,true,true);
}
else {
CRagdollProp::InitRagdoll
((CRagdollProp *)this,(Vector *)&vec3_origin,-1,(Vector *)&vec3_origin,local_301c,
local_3258,local_3254,param_4,true,true);
local_3234 = 0;
local_3230 = 0;
local_322c = 0xbf800000;
iVar8 = CBaseAnimating::GetHitboxesFrontside
(param_1,(int *)local_3260,0x80,(Vector *)&local_3234,
-*(float *)(param_3 + 0x14));
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
if (pCVar12 == (CStudioHdr *)0x0) {
iVar17 = CBaseEntity::GetModel((CBaseEntity *)param_1);
if (iVar17 == 0) {
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
else {
CBaseAnimating::LockStudioHdr(param_1);
pCVar12 = *(CStudioHdr **)(param_1 + 0x13e0);
}
if (pCVar12 != (CStudioHdr *)0x0) goto LAB_00799ebf;
pCVar11 = (CStudioHdr *)0x0;
}
else {
LAB_00799ebf:
pCVar11 = (CStudioHdr *)0x0;
if (*(int *)pCVar12 != 0) {
pCVar11 = pCVar12;
}
}
lVar18 = (longdouble)Studio_GetMass(pCVar11);
fVar19 = (float)lVar18;
if (fVar19 <= 1.0) {
fVar19 = 1.0;
}
if (10000.0 <= fVar19) {
fVar19 = 10000.0;
}
fVar19 = 1.0 / fVar19;
if (0 < iVar8) {
iVar17 = 0;
do {
iVar10 = iVar17 * 4;
iVar17 = iVar17 + 1;
iVar10 = CBaseAnimating::GetHitboxBone(param_1,*(int *)(local_3260 + iVar10));
iVar10 = CBaseAnimating::GetPhysicsBone(param_1,iVar10);
piVar7 = *(int **)(this + iVar10 * 0x54 + 0x1410);
pcVar4 = *(code **)(*piVar7 + 0xf4);
lVar18 = (longdouble)(**(code **)(*piVar7 + 0x78))(piVar7);
local_3220 = (float)lVar18;
local_3224 = *(float *)(param_3 + 4) * fVar19 * local_3220;
local_3228 = *(float *)param_3 * fVar19 * local_3220;
local_3220 = *(float *)(param_3 + 8) * fVar19 * local_3220;
(*pcVar4)(piVar7,local_3264);
} while (iVar17 != iVar8);
CVar1 = param_1[0x153];
goto joined_r0x00799fed;
}
}
CVar1 = param_1[0x153];
joined_r0x00799fed:
if (((byte)CVar1 & 0x10) == 0) {
if (param_5) {
uVar16 = *(uint *)(this + 0x148) | 0x1000;
if (*(uint *)(this + 0x148) != uVar16) {
if (this[0x6c] == (CBaseAnimating)0x0) {
pCVar3 = *(CBaseEdict **)(this + 0x30);
if (pCVar3 != (CBaseEdict *)0x0) {
*(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
iVar8 = CBaseEdict::GetChangeAccessor(pCVar3);
*(undefined2 *)(iVar8 + 2) = 0;
}
}
else {
this[0x70] = (CBaseAnimating)((byte)this[0x70] | 1);
}
*(uint *)(this + 0x148) = uVar16;
}
CRagdollLRURetirement::MoveToTopOfLRU((CRagdollLRURetirement *)s_RagdollLRU,this,1);
}
}
else {
CBaseAnimating::TransferDissolveFrom(this,param_1);
}
puVar9 = (undefined4 *)(**(code **)(*(int *)(param_1 + 0x194) + 4))(param_1 + 0x194);
local_3228 = (float)*puVar9;
local_3224 = (float)puVar9[1];
local_3220 = (float)puVar9[2];
puVar9 = (undefined4 *)(**(code **)(*(int *)(param_1 + 0x194) + 8))(param_1 + 0x194);
local_321c = (float)*puVar9;
local_3218 = (float)puVar9[1];
local_3214 = (float)puVar9[2];
CCollisionProperty::SetCollisionBounds((CCollisionProperty *)(this + 0x194),local_3264,local_3260)
;
return this;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.