L L4D2node

sb_takecontrol

0x009cae70 · 457 bytes · __cdecl

_ZL14sb_takecontrolRK8CCommand

Decompiled

undefined (1 param)

/* sb_takecontrol(CCommand const&) */

void sb_takecontrol(CCommand *param_1)

{
  int iVar1;
  char cVar2;
  CTerrorPlayer *this;
  int iVar3;
  SurvivorBot *this_00;
  undefined4 uVar4;
  char *pcVar5;
  SurvivorBot *local_28;
  BossZombiePlayerBot *local_24;
  CTerrorPlayer *local_20;
  
  this = (CTerrorPlayer *)UTIL_GetCommandClient();
  if (this == (CTerrorPlayer *)0x0) {
    return;
  }
  pcVar5 = "";
  if (1 < *(int *)param_1) {
    pcVar5 = *(char **)(param_1 + 0x40c);
  }
  if (*pcVar5 == '\0') {
    this_00 = (SurvivorBot *)GetNextCommandEntity((CBasePlayer *)this,"",(CBaseEntity *)0x0);
    if ((this_00 != (SurvivorBot *)0x0) &&
       (cVar2 = (**(code **)(*(int *)this_00 + 0x16c))(this_00), cVar2 != '\0')) goto LAB_009cafc5;
  }
  else {
    iVar3 = _V_stricmp(pcVar5,"next");
    if (iVar3 != 0) {
      uVar4 = GetCharacterFromName(pcVar5);
      this_00 = (SurvivorBot *)CTerrorPlayer::GetPlayerByCharacter(uVar4);
      if (this_00 == (SurvivorBot *)0x0) {
        return;
      }
      cVar2 = (**(code **)(*(int *)this_00 + 0x778))(this_00);
      if (cVar2 == '\0') {
        return;
      }
LAB_009cafc5:
      cVar2 = (**(code **)(*(int *)this_00 + 0x778))(this_00);
      if ((cVar2 != '\0') &&
         (iVar3 = CBaseEntity::GetTeamNumber((CBaseEntity *)this_00), iVar3 == 2))
      goto LAB_009caf0d;
    }
  }
  iVar3 = *(int *)(this + 0x2ba0);
  iVar1 = iVar3;
  do {
    iVar1 = (iVar1 + 1) % 4;
    if (iVar3 == iVar1) {
      return;
    }
    this_00 = (SurvivorBot *)CTerrorPlayer::GetPlayerByCharacter(iVar1);
  } while ((this_00 == (SurvivorBot *)0x0) ||
          (cVar2 = (**(code **)(*(int *)this_00 + 0x778))(this_00), cVar2 == '\0'));
LAB_009caf0d:
  local_28 = (SurvivorBot *)0x0;
  local_24 = (BossZombiePlayerBot *)0x0;
  local_20 = this;
  ForEachTerrorPlayer<FindBotSpectator>((FindBotSpectator *)&local_28);
  if (local_28 != (SurvivorBot *)0x0) {
    SurvivorBot::ResetHumanSpectator(local_28);
  }
  if (local_24 != (BossZombiePlayerBot *)0x0) {
    BossZombiePlayerBot::ResetHumanSpectator(local_24);
  }
  (**(code **)(*(int *)this + 0x194))(this,1);
  SurvivorBot::SetHumanSpectator(this_00,this);
  (**(code **)(*(int *)this + 0x64c))(this,this_00);
  CTerrorPlayer::TakeOverBot(this,false);
  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)