Skip to content

Commit 0211ad5

Browse files
DrombeysHozar2002
andcommitted
Implement g_spawn_inv console command
Only singleplayer Co-authored-by: Hozar2002 <hoz2002team@gmail.com>
1 parent b8a5b71 commit 0211ad5

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/xrGame/console_commands.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#endif // DEBUG
6060

6161
#include "ai_object_location.h"
62+
#include "xrServer_Objects_ALife_Monsters.h"
6263

6364
string_path g_last_saved_game;
6465

@@ -1931,6 +1932,53 @@ class CCC_GSpawn : public IConsole_Command {
19311932
std::sort(tips.begin(), tips.end());
19321933
}
19331934
};
1935+
1936+
extern CSE_Abstract* CALifeSimulator__spawn_item2(CALifeSimulator* self_, LPCSTR section, const Fvector& position,
1937+
u32 level_vertex_id, GameGraph::_GRAPH_ID game_vertex_id, ALife::_OBJECT_ID id_parent);
1938+
1939+
class CCC_GSpawnToInventory : public IConsole_Command {
1940+
public:
1941+
CCC_GSpawnToInventory(LPCSTR N) : IConsole_Command(N) {
1942+
}
1943+
1944+
virtual void Execute(LPCSTR args) override {
1945+
if (g_pGameLevel == nullptr) {
1946+
return;
1947+
}
1948+
1949+
auto actor = smart_cast<CActor*>(Level().CurrentEntity());
1950+
if (actor == nullptr) {
1951+
return;
1952+
}
1953+
1954+
if (!pSettings->section_exist(args)) {
1955+
Msg("! Can't find section: %s", args);
1956+
return;
1957+
}
1958+
1959+
auto tpGame = smart_cast<game_sv_Single*>(Level().Server->game);
1960+
if (tpGame != nullptr) {
1961+
CALifeSimulator__spawn_item2(&tpGame->alife(), args, actor->Position(), actor->ai_location().level_vertex_id(),
1962+
actor->ai_location().game_vertex_id(), actor->ID());
1963+
}
1964+
}
1965+
1966+
virtual void fill_tips(vecTips& tips, u32 mode) override {
1967+
if (!ai().get_alife()) {
1968+
Msg("! ALife simulator is needed to perform specified command!");
1969+
return;
1970+
}
1971+
1972+
for (const auto& section : pSettings->sections()) {
1973+
if (section->line_exist("cost") && section->line_exist("inv_weight")) {
1974+
tips.push_back(section->Name.c_str());
1975+
}
1976+
}
1977+
1978+
std::sort(tips.begin(), tips.end());
1979+
}
1980+
};
1981+
19341982
void CCC_RegisterCommands()
19351983
{
19361984
// options
@@ -1942,6 +1990,8 @@ void CCC_RegisterCommands()
19421990
CMD1(CCC_GiveMoney, "g_money");
19431991

19441992
CMD1(CCC_GSpawn, "g_spawn");
1993+
CMD1(CCC_GSpawnToInventory, "g_spawn_inv");
1994+
19451995
CMD1(CCC_MemStats, "stat_memory" );
19461996
#ifdef DEBUG
19471997
CMD1(CCC_MemCheckpoint, "stat_memory_checkpoint");

0 commit comments

Comments
 (0)