Merge pull request #256 from diamante0018/develop
[Bots] Add isBot GSC meth back
This commit is contained in:
commit
4ad41c72b5
@ -108,8 +108,17 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bots::GScr_isTestClient(Game::scr_entref_t entref)
|
||||||
|
{
|
||||||
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
|
Game::Scr_AddBool(Game::SV_IsTestClient(ent->s.number) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
void Bots::AddMethods()
|
void Bots::AddMethods()
|
||||||
{
|
{
|
||||||
|
Script::AddMethod("IsBot", Bots::GScr_isTestClient); // Usage: self IsBot();
|
||||||
|
Script::AddMethod("IsTestClient", Bots::GScr_isTestClient); // Usage: self IsTestClient();
|
||||||
|
|
||||||
Script::AddMethod("SetPing", [](Game::scr_entref_t entref) // gsc: self SetPing(<int>)
|
Script::AddMethod("SetPing", [](Game::scr_entref_t entref) // gsc: self SetPing(<int>)
|
||||||
{
|
{
|
||||||
auto ping = Game::Scr_GetInt(0);
|
auto ping = Game::Scr_GetInt(0);
|
||||||
@ -119,7 +128,7 @@ namespace Components
|
|||||||
const auto* ent = Game::GetPlayerEntity(entref);
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
auto* client = Script::GetClient(ent);
|
auto* client = Script::GetClient(ent);
|
||||||
|
|
||||||
if (!client->bIsTestClient)
|
if (Game::SV_IsTestClient(ent->s.number) == 0)
|
||||||
{
|
{
|
||||||
Game::Scr_Error("^1SetPing: Can only call on a bot!\n");
|
Game::Scr_Error("^1SetPing: Can only call on a bot!\n");
|
||||||
return;
|
return;
|
||||||
@ -128,20 +137,11 @@ namespace Components
|
|||||||
client->ping = static_cast<int16_t>(ping);
|
client->ping = static_cast<int16_t>(ping);
|
||||||
});
|
});
|
||||||
|
|
||||||
Script::AddMethod("IsTestClient", [](Game::scr_entref_t entref) // Usage: <bot> IsTestClient();
|
|
||||||
{
|
|
||||||
const auto* gentity = Game::GetPlayerEntity(entref);
|
|
||||||
const auto* client = Script::GetClient(gentity);
|
|
||||||
|
|
||||||
Game::Scr_AddBool(client->bIsTestClient == 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
Script::AddMethod("BotStop", [](Game::scr_entref_t entref) // Usage: <bot> BotStop();
|
Script::AddMethod("BotStop", [](Game::scr_entref_t entref) // Usage: <bot> BotStop();
|
||||||
{
|
{
|
||||||
const auto* ent = Game::GetPlayerEntity(entref);
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
const auto* client = Script::GetClient(ent);
|
|
||||||
|
|
||||||
if (!client->bIsTestClient)
|
if (Game::SV_IsTestClient(ent->s.number) == 0)
|
||||||
{
|
{
|
||||||
Game::Scr_Error("^1BotStop: Can only call on a bot!\n");
|
Game::Scr_Error("^1BotStop: Can only call on a bot!\n");
|
||||||
return;
|
return;
|
||||||
@ -154,17 +154,16 @@ namespace Components
|
|||||||
|
|
||||||
Script::AddMethod("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
|
Script::AddMethod("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
|
||||||
{
|
{
|
||||||
const auto* weapon = Game::Scr_GetString(0);
|
|
||||||
|
|
||||||
const auto* ent = Game::GetPlayerEntity(entref);
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
const auto* client = Script::GetClient(ent);
|
|
||||||
|
|
||||||
if (!client->bIsTestClient)
|
if (Game::SV_IsTestClient(ent->s.number) == 0)
|
||||||
{
|
{
|
||||||
Game::Scr_Error("^1BotWeapon: Can only call on a bot!\n");
|
Game::Scr_Error("^1BotWeapon: Can only call on a bot!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto* weapon = Game::Scr_GetString(0);
|
||||||
|
|
||||||
if (weapon == nullptr || weapon[0] == '\0')
|
if (weapon == nullptr || weapon[0] == '\0')
|
||||||
{
|
{
|
||||||
g_botai[entref.entnum].weapon = 1;
|
g_botai[entref.entnum].weapon = 1;
|
||||||
@ -178,6 +177,14 @@ namespace Components
|
|||||||
|
|
||||||
Script::AddMethod("BotAction", [](Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>);
|
Script::AddMethod("BotAction", [](Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>);
|
||||||
{
|
{
|
||||||
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
|
|
||||||
|
if (Game::SV_IsTestClient(ent->s.number) == 0)
|
||||||
|
{
|
||||||
|
Game::Scr_Error("^1BotAction: Can only call on a bot!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto* action = Game::Scr_GetString(0);
|
const auto* action = Game::Scr_GetString(0);
|
||||||
|
|
||||||
if (action == nullptr)
|
if (action == nullptr)
|
||||||
@ -186,15 +193,6 @@ namespace Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto* ent = Game::GetPlayerEntity(entref);
|
|
||||||
const auto* client = Script::GetClient(ent);
|
|
||||||
|
|
||||||
if (!client->bIsTestClient)
|
|
||||||
{
|
|
||||||
Game::Scr_Error("^1BotAction: Can only call on a bot!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action[0] != '+' && action[0] != '-')
|
if (action[0] != '+' && action[0] != '-')
|
||||||
{
|
{
|
||||||
Game::Scr_ParamError(0, "^1BotAction: Sign for action must be '+' or '-'.\n");
|
Game::Scr_ParamError(0, "^1BotAction: Sign for action must be '+' or '-'.\n");
|
||||||
@ -220,20 +218,16 @@ namespace Components
|
|||||||
|
|
||||||
Script::AddMethod("BotMovement", [](Game::scr_entref_t entref) // Usage: <bot> BotMovement(<int>, <int>);
|
Script::AddMethod("BotMovement", [](Game::scr_entref_t entref) // Usage: <bot> BotMovement(<int>, <int>);
|
||||||
{
|
{
|
||||||
auto forwardInt = Game::Scr_GetInt(0);
|
|
||||||
auto rightInt = Game::Scr_GetInt(1);
|
|
||||||
|
|
||||||
const auto* ent = Game::GetPlayerEntity(entref);
|
const auto* ent = Game::GetPlayerEntity(entref);
|
||||||
const auto* client = Script::GetClient(ent);
|
|
||||||
|
|
||||||
if (!client->bIsTestClient)
|
if (Game::SV_IsTestClient(ent->s.number) == 0)
|
||||||
{
|
{
|
||||||
Game::Scr_Error("^1BotMovement: Can only call on a bot!\n");
|
Game::Scr_Error("^1BotMovement: Can only call on a bot!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
forwardInt = std::clamp<int>(forwardInt, std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
const auto forwardInt = std::clamp<int>(Game::Scr_GetInt(0), std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
||||||
rightInt = std::clamp<int>(rightInt, std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
const auto rightInt = std::clamp<int>(Game::Scr_GetInt(1), std::numeric_limits<char>::min(), std::numeric_limits<char>::max());
|
||||||
|
|
||||||
g_botai[entref.entnum].forward = static_cast<int8_t>(forwardInt);
|
g_botai[entref.entnum].forward = static_cast<int8_t>(forwardInt);
|
||||||
g_botai[entref.entnum].right = static_cast<int8_t>(rightInt);
|
g_botai[entref.entnum].right = static_cast<int8_t>(rightInt);
|
||||||
@ -327,6 +321,8 @@ namespace Components
|
|||||||
|
|
||||||
Bots::Bots()
|
Bots::Bots()
|
||||||
{
|
{
|
||||||
|
AssertOffset(Game::client_s, bIsTestClient, 0x41AF0);
|
||||||
|
|
||||||
// Replace connect string
|
// Replace connect string
|
||||||
Utils::Hook::Set<const char*>(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\"");
|
Utils::Hook::Set<const char*>(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\"");
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace Components
|
|||||||
|
|
||||||
static void Spawn(unsigned int count);
|
static void Spawn(unsigned int count);
|
||||||
|
|
||||||
|
static void GScr_isTestClient(Game::scr_entref_t entref);
|
||||||
static void AddMethods();
|
static void AddMethods();
|
||||||
|
|
||||||
static void BotAiAction(Game::client_t* cl);
|
static void BotAiAction(Game::client_t* cl);
|
||||||
|
Loading…
Reference in New Issue
Block a user