Code Monkey home page Code Monkey logo

csbotenabler's Introduction

image

CS Bot Enabler GitHub version Build Status Build status

A Metamod module to enable CS Bot in Counter-Strike 1.6.

Introduction

Originally written by Whistler using metamod hooks, modified by Immortal_BLG and Safety1st to patch memory directly instead.

What are the difference?

This version is based on memory patching as well for efficiency and targeting only bot stuff, in addition to:

  • Linux support
  • Works only on HLDS build >= 5971
  • An option to precache radio sounds
  • Non-bot stuffs removed
  • Some general code cleanup

Configuration

The only configuration of this module is a cvar which allows to precache radio sounds used by the bots. Located in ๐Ÿ“„csbot_enabler/config.ini:

// Precache all bot radio sounds.
// Please note:
//   BotChatter.db must be present.
//   Keep in mind that's about 487 files for ~10 Mo total to download.
//   Files are precached via the generic files buffer.
// -
// Default: "0"
csbot_precache_radio_sounds "0"

if you want to know what are the cvars and commands available for CS Bots, type in the server console:

cvarlist bot
cmdlist bot

Installation

Steps

  1. Stop your server 1
  2. Donwload the latest module version from the Releases section
  3. Download the bot resources files from this archive (~6 Mo)
  4. Unzip both content to your server in ๐Ÿ“‚cstrike
  5. Open & add an entry in ๐Ÿ“„metamod/plugins.ini:
    Windows `win32 addons/csbot_enabler/csbot_enabler_mm.dll`
    Linux `linux addons/csbot_enabler/csbot_enabler_mm_i386.so`
  6. Configure the cvar in ๐Ÿ“„csbot_enabler/config.ini
  7. Start your server and enjoy.

Expected files location

โ”œโ”€ addons
โ”‚   โ””โ”€ csbot_enabler
โ”‚       โ”œโ”€ config.cfg
โ”‚       โ”œโ”€ csbot_enabler_mm.dll
โ”‚       โ””โ”€ csbot_enabler_mm_i386.so
โ”œโ”€ sound
โ”‚   โ””โ”€ radio
โ”‚       โ””โ”€ bot
โ”‚           โ”œโ”€ a.wav
โ”‚           โ”œโ”€ a_bunch_of_them.wav
โ”‚           โ””โ”€ ...
โ”œโ”€ BotChatter.db
โ””โ”€ BotProfile.db

__

1 Whatever it's your first install or just updating โ†ฉ [1]: http://google.com/ "Google"

Troubleshooting

To check if plugin is properly loaded, type in the server console: meta list. You see something like:

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src  load unlod
 [ 1] CS Bot Enabler   RUN   -    csbot_enabler_mm  v1.0.0    ini  ANY   ANY

Check the server log as well:

CS Bot Enabler v1.0.0
Status: Loaded.
  • If you see nothing, this means plugins.ini of metamod has not been modified. See step 3 above.
  • If you see badf load, make sure you did not do a typo in plugins.ini of metamod. If not, then report the issue.
  • If you see RUN but bots are not available, check the server log. It should give some message errors. This means likely memory path has failed. Keep in mind that it works only on HLDS build >= 5971. Report the issue if you have the right version.

csbotenabler's People

Contributors

arkshine avatar evandrocoan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csbotenabler's Issues

Not wroking for me!

Hello
I have ReGameDLL v5.15.0.458-dev and ReHLDS v2186
Starting server have this error in console:

   CS Bot Enabler v1.0.1                                                                                                                                     
   Error: Could not patch "CS Bot Enabler"                                                                                                                   
   Error: Could not patch "CS Bot Enabler"                                                                                                                   
   Error: Could not patch "CS Bot Enabler"                                                                                                                   
   Error: Could not patch "CS Bot Enabler"                                                                                                                   
   Error: Could not patch "CS Bot Enabler"                                                                                                                  
   Error: Could not patch "CS Bot Enabler"
   Error: Could not patch "HOSTAGE_IDLETHINK"                                                                                                               
   Status: Failed.

Reappearing crashes on linux

Crashes the server sometimes few times a day, sometimes few times a week, but always with the same error:

0 0xc2100000 in ?? ()

0 0xc2100000 in ?? ()

