diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index c0571cea4..57b699121 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -347,14 +347,10 @@ void ctrlGetInput(void) void registerinputcommands() { C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend.pause = 1; sendPause = true; return CCMD_OK; }); - C_RegisterFunction("jumpboots", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useJumpBoots = 1; return CCMD_OK; }); - C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useMedKit = 1; return CCMD_OK; }); C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend.lookCenter = 1; return CCMD_OK; }); C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend.holsterWeapon = 1; return CCMD_OK; }); C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend.prevItem = 1; return CCMD_OK; }); C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend.nextItem = 1; return CCMD_OK; }); - C_RegisterFunction("crystalball", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useCrystalBall = 1; return CCMD_OK; }); - C_RegisterFunction("beastvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useBeastVision = 1; return CCMD_OK; }); C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend.spin180 = 1; return CCMD_OK; }); C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend.useItem = 1; return CCMD_OK; }); } diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index f9a692621..b7c962f2c 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1295,6 +1295,14 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3) void ProcessInput(PLAYER *pPlayer) { + enum + { + Item_MedKit = 0, + Item_CrystalBall = 1, + Item_BeastVision = 2, + Item_JumpBoots = 3 + }; + spritetype *pSprite = pPlayer->pSprite; XSPRITE *pXSprite = pPlayer->pXSprite; int nSprite = pPlayer->nSprite; @@ -1643,27 +1651,27 @@ void ProcessInput(PLAYER *pPlayer) if (pPlayer->packSlots[pPlayer->packItemId].curAmount > 0) packUseItem(pPlayer, pPlayer->packItemId); } - if (pInput->syncFlags.useBeastVision) + if (pInput->isItemUsed(Item_BeastVision)) { - pInput->syncFlags.useBeastVision = 0; + pInput->clearItemUsed(Item_BeastVision); if (pPlayer->packSlots[3].curAmount > 0) packUseItem(pPlayer, 3); } - if (pInput->syncFlags.useCrystalBall) + if (pInput->isItemUsed(Item_CrystalBall)) { - pInput->syncFlags.useCrystalBall = 0; + pInput->clearItemUsed(Item_CrystalBall); if (pPlayer->packSlots[2].curAmount > 0) packUseItem(pPlayer, 2); } - if (pInput->syncFlags.useJumpBoots) + if (pInput->isItemUsed(Item_JumpBoots)) { - pInput->syncFlags.useJumpBoots = 0; + pInput->clearItemUsed(Item_JumpBoots); if (pPlayer->packSlots[4].curAmount > 0) packUseItem(pPlayer, 4); } - if (pInput->syncFlags.useMedKit) + if (pInput->isItemUsed(Item_MedKit)) { - pInput->syncFlags.useMedKit = 0; + pInput->clearItemUsed(Item_MedKit); if (pPlayer->packSlots[0].curAmount > 0) packUseItem(pPlayer, 0); } diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index e9921e54a..04465d81e 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -42,7 +42,7 @@ #include "gamecontrol.h" static int WeaponToSend = 0; - +ESyncBits ActionsToSend = 0; //========================================================================== // // @@ -259,6 +259,24 @@ CCMD(weapalt) WeaponToSend = WeaponSel_Alt; // Only used by SW - should also be made usable by Blood ans Duke which put multiple weapons in the same slot. } +CCMD(useitem) +{ + int max = (g_gameType & GAMEFLAG_PSEXHUMED)? 6 : (g_gameType & GAMEFLAG_SW)? 7 : (g_gameType & GAMEFLAG_BLOOD) ? 4 : 5; + if (argv.argc() != 2) + { + Printf("useitem : activates an inventory item (1-%d)", max); + } + + auto slot = atoi(argv[1]); + if (slot >= 1 && slot <= max) + { + ActionsToSend |= ESyncBits::FromInt(SB_ITEM_BIT_1 << (slot - 1)); + } +} + + + + void ApplyGlobalInput(InputPacket& input, ControlInfo *info) { if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend); @@ -275,5 +293,7 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo *info) info->dz = 0; info->dyaw = 0; } + input.actions |= ActionsToSend; + ActionsToSend = 0; } \ No newline at end of file diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 221b48204..1c28311d8 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -100,4 +100,4 @@ enum GameFunction_t void SetupGameButtons(); void ApplyGlobalInput(InputPacket& input, ControlInfo *info); - +extern ESyncBits ActionsToSend; \ No newline at end of file diff --git a/source/core/packet.h b/source/core/packet.h index 7942aa965..668b2d96e 100644 --- a/source/core/packet.h +++ b/source/core/packet.h @@ -6,13 +6,24 @@ enum ESyncBits_ : uint32_t { - SB_FIRST_WEAPON_BIT = 1 << 0, + SB_FIRST_WEAPON_BIT = 1 << 0, + SB_ITEM_BIT_1 = 1 << 4, + SB_ITEM_BIT_2 = 1 << 5, + SB_ITEM_BIT_3 = 1 << 6, + SB_ITEM_BIT_4 = 1 << 7, + SB_ITEM_BIT_5 = 1 << 8, + SB_ITEM_BIT_6 = 1 << 9, + SB_ITEM_BIT_7 = 1 << 10, + + // Exhumed has 6 items but doesn't use the network packet to activate them. Need to change + SB_WEAPONMASK_BITS = (15u * SB_FIRST_WEAPON_BIT), // Weapons take up 4 bits + SB_ITEMUSE_BITS = (127u * SB_ITEM_BIT_1), SB_BUTTON_MASK = 0, // all input from buttons (i.e. active while held) SB_INTERFACE_MASK = 0, // all input from CCMDs - SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_INTERFACE_MASK) + SB_INTERFACE_BITS = (SB_WEAPONMASK_BITS | SB_ITEMUSE_BITS | SB_INTERFACE_MASK) }; // enforce type safe operations on the input bits. @@ -52,11 +63,8 @@ enum EDukeSyncBits_ : uint32_t SKB_RUN = 1 << 5, SKB_LOOK_LEFT = 1 << 6, SKB_LOOK_RIGHT = 1 << 7, - SKB_STEROIDS = 1 << 12, SKB_LOOK_UP = 1 << 13, SKB_LOOK_DOWN = 1 << 14, - SKB_NIGHTVISION = 1 << 15, - SKB_MEDKIT = 1 << 16, SKB_MULTIFLAG = 1 << 17, SKB_CENTER_VIEW = 1 << 18, SKB_HOLSTER = 1 << 19, @@ -64,8 +72,6 @@ enum EDukeSyncBits_ : uint32_t SKB_PAUSE = 1 << 21, SKB_QUICK_KICK = 1 << 22, SKB_AIMMODE = 1 << 23, - SKB_HOLODUKE = 1 << 24, - SKB_JETPACK = 1 << 25, SKB_GAMEQUIT = 1 << 26, SKB_INV_RIGHT = 1 << 27, SKB_TURNAROUND = 1 << 28, @@ -73,8 +79,8 @@ enum EDukeSyncBits_ : uint32_t SKB_INVENTORY = 1 << 30, SKB_ESCAPE = 1u << 31, - SKB_INTERFACE_BITS = (SKB_STEROIDS | SKB_NIGHTVISION | SKB_MEDKIT | SKB_QUICK_KICK | \ - SKB_HOLSTER | SKB_INV_LEFT | SKB_PAUSE | SKB_HOLODUKE | SKB_JETPACK | SKB_INV_RIGHT | \ + SKB_INTERFACE_BITS = (SKB_QUICK_KICK | \ + SKB_HOLSTER | SKB_INV_LEFT | SKB_PAUSE | SKB_INV_RIGHT | \ SKB_TURNAROUND | SKB_OPEN | SKB_INVENTORY | SKB_ESCAPE), SKB_NONE = 0, @@ -111,10 +117,6 @@ union SYNCFLAGS unsigned int pause : 1; unsigned int quit : 1; unsigned int restart : 1; - unsigned int useBeastVision : 1; - unsigned int useCrystalBall : 1; - unsigned int useJumpBoots : 1; - unsigned int useMedKit : 1; }; }; @@ -124,10 +126,6 @@ union SYNCFLAGS // NETWORK - REDEFINABLE SHARED (SYNC) KEYS BIT POSITIONS // -#define SK_INV_HOTKEY_BIT0 4 -#define SK_INV_HOTKEY_BIT1 5 -#define SK_INV_HOTKEY_BIT2 6 -#define SK_INV_HOTKEY_MASK (BIT(SK_INV_HOTKEY_BIT0)|BIT(SK_INV_HOTKEY_BIT1)|BIT(SK_INV_HOTKEY_BIT2)) #define SK_AUTO_AIM 7 #define SK_CENTER_VIEW 8 @@ -148,8 +146,6 @@ union SYNCFLAGS #define SK_SNAP_DOWN 22 #define SK_QUIT_GAME 23 -#define SK_MULTI_VIEW 24 - #define SK_TURN_180 25 #define SK_INV_LEFT 26 @@ -210,6 +206,22 @@ struct InputPacket { actions = (actions & ~SB_WEAPONMASK_BITS) | (ESyncBits::FromInt(weap) & SB_WEAPONMASK_BITS); } + + bool isItemUsed(int num) + { + return !!(actions & ESyncBits::FromInt(SB_ITEM_BIT_1 << num)); + } + + void setItemUsed(int num) + { + actions |= ESyncBits::FromInt(SB_ITEM_BIT_1 << num); + } + + void clearItemUsed(int num) + { + actions &= ~ESyncBits::FromInt(SB_ITEM_BIT_1 << num); + } + }; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 78d7e0f17..559912a10 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -528,6 +528,25 @@ void GameTicker() weap2 = SelectAltWeapon(weap2); } + for (int i = 0; i < 6; i++) + { + if (localInput.isItemUsed(i)) + { + localInput.clearItemUsed(i); + if (PlayerList[nLocalPlayer].items[i] > 0) + { + if (nItemMagic[i] <= PlayerList[nLocalPlayer].nMagic) + { + sPlayerInput[nLocalPlayer].nItem = i; + break; + } + } + } + } + + + + sPlayerInput[nLocalPlayer].xVel = lPlayerXVel; sPlayerInput[nLocalPlayer].yVel = lPlayerYVel; // make weapon selection persist until it gets used up. diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index fe48d7f34..22866714c 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -388,7 +388,7 @@ void registerinputcommands() C_RegisterFunction("centerview", nullptr, ccmd_centerview); C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetPrevItem(nLocalPlayer); return CCMD_OK; }); C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) SetNextItem(nLocalPlayer); return CCMD_OK; }); - C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) UseCurItem(nLocalPlayer); return CCMD_OK; }); + //C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { if (PlayerList[nLocalPlayer].nHealth > 0) UseCurItem(nLocalPlayer); return CCMD_OK; }); // These are only here to silence the engine when the keys bound to them are pressed. The functions do not exist. C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { return CCMD_OK; }); diff --git a/source/exhumed/src/items.cpp b/source/exhumed/src/items.cpp index 35d1a57c0..4956ab5aa 100644 --- a/source/exhumed/src/items.cpp +++ b/source/exhumed/src/items.cpp @@ -316,22 +316,6 @@ void UseItem(short nPlayer, short nItem) } } -void UseCurItem(short nPlayer) -{ - int nItem = nPlayerItem[nPlayer]; - - if (nItem >= 0) - { - if (PlayerList[nPlayer].items[nItem] > 0) - { - if (nItemMagic[nItem] <= PlayerList[nPlayer].nMagic) - { - sPlayerInput[nPlayer].nItem = nItem; - } - } - } -} - // TODO - bool return type? int GrabItem(short nPlayer, short nItem) { diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 4d9075237..710b4abe9 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -146,6 +146,16 @@ inline int PlayerNewWeapon(int pl) return sync[pl].getNewWeapon(); } +inline void PlayerSetItemUsed(int pl, int num) +{ + sync[pl].setItemUsed(num - 1); +} + +inline bool PlayerUseItem(int pl, int num) +{ + return sync[pl].isItemUsed(num - 1); +} + inline int PlayerInputSideVel(int pl) { return sync[pl].svel; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 4fa868bc2..6b1592630 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -210,19 +210,11 @@ void hud_input(int snum) OnEvent(EVENT_INVENTORY, -1, snum, -1); if (GetGameVarID(g_iReturnVarID, -1, snum) == 0) { - switch (p->inven_icon) - { - // Yet another place where no symbolic constants were used. :( - case ICON_JETPACK: PlayerSetInput(snum, SKB_JETPACK); break; - case ICON_HOLODUKE: PlayerSetInput(snum, SKB_HOLODUKE); break; - case ICON_HEATS: PlayerSetInput(snum, SKB_NIGHTVISION); break; - case ICON_FIRSTAID: PlayerSetInput(snum, SKB_MEDKIT); break; - case ICON_STEROIDS: PlayerSetInput(snum, SKB_STEROIDS); break; - } + if (p->inven_icon > ICON_NONE && p->inven_icon <= ICON_HEATS) PlayerSetItemUsed(snum, p->inven_icon); } } - if (!isRR() && PlayerInput(snum, SKB_NIGHTVISION)) + if (!isRR() && PlayerUseItem(snum, ICON_HEATS)) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_USENIGHTVISION, -1, snum, -1); @@ -236,7 +228,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SKB_STEROIDS)) + if (PlayerUseItem(snum, ICON_STEROIDS)) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_USESTEROIDS, -1, snum, -1); @@ -363,7 +355,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SKB_HOLODUKE) && (isRR() || p->newowner == -1)) + if (PlayerUseItem(snum, ICON_HOLODUKE) && (isRR() || p->newowner == -1)) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_HOLODUKEON, -1, snum, -1); @@ -419,7 +411,7 @@ void hud_input(int snum) } } - if (isRR() && PlayerInput(snum, SKB_NIGHTVISION) && p->newowner == -1) + if (isRR() && PlayerUseItem(snum, ICON_HEATS) && p->newowner == -1) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_USENIGHTVISION, -1, snum, -1); @@ -451,7 +443,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SKB_MEDKIT)) + if (PlayerUseItem(snum, ICON_FIRSTAID)) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_USEMEDKIT, -1, snum, -1); @@ -504,7 +496,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SKB_JETPACK) && (isRR() || p->newowner == -1)) + if (PlayerUseItem(snum, ICON_JETPACK) && (isRR() || p->newowner == -1)) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_USEJETPACK, -1, snum, -1); @@ -1169,15 +1161,10 @@ void GetInput() void registerinputcommands() { C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_PAUSE; sendPause = true; return CCMD_OK; }); - C_RegisterFunction("steroids", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_STEROIDS; return CCMD_OK; }); - C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_NIGHTVISION; return CCMD_OK; }); - C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_MEDKIT; return CCMD_OK; }); C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_CENTER_VIEW; return CCMD_OK; }); C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLSTER; return CCMD_OK; }); C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_LEFT; return CCMD_OK; }); C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_RIGHT; return CCMD_OK; }); - C_RegisterFunction("holoduke", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLODUKE; return CCMD_OK; }); - C_RegisterFunction("jetpack", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_JETPACK; return CCMD_OK; }); C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_TURNAROUND; return CCMD_OK; }); C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INVENTORY; return CCMD_OK; }); C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; }); diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index bb922ee02..579b22b12 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -423,9 +423,6 @@ getinput(InputPacket *loc, SWBOOL tied) loc->bits |= BitsToSend; BitsToSend = 0; - SET(loc->bits, inv_hotkey<bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open)); SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump)); SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch)); @@ -474,16 +471,10 @@ getinput(InputPacket *loc, SWBOOL tied) void registerinputcommands() { C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_PAUSE); sendPause = true; return CCMD_OK; }); - C_RegisterFunction("smoke_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CLOAK + 1; return CCMD_OK; }); - C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_NIGHT_VISION + 1; return CCMD_OK; }); - C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_MEDKIT + 1; return CCMD_OK; }); C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_CENTER_VIEW); return CCMD_OK; }); C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_HIDE_WEAPON); return CCMD_OK; }); C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_LEFT); return CCMD_OK; }); C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_RIGHT); return CCMD_OK; }); - C_RegisterFunction("gas_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CHEMBOMB + 1; return CCMD_OK; }); - C_RegisterFunction("flash_bomb", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_FLASHBOMB + 1; return CCMD_OK; }); - C_RegisterFunction("caltrops", nullptr, [](CCmdFuncPtr)->int { inv_hotkey = INVENTORY_CALTROPS + 1; return CCMD_OK; }); C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_TURN_180); return CCMD_OK; }); C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= BIT(SK_INV_USE); return CCMD_OK; }); } diff --git a/source/sw/src/inv.cpp b/source/sw/src/inv.cpp index 7f60f702a..d4b07c58b 100644 --- a/source/sw/src/inv.cpp +++ b/source/sw/src/inv.cpp @@ -367,8 +367,6 @@ DoPlayerNightVisionPalette(PLAYERp pp) void UseInventoryNightVision(PLAYERp pp) { -#define NIGHT_INVENTORY_TIME 30 - if (pp->InventoryActive[pp->InventoryNum]) { StopInventoryNightVision(pp, pp->InventoryNum); @@ -473,33 +471,33 @@ void InventoryKeys(PLAYERp pp) FLAG_KEY_RESET(pp, SK_INV_USE); } - // get hotkey number out of input bits - inv_hotkey = TEST(pp->input.bits, SK_INV_HOTKEY_MASK) >> SK_INV_HOTKEY_BIT0; - - if (inv_hotkey) + // test all 7 items + for (int i = 0; i <= 7; i++) { - if (FLAG_KEY_PRESSED(pp, SK_INV_HOTKEY_BIT0)) + ESyncBits bit = ESyncBits::FromInt(SB_ITEM_BIT_1 << i); + if (pp->input.isItemUsed(i)) { - FLAG_KEY_RELEASE(pp, SK_INV_HOTKEY_BIT0); - - inv_hotkey -= 1; - - // switches you to this inventory item - pp->InventoryNum = inv_hotkey; - - if (InventoryData[pp->InventoryNum].Init && !TEST(pp->Flags, PF_CLIMBING)) + if (pp->KeyPressBits & bit) { - if (pp->InventoryAmount[pp->InventoryNum]) - { - InventoryUse(pp); - } - } + pp->KeyPressBits &= ~bit; + + // switches you to this inventory item + pp->InventoryNum = i; + + if (InventoryData[pp->InventoryNum].Init && !TEST(pp->Flags, PF_CLIMBING)) + { + if (pp->InventoryAmount[pp->InventoryNum]) + { + InventoryUse(pp); + } + } + } + } + else + { + pp->KeyPressBits |= bit; } } - else - { - FLAG_KEY_RESET(pp, SK_INV_HOTKEY_BIT0); - } } void InventoryTimer(PLAYERp pp) diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index 84b7687a3..6aaaa24ac 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -83,22 +83,20 @@ DoPrediction(PLAYERp ppp) // get rid of input bits so it doesn't go into other code branches that would // get it out of sync - ppp->input.actions &= ~(SB_WEAPONMASK_BITS); - ppp->KeyPressBits |= (SB_WEAPONMASK_BITS); + ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS); + ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS); RESET(ppp->input.bits, BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)| BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)| BIT(SK_AUTO_AIM)| - BIT(SK_CENTER_VIEW)| - SK_INV_HOTKEY_MASK + BIT(SK_CENTER_VIEW) ); SET(ppp->KeyPressFlags, BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)| BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)| BIT(SK_AUTO_AIM)| - BIT(SK_CENTER_VIEW)| - SK_INV_HOTKEY_MASK + BIT(SK_CENTER_VIEW) ); // back up things so they won't get stepped on diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 839f415ee..f31cbb28a 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -7518,7 +7518,7 @@ const char *DeathString(short SpriteNum) case RADIATION_CLOUD: return GStrings("radiation"); case CALTROPS: - return GStrings("caltrops"); + return GStrings("useitem 7"); } return ""; } diff --git a/wadsrc/static/engine/commonbinds.txt b/wadsrc/static/engine/commonbinds.txt index a9da9dc9e..d38e6e8a9 100644 --- a/wadsrc/static/engine/commonbinds.txt +++ b/wadsrc/static/engine/commonbinds.txt @@ -34,7 +34,7 @@ RCtrl "+Fire" Pause "pause" ` "toggleconsole" -T "+Send_Message" +T "messagemode" Tab "togglemap" mapbind F "togglefollow" mapbind - "+Shrink_Screen" diff --git a/wadsrc/static/engine/menudef.txt b/wadsrc/static/engine/menudef.txt index c471e8e08..14af5aa80 100644 --- a/wadsrc/static/engine/menudef.txt +++ b/wadsrc/static/engine/menudef.txt @@ -584,15 +584,15 @@ OptionMenu "WeaponsControlMenu"// protected } ifgame(Blood) { - Control "$CNTRLMNU_PROXIMITYBOMBS","proximitybombs" - Control "$CNTRLMNU_REMOTEBOMBS" ,"remotebombs" + Control "$CNTRLMNU_PROXIMITYBOMBS","slot 11" + Control "$CNTRLMNU_REMOTEBOMBS" ,"slot 12" } ifgame(ShadowWarrior) { - Control "$CNTRLMNU_SMOKEBOMB","smoke_bomb" - Control "$CNTRLMNU_GASBOMB" ,"gas_bomb" - Control "$CNTRLMNU_FLASHBOMB","flash_bomb" - Control "$CNTRLMNU_CALTROPS" ,"caltrops" + Control "$CNTRLMNU_SMOKEBOMB","useitem 3" + Control "$CNTRLMNU_GASBOMB" ,"useitem 5" + Control "$CNTRLMNU_FLASHBOMB","useitem 6" + Control "$CNTRLMNU_CALTROPS" ,"useitem 7" } } @@ -610,54 +610,65 @@ OptionMenu "InventoryControlsMenu"// protected Control "$CNTRLMNU_NEXTITEM" , "invnext" Control "$CNTRLMNU_PREVIOUSITEM" , "invprev" + // Item numbers here are are defined by the games' internal order. ifgame(Duke) { StaticText "" - Control "$CNTRLMNU_HOLODUKE" , "holoduke" - Control "$CNTRLMNU_JETPACK" , "jetpack" - Control "$CNTRLMNU_NIGHTVISION" , "nightvision" - Control "$CNTRLMNU_MEDKIT" , "medkit" - Control "$CNTRLMNU_STEROIDS" , "steroids" + Control "$CNTRLMNU_HOLODUKE" , "useitem 3" + Control "$CNTRLMNU_JETPACK" , "useitem 4" + Control "$CNTRLMNU_NIGHTVISION" , "useitem 5" + Control "$CNTRLMNU_MEDKIT" , "useitem 1" + Control "$CNTRLMNU_STEROIDS" , "useitem 2" } ifgame(Nam) { StaticText "" - Control "$CNTRLMNU_HOLOSOLDIER" , "holoduke" - Control "$CNTRLMNU_HUEY" , "jetpack" - Control "$CNTRLMNU_NIGHTVISION" , "nightvision" - Control "$CNTRLMNU_MEDKIT" , "medkit" - Control "$CNTRLMNU_TANKMODE" , "steroids" + Control "$CNTRLMNU_HOLOSOLDIER" , "useitem 3" + Control "$CNTRLMNU_HUEY" , "useitem 4" + Control "$CNTRLMNU_NIGHTVISION" , "useitem 5" + Control "$CNTRLMNU_MEDKIT" , "useitem 1" + Control "$CNTRLMNU_TANKMODE" , "useitem 2" } ifgame(WW2GI) { StaticText "" - Control "$CNTRLMNU_FIRE MISSION" , "holoduke" - Control "$CNTRLMNU_NIGHTVISION" , "nightvision" - Control "$CNTRLMNU_MEDKIT" , "medkit" - Control "$CNTRLMNU_SMOKES" , "steroids" + Control "$CNTRLMNU_FIRE MISSION" , "useitem 3" + Control "$CNTRLMNU_NIGHTVISION" , "useitem 5" + Control "$CNTRLMNU_MEDKIT" , "useitem 1" + Control "$CNTRLMNU_SMOKES" , "useitem 2" } ifgame(Redneck, RedneckRides) { StaticText "" - Control "$CNTRLMNU_BEER" , "holoduke" - Control "$CNTRLMNU_COWPIE" , "jetpack" - Control "$CNTRLMNU_YEEHAA" , "nightvision" - Control "$CNTRLMNU_WHISKEY" , "medkit" - Control "$CNTRLMNU_MOONSHINE" , "steroids" + Control "$CNTRLMNU_BEER" , "useitem 3" + Control "$CNTRLMNU_COWPIE" , "useitem 4" + Control "$CNTRLMNU_YEEHAA" , "useitem 5" + Control "$CNTRLMNU_WHISKEY" , "useitem 1" + Control "$CNTRLMNU_MOONSHINE" , "useitem 2" } ifgame(Blood) { StaticText "" - Control "$CNTRLMNU_CRYSTALBALL" , "crystalball" - Control "$CNTRLMNU_JUMPBOOTS" , "jumpboots" - Control "$CNTRLMNU_BEASTVISION" , "beastvision" - Control "$CNTRLMNU_MEDKIT" , "medkit" + Control "$CNTRLMNU_CRYSTALBALL" , "useitem 2" + Control "$CNTRLMNU_JUMPBOOTS" , "useitem 4" + Control "$CNTRLMNU_BEASTVISION" , "useitem 3" + Control "$CNTRLMNU_MEDKIT" , "useitem 1" } ifgame(ShadowWarrior) { StaticText "" - Control "$CNTRLMNU_NIGHTVISION" , "nightvision" - Control "$CNTRLMNU_MEDKIT" , "medkit" + Control "$CNTRLMNU_NIGHTVISION" , "useitem 4" + Control "$CNTRLMNU_MEDKIT" , "useitem 1" + } + ifgame(Exhumed) + { + StaticText "" + Control "$TXT_USEINV1" , "useitem 1" + Control "$TXT_USEINV2" , "useitem 2" + Control "$TXT_USEINV3" , "useitem 3" + Control "$TXT_USEINV4" , "useitem 4" + Control "$TXT_USEINV5" , "useitem 5" + Control "$TXT_USEINV6" , "useitem 6" } } diff --git a/wadsrc/static/filter/blood/engine/defbinds.txt b/wadsrc/static/filter/blood/engine/defbinds.txt index 3e57e634e..027ece43e 100644 --- a/wadsrc/static/filter/blood/engine/defbinds.txt +++ b/wadsrc/static/filter/blood/engine/defbinds.txt @@ -1,11 +1,11 @@ U "+Mouse_Aiming" I "toggle cl_crosshair" Scroll "+Holster_Weapon" -B "BeastVision" -C "CrystalBall" -P "ProximityBombs" -R "RemoteBombs" +B "useitem 3" +C "useitem 2" +P "slot 11" +R "slot 12" X "+Alt_Fire" -J "jumpboots" -M "MedKit" +J "useitem 4" +M "useitem 1" Mouse2 "+Alt_Fire" diff --git a/wadsrc/static/filter/blood/engine/leftbinds.txt b/wadsrc/static/filter/blood/engine/leftbinds.txt index bc13285ed..9fed4e5be 100644 --- a/wadsrc/static/filter/blood/engine/leftbinds.txt +++ b/wadsrc/static/filter/blood/engine/leftbinds.txt @@ -1,9 +1,9 @@ // W "+Show_Opponents_Weapon" -B "BeastVision" -C "CrystalBall" -P "ProximityBombs" -R "RemoteBombs" +B "useitem 3" +C "useitem 2" +P "slot 11" +R "slot 12" X "+Alt_Fire" -J "jumpboots" -M "MedKit" +J "useitem 4" +M "useitem 1" diff --git a/wadsrc/static/filter/blood/engine/origbinds.txt b/wadsrc/static/filter/blood/engine/origbinds.txt index ef059205f..c8e4e65da 100644 --- a/wadsrc/static/filter/blood/engine/origbinds.txt +++ b/wadsrc/static/filter/blood/engine/origbinds.txt @@ -1,10 +1,10 @@ // -X "+Alt_Fire" W "+Show_Opponents_Weapon" -B "BeastVision" -C "CrystalBall" -J "jumpboots" -M "MedKit" -P "ProximityBombs" -R "RemoteBombs" +B "useitem 3" +C "useitem 2" +P "slot 11" +R "slot 12" +X "+Alt_Fire" +J "useitem 4" +M "useitem 1" Mouse2 "+Alt_Fire" diff --git a/wadsrc/static/filter/duke/engine/defbinds.txt b/wadsrc/static/filter/duke/engine/defbinds.txt index 5bcd053fb..2abe049a8 100644 --- a/wadsrc/static/filter/duke/engine/defbinds.txt +++ b/wadsrc/static/filter/duke/engine/defbinds.txt @@ -1,10 +1,10 @@ // -R "Steroids" +R "useitem 2" Q "+Quick_Kick" -H "HoloDuke" -J "Jetpack" -N "NightVision" -M "MedKit" +H "useitem 3" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "+Toggle_Crouch" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" diff --git a/wadsrc/static/filter/duke/engine/leftbinds.txt b/wadsrc/static/filter/duke/engine/leftbinds.txt index ce00aa0c8..d04297d13 100644 --- a/wadsrc/static/filter/duke/engine/leftbinds.txt +++ b/wadsrc/static/filter/duke/engine/leftbinds.txt @@ -1,7 +1,7 @@ -H "HoloDuke" -R "Steroids" +H "useitem 3" +R "useitem 2" Q "+Quick_Kick" -J "Jetpack" -N "NightVision" -M "MedKit" +J "useitem 4" +N "useitem 5" +M "useitem 1" W "+Show_Opponents_Weapon" diff --git a/wadsrc/static/filter/duke/engine/origbinds.txt b/wadsrc/static/filter/duke/engine/origbinds.txt index 4da1d5fb4..8c12f9162 100644 --- a/wadsrc/static/filter/duke/engine/origbinds.txt +++ b/wadsrc/static/filter/duke/engine/origbinds.txt @@ -1,13 +1,13 @@ // -R "Steroids" +R "useitem 2" ` "+Quick_Kick" W "+Show_Opponents_Weapon" H "Holo_Duke" -J "Jetpack" -N "NightVision" -M "MedKit" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "toggleconsole" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" \ No newline at end of file diff --git a/wadsrc/static/filter/nam/engine/defbinds.txt b/wadsrc/static/filter/nam/engine/defbinds.txt index 5bcd053fb..2abe049a8 100644 --- a/wadsrc/static/filter/nam/engine/defbinds.txt +++ b/wadsrc/static/filter/nam/engine/defbinds.txt @@ -1,10 +1,10 @@ // -R "Steroids" +R "useitem 2" Q "+Quick_Kick" -H "HoloDuke" -J "Jetpack" -N "NightVision" -M "MedKit" +H "useitem 3" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "+Toggle_Crouch" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" diff --git a/wadsrc/static/filter/nam/engine/leftbinds.txt b/wadsrc/static/filter/nam/engine/leftbinds.txt index ce00aa0c8..d04297d13 100644 --- a/wadsrc/static/filter/nam/engine/leftbinds.txt +++ b/wadsrc/static/filter/nam/engine/leftbinds.txt @@ -1,7 +1,7 @@ -H "HoloDuke" -R "Steroids" +H "useitem 3" +R "useitem 2" Q "+Quick_Kick" -J "Jetpack" -N "NightVision" -M "MedKit" +J "useitem 4" +N "useitem 5" +M "useitem 1" W "+Show_Opponents_Weapon" diff --git a/wadsrc/static/filter/nam/engine/origbinds.txt b/wadsrc/static/filter/nam/engine/origbinds.txt index 52014371c..253985daa 100644 --- a/wadsrc/static/filter/nam/engine/origbinds.txt +++ b/wadsrc/static/filter/nam/engine/origbinds.txt @@ -1,13 +1,13 @@ // -R "Steroids" +R "useitem 2" ` "+Quick_Kick" W "+Show_Opponents_Weapon" -H "HoloDuke" -J "Jetpack" -N "NightVision" -M "MedKit" +H "useitem 3" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "toggleconsole" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" \ No newline at end of file diff --git a/wadsrc/static/filter/redneck/engine/defbinds.txt b/wadsrc/static/filter/redneck/engine/defbinds.txt index 44ff76647..2ac4d63ac 100644 --- a/wadsrc/static/filter/redneck/engine/defbinds.txt +++ b/wadsrc/static/filter/redneck/engine/defbinds.txt @@ -1,10 +1,10 @@ // V "+Show_Opponents_Weapon" -B "HoloDuke" -C "Jetpack" -Y "NightVision" -R "MedKit" -M "Steroids" +B "useitem 3" +C "useitem 4" +Y "useitem 5" +R "useitem 1" +M "useitem 2" Q "+Quick_Kick" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" diff --git a/wadsrc/static/filter/redneck/engine/leftbinds.txt b/wadsrc/static/filter/redneck/engine/leftbinds.txt index 52bd1cf24..83ffb9f72 100644 --- a/wadsrc/static/filter/redneck/engine/leftbinds.txt +++ b/wadsrc/static/filter/redneck/engine/leftbinds.txt @@ -1,7 +1,7 @@ E "+Show_Opponents_Weapon" -M "Steroids" +M "useitem 2" Q "+Quick_Kick" -B "HoloDuke" -C "Jetpack" -Y "NightVision" -W "MedKit" +B "useitem 3" +C "useitem 4" +Y "useitem 5" +W "useitem 1" diff --git a/wadsrc/static/filter/redneck/engine/origbinds.txt b/wadsrc/static/filter/redneck/engine/origbinds.txt index 6aa9210bb..ac76b35e8 100644 --- a/wadsrc/static/filter/redneck/engine/origbinds.txt +++ b/wadsrc/static/filter/redneck/engine/origbinds.txt @@ -1,8 +1,8 @@ V "toggleconsole" E "+Show_Opponents_Weapon" -M "Steroids" +M "useitem 2" ` "+Quick_Kick" -B "HoloDuke" -C "Jetpack" -Y "NightVision" -W "MedKit" +B "useitem 3" +C "useitem 4" +Y "useitem 5" +W "useitem 1" diff --git a/wadsrc/static/filter/shadowwarrior/engine/defbinds.txt b/wadsrc/static/filter/shadowwarrior/engine/defbinds.txt index e9d6d2d71..78f8097d5 100644 --- a/wadsrc/static/filter/shadowwarrior/engine/defbinds.txt +++ b/wadsrc/static/filter/shadowwarrior/engine/defbinds.txt @@ -1,9 +1,9 @@ // I "toggle cl_crosshair" -Mouse2 "MedKit" -M "MedKit" -B "Smoke_Bomb" -N "Nightvision" -G "Gas_Bomb" -F "Flash_Bomb" -C "Caltrops" +Mouse2 "useitem 1" +M "useitem 1" +B "useitem 3" +N "useitem 4" +G "useitem 5" +F "useitem 6" +C "useitem 7" diff --git a/wadsrc/static/filter/shadowwarrior/engine/leftbinds.txt b/wadsrc/static/filter/shadowwarrior/engine/leftbinds.txt index e45842f26..a51ed08dc 100644 --- a/wadsrc/static/filter/shadowwarrior/engine/leftbinds.txt +++ b/wadsrc/static/filter/shadowwarrior/engine/leftbinds.txt @@ -1,6 +1,6 @@ -M "MedKit" -B "Smoke_Bomb" -N "Nightvision" -G "Gas_Bomb" -F "Flash_Bomb" -C "Caltrops" +M "useitem 1" +B "useitem 3" +N "useitem 4" +G "useitem 5" +F "useitem 6" +C "useitem 7" diff --git a/wadsrc/static/filter/shadowwarrior/engine/origbinds.txt b/wadsrc/static/filter/shadowwarrior/engine/origbinds.txt index 1eaf623ab..5d349cb28 100644 --- a/wadsrc/static/filter/shadowwarrior/engine/origbinds.txt +++ b/wadsrc/static/filter/shadowwarrior/engine/origbinds.txt @@ -1,7 +1,7 @@ -M "MedKit" -S "Smoke_Bomb" -N "Nightvision" -G "Gas_Bomb" -F "Flash_Bomb" -C "Caltrops" -Mouse2 "MedKit" +M "useitem 1" +S "useitem 3" +N "useitem 4" +G "useitem 5" +F "useitem 6" +C "useitem 7" +Mouse2 "useitem 1" diff --git a/wadsrc/static/filter/ww2gi/engine/defbinds.txt b/wadsrc/static/filter/ww2gi/engine/defbinds.txt index 5bcd053fb..2abe049a8 100644 --- a/wadsrc/static/filter/ww2gi/engine/defbinds.txt +++ b/wadsrc/static/filter/ww2gi/engine/defbinds.txt @@ -1,10 +1,10 @@ // -R "Steroids" +R "useitem 2" Q "+Quick_Kick" -H "HoloDuke" -J "Jetpack" -N "NightVision" -M "MedKit" +H "useitem 3" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "+Toggle_Crouch" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" diff --git a/wadsrc/static/filter/ww2gi/engine/leftbinds.txt b/wadsrc/static/filter/ww2gi/engine/leftbinds.txt index ce00aa0c8..d04297d13 100644 --- a/wadsrc/static/filter/ww2gi/engine/leftbinds.txt +++ b/wadsrc/static/filter/ww2gi/engine/leftbinds.txt @@ -1,7 +1,7 @@ -H "HoloDuke" -R "Steroids" +H "useitem 3" +R "useitem 2" Q "+Quick_Kick" -J "Jetpack" -N "NightVision" -M "MedKit" +J "useitem 4" +N "useitem 5" +M "useitem 1" W "+Show_Opponents_Weapon" diff --git a/wadsrc/static/filter/ww2gi/engine/origbinds.txt b/wadsrc/static/filter/ww2gi/engine/origbinds.txt index 52014371c..253985daa 100644 --- a/wadsrc/static/filter/ww2gi/engine/origbinds.txt +++ b/wadsrc/static/filter/ww2gi/engine/origbinds.txt @@ -1,13 +1,13 @@ // -R "Steroids" +R "useitem 2" ` "+Quick_Kick" W "+Show_Opponents_Weapon" -H "HoloDuke" -J "Jetpack" -N "NightVision" -M "MedKit" +H "useitem 3" +J "useitem 4" +N "useitem 5" +M "useitem 1" C "toggleconsole" -Mouse2 "Jetpack" -Mouse3 "MediKit" +Mouse2 "useitem 4" +Mouse3 "useitem 1" \ No newline at end of file