L L4D2node

CResponseSystem::FindBestResponse

0x005b8f00 · 1386 bytes · __thiscall

_ZN15CResponseSystem16FindBestResponseERK14AI_CriteriaSetR11AI_ResponseP15IResponseFilter

Decompiled

undefined (4 params)

/* CResponseSystem::FindBestResponse(AI_CriteriaSet const&, AI_Response&, IResponseFilter*) */

char __thiscall
CResponseSystem::FindBestResponse
          (CResponseSystem *this,AI_CriteriaSet *param_1,AI_Response *param_2,
          IResponseFilter *param_3)

{
  Rule *pRVar1;
  bool bVar2;
  char cVar3;
  undefined2 uVar4;
  ushort uVar5;
  uint uVar6;
  undefined4 uVar7;
  int iVar8;
  char *pcVar9;
  int iVar10;
  char *pcVar11;
  int iVar12;
  Rule RVar13;
  byte bVar14;
  byte bVar15;
  int in_GS_OFFSET;
  ScriptFollowup_t *local_168;
  float local_15c;
  undefined4 local_158;
  undefined4 *local_154;
  undefined4 local_150 [2];
  undefined4 local_145;
  undefined4 local_141;
  undefined4 local_13d;
  undefined2 local_139;
  undefined2 local_137;
  undefined1 local_135;
  undefined4 local_134;
  undefined4 *local_130;
  undefined4 local_12c;
  undefined4 local_128;
  undefined4 local_124;
  char local_120 [128];
  char local_a0 [128];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  iVar8 = *(int *)(rr_debugresponses._28_4_ + 0x30);
  bVar2 = iVar8 - 1U < 3;
  uVar6 = FindBestMatchingRule(this,param_1,iVar8 == 3,&local_15c);
  local_12c = 0;
  local_128 = 0;
  local_124 = 0;
  local_137 = 0;
  local_139 = 100;
  uVar4 = float16::ConvertFloatTo16bits(0.0);
  local_135 = 0;
  local_145 = CONCAT22(uVar4,uVar4);
  local_141 = CONCAT22(uVar4,uVar4);
  local_13d = CONCAT22(uVar4,uVar4);
  local_134 = CONCAT22(uVar4,uVar4);
  local_130 = (undefined4 *)0x0;
  local_120[0] = '\0';
  local_a0[0] = '\0';
  if ((uVar6 == 0xffffffff) || (0xff < uVar6 >> 0x10)) {
LAB_005b902a:
    bVar14 = 0;
    uVar7 = 0;
    cVar3 = '\0';
    bVar15 = 0;
  }
  else {
    iVar12 = (uVar6 >> 0x10) * 0x38;
    if (*(ushort *)(this + iVar12 + 0x8e) <= (ushort)uVar6) goto LAB_005b902a;
    local_158 = 0;
    iVar10 = (uVar6 & 0xffff) * 0x10;
    local_154 = (undefined4 *)0x0;
    pRVar1 = *(Rule **)(*(int *)(this + iVar12 + 0x80) + 0xc + iVar10);
    cVar3 = GetBestResponse(this,(ResponseSearchResult *)&local_158,pRVar1,bVar2,param_3);
    if (cVar3 == '\0') {
      bVar15 = 0;
    }
    else {
      V_strncpy(local_a0,(char *)local_154[10],0x80);
      local_145 = *local_154;
      bVar15 = *(byte *)((int)local_154 + 0x2f) & 0x3f;
      local_141 = local_154[1];
      local_13d = local_154[2];
      local_139 = *(undefined2 *)(local_154 + 3);
      local_137 = *(undefined2 *)((int)local_154 + 0xe);
      local_135 = *(undefined1 *)(local_154 + 4);
      local_134 = *(undefined4 *)((int)local_154 + 0x11);
      local_130 = *(undefined4 **)((int)local_154 + 0x15);
      AI_ResponseParams::ScriptFollowup_t::operator=
                ((ScriptFollowup_t *)&local_12c,(ScriptFollowup_t *)((int)local_154 + 0x19));
      local_130 = local_154 + 0xc;
    }
    local_150[0] = *(undefined4 *)(*(int *)(this + iVar12 + 0x80) + 8 + iVar10);
    uVar5 = CUtlRBTree<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,char_const*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
            ::Find((CUtlRBTree<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short,CUtlMap<unsigned_int,char_const*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<unsigned_int,char_const*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
                    *)(this + iVar12 + 0x98),(Node_t *)local_150);
    if (uVar5 == 0xffff) {
      pcVar11 = "";
    }
    else {
      pcVar11 = *(char **)((uint)uVar5 * 0x10 + *(int *)(this + iVar12 + 0x9c) + 0xc);
    }
    V_strncpy(local_120,pcVar11,0x80);
    RVar13 = pRVar1[0x25];
    if (((byte)RVar13 & 2) != 0) {
      RVar13 = (Rule)((byte)RVar13 & 0xfb);
      pRVar1[0x25] = RVar13;
    }
    bVar14 = (byte)RVar13 & 1;
    cVar3 = '\x01';
    uVar7 = *(undefined4 *)(pRVar1 + 0x20);
    *(float *)(param_2 + 0xb0) = local_15c;
  }
  local_168 = (ScriptFollowup_t *)&local_12c;
                    /* try { // try from 005b9076 to 005b93fd has its CatchHandler @ 005b948e */
  AI_Response::Init(param_2,bVar15,local_a0,&local_145,local_120,uVar7,bVar14);
  if ((bVar2) && ((cVar3 != '\0' || (iVar8 - 2U < 2)))) {
    pcVar11 = "FCVAR_NEVER_AS_STRING";
    if ((rr_debugresponseconcept[0x15] & 0x10) == 0) {
      pcVar11 = "";
      if (*(char **)(rr_debugresponseconcept._28_4_ + 0x24) != (char *)0x0) {
        pcVar11 = *(char **)(rr_debugresponseconcept._28_4_ + 0x24);
      }
    }
    iVar8 = _V_strlen(pcVar11);
    if ((iVar8 < 1) || (*(int *)(rr_debugresponseconcept._28_4_ + 0x30) != 0)) {
      if (((-1 < (int)DAT_00fb7c8c) &&
          (((int)DAT_00fb7c8c < DAT_00fb7c84 && (DAT_00fb7c8c <= DAT_00fb7ca0)))) &&
         ((iVar8 = m_DebugExcludeList + DAT_00fb7c8c * 0xc, DAT_00fb7c8c != *(ushort *)(iVar8 + 8)
          || (DAT_00fb7c8c == *(ushort *)(iVar8 + 10))))) {
        iVar8 = AI_CriteriaSet::FindCriterionIndex(param_1,"concept");
        pcVar11 = (char *)AI_CriteriaSet::GetValue(param_1,iVar8);
        CAI_Concept::CAI_Concept((CAI_Concept *)local_150,pcVar11);
        for (uVar6 = DAT_00fb7c8c; uVar6 != 0xffff;
            uVar6 = (uint)*(ushort *)(m_DebugExcludeList + 10 + uVar6 * 0xc)) {
          iVar8 = CAI_Concept::GetStringConcept((CAI_Concept *)(m_DebugExcludeList + uVar6 * 0xc));
          iVar12 = CAI_Concept::GetStringConcept((CAI_Concept *)local_150);
          if (iVar8 == iVar12) {
            if ((int)uVar6 < 0) goto LAB_005b93f0;
            goto LAB_005b943a;
          }
        }
        uVar6 = 0xffff;
LAB_005b943a:
        if ((((int)uVar6 < DAT_00fb7c84) && (uVar6 <= DAT_00fb7ca0)) &&
           ((iVar8 = m_DebugExcludeList + uVar6 * 0xc, uVar6 != *(ushort *)(iVar8 + 8) ||
            (uVar6 == *(ushort *)(iVar8 + 10))))) goto LAB_005b9110;
      }
    }
    else {
      iVar8 = AI_CriteriaSet::FindCriterionIndex(param_1,"concept");
      pcVar9 = (char *)AI_CriteriaSet::GetValue(param_1,iVar8);
      iVar8 = _V_stricmp(pcVar11,pcVar9);
      if (iVar8 != 0) goto LAB_005b9110;
    }
LAB_005b93f0:
    AI_Response::Describe(param_2);
  }
LAB_005b9110:
  AI_ResponseParams::ScriptFollowup_t::~ScriptFollowup_t(local_168);
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return cVar3;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)