Unlockstats command

This commit is contained in:
momo5502 2016-01-04 15:43:09 +01:00
parent 85d47594d7
commit a568e253eb
5 changed files with 68 additions and 0 deletions

View File

@ -9,6 +9,41 @@ namespace Components
return &id;
}
void QuickPatch::UnlockStats()
{
Command::Execute("setPlayerData prestige 10");
Command::Execute("setPlayerData experience 2516000");
Command::Execute("setPlayerData iconUnlocked cardicon_prestige10_02 1");
// Unlock challenges
Game::StringTable* challengeTable = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_STRINGTABLE, "mp/allchallengestable.csv").stringTable;
if (challengeTable)
{
for (int i = 0; i < challengeTable->rowCount; i++)
{
// Find challenge
const char* challenge = Game::TabeLookup(challengeTable, i, 0);
int maxState = 0;
int maxProgress = 0;
// Find correct tier and progress
for (int j = 0; j < 10; j++)
{
int progress = atoi(Game::TabeLookup(challengeTable, i, 6 + j * 2));
if (!progress )break;
maxState = j + 2;
maxProgress = progress;
}
Command::Execute(Utils::VA("setPlayerData challengeState %s %d", challenge, maxState));
Command::Execute(Utils::VA("setPlayerData challengeProgress %s %d", challenge, maxProgress));
}
}
}
QuickPatch::QuickPatch()
{
// protocol version (workaround for hacks)
@ -112,5 +147,10 @@ namespace Components
Utils::Hook::Nop(0x6830B1, 20);
Utils::Hook(0x682EBF, QuickPatch::GetStatsID, HOOK_CALL).Install()->Quick();
Utils::Hook(0x6830B1, QuickPatch::GetStatsID, HOOK_CALL).Install()->Quick();
Command::Add("unlockstats", [] (Command::Params params)
{
QuickPatch::UnlockStats();
});
}
}

View File

@ -6,6 +6,8 @@ namespace Components
QuickPatch();
const char* GetName() { return "QuickPatch"; };
static void UnlockStats();
private:
static _int64* GetStatsID();
};

View File

@ -151,6 +151,16 @@ namespace Game
}
}
const char* TabeLookup(StringTable* stringtable, int row, int column)
{
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";
const char* value = stringtable->values[row * stringtable->columnCount + column].string;
if (!value) value = "";
return value;
}
void OOBPrintT(int type, netadr_t netadr, const char* message)
{
int* adr = (int*)&netadr;

View File

@ -257,6 +257,7 @@ namespace Game
void Menu_FreeItemMemory(Game::itemDef_t* item);
void OOBPrintT(int type, netadr_t netadr, const char* message);
void OOBPrintRaw(int type, netadr_t netadr, const char* message, size_t length);
const char* TabeLookup(StringTable* stringtable, int row, int column);
const char* UI_LocalizeMapName(const char* mapName);
const char* UI_LocalizeGameType(const char* gameType);
}

View File

@ -878,6 +878,20 @@ namespace Game
const char* entitystring;
};
struct StringTableCell
{
const char *string;
int hash;
};
struct StringTable
{
const char *name;
int columnCount;
int rowCount;
StringTableCell *values;
};
union XAssetHeader
{
void *data;
@ -886,6 +900,7 @@ namespace Game
Material *material;
snd_alias_list_t *aliasList;
localizedEntry_s *localize;
StringTable *stringTable;
MapEnts* mapEnts;
};