From f5f1fb3247a18db743b96d00923514fa078ffbed Mon Sep 17 00:00:00 2001 From: NFS_MONSTR Date: Mon, 18 Jun 2018 22:15:31 +0300 Subject: [PATCH] Implement some cheats and cheat activated message --- rwengine/src/engine/GameState.cpp | 5 ++ rwengine/src/engine/GameState.hpp | 5 ++ rwgame/RWGame.cpp | 96 +++++++++++++++---------------- 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/rwengine/src/engine/GameState.cpp b/rwengine/src/engine/GameState.cpp index 61a25fba..20575ea4 100644 --- a/rwengine/src/engine/GameState.cpp +++ b/rwengine/src/engine/GameState.cpp @@ -217,3 +217,8 @@ bool GameState::isFading() const { void GameState::setFadeColour(glm::i32vec3 colour) { fadeColour = colour; } + +void GameState::showHelpMessage(const GameStringKey& id) { + text.addText( + ScreenTextEntry::makeHelp(id, world->data->texts.text(id))); +} \ No newline at end of file diff --git a/rwengine/src/engine/GameState.hpp b/rwengine/src/engine/GameState.hpp index 6aa28801..077cbe96 100644 --- a/rwengine/src/engine/GameState.hpp +++ b/rwengine/src/engine/GameState.hpp @@ -450,6 +450,11 @@ public: void swapInputState() { input[1] = input[0]; } + + /** + * Adds help message + */ + void showHelpMessage(const GameStringKey& id); }; #endif diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index c772bf55..6aadb4be 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -195,8 +195,7 @@ void RWGame::handleCheatInput(char symbol) { #endif checkForCheat(health_cheat, [&] { player->getCurrentState().health = 100.f; - // @todo ShowHelpMessage("CHEAT3"); // III / VC: Inputting health - // cheat. + state.showHelpMessage("CHEAT3"); // III / VC: Inputting health cheat. }); #if RW_GAME_VERSION >= 1100 // Changed cheat name in version 1.1 @@ -206,31 +205,40 @@ void RWGame::handleCheatInput(char symbol) { #endif checkForCheat(armor_cheat, [&] { player->getCurrentState().armour = 100.f; - // @todo ShowHelpMessage("CHEAT4"); // III / VC: Inputting armor - // cheat. + state.showHelpMessage("CHEAT4"); // III / VC: Inputting armor cheat. }); checkForCheat("GUNSGUNSGUNS", [&] { - // @todo give player weapons - // @todo ShowHelpMessage("CHEAT2"); // III / VC: Inputting weapon - // cheats. + constexpr std::array ammo = {1, //baseball bat + 100,//pistol + 100,//uzi + 20, //shotgun + 5, //grenade + 5, //molotov + 5, //rocket launcher + 20, //flamethrower + 200,//ak47 + 200,//m16 + 5 //sniper rifle + }; + for (std::array::size_type i = 0; i < ammo.size(); i++) + player->addToInventory(i+1,ammo[i]); + state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats. }); checkForCheat("IFIWEREARICHMAN", [&] { state.playerInfo.money += 250000; - // @todo ShowHelpMessage("CHEAT6"); // III: Inputting money cheat. + state.showHelpMessage("CHEAT6"); // III: Inputting money cheat. }); checkForCheat("MOREPOLICEPLEASE", [&] { // @todo raise to next wanted level - // @todo ShowHelpMessage("CHEAT5"); // III / VC: Inputting wanted - // level cheats. + state.showHelpMessage("CHEAT5"); // III / VC: Inputting wanted level cheats. }); checkForCheat("NOPOLICEPLEASE", [&] { // @todo lower to next lower wanted level - // @todo ShowHelpMessage("CHEAT5"); // III / VC: Inputting wanted - // level cheats. + state.showHelpMessage("CHEAT5"); // III / VC: Inputting wanted level cheats. }); } @@ -239,51 +247,49 @@ void RWGame::handleCheatInput(char symbol) { checkForCheat("BANGBANGBANG", [&] { // @todo Explode nearby vehicles // @todo What radius? - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("GIVEUSATANK", [&] { // The iPod / Android version of the game (10th year anniversary) spawns random // (?) vehicles instead of always rhino -#ifdef RW_GAME_GTA3_ANNIVERSARY - // uint16_t vehicleModel = 110; // @todo Which cars are spawned?! +#if RW_GAME_GTA3_ANNIVERSARY != 0 + uint16_t vehicleModel = 110; // @todo Which cars are spawned?! #else - // uint16_t vehicleModel = 122; + uint16_t vehicleModel = 122; #endif - // @todo Spawn rhino - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + const auto ch = getWorld()->getPlayer()->getCharacter();// @todo Change spawn place to be more like in original game + const auto playerRot = ch->getRotation(); + const auto spawnPos = ch->getPosition() + playerRot * glm::vec3(0.f, 3.f, 0.f); + const auto spawnRot = glm::quat( + glm::vec3(0.f, 0.f, glm::roll(playerRot) + glm::half_pi())); + getWorld()->createVehicle(vehicleModel, spawnPos, spawnRot); + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("CORNERSLIKEMAD", [&] { // @todo Weird car handling - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("ANICESETOFWHEELS", [&] { // @todo Hide car bodies - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("CHITTYCHITTYBB", [&] { // @todo Cars can fly - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("NASTYLIMBCHEAT", [&] { // @todo Makes it possible to shoot limbs off, iirc? - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("ILIKEDRESSINGUP", [&] { // @todo Which skins will be chosen? - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); } @@ -293,36 +299,31 @@ void RWGame::handleCheatInput(char symbol) { // @todo Give all pedestrians weapons.. this is also saved in the // savegame?! // @todo Which weapons do they get? - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("NOBODYLIKESME", [&] { // @todo Set all pedestrians hostile towards player.. this is also // saved in the savegame?! - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("ITSALLGOINGMAAAD", [&] { // @todo Set all pedestrians to fighting each other.. this is also // saved in the savegame?! - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); // Game speed cheats checkForCheat("TIMEFLIESWHENYOU", [&] { // @todo Set fast gamespeed - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); checkForCheat("BOOOOORING", [&] { // @todo Set slow gamespeed - // @todo ShowHelpMessage("CHEAT1"); // III / VC: Inputting most - // cheats. + state.showHelpMessage("CHEAT1"); // III / VC: Inputting most cheats. }); } @@ -330,32 +331,27 @@ void RWGame::handleCheatInput(char symbol) { { checkForCheat("ILIKESCOTLAND", [&] { // @todo Set weather to cloudy - // @todo ShowHelpMessage("CHEAT7"); // III / VC: Inputting weather - // cheats. + state.showHelpMessage("CHEAT7"); // III / VC: Inputting weather cheats. }); checkForCheat("SKINCANCERFORME", [&] { // @todo Set sunny / normal weather - // @todo ShowHelpMessage("CHEAT7"); // III / VC: Inputting weather - // cheats. + state.showHelpMessage("CHEAT7"); // III / VC: Inputting weather cheats. }); checkForCheat("MADWEATHER", [&] { // @todo Set bad weather - // @todo ShowHelpMessage("CHEAT7"); // III / VC: Inputting weather - // cheats. + state.showHelpMessage("CHEAT7"); // III / VC: Inputting weather cheats. }); checkForCheat("ILOVESCOTLAND", [&] { // @todo Set weather to rainy - // @todo ShowHelpMessage("CHEAT7"); // III / VC: Inputting weather - // cheats. + state.showHelpMessage("CHEAT7"); // III / VC: Inputting weather cheats. }); checkForCheat("PEASOUP", [&] { // @todo Set weather to foggy - // @todo ShowHelpMessage("CHEAT7"); // III / VC: Inputting weather - // cheats. + state.showHelpMessage("CHEAT7"); // III / VC: Inputting weather cheats. }); } }