Script_CommandABot
0x00b487f0 · 1182 bytes · __cdecl
_ZL18Script_CommandABotP9HSCRIPT__
Decompiled
undefined (1 param)
/* Script_CommandABot(HSCRIPT__*) */
char Script_CommandABot(HSCRIPT__ *param_1)
{
code *pcVar1;
bool bVar2;
bool bVar3;
char cVar4;
ScriptClassDesc_t *pSVar5;
CBaseEntity *this;
float *pfVar6;
int *piVar7;
undefined4 uVar8;
int iVar9;
uint uVar10;
int iVar11;
float *pfVar12;
float *local_4c;
CBaseEntity *local_44;
char local_3d;
float *local_34 [2];
short local_2c;
ushort local_2a;
float local_28;
float local_24;
float local_20;
local_2c = 0;
local_2a = 0;
local_34[0] = (float *)0x0;
local_28 = 0.0;
local_24 = 0.0;
local_20 = 0.0;
/* try { // try from 00b48841 to 00b48cd3 has its CatchHandler @ 00b48ce5 */
local_3d = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,param_1,&DAT_00c6d1d3,local_34);
if (local_3d == '\0') {
Warning("You can\'t CommandABot w/o a Command!\n");
LAB_00b48a5c:
local_3d = '\0';
}
else {
pfVar12 = (float *)(int)(float)local_34[0];
if (local_2c == 5) {
pfVar12 = local_34[0];
}
cVar4 = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,param_1,"bot",local_34);
pfVar6 = local_34[0];
if (cVar4 == '\0') {
local_44 = (CBaseEntity *)0x0;
}
else {
if (local_34[0] == (float *)0x0) {
local_44 = (CBaseEntity *)0x0;
}
else {
pcVar1 = *(code **)(*g_pScriptVM + 0x68);
pSVar5 = GetScriptDesc<CBaseEntity>((CBaseEntity *)0x0);
local_44 = (CBaseEntity *)(*pcVar1)(g_pScriptVM,pfVar6,pSVar5);
}
iVar9 = (**(code **)(*(int *)local_44 + 0x148))(local_44);
if (iVar9 == 0) {
uVar8 = CBaseEntity::GetDebugName(local_44);
Warning("You can\'t CommandABot a non-Bot! [%s]\n",uVar8);
goto LAB_00b48a5c;
}
}
cVar4 = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,param_1,"target",local_34);
pfVar6 = local_34[0];
if ((cVar4 == '\0') || (local_34[0] == (float *)0x0)) {
this = (CBaseEntity *)0x0;
}
else {
pcVar1 = *(code **)(*g_pScriptVM + 0x68);
pSVar5 = GetScriptDesc<CBaseEntity>((CBaseEntity *)0x0);
this = (CBaseEntity *)(*pcVar1)(g_pScriptVM,pfVar6,pSVar5);
}
cVar4 = (**(code **)(*g_pScriptVM + 0x90))(g_pScriptVM,param_1,"pos",local_34);
if (cVar4 != '\0') {
pfVar6 = (float *)&vec3_origin;
if (local_34[0] != (float *)0x0) {
pfVar6 = local_34[0];
}
local_28 = *pfVar6;
local_24 = pfVar6[1];
local_20 = pfVar6[2];
}
if (pfVar12 == (float *)0x1) {
if (this != (CBaseEntity *)0x0) {
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(this);
}
local_28 = local_28 + *(float *)(this + 0x2e0);
local_24 = local_24 + *(float *)(this + 0x2e4);
local_20 = local_20 + *(float *)(this + 0x2e8);
}
local_4c = &local_28;
bVar2 = false;
bVar3 = false;
this = (CBaseEntity *)0x0;
}
else if ((int)pfVar12 < 2) {
if (pfVar12 != (float *)0x0) {
LAB_00b48ab0:
Warning("Invalid Command passed to CommandABot\n");
goto LAB_00b48a5c;
}
bVar2 = false;
bVar3 = false;
local_4c = (float *)0x0;
if (this == (CBaseEntity *)0x0) {
Warning("Cannot CommandABot to attack w/o a Target!\n");
goto LAB_00b48a5c;
}
}
else if (pfVar12 == (float *)0x2) {
bVar2 = false;
bVar3 = true;
local_4c = (float *)0x0;
if (this == (CBaseEntity *)0x0) {
Warning("Cannot CommandABot to retreat w/o a Threat entity!\n");
goto LAB_00b48a5c;
}
}
else {
if (pfVar12 != (float *)0x3) goto LAB_00b48ab0;
bVar2 = true;
bVar3 = false;
this = (CBaseEntity *)0x0;
local_4c = (float *)0x0;
}
if (local_44 == (CBaseEntity *)0x0) {
iVar9 = TheNextBots();
uVar10 = (uint)*(ushort *)(iVar9 + 0x10);
if (uVar10 != 0xffff) {
iVar11 = *(int *)(iVar9 + 4);
do {
piVar7 = *(int **)(iVar11 + uVar10 * 8);
if (piVar7 == (int *)0x0) {
Warning("Null bot passed to botcmd from script\n");
}
else if (bVar2) {
(**(code **)(*piVar7 + 0xa4))(piVar7);
}
else if (bVar3) {
if (this == (CBaseEntity *)0x0) {
LAB_00b48c40:
if (local_4c == (float *)0x0) {
Warning("No valid command for bot functor in CommandABot\n");
}
else {
(**(code **)(*piVar7 + 0x8c))(piVar7,local_4c,0);
}
}
else {
(**(code **)(*piVar7 + 0x94))(piVar7,this,0);
}
}
else {
if (this == (CBaseEntity *)0x0) goto LAB_00b48c40;
(**(code **)(*piVar7 + 0x84))(piVar7,this);
}
iVar11 = *(int *)(iVar9 + 4);
uVar10 = (uint)*(ushort *)(iVar11 + 6 + uVar10 * 8);
} while (uVar10 != 0xffff);
}
}
else {
piVar7 = (int *)(**(code **)(*(int *)local_44 + 0x148))(local_44);
if (piVar7 == (int *)0x0) {
Warning("Null bot passed to botcmd from script\n");
}
else if (bVar2) {
(**(code **)(*piVar7 + 0xa4))(piVar7);
}
else {
if (bVar3) {
if (this != (CBaseEntity *)0x0) {
(**(code **)(*piVar7 + 0x94))(piVar7,this,0);
goto LAB_00b48a60;
}
}
else if (this != (CBaseEntity *)0x0) {
(**(code **)(*piVar7 + 0x84))(piVar7,this);
goto LAB_00b48a60;
}
if (local_4c == (float *)0x0) {
Warning("No valid command for bot functor in CommandABot\n");
}
else {
(**(code **)(*piVar7 + 0x8c))(piVar7,local_4c,0);
}
}
}
}
LAB_00b48a60:
if ((local_2a & 1) != 0) {
free(local_34[0]);
}
return local_3d;
}
SourceMod gamedata
paste intoaddons/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.
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.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.