CAI_Expresser::SpeakDispatchResponse
0x005d3dc0 · 2876 bytes · __thiscall
_ZN13CAI_Expresser21SpeakDispatchResponseER11CAI_ConceptP11AI_ResponseP14AI_CriteriaSetP16IRecipientFilter
Decompiled
undefined (5 params)
/* CAI_Expresser::SpeakDispatchResponse(CAI_Concept&, AI_Response*, AI_CriteriaSet*,
IRecipientFilter*) */
undefined4 __thiscall
CAI_Expresser::SpeakDispatchResponse
(CAI_Expresser *this,CAI_Concept *param_1,AI_Response *param_2,AI_CriteriaSet *param_3,
IRecipientFilter *param_4)
{
undefined4 *puVar1;
float fVar2;
AI_Response AVar3;
uint uVar4;
byte *pbVar5;
char cVar6;
undefined4 uVar7;
CBaseEntity *pCVar8;
char *pcVar9;
CBaseFlex *pCVar10;
undefined *puVar11;
int iVar12;
int *piVar13;
undefined1 *puVar14;
int in_GS_OFFSET;
longdouble lVar15;
undefined4 local_27c;
int local_278;
char *local_274;
int local_268;
CBaseEntity *local_264;
void *local_250 [3];
void *local_244;
undefined4 local_240;
uint local_23c;
void *local_238;
undefined4 local_234;
undefined2 local_230;
ushort local_22e;
char local_22c [256];
CFmtStrN<256> local_12c [5];
char local_127 [263];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
AI_Response::GetResponse(param_2,local_22c,0x100);
lVar15 = (longdouble)AI_Response::GetDelay(param_2);
fVar2 = (float)lVar15;
uVar7 = AI_Response::GetSoundLevel(param_2);
cVar6 = (**(code **)(*(int *)this + 0x10))(this);
if (((cVar6 != '\0') &&
(pcVar9 = (char *)CAI_Concept::GetStringConcept((CAI_Concept *)param_1), *pcVar9 != '\0')) &&
(*param_2 != (AI_Response)0x5)) {
local_274 = (char *)0x0;
uVar4 = *(uint *)(this + 0x40);
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
local_274 = *(char **)(puVar11 + 4);
}
puVar1 = (undefined4 *)((int)local_274 + 0x154);
local_274 = "";
if ((char *)*puVar1 != (char *)0x0) {
local_274 = (char *)*puVar1;
}
piVar13 = (int *)0x0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
piVar13 = *(int **)(puVar11 + 4);
}
cVar6 = (**(code **)(*piVar13 + 0x16c))(piVar13);
if (cVar6 == '\0') {
local_27c = CAI_Concept::GetStringConcept((CAI_Concept *)param_1);
pcVar9 = local_274;
}
else {
uVar4 = *(uint *)(this + 0x40);
if ((((uVar4 == 0xffffffff) ||
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 == (undefined *)0xfffffffc))
|| (*(uint *)(puVar11 + 8) != uVar4 >> 0xc)) ||
((piVar13 = *(int **)(puVar11 + 4), piVar13 == (int *)0x0 ||
(cVar6 = (**(code **)(*piVar13 + 0x16c))(piVar13), cVar6 == '\0')))) {
piVar13 = (int *)0x0;
}
local_274 = (char *)(**(code **)(*piVar13 + 0xb8))(piVar13);
local_27c = CAI_Concept::GetStringConcept((CAI_Concept *)param_1);
pcVar9 = "UNKNOWN";
if (local_274 != (char *)0x0) {
pcVar9 = local_274;
}
}
local_278 = 0;
uVar4 = *(uint *)(this + 0x40);
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
local_278 = *(int *)(puVar11 + 4);
}
if (*(int *)(local_278 + 0x30) == 0) {
iVar12 = 0;
}
else {
iVar12 = *(int *)(local_278 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
DevMsg(2,"SpeakDispatchResponse: Entity ( %i/%s ) already speaking, forcing \'%s\'\n",iVar12,
pcVar9,local_27c);
uVar4 = *(uint *)(this + 0x40);
pCVar10 = (CBaseFlex *)0x0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
pCVar10 = *(CBaseFlex **)(puVar11 + 4);
}
RemoveActorFromScriptedScenes(pCVar10,true,false,(char *)0x0);
uVar4 = *(uint *)(this + 0x40);
pCVar8 = (CBaseEntity *)0x0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
pCVar8 = *(CBaseEntity **)(puVar11 + 4);
}
CBaseEntity::EmitSound(pCVar8,"AI_BaseNPC.SentenceStop",0.0,(float *)0x0);
uVar4 = *(uint *)(this + 0x40);
pCVar10 = (CBaseFlex *)0x0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
pCVar10 = *(CBaseFlex **)(puVar11 + 4);
}
cVar6 = IsRunningScriptedScene(pCVar10,true);
if (cVar6 != '\0') {
uVar7 = CAI_Concept::GetStringConcept((CAI_Concept *)param_1);
uVar4 = *(uint *)(this + 0x40);
pcVar9 = "UNKNOWN";
if (local_274 != (char *)0x0) {
pcVar9 = local_274;
}
iVar12 = 0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
iVar12 = *(int *)(puVar11 + 4);
}
if (*(int *)(iVar12 + 0x30) == 0) {
iVar12 = 0;
}
else {
iVar12 = *(int *)(iVar12 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
DevMsg("SpeakDispatchResponse: Entity ( %i/%s ) refusing to speak due to scene entity, tossing \'%s\'\n"
,iVar12,pcVar9,uVar7);
uVar7 = 0;
goto LAB_005d4251;
}
}
if (*(int *)(param_2 + 0x84) == 0) {
cVar6 = '\0';
}
else {
uVar4 = *(uint *)(this + 0x40);
if (((uVar4 == 0xffffffff) ||
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 == (undefined *)0xfffffffc)) ||
(*(uint *)(puVar11 + 8) != uVar4 >> 0xc)) {
CSpeechScriptBridge::AICriteriaSetToScript((CSpeechScriptBridge *)local_250,param_3);
LAB_005d3e9b:
local_244 = (void *)0x0;
local_238 = local_250[0];
}
else {
pCVar8 = *(CBaseEntity **)(puVar11 + 4);
CSpeechScriptBridge::AICriteriaSetToScript((CSpeechScriptBridge *)local_250,param_3);
local_238 = local_250[0];
if (pCVar8 == (CBaseEntity *)0x0) goto LAB_005d3e9b;
/* try { // try from 005d45cb to 005d45cf has its CatchHandler @ 005d496b */
local_244 = (void *)CBaseEntity::GetScriptInstance(pCVar8);
}
local_22e = 0;
local_240 = 0;
local_23c = 0x20;
local_234 = 0;
local_230 = 0x20;
/* try { // try from 005d3f23 to 005d3f25 has its CatchHandler @ 005d4990 */
(**(code **)(*g_pScriptVM + 0x50))
(g_pScriptVM,*(undefined4 *)(param_2 + 0x84),&local_244,2,0,0,1);
if ((local_22e & 1) != 0) {
free(local_238);
local_22e = local_22e & 0xfffe;
}
local_238 = (void *)0x0;
local_234 = 0;
local_230 = 0;
if ((local_23c & 0x10000) != 0) {
free(local_244);
}
if (local_250[0] != (void *)0x0) {
(**(code **)(*g_pScriptVM + 0x30))(g_pScriptVM,local_250[0]);
}
cVar6 = '\x01';
}
AVar3 = *param_2;
if (AVar3 == (AI_Response)0x2) {
iVar12 = (**(code **)(*(int *)this + 8))(this,local_22c,fVar2,0x3f800000,uVar7,0);
cVar6 = iVar12 != -1;
joined_r0x005d469c:
uVar7 = 0;
if (cVar6 == '\0') goto LAB_005d4251;
}
else {
if ((byte)AVar3 < 3) {
if (AVar3 == (AI_Response)0x1) {
cVar6 = AI_Response::ShouldntUseScene(param_2);
if (cVar6 != '\0') {
lVar15 = (longdouble)GetResponseDuration(this,param_2);
uVar4 = *(uint *)(this + 0x40);
pCVar8 = (CBaseEntity *)0x0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)
) && (*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
pCVar8 = *(CBaseEntity **)(puVar11 + 4);
}
iVar12 = 0;
CBaseEntity::EmitSound(pCVar8,local_22c,0.0,(float *)0x0);
uVar4 = *(uint *)(this + 0x40);
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)
) && (*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
iVar12 = *(int *)(puVar11 + 4);
}
local_264 = (CBaseEntity *)0x0;
puVar14 = &DAT_00d539c2;
if (*(undefined1 **)(iVar12 + 0x154) != (undefined1 *)0x0) {
puVar14 = *(undefined1 **)(iVar12 + 0x154);
}
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)
) && (*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
local_264 = *(CBaseEntity **)(puVar11 + 4);
}
if (*(int *)((int)local_264 + 0x30) == 0) {
iVar12 = 0;
}
else {
iVar12 = *(int *)((int)local_264 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
}
DevMsg(2,"SpeakDispatchResponse: Entity ( %i/%s ) playing sound \'%s\'\n",iVar12,puVar14,
local_22c);
NoteSpeaking(this,(float)lVar15,fVar2);
goto LAB_005d4080;
}
cVar6 = SpeakAutoGeneratedScene(this,local_22c,fVar2);
}
goto joined_r0x005d469c;
}
if (AVar3 == (AI_Response)0x3) {
cVar6 = SpeakRawScene(this,local_22c,fVar2,param_2,param_4);
goto joined_r0x005d469c;
}
if (AVar3 != (AI_Response)0x5) goto joined_r0x005d469c;
cVar6 = (**(code **)(*engine + 8))(engine);
if ((cVar6 == '\0') && (0 < *(int *)(*(int *)(g_pDeveloper + 0x1c) + 0x30))) {
local_244 = (void *)0x3f000000;
uVar4 = *(uint *)(this + 0x40);
iVar12 = 0;
local_240 = 0x3f000000;
local_23c = 0x3f800000;
if ((uVar4 != 0xffffffff) &&
((puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)))) {
iVar12 = *(int *)(puVar11 + 4);
}
CCollisionProperty::NormalizedToWorldSpace
((CCollisionProperty *)(iVar12 + 0x194),(Vector *)&local_244,(Vector *)local_250);
NDebugOverlay::Text((Vector *)local_250,local_22c,true,1.5);
}
}
LAB_005d4080:
uVar7 = ai_debug_speech._28_4_;
*(undefined4 *)(this + 0x3c) = *(undefined4 *)(gpGlobals + 0xc);
if (((*(int *)(uVar7 + 0x30) != 0) && (0 < *(int *)(*(int *)(g_pDeveloper + 0x1c) + 0x30))) &&
(*param_2 != (AI_Response)0x5)) {
local_244 = (void *)0x3f000000;
uVar4 = *(uint *)(this + 0x40);
local_240 = 0x3f000000;
local_23c = 0x3f800000;
local_268 = 0;
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
local_268 = *(int *)(puVar11 + 4);
}
CCollisionProperty::NormalizedToWorldSpace
((CCollisionProperty *)(local_268 + 0x194),(Vector *)&local_244,(Vector *)local_250);
uVar7 = CAI_Concept::GetStringConcept((CAI_Concept *)param_1);
CFmtStrN<256>::CFmtStrN(local_12c,"%s: %s",uVar7,local_22c);
NDebugOverlay::Text((Vector *)local_250,local_127,true,1.5);
}
if (param_2[0xb8] == (AI_Response)0x0) {
local_264 = (CBaseEntity *)0x0;
uVar4 = *(uint *)(this + 0x40);
if (((uVar4 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar4 >> 0xc)) {
local_264 = *(CBaseEntity **)(puVar11 + 4);
}
CBaseEntity::AddContext(local_264,*(char **)(param_2 + 0xb4));
}
else {
pbVar5 = *(byte **)(gpGlobals + 0x58);
if ((((pbVar5 != (byte *)0x0) && ((*pbVar5 & 2) == 0)) &&
(piVar13 = *(int **)(pbVar5 + 0xc), piVar13 != (int *)0x0)) &&
(pCVar8 = (CBaseEntity *)(**(code **)(*piVar13 + 0x18))(piVar13),
pCVar8 != (CBaseEntity *)0x0)) {
CBaseEntity::AddContext(pCVar8,*(char **)(param_2 + 0xb4));
}
}
local_244 = (void *)CONCAT22(local_244._2_2_,*(undefined2 *)param_1);
local_240 = *(undefined4 *)(param_1 + 4);
SetSpokeConcept(this,(Vector *)&local_244,param_2,1);
uVar7 = 1;
LAB_005d4251:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return uVar7;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
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.
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.