Merge pull request #137 from diamante0018/feature/no-clip-and-ufo

[Script] Add ufo and noclip function
This commit is contained in:
Jan 2021-10-16 18:53:21 +02:00 committed by GitHub
commit b25787ec68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -531,6 +531,56 @@ namespace Components
{ {
Script::ScriptStorage.clear(); Script::ScriptStorage.clear();
}); });
Script::AddFunction("Noclip", [](Game::scr_entref_t entref)
{
if (entref >= Game::MAX_GENTITIES || Game::g_entities[entref].client == nullptr)
{
Game::Scr_Error(Utils::String::VA("^1NoClip: entity %u is not a client\n", entref));
return;
}
if (Game::Scr_GetNumParam() == 1 && Game::Scr_GetType(0) == Game::VAR_INTEGER)
{
if (Game::Scr_GetInt(0))
{
Game::g_entities[entref].client->flags |= Game::PLAYER_FLAG_NOCLIP;
}
else
{
Game::g_entities[entref].client->flags &= ~Game::PLAYER_FLAG_NOCLIP;
}
}
else
{
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_NOCLIP;
}
});
Script::AddFunction("Ufo", [](Game::scr_entref_t entref)
{
if (entref >= Game::MAX_GENTITIES || Game::g_entities[entref].client == nullptr)
{
Game::Scr_Error(Utils::String::VA("^1Ufo: entity %u is not a client\n", entref));
return;
}
if (Game::Scr_GetNumParam() == 1 && Game::Scr_GetType(0) == Game::VAR_INTEGER)
{
if (Game::Scr_GetInt(0))
{
Game::g_entities[entref].client->flags |= Game::PLAYER_FLAG_UFO;
}
else
{
Game::g_entities[entref].client->flags &= ~Game::PLAYER_FLAG_UFO;
}
}
else
{
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_UFO;
}
});
} }
Script::Script() Script::Script()

View File

@ -931,6 +931,7 @@ namespace Game
extern int* demoRecording; extern int* demoRecording;
extern int* serverMessageSequence; extern int* serverMessageSequence;
constexpr auto MAX_GENTITIES = 2048u;
extern gentity_t* g_entities; extern gentity_t* g_entities;
extern netadr_t* connectedHost; extern netadr_t* connectedHost;