L L4D2node

CFish::Update

0x006a54f0 · 2399 bytes · __thiscall

_ZN5CFish6UpdateEf

Decompiled

undefined (2 params)

/* CFish::Update(float) */

void __thiscall CFish::Update(CFish *this,float param_1)

{
  int iVar1;
  uint uVar2;
  CBaseEdict *pCVar3;
  undefined *puVar4;
  int iVar5;
  longdouble lVar6;
  float fVar7;
  float fVar8;
  float fVar9;
  float fVar10;
  float fVar11;
  float fVar12;
  float local_5c;
  double local_4c;
  double local_44 [2];
  float local_34;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  
  if (((byte)this[0x14d] & 8) != 0) {
    CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
  }
  fVar12 = *(float *)(this + 0x2e0) - *(float *)(this + 0x1428);
  fVar9 = fVar12;
  if (fVar12 <= -255.0) {
    fVar9 = -255.0;
  }
  fVar10 = *(float *)(this + 0x2e4) - *(float *)(this + 0x142c);
  fVar11 = *(float *)(this + 0x2e8) - *(float *)(this + 0x1430);
  if (255.0 <= fVar9) {
    fVar9 = 255.0;
  }
  if (fVar9 != *(float *)(this + 0x13fc)) {
    if (this[0x6c] == (CFish)0x0) {
      pCVar3 = *(CBaseEdict **)(this + 0x30);
      if (pCVar3 != (CBaseEdict *)0x0) {
        *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar3);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CFish)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x13fc) = fVar9;
  }
  fVar9 = -255.0;
  if (-255.0 <= fVar10) {
    fVar9 = fVar10;
  }
  if (255.0 <= fVar9) {
    fVar9 = 255.0;
  }
  if (fVar9 != *(float *)(this + 0x1400)) {
    if (this[0x6c] == (CFish)0x0) {
      pCVar3 = *(CBaseEdict **)(this + 0x30);
      if (pCVar3 != (CBaseEdict *)0x0) {
        *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar3);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CFish)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x1400) = fVar9;
  }
  fVar9 = *(float *)(this + 0x1430);
  if (fVar9 != *(float *)(this + 0x1404)) {
    if (this[0x6c] == (CFish)0x0) {
      pCVar3 = *(CBaseEdict **)(this + 0x30);
      if (pCVar3 != (CBaseEdict *)0x0) {
        *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar3);
        *(undefined2 *)(iVar5 + 2) = 0;
      }
    }
    else {
      this[0x70] = (CFish)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x1404) = fVar9;
  }
  if (this[0x104] == (CFish)0x2) {
    uVar2 = *(uint *)(this + 0x13f4);
    iVar5 = 0;
    if (((uVar2 != 0xffffffff) &&
        (puVar4 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar4 != (undefined *)0xfffffffc)) &&
       (*(uint *)(puVar4 + 8) == uVar2 >> 0xc)) {
      iVar5 = *(int *)(puVar4 + 4);
    }
    fVar9 = *(float *)(iVar5 + 0x450) - 5.0;
    if (fVar9 * fVar9 < fVar10 * fVar10 + fVar11 * fVar11 + fVar12 * fVar12) {
      local_28 = 0.0;
      local_24 = 0.0;
      local_20 = 0.0;
      CBaseEntity::SetAbsVelocity((CBaseEntity *)this,(Vector *)&local_28);
      return;
    }
    if (((byte)this[0x14d] & 0x10) != 0) {
      CBaseEntity::CalcAbsoluteVelocity((CBaseEntity *)this);
    }
    local_28 = *(float *)(this + 0x274) - param_1 * *(float *)(this + 0x274);
    local_24 = *(float *)(this + 0x278) - param_1 * *(float *)(this + 0x278);
    local_20 = *(float *)(this + 0x27c) - param_1 * *(float *)(this + 0x27c);
    CBaseEntity::SetAbsVelocity((CBaseEntity *)this,(Vector *)&local_28);
    return;
  }
  lVar6 = (longdouble)CountdownTimer::Now();
  if (*(float *)(this + 0x1454) <= (float)lVar6) {
    lVar6 = (longdouble)RandomFloat(0x41200000);
    fVar9 = (float)lVar6;
    lVar6 = (longdouble)CountdownTimer::Now();
    if ((float)lVar6 + fVar9 != *(float *)(this + 0x1454)) {
      (**(code **)(*(int *)(this + 0x144c) + 4))(this + 0x144c);
      *(float *)(this + 0x1454) = (float)lVar6 + fVar9;
    }
    if (fVar9 != *(float *)(this + 0x1450)) {
      (**(code **)(*(int *)(this + 0x144c) + 4))(this + 0x144c);
      *(float *)(this + 0x1450) = fVar9;
    }
    this[0x1458] = (CFish)((byte)this[0x1458] ^ 1);
  }
  fVar9 = *(float *)(this + 0x147c);
  lVar6 = (longdouble)CountdownTimer::Now();
  if (fVar9 - (float)lVar6 <= 0.0) {
    fVar9 = *(float *)(this + 0x1470);
    lVar6 = (longdouble)CountdownTimer::Now();
    if (fVar9 - (float)lVar6 <= 0.0) {
      lVar6 = (longdouble)CountdownTimer::Now();
      if ((float)lVar6 < *(float *)(this + 0x1464)) goto LAB_006a5611;
      lVar6 = (longdouble)RandomFloat(0x41200000);
      fVar9 = (float)lVar6;
      lVar6 = (longdouble)CountdownTimer::Now();
      if ((float)lVar6 + fVar9 != *(float *)(this + 0x1464)) {
        (**(code **)(*(int *)(this + 0x145c) + 4))(this + 0x145c);
        *(float *)(this + 0x1464) = (float)lVar6 + fVar9;
      }
      if (fVar9 != *(float *)(this + 0x1460)) {
        (**(code **)(*(int *)(this + 0x145c) + 4))(this + 0x145c);
        *(float *)(this + 0x1460) = fVar9;
      }
      lVar6 = (longdouble)RandomFloat(0x40000000);
      fVar9 = (float)lVar6;
      lVar6 = (longdouble)CountdownTimer::Now();
      if ((float)lVar6 + fVar9 != *(float *)(this + 0x1470)) {
        (**(code **)(*(int *)(this + 0x1468) + 4))(this + 0x1468);
        *(float *)(this + 0x1470) = (float)lVar6 + fVar9;
      }
      if (fVar9 != *(float *)(this + 0x146c)) {
        (**(code **)(*(int *)(this + 0x1468) + 4))(this + 0x1468);
        *(float *)(this + 0x146c) = fVar9;
      }
    }
    *(undefined4 *)(this + 0x143c) = *(undefined4 *)(this + 0x1440);
  }
  else {
    *(undefined4 *)(this + 0x143c) = *(undefined4 *)(this + 0x1444);
  }