1 0xb31f49d6 in CCSBot::GetAttacker (this=0xbdbbb30) at ../cstrike/dlls/bot/cs_bot.cpp:612

2 0xb324e751 in AttackState::OnUpdate (this=0xbdbc5cc, me=0xbdbbb30) at ../cstrike/dlls/bot/states/cs_bot_attack.cpp:477

3 0xb3210aca in CCSBot::Update (this=0xbdbbb30) at ../cstrike/dlls/bot/cs_bot_update.cpp:908

4 0xb322c98e in CBot::BotThink (this=0xbdbbb30) at ../game_shared/bot/bot.cpp:110

5 0xb322d31a in CBotManager::StartFrame (this=0xa4ec648) at ../game_shared/bot/bot_manager.cpp:180

6 0xb3205029 in CCSBotManager::StartFrame (this=0xa4ec648) at ../cstrike/dlls/bot/cs_bot_manager.cpp:199

7 0xb3149e9a in StartFrame () at ../cstrike/dlls/client.cpp:4525

8 0xb33f56a9 in ?? () from /root/public/./cstrike/addons/metamod/dlls/metamod.so

9 0xb7011c28 in SV_Physics () at ../engine/sv_phys.c:1985

10 0xb7009b26 in SV_Frame () at ../engine/sv_main.c:9236

11 0xb6fd1e92 in _Host_Frame (time=0.00144590402) at ../engine/host.c:1404

12 0xb6fd2252 in Host_Frame (time=0.00144590402, iState=1, stateInfo=0xbfe4ca6c) at ../engine/host.c:1522

13 0xb6ff68dc in CEngine::Frame (this=0xb708d6a0) at ../engine/sys_engine.cpp:245

14 0xb6ff3c43 in RunFrame (this=) at ../engine/sys_dll2.cpp:1235

15 CDedicatedServerAPI::RunFrame (this=0xb7088d00) at ../engine/sys_dll2.cpp:1226

16 0x08049c65 in RunServer () at ../dedicated/sys_ded.cpp:766

17 0x08049472 in main (argc=16, argv=0xbfe4ccb4) at ../dedicated/sys_ded.cpp:1146

No symbol table info available.

Little Suggestion

Would be nice to have a bot_quota_mode feature, something like:

Determines the type of quota.
normal - default behaviour
fill - the server will adjust bots to keep N players in the game, where N is bot_quota

Just a suggestion, I'm using your module, It works just fine

Thanks

bot quota problem?

Everytime I go to add a bot, or change the quota/quota_match it says
"All bot profiles at this difficulty level are in use."
and just repeats that indefinitely in the server console. No players are able to connect to the server until I manually set the quota to 0 again.

Crash on player join / bot kick disconnect

I am running a windows server, metamod 1.21-am, amxmodx latest dev, dm, and the plugin cz bot menu 2.2 which controls the bot_quota depending on total current players on a team and not just on the server. I have been getting occasional crashes as soon as a real player joins, and a bot is kicked and logs "disconnected" and this is where the log ends at crash everytime. Is this a plugin issue or something else?

2023 Offsets

#define CS_BOTS 0xE8, '*', '*', '*', '*'

#ifdef WIN32

#define CS_BOTS_W CS_BOTS, 0x83, 0xC4, 0x04, 0x84, 0xC0, '*', '*', '*', '*', '*', '*'

unsigned char CS_BOTS_RADIO[]{ CS_BOTS_W, '*', '*', 0xE8, '*', '*', '*', '*', 0x83, }; // phraseMan

