L L4D2node

CSpeechScriptBridge::Script_FindBestResponse

0x0080d170 · 381 bytes · __cdecl

_ZN19CSpeechScriptBridge23Script_FindBestResponseEP9HSCRIPT__S1_

Decompiled

undefined (2 params)

/* CSpeechScriptBridge::Script_FindBestResponse(HSCRIPT__*, HSCRIPT__*) */

int CSpeechScriptBridge::Script_FindBestResponse(HSCRIPT__ *param_1,HSCRIPT__ *param_2)

{
  code *pcVar1;
  char cVar2;
  ScriptClassDesc_t *pSVar3;
  CBaseEntity *this;
  CAI_Expresser *this_00;
  undefined4 uVar4;
  int iVar5;
  int in_GS_OFFSET;
  int local_108;
  CSpeechScriptBridge local_104 [8];
  AI_CriteriaSet local_fc [32];
  AI_Response local_dc [188];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (param_1 != (HSCRIPT__ *)0x0) {
    pcVar1 = *(code **)(*g_pScriptVM + 0x68);
    pSVar3 = GetScriptDesc<CBaseEntity>((CBaseEntity *)0x0);
    this = (CBaseEntity *)(*pcVar1)(g_pScriptVM,param_1,pSVar3);
    if (this != (CBaseEntity *)0x0) {
      this_00 = (CAI_Expresser *)InferExpresserFromBaseEntity(this);
      if (this_00 == (CAI_Expresser *)0x0) {
        uVar4 = CBaseEntity::GetDebugName(this);
        Warning("Couldn\'t resolve entity %s to its AI expresser; you can\'t send it a speech query.\n"
                ,uVar4);
        iVar5 = 0;
      }
      else {
        AI_CriteriaSet::AI_CriteriaSet(local_fc);
                    /* try { // try from 0080d1ee to 0080d208 has its CatchHandler @ 0080d319 */
        cVar2 = ScriptToAICriteriaSet(local_fc,param_2);
        if (cVar2 == '\0') {
                    /* try { // try from 0080d297 to 0080d29b has its CatchHandler @ 0080d319 */
          Warning(
                 "Script_FindBestResponse couldn\'t convert second parameter to a criterion set.\n "
                 );
          iVar5 = 0;
        }
        else {
          AI_Response::AI_Response(local_dc);
                    /* try { // try from 0080d216 to 0080d25d has its CatchHandler @ 0080d2ff */
          AIConceptFromCriteriaSet(local_104,local_fc);
          CAI_Expresser::GatherLocalCriteria(this_00,local_fc);
          cVar2 = CAI_Expresser::FindResponse(this_00,local_dc,local_104,local_fc);
          if (cVar2 == '\0') {
            iVar5 = 0;
            AI_Response::~AI_Response(local_dc);
          }
          else {
            CopyAIResponseToScriptTable((CSpeechScriptBridge *)&local_108,local_dc,local_fc);
            if (local_108 != 0) {
              (**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_108);
            }
            AI_Response::~AI_Response(local_dc);
            iVar5 = local_108;
          }
        }
        AI_CriteriaSet::~AI_CriteriaSet(local_fc);
      }
      goto LAB_0080d2a6;
    }
  }
  iVar5 = 0;
  Warning("Couldn\'t resolve entity in Script_FindBestResponse\n");
LAB_0080d2a6:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return iVar5;
  }
                    /* 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)