LAB_006a5611:
  lVar6 = (longdouble)Avoid(this);
  if (*(int *)(this + 0x1498) < 1) {
    local_5c = 1.0 - (float)lVar6;
  }
  else {
    iVar5 = 0;
    local_5c = 1.0 - (float)lVar6;
    do {
      iVar1 = iVar5 * 4;
      iVar5 = iVar5 + 1;
      FlockTo(this,*(CFish **)(*(int *)(this + 0x148c) + iVar1),local_5c);
    } while (iVar5 < *(int *)(this + 0x1498));
  }
  FlockTo(this,(CFish *)0x0,local_5c);
  fVar9 = *(float *)(this + 0x1438);
  fVar8 = *(float *)(this + 0x140c);
  fVar7 = ((fVar9 / *(float *)(this + 0x1444)) * 175.0 + 25.0) * param_1;
  if (fVar8 <= fVar7) {
    fVar7 = -fVar7;
    if (fVar8 < fVar7) {
      *(float *)(this + 0x140c) = fVar7;
      fVar8 = fVar7;
    }
  }
  else {
    *(float *)(this + 0x140c) = fVar7;
    fVar8 = fVar7;
  }
  fVar7 = *(float *)(this + 0x1408);
  fVar8 = fVar8 + fVar7;
  if (fVar7 != fVar8) {
    if (this[0x6c] == (CFish)0x0) {
      pCVar3 = *(CBaseEdict **)(this + 0x30);
      if (pCVar3 != (CBaseEdict *)0x0) {
        *(uint *)pCVar3 = *(uint *)pCVar3 | 0x101;
        iVar5 = CBaseEdict::GetChangeAccessor(pCVar3);
        *(undefined2 *)(iVar5 + 2) = 0;
        fVar9 = *(float *)(this + 0x1438);
      }
    }
    else {
      this[0x70] = (CFish)((byte)this[0x70] | 1);
    }
    *(float *)(this + 0x1408) = fVar8;
    fVar7 = fVar8;
  }
  *(undefined4 *)(this + 0x140c) = 0;
  sincos((double)fVar7 * 0.017453292519943295,local_44,&local_4c);
  *(float *)(this + 0x1410) = (float)local_4c;
  *(float *)(this + 0x1420) = (float)local_4c;
  *(undefined4 *)(this + 0x1418) = 0;
  *(float *)(this + 0x1414) = (float)local_44[0];
  *(float *)(this + 0x141c) = -(float)local_44[0];
  *(undefined4 *)(this + 0x1424) = 0;
  *(float *)(this + 0x1438) = (param_1 + param_1) * (*(float *)(this + 0x143c) - fVar9) + fVar9;
  lVar6 = (longdouble)CountdownTimer::Now();
  if (*(float *)(this + 0x1470) <= (float)lVar6) {
    fVar9 = *(float *)(this + 0x143c) - param_1;
    if (fVar9 <= 0.0) {
      fVar9 = 0.0;
    }
    *(float *)(this + 0x143c) = fVar9;
  }
  local_2c = *(float *)(this + 0x1438);
  iVar5 = 0;
  local_34 = *(float *)(this + 0x1410) * local_2c;
  uVar2 = *(uint *)(this + 0x13f4);
  local_30 = *(float *)(this + 0x1414) * local_2c;
  local_2c = *(float *)(this + 0x1418) * local_2c;
  if (((uVar2 != 0xffffffff) &&
      (puVar4 = g_pEntityList + (uVar2 & 0xfff) * 0x10, puVar4 != (undefined *)0xfffffffc)) &&
     (*(uint *)(puVar4 + 8) == uVar2 >> 0xc)) {
    iVar5 = *(int *)(puVar4 + 4);
  }
  fVar9 = *(float *)(iVar5 + 0x450) - 5.0;
  if (fVar9 * fVar9 < fVar12 * fVar12 + fVar11 * fVar11 + fVar10 * fVar10) {
    local_24 = -fVar10;
    local_28 = -fVar12;
    local_20 = -fVar11;
    if (local_24 * local_30 + local_34 * local_28 + local_20 * local_2c < 0.0) {
      VectorNormalize((Vector *)&local_28);
      local_2c = 0.0;
      local_30 = local_34 * -local_24 + local_30 * local_28;
      local_34 = -local_24 * local_30;
      local_30 = local_30 * local_28;
    }
  }
  CBaseEntity::SetAbsVelocity((CBaseEntity *)this,(Vector *)&local_34);
  *(undefined4 *)(this + 0x11c) = *(undefined4 *)(this + 0x1438);
  return;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)