unsigned char CS_BOTS_PROFILES[]{ CS_BOTS_W, 0x57, 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xE9, };
unsigned char CS_BOTS_CON_VARS[]{ CS_BOTS_W, 0x68, '*', '*', '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xFF, };
unsigned char CS_BOTS_CON_CMDS_REG[]{ CS_BOTS_W, 0x8B, '*', 0x8B, '*', 0x68, '*', '*', '*', '*', 0xFF, '*', '*', 0x8B, '*', 0x8B, '*', 0x68, };
unsigned char CS_BOTS_CON_CMDS_EXEC[]{ CS_BOTS_W, 0x56, 0x8B, '*', '*', 0xB9, '*', '*', '*', '*', 0x8B, '*', 0x0F, };
unsigned char CS_BOTS_MAP_NAV[]{ CS_BOTS_W, 0xC6, '*', '*', '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x85, '*', 0x74, '*', 0x68, };
unsigned char CS_BOTS_MANAGER[]{ CS_BOTS_W, '*', '*', 0x83, '*', '*', 0x75, '*', 0x8B, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xFF, }; // addBot

unsigned char CS_BOTS_DISPLAY[]{ CS_BOTS, 0x83, '*', '*', 0x80, '*', '*', '*', 0x74, '*', 0x8B, '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x6A, '*', 0x6A, '*', 0x6A, '*', 0xFF, '*', '*', '*', '*', '*', 0x6A, '*', 0xFF, }; // clientPrint #Game_radio_loc...

#else

#define CS_BOTS_L CS_BOTS, 0x83, 0xC4, 0x10, 0x84, 0xC0, '*', '*', '*', '*', '*', '*'

unsigned char CS_BOTS_RADIO[]{ CS_BOTS_L, 0x83, '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x83, '*', '*', 0x31, '*', 0xE9, }; // phraseMan

unsigned char CS_BOTS_PROFILES[]{ CS_BOTS, 0x84, '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', 0xC7, '*', '*', '*', '*', '*', '*', 0x89, '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xE9, };
unsigned char CS_BOTS_CON_VARS[]{ CS_BOTS_L, 0x83, '*', '*', 0x68, '*', '*', '*', '*', 0xFF, '*', '*', '*', '*', '*', 0xC7, '*', '*', '*', '*', '*', '*', 0xFF, };
unsigned char CS_BOTS_CON_CMDS_REG[]{ CS_BOTS_L, '*', 0x68, '*', '*', '*', '*', 0x53, 0xFF, '*', '*', 0x58, 0x8B, '*', 0x5A, 0x68, '*', '*', '*', '*', 0x53, 0xFF, '*', '*', 0x59, 0x58, 0x8B, };
unsigned char CS_BOTS_CON_CMDS_EXEC[]{ CS_BOTS_L, '*', '*', 0xBF, '*', '*', '*', '*', 0xB9, '*', '*', '*', '*', 0xF3, '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0xBF, };
unsigned char CS_BOTS_MAP_NAV[]{ CS_BOTS_L, '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x85, '*', 0x0F, '*', '*', '*', '*', '*', 0x83, '*', '*', 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xA1, };
unsigned char CS_BOTS_MANAGER[]{ CS_BOTS_L, 0x83, '*', '*', 0x89, '*', 0x8B, '*', '*', '*', '*', '*', 0x0F, '*', '*', '*', '*', '*', 0x85, '*', 0x0F, '*', '*', '*', '*', '*', 0x83, '*', '*', 0x0F, }; // addBot

unsigned char CS_BOTS_DISPLAY[]{ CS_BOTS, 0x80, '*', '*', '*', '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', 0x31, '*', 0xBB, '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0x89, '*', '*', '*', 0x89, }; // clientPrint #Game_radio_loc...

#endif

Use Orpheu to patch void CHostage::IdleThink(void).

The \steamapps\common\Half-Life\cstrike\addons\amxmodx\configs\orpheu\functions\CHostage\IdleThink file.

{
    "name"          : "IdleThink",
    "class"         : "CHostage",
    "library"       : "mod",
    "identifiers"   :
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : "?IdleThink@CHostage@@QAEXXZ"
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "_ZN8CHostage9IdleThinkEv"
        }
    ]
}
#pragma tabsize 0
#pragma semicolon 0
#pragma ctrlchar '\'
#pragma dynamic 4194304

#include <amxmodx>

#tryinclude <amxmisc>

/// #include <fun>
/// #include <csx>
/// #include <json>
/// #include <sqlx>
/// #include <geoip>
/// #include <regex>
/// #include <engine>
/// #include <nvault>
/// #include <cstrike>
/// #include <sockets>
/// #include <fakemeta>
/// #include <hamsandwich>

#include <orpheu>

#tryinclude <orpheu_memory>

public plugin_init()
{
    register_plugin("CS Block Hostage Think", __DATE__, "Hattrick HKS (Caramel)");

    return PLUGIN_CONTINUE;
}

public plugin_precache()
{
    new OrpheuFunction: eOnHostageIdleThink = OrpheuGetFunction("IdleThink", "CHostage");

    if (OrpheuInvalidFunction != eOnHostageIdleThink)
    {
        OrpheuRegisterHook(eOnHostageIdleThink, "OnHostageIdleThink_PRE", OrpheuHookPre);
    }

    return PLUGIN_CONTINUE;
}

public OrpheuHookReturn: OnHostageIdleThink_PRE(nHostage)
{
    return OrpheuSupercede;
}

Wasn't able to test the Linux signatures. EDIT: Tested, working.

void CHostage::IdleThink(void) L/ W Signatures (To Block This Function)

L/ 57 56 53 83 ?? ?? 81 ?? ?? ?? ?? ?? ?? ?? ?? ?? 8B ?? ?? ?? 0F ?? ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 85 ?? 0F
W/ 55 8B ?? 6A ?? 68 ?? ?? ?? ?? 64 ?? ?? ?? ?? ?? 50 83 ?? ?? 53 56 57 A1 ?? ?? ?? ?? 33 ?? 50 8D ?? ?? 64 ?? ?? ?? ?? ?? 8B ?? 83 ?? ?? ?? ?? ?? ?? 8B ?? ?? ?? ?? ?? 75 ?? 85 ?? 74 ?? 8B ?? 6A ?? FF

[Update on Dec. 17, 2013] Patching void CHostage::IdleThink(void)/ blocking its execution will cause hostages to not work anymore. So:

#define CS_BOTS 0xE8, '*', '*', '*', '*'

#ifdef WIN32

#define CS_BOTS_W CS_BOTS, 0x83, 0xC4, 0x04, 0x84, 0xC0, '*', '*', '*', '*', '*', '*'

unsigned char CS_BOTS_RADIO[]{ CS_BOTS_W, '*', '*', 0xE8, '*', '*', '*', '*', 0x83, };                                                                                                                                          /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `int __cdecl BotPhraseManager::Initialize (BotPhraseManager * this, char * a2, int a3)` ( LINUX )

unsigned char CS_BOTS_PROFILES[]{ CS_BOTS_W, 0x57, 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xE9, };                                                                                                                 /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl BotProfileManager::Init (BotProfileManager * const this, char * filename, unsigned int * checksum)` ( LINUX )
unsigned char CS_BOTS_CON_VARS[]{ CS_BOTS_W, 0x68, '*', '*', '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xFF, };                                                                                        /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void Bot_RegisterCvars (void)` ( LINUX )
unsigned char CS_BOTS_CON_CMDS_REG[]{ CS_BOTS_W, 0x8B, '*', 0x8B, '*', 0x68, '*', '*', '*', '*', 0xFF, '*', '*', 0x8B, '*', 0x8B, '*', 0x68, };                                                                                 /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl CCSBotManager::AddServerCommands (CCSBotManager * this)` ( LINUX )
unsigned char CS_BOTS_CON_CMDS_EXEC[]{ CS_BOTS_W, 0x56, 0x8B, '*', '*', 0xB9, '*', '*', '*', '*', 0x8B, '*', 0x0F, };                                                                                                           /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `unsigned int __cdecl CCSBotManager::ServerCommand (CCSBotManager * this, const char * a2)` ( LINUX )
unsigned char CS_BOTS_MAP_NAV[]{ CS_BOTS_W, 0xC6, '*', '*', '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x85, '*', 0x74, '*', 0x68, };                                                                                        /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl CCSBotManager::ValidateMapData (CCSBotManager * this)` ( LINUX )
unsigned char CS_BOTS_MANAGER[]{ CS_BOTS_W, '*', '*', 0x83, '*', '*', 0x75, '*', 0x8B, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xFF, };                                                                              /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `int __usercall CCSBotManager::AddBot @ <eax> (int a1 @ <edi>, BotProfile * this, const BotProfile * a3)` ( LINUX )

unsigned char CS_BOTS_DISPLAY[]{ CS_BOTS, 0x83, '*', '*', 0x80, '*', '*', '*', 0x74, '*', 0x8B, '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x6A, '*', 0x6A, '*', 0x6A, '*', 0xFF, '*', '*', '*', '*', '*', 0x6A, '*', 0xFF, };    /// `void __cdecl ClientPrint (entvars_t * client, int msg_dest, const char * msg_name, const char * param1, const char * param2, const char * param3, const char * param4)` CALL WITH "#Game_radio_location" PARAMETER INSIDE FUNCTION `void __cdecl CBasePlayer::Radio (CBasePlayer * const this, const char * msg_id, const char * msg_verbose, __int16 pitch, bool showIcon)` ( LINUX )

unsigned char CS_BOTS_HOSTAGE[]{ 0x55, 0x8B, '*', 0x6A, '*', 0x68, '*', '*', '*', '*', 0x64, '*', '*', '*', '*', '*', 0x50, 0x83, '*', '*', 0x53, 0x56, 0x57, 0xA1, '*', '*', '*', '*', 0x33, '*', 0x50, 0x8D, '*', '*',        /// `void __thiscall CHostage::IdleThink (CHostage * this)` FUNCTION ( WINDOWS )
0x64, '*', '*', '*', '*', '*', 0x8B, '*', 0x83, '*', '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0x75, '*', 0x85, '*', 0x74, '*', 0x8B, '*', 0x6A, '*', 0xFF, };                                                    /// `void __cdecl CHostage::IdleThink (CHostage * const this)` FUNCTION ( LINUX )

unsigned char CS_BOTS_IMPROV[]{ 0x53, 0x8B, '*', 0x83, '*', '*', 0x83, '*', '*', 0x83, '*', '*', 0x55, 0x8B, '*', '*', 0x89, '*', '*', '*', 0x8B, '*', 0x6A, '*', 0x68, '*', '*', '*', '*', 0x64, '*', '*', '*', '*', '*',      /// `int * __userpurge sub_1004DBB0 @ <eax> (int * a1 @ <ecx>, int a2 @ <edi>, int a3 @ <esi>, int a4)` FUNCTION ( WINDOWS )
0x50, 0x53, 0x83, '*', '*', 0x56, 0x57, 0xA1, '*', '*', '*', '*', 0x33, '*', 0x50, 0x8D, '*', '*', 0x64, '*', '*', '*', '*', '*', 0x8B, '*', 0x89, '*', '*', 0xC7, };                                                           /// `void __cdecl CHostageImprov::CHostageImprov (CHostageImprov * const this, CHostage * entity)` FUNCTION ( LINUX )

unsigned char CS_BOTS_NEW[]{ CS_BOTS, 0x83, '*', '*', 0x89, '*', '*', 0xC7, '*', '*', '*', '*', '*', '*', 0x85, '*', 0x74, '*', 0x57, 0x8B, '*', 0xE8, '*', '*', '*', '*', 0xEB, };                                             /// `void * __cdecl operator new (unsigned size)` CALL INSIDE FUNCTION `void __cdecl CHostage::IdleThink (CHostage * const this)` ( LINUX )

#else

#define CS_BOTS_L CS_BOTS, 0x83, 0xC4, 0x10, 0x84, 0xC0, '*', '*', '*', '*', '*', '*'

unsigned char CS_BOTS_RADIO[]{ CS_BOTS_L, 0x83, '*', '*', 0xFF, '*', '*', '*', '*', '*', 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x83, '*', '*', 0x31, '*', 0xE9, };                                                /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `int __cdecl BotPhraseManager::Initialize (BotPhraseManager * this, char * a2, int a3)` ( LINUX )

unsigned char CS_BOTS_PROFILES[]{ CS_BOTS, 0x84, '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', 0xC7, '*', '*', '*', '*', '*', '*', 0x89, '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xE9, };                           /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl BotProfileManager::Init (BotProfileManager * const this, char * filename, unsigned int * checksum)` ( LINUX )
unsigned char CS_BOTS_CON_VARS[]{ CS_BOTS_L, 0x83, '*', '*', 0x68, '*', '*', '*', '*', 0xFF, '*', '*', '*', '*', '*', 0xC7, '*', '*', '*', '*', '*', '*', 0xFF, };                                                              /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void Bot_RegisterCvars (void)` ( LINUX )
unsigned char CS_BOTS_CON_CMDS_REG[]{ CS_BOTS_L, '*', 0x68, '*', '*', '*', '*', 0x53, 0xFF, '*', '*', 0x58, 0x8B, '*', 0x5A, 0x68, '*', '*', '*', '*', 0x53, 0xFF, '*', '*', 0x59, 0x58, 0x8B, };                               /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl CCSBotManager::AddServerCommands (CCSBotManager * this)` ( LINUX )
unsigned char CS_BOTS_CON_CMDS_EXEC[]{ CS_BOTS_L, '*', '*', 0xBF, '*', '*', '*', '*', 0xB9, '*', '*', '*', '*', 0xF3, '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0xBF, };                               /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `unsigned int __cdecl CCSBotManager::ServerCommand (CCSBotManager * this, const char * a2)` ( LINUX )
unsigned char CS_BOTS_MAP_NAV[]{ CS_BOTS_L, '*', '*', '*', 0xE8, '*', '*', '*', '*', 0x85, '*', 0x0F, '*', '*', '*', '*', '*', 0x83, '*', '*', 0x68, '*', '*', '*', '*', 0xE8, '*', '*', '*', '*', 0xA1, };                     /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `void __cdecl CCSBotManager::ValidateMapData (CCSBotManager * this)` ( LINUX )
unsigned char CS_BOTS_MANAGER[]{ CS_BOTS_L, 0x83, '*', '*', 0x89, '*', 0x8B, '*', '*', '*', '*', '*', 0x0F, '*', '*', '*', '*', '*', 0x85, '*', 0x0F, '*', '*', '*', '*', '*', 0x83, '*', '*', 0x0F, };                         /// `int __cdecl UTIL_IsGame (const char * gameName)` CALL INSIDE FUNCTION `int __usercall CCSBotManager::AddBot @ <eax> (int a1 @ <edi>, BotProfile * this, const BotProfile * a3)` ( LINUX )

unsigned char CS_BOTS_DISPLAY[]{ CS_BOTS, 0x80, '*', '*', '*', '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', 0x31, '*', 0xBB, '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0x89, '*', '*', '*', 0x89, };            /// `void __cdecl ClientPrint (entvars_t * client, int msg_dest, const char * msg_name, const char * param1, const char * param2, const char * param3, const char * param4)` CALL WITH "#Game_radio_location" PARAMETER INSIDE FUNCTION `void __cdecl CBasePlayer::Radio (CBasePlayer * const this, const char * msg_id, const char * msg_verbose, __int16 pitch, bool showIcon)` ( LINUX )

unsigned char CS_BOTS_HOSTAGE[]{ 0x57, 0x56, 0x53, 0x83, '*', '*', 0x81, '*', '*', '*', '*', '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', 0x0F, '*', '*', '*', '*', '*', 0x8B, '*', '*', '*', '*', '*', 0x85, '*', 0x0F, };    /// `void __cdecl CHostage::IdleThink (CHostage * const this)` FUNCTION ( LINUX )

unsigned char CS_BOTS_IMPROV[]{ 0x57, 0x31, '*', 0x66, '*', '*', '*', 0x56, 0xBA, '*', '*', '*', '*', 0x53, 0xB9, '*', '*', '*', '*', 0x83, '*', '*', 0xBF, '*', '*', '*', '*', 0x8B, '*', '*', '*', 0x0F, '*', '*', '*', '*',  /// `int * __userpurge sub_1004DBB0 @ <eax> (int * a1 @ <ecx>, int a2 @ <edi>, int a3 @ <esi>, int a4)` FUNCTION ( WINDOWS )
'*', '*', 0x8B, '*', '*', '*', 0x0F, '*', '*', '*', 0x0F, '*', '*', '*', 0xF3, '*', '*', '*', '*', '*', '*', '*', 0x89, '*', '*', '*', '*', '*', 0xB8, };                                                                       /// `void __cdecl CHostageImprov::CHostageImprov (CHostageImprov * const this, CHostage * entity)` FUNCTION ( LINUX )

unsigned char CS_BOTS_NEW[]{ CS_BOTS, 0x89, '*', '*', '*', 0x89, '*', '*', 0x89, '*', 0xE8, '*', '*', '*', '*', 0x89, '*', '*', '*', '*', '*', 0xE9, };                                                                         /// `void * __cdecl operator new (unsigned size)` CALL INSIDE FUNCTION `void __cdecl CHostage::IdleThink (CHostage * const this)` ( LINUX )

#endif
  1. Should block void __cdecl CHostageImprov::CHostageImprov (CHostageImprov * const this, CHostage * entity) function.
    On Windows, it's a int * function. Not void. So in Windows, return nullptr; is needed.

  2. Should block void * __cdecl operator new (unsigned size) call inside function void __cdecl CHostage::IdleThink (CHostage * const this).
    On Windows and Linux, return nullptr; is needed. The void * __cdecl operator new (unsigned size) function is a void * function.

  3. Warning, void __cdecl CHostageImprov::CHostageImprov (CHostageImprov * const this, CHostage * entity) is a main function, not a sub-function which resides inside a main function (like the others are). Perhaps this needs a different hook method.

  4. No need to hook/ block void __cdecl CHostage::IdleThink (CHostage * const this) anymore. Can still be hooked but call the original function into the hook.

unsigned char* Hook_LoadFileForMe(const char* pcszFileName, int* pnLength) noexcept
{
    static bool bShouldBlock{ };

    if (!::g_strGameDir.empty())
    {
        if (!::g_strGameDir.compare("cstrike"))
        {
            if (pcszFileName)
            {
                if (*pcszFileName)
                {
                    if (::std::strcmp("tutordata.txt", pcszFileName))
                    {
                        if (::std::strcmp("BotChatter.db", pcszFileName))
                        {
                            if (!::std::strstr(pcszFileName, "sound\\radio\\bot\\"))
                            {
                                if (!::std::strstr(pcszFileName, "sound/radio/bot/"))
                                {
                                    bShouldBlock = { };
                                }

                                else
                                {
                                    bShouldBlock = true;
                                }
                            }

                            else
                            {
                                bShouldBlock = true;
                            }
                        }

                        else
                        {
                            bShouldBlock = true;
                        }
                    }

                    else
                    {
                        bShouldBlock = true;
                    }
                }

                else
                {
                    bShouldBlock = { };
                }
            }

            else
            {
                bShouldBlock = { };
            }
        }

        else
        {
            bShouldBlock = { };
        }
    }

    else
    {
        bShouldBlock = { };
    }

    if (!::g_bNoReturn)
    {
        do
        {
            ::gpMetaGlobals->mres = ((bShouldBlock) ? (::MRES_SUPERCEDE) : (::MRES_IGNORED));

            if (((::gpMetaGlobals)->orig_ret))
            {
                if (bShouldBlock)
                {
                    return { };
                }

                return (*(unsigned char**) ::gpMetaGlobals->orig_ret);
            }

            else
            {
                return { };
            }

            return { };
        }

        while (false);
    }

    else
    {
        return { };
    }

    return { };
}

I use bot_chatter off setting and I don't need talkable bots. I use this Meta Mod hook above as is. And return false; into the custom hook for: int __cdecl UTIL_IsGame(const char * gameName) call inside function int __cdecl BotPhraseManager::Initialize (BotPhraseManager * this, char * a2, int a3).

To hook functions (not sub-functions) on Windows/ Linux you can use https://github.com/Zeex/subhook
To hook functions (not sub-functions) on Windows you can use https://github.com/microsoft/Detours

Crashing when preache certain spr

Crashes when i precache a certain sprite both with precache_model + fakemeta alternative in a certain map.
Tried recompiling the sprite too.

Not working spr:
Download sprite (Zippyshare)

Working spr:
Download sprite (Zippyshare)
Download sprite (Zippyshare)

  1. Doesnt crash if i disable this module.
  2. Only crashes on cs_havana.
  3. Doesnt crash if i change sprite to a lowres/lower size one.
  4. Tried both single frame + multi frame sprite. Still crash if its too large/highres.

MM ver: 1.21p38
AMXX ver: 1.9.0.5294

AMXX Code:

new const g_szMedkitSprite[] = "sprites/zr2/voodoo_heal_fix.spr";

public plugin_precache()
{
	g_iIDHealSpr = precache_model( g_szMedkitSprite );
}

Server commandline:

hlds.exe -console -game cstrike +port 27015 +sys_ticrate 10000 +heapsize 1048576 +maxplayers 32 +map cs_havana -bots -debug -condebug

Error in command window:

L 01/26/2023 - 20:40:43: FATAL ERROR (shutting down): Cache_TryAlloc: 5668880 is greater then free hunk FATAL ERROR (shutting down): Cache_TryAlloc: 5668880 is greater then free hunk src\tier1\fileio.cpp (5307) : m_vecRegisteredWriters.Count() == 0 src\tier1\fileio.cpp (5307) : m_vecRegisteredWriters.Count() == 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.