diff --git a/source/exhumed/src/cheats.cpp b/source/exhumed/src/cheats.cpp index 0db0081c6..a5cdfb495 100644 --- a/source/exhumed/src/cheats.cpp +++ b/source/exhumed/src/cheats.cpp @@ -38,6 +38,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "inputstate.h" #include "d_protocol.h" #include "gstrings.h" +#include "aistuff.h" +#include "mmulti.h" BEGIN_PS_NS @@ -154,9 +156,74 @@ static cheatseq_t excheats[] = { }; +static void cmd_Give(int player, uint8_t** stream, bool skip) +{ + int type = ReadByte(stream); + if (skip) return; + + if (PlayerList[player].nHealth <= 0 || nNetPlayerCount || gamestate != GS_LEVEL) + { + Printf("give: Cannot give while dead or not in a single-player game.\n"); + return; + } + int buttons = 0; + + switch (type) + { + case GIVE_ALL: + buttons |= kButtonCheatGuns | kButtonCheatItems | kButtonCheatKeys; + break; + + case GIVE_HEALTH: + PlayerList[player].nHealth = 800; + return; + + case GIVE_WEAPONS: + case GIVE_AMMO: + buttons |= kButtonCheatGuns; + break; + + case GIVE_ARMOR: + // not implemented + break; + + case GIVE_KEYS: + buttons |= kButtonCheatKeys; + break; + + case GIVE_INVENTORY: + buttons |= kButtonCheatItems; + break; + + case GIVE_ITEMS: + buttons |= kButtonCheatItems | kButtonCheatKeys; + break; + } + + if (buttons & kButtonCheatGuns) // LOBOCOP cheat + { + FillWeapons(player); + if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_WEAPONS")); + } + if (buttons & kButtonCheatKeys) // LOBOPICK cheat + { + PlayerList[player].keys = 0xFFFF; + if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_KEYS")); + RefreshStatus(); + } + if (buttons & kButtonCheatItems) // LOBOSWAG cheat + { + FillItems(player); + if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_ITEMS")); + } + +} + + void InitCheats() { SetCheats(excheats, countof(excheats)); + Net_SetCommandHandler(DEM_GIVE, cmd_Give); } END_PS_NS diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index fce8a25ff..6c3f8596d 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -185,45 +185,6 @@ static int osdcmd_third_person_view(CCmdFuncPtr parm) return CCMD_OK; } -static int ccmd_give(CCmdFuncPtr parm) -{ - if (PlayerList[myconnectindex].nHealth <= 0 || nNetPlayerCount) - { - Printf("give: Cannot give while dead or not in a single-player game.\n"); - return CCMD_OK; - } - - if (parm->numparms != 1) return CCMD_SHOWHELP; - - cheatseq_t* cs = (cheatseq_t*)(intptr_t)1; - if (!stricmp(parm->parms[0], "all")) - { - lLocalCodes |= kButtonCheatGuns | kButtonCheatItems | kButtonCheatKeys; - } - else if (!stricmp(parm->parms[0], "health")) - { - PlayerList[myconnectindex].nHealth = 800; - } - else if (!stricmp(parm->parms[0], "weapons")) - { - lLocalCodes |= kButtonCheatGuns; - } - else if (!stricmp(parm->parms[0], "keys")) - { - lLocalCodes |= kButtonCheatKeys; - } - else if (!stricmp(parm->parms[0], "inventory")) - { - lLocalCodes |= kButtonCheatItems; - } - else if (!stricmp(parm->parms[0], "items")) - { - lLocalCodes |= kButtonCheatItems | kButtonCheatKeys; - } - else return CCMD_SHOWHELP; - return CCMD_OK; -} - static int osdcmd_noop(CCmdFuncPtr parm) { @@ -243,7 +204,6 @@ int32_t registerosdcommands(void) C_RegisterFunction("third_person_view", "Switch to third person view", osdcmd_third_person_view); C_RegisterFunction("coop_view", "Switch player to view from in coop", osdcmd_noop); C_RegisterFunction("show_weapon", "Show opponents' weapons", osdcmd_noop); - //C_RegisterFunction("give", "give : gives requested item", ccmd_give); return 0; } diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index dfa5d87f2..6d16b3119 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -1281,23 +1281,6 @@ loc_1AB8E: uint16_t buttons = sPlayerInput[nPlayer].buttons; auto actions = sPlayerInput[nPlayer].actions; - if (buttons & kButtonCheatGuns) // LOBOCOP cheat - { - FillWeapons(nPlayer); - StatusMessage(150, "All weapons loaded for player"); - } - if (buttons & kButtonCheatKeys) // LOBOPICK cheat - { - PlayerList[nPlayer].keys = 0xFFFF; - StatusMessage(150, "All keys loaded for player"); - RefreshStatus(); - } - if (buttons & kButtonCheatItems) // LOBOSWAG cheat - { - FillItems(nPlayer); - StatusMessage(150, "All items loaded for player"); - } - // loc_1AEF5: if (PlayerList[nPlayer].nHealth > 0) { diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index 7a7d0d840..aee73a047 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -37,13 +37,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) BEGIN_DUKE_NS -bool cheatGod(cheatseq_t*); -bool cheatWeapons(cheatseq_t* s); -bool cheatStuff(cheatseq_t* s); -bool cheatKeys(cheatseq_t* s); -bool cheatInventory(cheatseq_t* s); -bool cheatItems(cheatseq_t* s); - static void dowarp(MapRecord *map) { ud.m_monsters_off = ud.monsters_off = 0; @@ -190,57 +183,6 @@ static int ccmd_spawn(CCmdFuncPtr parm) return CCMD_OK; } -// Strangely enough JFDuke does not have a 'give' CCMD, so this is based on the version in EDuke32. -static int ccmd_give(CCmdFuncPtr parm) -{ - if (numplayers != 1 || (ps[myconnectindex].gm & MODE_GAME) == 0 || - ps[myconnectindex].dead_flag != 0) - { - Printf("give: Cannot give while dead or not in a single-player game.\n"); - return CCMD_OK; - } - - if (parm->numparms != 1) return CCMD_SHOWHELP; - - cheatseq_t* cs = (cheatseq_t*)(intptr_t)1; - if (!stricmp(parm->parms[0], "all")) - { - cheatStuff(cs); - } - else if (!stricmp(parm->parms[0], "health")) - { - sprite[ps[myconnectindex].i].extra = max_player_health<<1; - } - else if (!stricmp(parm->parms[0], "weapons")) - { - cheatWeapons(cs); - } - else if (!stricmp(parm->parms[0], "ammo")) - { - int maxw = VOLUMEONE ? SHRINKER_WEAPON : MAX_WEAPONS; - for (int i = maxw; i >= PISTOL_WEAPON; i--) - addammo(i, &ps[myconnectindex], max_ammo_amount[i]); - } - else if (!stricmp(parm->parms[0], "armor")) - { - ps[myconnectindex].shield_amount = 100; - } - else if (!stricmp(parm->parms[0], "keys")) - { - cheatKeys(cs); - } - else if (!stricmp(parm->parms[0], "inventory")) - { - cheatInventory(cs); - } - else if (!stricmp(parm->parms[0], "items")) - { - cheatItems(cs); - } - else return CCMD_SHOWHELP; - return CCMD_OK; -} - static int osdcmd_warptocoords(CCmdFuncPtr parm) { if (parm->numparms < 3 || parm->numparms > 5) @@ -312,7 +254,6 @@ int registerosdcommands(void) { C_RegisterFunction("map","map : warp to the given map, identified by its name", ccmd_map); C_RegisterFunction("levelwarp","levelwarp : warp to episode 'e' and map 'm'", ccmd_levelwarp); - //C_RegisterFunction("give","give : gives requested item", ccmd_give); C_RegisterFunction("restartmap", "restartmap: restarts the current map", ccmd_restartmap); C_RegisterFunction("spawn","spawn [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",ccmd_spawn); C_RegisterFunction("warptocoords","warptocoords [x] [y] [z] [ang] (optional) [horiz] (optional): warps the player to the specified coordinates",osdcmd_warptocoords); diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 5bed1c4cb..12dfd0bbd 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -39,6 +39,7 @@ source as it is released. #include "mapinfo.h" #include "cheathandler.h" #include "c_dispatch.h" +#include "gamestate.h" EXTERN_CVAR(Int, developer) EXTERN_CVAR(Bool, sv_cheats) @@ -217,81 +218,70 @@ const char* GameInterface::GenericCheat(int player, int cheat) } } - - - -bool cheatWeapons(cheatseq_t *s) +static bool cheatWeapons(int player) { int weaponLimit = (VOLUMEONE) ? SHRINKER_WEAPON : MAX_WEAPONS; for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ ) { - addammo( weapon, &ps[myconnectindex], max_ammo_amount[weapon] ); - ps[myconnectindex].gotweapon.Set(weapon); + addammo( weapon, &ps[player], max_ammo_amount[weapon] ); + ps[player].gotweapon.Set(weapon); } if (isRRRA()) - ps[myconnectindex].ammo_amount[SLINGBLADE_WEAPON] = 1; + ps[player].ammo_amount[SLINGBLADE_WEAPON] = 1; - if (s) FTA(119,&ps[myconnectindex]); return true; } -bool cheatInventory(cheatseq_t *s) +static bool cheatInventory(int player) { - auto invGet = [](int defvalue, int evtype, int16_t &dest) + auto invGet = [=](int defvalue, int evtype, int16_t &dest) { - SetGameVarID(g_iReturnVarID, defvalue, -1, myconnectindex); - OnEvent(evtype, -1, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, -1, myconnectindex) >= 0) + SetGameVarID(g_iReturnVarID, defvalue, -1, player); + OnEvent(evtype, -1, player, -1); + if (GetGameVarID(g_iReturnVarID, -1, player) >= 0) { - dest = GetGameVarID(g_iReturnVarID, -1, myconnectindex); + dest = GetGameVarID(g_iReturnVarID, -1, player); } }; - invGet(400, EVENT_CHEATGETSTEROIDS, ps[myconnectindex].steroids_amount); - if (!isRR()) invGet(1200, EVENT_CHEATGETHEAT, ps[myconnectindex].heat_amount); - invGet(isRR() ? 2000 : 200, EVENT_CHEATGETBOOT, ps[myconnectindex].boot_amount); - invGet(100, EVENT_CHEATGETSHIELD, ps[myconnectindex].shield_amount); - invGet(6400, EVENT_CHEATGETSCUBA, ps[myconnectindex].scuba_amount); - invGet(2400, EVENT_CHEATGETHOLODUKE, ps[myconnectindex].holoduke_amount); - invGet(isRR() ? 600 : 1600, EVENT_CHEATGETJETPACK, ps[myconnectindex].jetpack_amount); - invGet(max_player_health, EVENT_CHEATGETFIRSTAID, ps[myconnectindex].firstaid_amount); - if (s) FTA(120,&ps[myconnectindex]); + invGet(400, EVENT_CHEATGETSTEROIDS, ps[player].steroids_amount); + if (!isRR()) invGet(1200, EVENT_CHEATGETHEAT, ps[player].heat_amount); + invGet(isRR() ? 2000 : 200, EVENT_CHEATGETBOOT, ps[player].boot_amount); + invGet(100, EVENT_CHEATGETSHIELD, ps[player].shield_amount); + invGet(6400, EVENT_CHEATGETSCUBA, ps[player].scuba_amount); + invGet(2400, EVENT_CHEATGETHOLODUKE, ps[player].holoduke_amount); + invGet(isRR() ? 600 : 1600, EVENT_CHEATGETJETPACK, ps[player].jetpack_amount); + invGet(max_player_health, EVENT_CHEATGETFIRSTAID, ps[player].firstaid_amount); return true; } -bool cheatKeys(cheatseq_t *s) +static bool cheatKeys(int player) { - ps[myconnectindex].got_access = 7; + ps[player].got_access = 7; if (isRR()) for (int ikey = 0; ikey < 5; ikey++) - ps[myconnectindex].keys[ikey] = 1; - if (s) FTA(121,&ps[myconnectindex]); + ps[player].keys[ikey] = 1; return true; } -static bool cheatDebug(cheatseq_t *) +static bool cheatStuff(int player) { - // Let's do something useful with this. - if (developer == 0) developer = 3; - else developer = 0; + cheatWeapons(player); + cheatInventory(player); + if (!isNamWW2GI()) cheatKeys(player); return true; + } -static bool cheatAllen(cheatseq_t *) +static bool cheatItems(int player) { - FTA(79,&ps[myconnectindex]); + cheatInventory(player); + if (!isNamWW2GI()) cheatKeys(player); return true; } -bool cheatStuff(cheatseq_t *) -{ - cheatWeapons(nullptr); - cheatInventory(nullptr); - if (!isNamWW2GI()) cheatKeys(nullptr); - FTA(5,&ps[myconnectindex]); - return true; -} + static bool cheatLevel(cheatseq_t *s) { @@ -313,15 +303,6 @@ static bool cheatLevel(cheatseq_t *s) return true; } -bool cheatItems(cheatseq_t *) -{ - cheatInventory(nullptr); - if (!isNamWW2GI()) cheatKeys(nullptr); - FTA(5,&ps[myconnectindex]); - return true; -} - - static bool cheatSkill(cheatseq_t *s) { lastlevel = 0; @@ -334,6 +315,20 @@ static bool cheatSkill(cheatseq_t *s) // The remaining cheats are client side only. +static bool cheatDebug(cheatseq_t*) +{ + // Let's do something useful with this. + if (developer == 0) developer = 3; + else developer = 0; + return true; +} + +static bool cheatAllen(cheatseq_t*) +{ + FTA(79, &ps[myconnectindex]); + return true; +} + static bool cheatBeta(cheatseq_t *) { FTA(105,&ps[myconnectindex]); @@ -473,6 +468,64 @@ static cheatseq_t rrcheats[] = { { "rdvan", nullptr, SendGenericCheat, 0, CHT_VAN }, }; + +static void cmd_Give(int player, uint8_t** stream, bool skip) +{ + int type = ReadByte(stream); + if (skip) return; + + if (numplayers != 1 || gamestate != GS_LEVEL || ps[player].dead_flag != 0) + { + Printf("give: Cannot give while dead or not in a single-player game.\n"); + return; + } + + switch (type) + { + case GIVE_ALL: + cheatStuff(player); + FTA(5, &ps[player]); + break; + + case GIVE_HEALTH: + sprite[ps[player].i].extra = max_player_health << 1; + break; + + case GIVE_WEAPONS: + cheatWeapons(player); + FTA(119, &ps[player]); + break; + + case GIVE_AMMO: + { + int maxw = VOLUMEONE ? SHRINKER_WEAPON : MAX_WEAPONS; + for (int i = maxw; i >= PISTOL_WEAPON; i--) + addammo(i, &ps[player], max_ammo_amount[i]); + break; + } + + case GIVE_ARMOR: + ps[player].shield_amount = 100; + break; + + case GIVE_KEYS: + cheatKeys(player); + FTA(121, &ps[player]); + break; + + case GIVE_INVENTORY: + cheatInventory(player); + FTA(120, &ps[player]); + break; + + case GIVE_ITEMS: + cheatItems(player); + FTA(5, &ps[player]); + break; + } +} + + void InitCheats() { if (isRRRA()) SetCheats(rrcheats, countof(rrcheats)); @@ -480,6 +533,7 @@ void InitCheats() else if (isWW2GI()) SetCheats(ww2cheats, countof(ww2cheats)); else if (isNam()) SetCheats(namcheats, countof(namcheats)); else SetCheats(dukecheats, countof(dukecheats)); + Net_SetCommandHandler(DEM_GIVE, cmd_Give); } END_DUKE_NS diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp index 6d2bf2a38..b7ff95197 100644 --- a/source/sw/src/cheats.cpp +++ b/source/sw/src/cheats.cpp @@ -39,6 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "cheathandler.h" #include "d_protocol.h" #include "cheats.h" +#include "gamestate.h" //#include "inv.h" BEGIN_SW_NS @@ -141,71 +142,6 @@ bool MapCheat(cheatseq_t* c) return true; } -bool WeaponCheat(cheatseq_t* c) -{ - if (!checkCheat(c)) return false; - PLAYERp p; - short pnum; - unsigned int i; - USERp u; - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - u = User[p->PlayerSprite]; - - if (!TEST(p->Flags, PF_TWO_UZI)) - { - SET(p->Flags, PF_TWO_UZI); - SET(p->Flags, PF_PICKED_UP_AN_UZI); - } - - // ALL WEAPONS - if (!SW_SHAREWARE) - p->WpnFlags = 0xFFFFFFFF; - else - p->WpnFlags = 0x0000207F; // Disallows high weapon cheat in shareware - - for (i = 0; i < SIZ(p->WpnAmmo); i++) - { - p->WpnAmmo[i] = DamageData[i].max_ammo; - } - - p->WpnShotgunAuto = 50; - p->WpnRocketHeat = 5; - p->WpnRocketNuke = 1; - - PlayerUpdateWeapon(p, u->WeaponNum); - } - return true; -} - -bool AmmoCheat(cheatseq_t* c) -{ - if (!checkCheat(c)) return false; - PLAYERp p; - short pnum; - unsigned int i; - USERp u; - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - u = User[p->PlayerSprite]; - - p->WpnShotgunAuto = 50; - p->WpnRocketHeat = 5; - p->WpnRocketNuke = 1; - - for (i = 0; i < SIZ(p->WpnAmmo); i++) - { - p->WpnAmmo[i] = DamageData[i].max_ammo; - } - - PlayerUpdateWeapon(p, u->WeaponNum); - } - return true; -} bool WarpCheat(cheatseq_t* c) { @@ -235,176 +171,6 @@ bool WarpCheat(cheatseq_t* c) return true; } -bool ItemCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - // - // Get all ITEMS - // - PLAYERp p; - short pnum; - short inv; - int i; - - PutStringInfo(pp, "ITEMS"); - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - memset(p->HasKey, TRUE, sizeof(p->HasKey)); - - p->WpnShotgunAuto = 50; - p->WpnRocketHeat = 5; - p->WpnRocketNuke = 1; - p->Armor = 100; - - for (inv = 0; inv < MAX_INVENTORY; inv++) - { - p->InventoryPercent[inv] = 100; - //p->InventoryAmount[inv] = 1; - p->InventoryAmount[inv] = InventoryData[inv].MaxInv; - //PlayerUpdateInventory(p, inv); - } - - PlayerUpdateInventory(p, p->InventoryNum); - //p->InventoryNum = 0; - } - - for (i=0; istag == SECT_LOCK_DOOR) - SectUser[i]->number = 0; // unlock all doors of this type - } - - WeaponCheat(c); - return true; -} - -bool InventoryCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - // - // Get all ITEMS - // - PLAYERp p; - short pnum; - short inv; - int i; - - PutStringInfo(pp, "INVENTORY"); - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - - p->WpnShotgunAuto = 50; - p->WpnRocketHeat = 5; - p->WpnRocketNuke = 1; - p->Armor = 100; - - for (inv = 0; inv < MAX_INVENTORY; inv++) - { - p->InventoryPercent[inv] = 100; - //p->InventoryAmount[inv] = 1; - p->InventoryAmount[inv] = InventoryData[inv].MaxInv; - //PlayerUpdateInventory(p, inv); - } - - PlayerUpdateInventory(p, p->InventoryNum); - //p->InventoryNum = 0; - } - return true; -} - -bool ArmorCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - short pnum; - const char *str = nullptr; - - TRAVERSE_CONNECT(pnum) - { - if (User[Player[pnum].PlayerSprite]->Health < pp->MaxHealth) - str = "ARMOR"; - Player[pnum].Armor = 100; - } - if (str) PutStringInfo(pp, GStrings(str)); - return true; -} - -bool HealCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - short pnum; - const char *str = nullptr; - - TRAVERSE_CONNECT(pnum) - { - if (User[Player[pnum].PlayerSprite]->Health < pp->MaxHealth) - str = "TXTS_ADDEDHEALTH"; - User[Player[pnum].PlayerSprite]->Health += 25; - } - if (str) PutStringInfo(pp, GStrings(str)); - return true; -} - -bool KeyCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - // Get KEYS - PLAYERp p; - short pnum; - const char *cp = (char*)c->Args; - const char *str = "TXTS_GIVEKEY"; - int keynum = 0; - - keynum = atol(cp); - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - if (keynum >= 1 && keynum <= 8) - { - if (p->HasKey[keynum-1] == FALSE) - { - p->HasKey[keynum-1] = TRUE; // cards: 0=red 1=blue 2=green 3=yellow | keys: 4=gold 5=silver 6=bronze 7=red - str = "TXTS_KEYGIVEN"; - } - else - { - p->HasKey[keynum-1] = FALSE; - str = "TXTS_KEYREMOVED"; - } - } - } - PutStringInfo(pp, GStrings(str)); - return true; -} - -bool KeysCheat(cheatseq_t* c) -{ - PLAYERp pp; - if (!(pp = checkCheat(c))) return false; - // Get KEYS - PLAYERp p; - short pnum; - const char* str = "TXTS_GIVEKEY"; - int keynum = 0; - - TRAVERSE_CONNECT(pnum) - { - p = &Player[pnum]; - memset(p->HasKey, TRUE, sizeof(p->HasKey)); - } - PutStringInfo(pp, GStrings(str)); - return true; -} - bool EveryCheatToggle(cheatseq_t* c) { EveryCheat ^= 1; @@ -420,7 +186,6 @@ static cheatseq_t swcheats[] = { {"lwchan", "god" }, {"lwgimme", "give all" }, {"lwmedic", "give health" }, - {"lwkey#", nullptr, KeyCheat, 0}, {"lwkeys", "give keys" }, {"lwammo", "give ammo" }, {"lwarmor", "give armor" }, @@ -435,10 +200,151 @@ static cheatseq_t swcheats[] = { {"lwroom", nullptr, RoomCheat, true}, // Room above room debug }; +static void WeaponCheat(int player) +{ + auto p = &Player[player]; + auto u = User[p->PlayerSprite]; + + if (!TEST(p->Flags, PF_TWO_UZI)) + { + SET(p->Flags, PF_TWO_UZI); + SET(p->Flags, PF_PICKED_UP_AN_UZI); + } + + // ALL WEAPONS + if (!SW_SHAREWARE) p->WpnFlags = 0xFFFFFFFF; + else p->WpnFlags = 0x0000207F; // Disallows high weapon cheat in shareware + + for (int i = 0; i < SIZ(p->WpnAmmo); i++) + { + p->WpnAmmo[i] = DamageData[i].max_ammo; + } + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + + PlayerUpdateWeapon(p, u->WeaponNum); +} + +static void ItemCheat(int player) +{ + auto p = &Player[player]; + PutStringInfo(p, GStrings("GIVING EVERYTHING!")); + memset(p->HasKey, TRUE, sizeof(p->HasKey)); + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + p->Armor = 100; + + for (int inv = 0; inv < MAX_INVENTORY; inv++) + { + p->InventoryPercent[inv] = 100; + p->InventoryAmount[inv] = InventoryData[inv].MaxInv; + } + + PlayerUpdateInventory(p, p->InventoryNum); + + for (int i = 0; i < numsectors; i++) + { + if (SectUser[i] && SectUser[i]->stag == SECT_LOCK_DOOR) + SectUser[i]->number = 0; // unlock all doors of this type + } +} + + +static void cmd_Give(int player, uint8_t** stream, bool skip) +{ + int type = ReadByte(stream); + if (skip) return; + + if (numplayers != 1 || gamestate != GS_LEVEL || (Player[player].Flags & PF_DEAD)) + { + Printf("give: Cannot give while dead or not in a single-player game.\n"); + return; + } + + switch (type) + { + case GIVE_ALL: + ItemCheat(player); + WeaponCheat(player); + break; + + case GIVE_HEALTH: + if (User[Player[player].PlayerSprite]->Health < Player[player].MaxHealth) + { + User[Player[player].PlayerSprite]->Health += 25; + PutStringInfo(&Player[player], GStrings("TXTS_ADDEDHEALTH")); + } + break; + + case GIVE_WEAPONS: + WeaponCheat(player); + break; + + case GIVE_AMMO: + { + auto p = &Player[player]; + auto u = User[p->PlayerSprite]; + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + + for (int i = 0; i < SIZ(p->WpnAmmo); i++) + { + p->WpnAmmo[i] = DamageData[i].max_ammo; + } + + PlayerUpdateWeapon(p, u->WeaponNum); + break; + } + + case GIVE_ARMOR: + if (User[Player[player].PlayerSprite]->Health < Player[player].MaxHealth) + { + Player[player].Armor = 100; + PutStringInfo(&Player[player], GStrings("TXTB_FULLARM")); + } + break; + + case GIVE_KEYS: + memset(Player[player].HasKey, TRUE, sizeof(Player[player].HasKey)); + PutStringInfo(&Player[player], GStrings("TXTS_GIVEKEY")); + break; + + case GIVE_INVENTORY: + { + auto p = &Player[player]; + PutStringInfo(p, GStrings("GOT ALL INVENTORY")); + + p->WpnShotgunAuto = 50; + p->WpnRocketHeat = 5; + p->WpnRocketNuke = 1; + p->Armor = 100; + + for (int inv = 0; inv < MAX_INVENTORY; inv++) + { + p->InventoryPercent[inv] = 100; + p->InventoryAmount[inv] = InventoryData[inv].MaxInv; + } + + PlayerUpdateInventory(p, p->InventoryNum); + } + break; + + case GIVE_ITEMS: + ItemCheat(player); + break; + } +} void InitCheats() { SetCheats(swcheats, countof(swcheats)); + Net_SetCommandHandler(DEM_GIVE, cmd_Give); } END_SW_NS diff --git a/source/sw/src/osdcmds.cpp b/source/sw/src/osdcmds.cpp index 0c4b95eb7..c95d285fd 100644 --- a/source/sw/src/osdcmds.cpp +++ b/source/sw/src/osdcmds.cpp @@ -114,60 +114,6 @@ int osdcmd_levelwarp(CCmdFuncPtr parm) return CCMD_OK; } -struct cheatseq_t; -bool WeaponCheat(cheatseq_t* c); -bool AmmoCheat(cheatseq_t* c); -bool ItemCheat(cheatseq_t* c); -bool InventoryCheat(cheatseq_t* c); -bool ArmorCheat(cheatseq_t* c); -bool HealCheat(cheatseq_t* c); -bool KeysCheat(cheatseq_t* c); - - -static int osdcmd_give(CCmdFuncPtr parm) -{ - int32_t i; - - if (parm->numparms != 1) return CCMD_SHOWHELP; - - if (!stricmp(parm->parms[0], "all")) - { - ItemCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "health")) - { - HealCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "weapons")) - { - WeaponCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "ammo")) - { - AmmoCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "armor")) - { - ArmorCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "keys")) - { - KeysCheat(nullptr); - return CCMD_OK; - } - else if (!stricmp(parm->parms[0], "inventory")) - { - InventoryCheat(nullptr); - return CCMD_OK; - } - return CCMD_SHOWHELP; -} - static int osdcmd_warptocoords(CCmdFuncPtr parm) { if (parm->numparms < 3 || parm->numparms > 5) @@ -280,7 +226,6 @@ static int osdcmd_noop(CCmdFuncPtr parm) int32_t registerosdcommands(void) { C_RegisterFunction("map","map : loads the given map", osdcmd_map); - //C_RegisterFunction("give","give : gives requested item", osdcmd_give); C_RegisterFunction("mirror_debug", "mirror [mirrornum]: print mirror debug info", osdcmd_mirror); C_RegisterFunction("levelwarp", "levelwarp : warp to level", osdcmd_levelwarp); C_RegisterFunction("restartmap", "restartmap: restarts the current map", osdcmd_restartmap);