From 85ac4583d03567aa54da559cea6abbebcfbc1a78 Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Sat, 20 Dec 2025 11:39:51 +0000 Subject: [PATCH] feat(IW3 MP): add gsc method `ButtonPressed` --- README.md | 31 ++++++++++++++++++++++++++++++- src/game/iw3/mp/main.cpp | 28 ++++++++++++++++++++++++++++ src/game/iw3/mp/structs.h | 35 +++++++++++++++++++++++++++++++++++ src/game/iw3/mp/symbols.h | 5 +++++ 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1b9a7c..77e69a3 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ GSC Entity fields: - `self.noclip = ` - toggles noclip - `self.ufo = ` - toggles ufomode -- `self.god = ` - toggles godmode +- `self.entityflags = ` - gentity flags e.g. `1` is godmode GSC Functions: @@ -76,6 +76,35 @@ GSC Methods: - `NightVisionButtonPressed` - `SetVelocity` - Changes current player velocity. `self setVelocity((0, 0, 300)); // Go up.` - `CloneBrushModelToScriptModel` +- **HOST ONLY** `ButtonPressed` e.g. `self ButtonPressed("DPAD_DOWN")` - See **keynames** below for valid button identifiers. + +
+keynames + +``` +BUTTON_A +BUTTON_B +BUTTON_X +BUTTON_Y +BUTTON_LSHLDR +BUTTON_RSHLDR +BUTTON_START +BUTTON_BACK +BUTTON_LSTICK +BUTTON_RSTICK +BUTTON_RTRIG +BUTTON_LTRIG +DPAD_UP +DPAD_DOWN +DPAD_LEFT +DPAD_RIGHT +APAD_UP +APAD_DOWN +APAD_LEFT +APAD_RIGHT +``` + +
### Loading single-player maps diff --git a/src/game/iw3/mp/main.cpp b/src/game/iw3/mp/main.cpp index 4090f39..ce0fa51 100644 --- a/src/game/iw3/mp/main.cpp +++ b/src/game/iw3/mp/main.cpp @@ -1454,6 +1454,33 @@ void PlayerCmd_GetRightMove(scr_entref_t entref) Scr_AddInt(cl->lastUsercmd.rightmove); } +int CL_IsKeyPressed(const int localClientNum, const char *keyName) +{ + const int keynum = Key_StringToKeynum(keyName); + if (keynum >= 0) + return playerKeys[0].keys[keynum].down; + else + return 0; +} + +void PlayerCmd_ButtonPressed(scr_entref_t entref) +{ + if (entref.classnum != 0) + Scr_ObjectError("not an entity"); + + char *button = Scr_GetString(0); + if (!button || !*button) + Scr_Error("usage: buttonPressed(